Collections
Collections provide a lightweight, workspace-scoped item store backed by PostgreSQL with a pgvector similarity index. Use collections to manage reusable content such as prompt templates, tool definitions, or procedures, grouped by a collection_name.
All collection endpoints operate on the workspace of the authenticated request. Reads require collections:read, creates and updates require collections:write, and deletes require collections:delete.
Create a Collection Item
curl -X POST "$MEMORYLAYER_URL/v1/collections" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "collection_name": "prompts", "name": "summarize-email", "content": "Summarize the following email thread into 3 bullet points...", "item_type": "prompt_template", "tags": ["email", "summarization"], "metadata": {"version": "1.2"}, "enabled": true }'Returns 201 Created with the item, including a generated id (prefixed col_), tenant_id, workspace_id, created_at, and updated_at.
Fields:
| Field | Required | Description |
|---|---|---|
collection_name | Yes | Logical grouping name (must not be empty) |
name | Yes | Item name |
content | Yes | Item content (text) |
item_type | No | Free-form type label within the collection |
tags | No | List of string tags |
metadata | No | Arbitrary key-value metadata |
enabled | No | Whether the item is active (default true) |
List Items
# All items in the workspacecurl "$MEMORYLAYER_URL/v1/collections?limit=50&offset=0" \ -H "Authorization: Bearer $API_KEY"
# Filter by collection namecurl "$MEMORYLAYER_URL/v1/collections?collection_name=prompts" \ -H "Authorization: Bearer $API_KEY"limit defaults to 50 (max 200). The response is {"items": [...], "total_count": N}.
Get a Single Item
curl "$MEMORYLAYER_URL/v1/collections/$ITEM_ID" \ -H "Authorization: Bearer $API_KEY"Returns 404 if the item does not exist in the workspace.
Update an Item
Only provided fields are updated; others remain unchanged. Updatable fields: name, content, item_type, tags, metadata, enabled.
curl -X PUT "$MEMORYLAYER_URL/v1/collections/$ITEM_ID" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "Updated prompt template text...", "tags": ["email", "summarization", "v2"] }'Delete an Item
curl -X DELETE "$MEMORYLAYER_URL/v1/collections/$ITEM_ID" \ -H "Authorization: Bearer $API_KEY"Returns 204 No Content on success.
Similarity Search
Search collection items by cosine similarity against a query embedding you supply. Only enabled items that have a stored embedding are considered.
curl -X POST "$MEMORYLAYER_URL/v1/collections/search" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "query_embedding": [0.12, -0.45, 0.78, ...], "collection_name": "prompts", "limit": 5 }'Search parameters:
| Field | Required | Description |
|---|---|---|
query_embedding | Yes | Query embedding vector (length must equal the server’s MEMORYLAYER_EMBEDDING_DIMENSIONS) |
collection_name | No | Restrict search to one collection |
limit | No | Maximum results to return (1—100, default 10) |
Results are ordered by similarity (1 - cosine distance):
{ "results": [ { "item": { "id": "col_3f9a1c2b7d4e5f60", "tenant_id": "tenant_abc", "workspace_id": "my-workspace", "collection_name": "prompts", "name": "summarize-email", "content": "Summarize the following email thread...", "item_type": "prompt_template", "tags": ["email", "summarization"], "metadata": {"version": "1.2"}, "enabled": true, "created_at": "2026-04-01T12:00:00Z", "updated_at": "2026-04-01T12:00:00Z" }, "similarity": 0.92 } ], "total_count": 1}Use Cases
| Use Case | Collection Name | Description |
|---|---|---|
| Prompt library | prompts | Store and retrieve prompt templates |
| Tool registry | tools | Register tool definitions for agent function calling |
| Procedures | procedures | Reusable step-by-step procedures |
| Code snippets | snippets | Reusable code patterns |