API Reference

Every endpoint of the SwarmV REST API. The SDKs wrap all of it; use this page when calling the API from another language or checking exact behaviour.

Download OpenAPI specOpenAPI 3.1: import it into Postman or Insomnia, or generate a client.

Basics

  • Base URL: https://api.swarmv.dev. Requests and responses are JSON.
  • Authentication: Authorization: Bearer <credential>, either an API key (backend only, evx_live_…) or a user token from Create a user token. Each API key belongs to one index. See Authentication.
  • Status: swarmv.dev/status shows whether search, writes and access control are working right now; the same data is at GET /v1/health for monitoring.
  • Errors: JSON { error, code? } for most, plain text for authentication failures. Temporary failures (429, 503) include Retry-After; the SDKs retry them for you. The full list is in the error table.

Vectors

Insert or update a vector

post/v1/insert
API key or user tokenscope: vector:write

Writes one record. If the id exists it's replaced, but only within the same container: an id can't move to another container. Writes are accepted at once and become searchable everywhere within seconds to about a minute; use fresh: true on search or fetch to read them immediately.

SDK: insert() in TypeScript, insert() in Python.

Request body

FieldDescription
id*string (id)Document id: an unsigned 32-bit integer (0 to 4294967295), sent as a string. "007" and "7" are the same document.
vector*array of numberFinite numbers. Every vector in an index has the same length (set by the first insert).
metadataobject (metadata)Flat key/value pairs (string, number or boolean), at most 8 KB in total, without the bytes \x00-\x02. Values come back as strings. container_id decides who can see the record.
auth_user_idstringWrite as this user (needs vector:impersonate). User tokens always write as their own user.
Request
curl -X POST https://api.swarmv.dev/v1/insert \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id": "4021", "vector": [0.12, -0.04, 0.33], "metadata": {"container_id": "container:handbook", "text": "Employees get 25 days of paid leave."}}'
Response 202
{
  "status": "accepted"
}

Errors

400Invalid id, vector or metadata; with a user token, metadata.container_id is missing; or a vector whose length differs from the index's (code dimension_mismatch).dimension_mismatch
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing vector:write scope; the user can't edit the container; or the id already belongs to another container (code container_limit_exceeded when the user reaches over 1,000 containers).container_limit_exceeded
413Metadata over 8 KB, or the index is full (code index_full).index_full
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.
503Temporary: the write backlog is full, the index is catching up with recent writes (code index_busy), or the index is being migrated (code migrating) or is frozen (code store_frozen). Retry after the Retry-After header.migratingstore_frozenstore_movedindex_busy

Insert or update up to 500 vectors

post/v1/upsert-batch
API key or user tokenscope: vector:write

Like insert, for up to 500 records at once. The batch is checked as a whole before anything is written: if any record is rejected, none are, and the error names the record (index). Also served at /upsert-batch for older clients. The SDKs' insertMany / insert_many use it.

SDK: insertMany() in TypeScript, insert_many() in Python.

Request body

FieldDescription
vectors*array of VectorRecordup to 500 items
vectors[].id*string (id)Document id: an unsigned 32-bit integer (0 to 4294967295), sent as a string. "007" and "7" are the same document.
vectors[].vector*array of numberFinite numbers. Every vector in an index has the same length (set by the first insert).
vectors[].metadataobject (metadata)Flat key/value pairs (string, number or boolean), at most 8 KB in total, without the bytes \x00-\x02. Values come back as strings. container_id decides who can see the record.
vectors[].auth_user_idstringWrite as this user (needs vector:impersonate). User tokens always write as their own user.
Request
curl -X POST https://api.swarmv.dev/v1/upsert-batch \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vectors": [{"id": "4021", "vector": [0.12, -0.04, 0.33], "metadata": {"container_id": "container:handbook"}}]}'
Response 202
{
  "success": true,
  "inserted": 2
}

Errors

400A record is invalid; the response's index says which; or a vector whose length differs from the index's (code dimension_mismatch).dimension_mismatch
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Same rules as insert, for any record in the batch.container_limit_exceeded
413More than 500 records, metadata over 8 KB, or the index is full (code index_full).index_full
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.
503Temporary: the write backlog is full, the index is catching up with recent writes (code index_busy), or the index is being migrated (code migrating) or is frozen (code store_frozen). Retry after the Retry-After header.migratingstore_frozenstore_movedindex_busy

Bulk import up to 2,000 records per request

post/v1/import
API keyscope: vector:write

For loading large datasets: up to 2,000 records per request in a compact binary chunk, with the same checks and ownership rules as upsert-batch (if any record is rejected, none are). Imported records become searchable once merged, usually within a minute; they are not visible to fresh searches before that. Backend API keys only (not user tokens). Each record counts as one write.

Body (application/octet-stream, little-endian): the 4 bytes EVI1, u32 dimension, u32 record count, then for each record: u32 id, the vector as f32 × dimension, u32 metadata length n, and n bytes of metadata as a UTF-8 JSON object (n = 0: no metadata). At most 16 MB. scripts/bulk-load.ts in the repository shows how to build chunks.

Query parameters

FieldDescription
bulkstringFirst load of a new index: stage this chunk under a bulk session instead of merging it. When every chunk is uploaded, POST /v1/import/commit builds the whole index in one pass (much faster for large loads). Only for an index with no records yet (409 bulk_needs_new_index otherwise).
Request
curl -X POST https://api.swarmv.dev/v1/import \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @chunk-0001.evi
Response 202
{
  "success": true,
  "accepted": 2000
}

Errors

400Not a valid chunk (code invalid_import), a record is invalid (the response's index says which), or a vector whose length differs from the index's (code dimension_mismatch).invalid_importdimension_mismatch
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing vector:write scope, a user token (bulk import needs a backend API key), or a record id that already exists in a different container.
409bulk_needs_new_index: ?bulk on an index that already has records; bulk_build_in_progress: a bulk build is running for this index (other writes wait for it).
413More than 500 records, metadata over 8 KB, or the index is full (code index_full).index_full
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.
503Temporary: the write backlog is full, the index is catching up with recent writes (code index_busy), or the index is being migrated (code migrating) or is frozen (code store_frozen). Retry after the Retry-After header.migratingstore_frozenstore_movedindex_busy

Delete a vector

post/v1/delete
API key or user tokenscope: vector:write

Deletes one record by id. With a user token, pass the record's container in metadata.container_id; the user needs editor access to it.

SDK: delete() in TypeScript, delete() in Python.

Request body

FieldDescription
id*string (id)Document id: an unsigned 32-bit integer (0 to 4294967295), sent as a string. "007" and "7" are the same document.
metadataobjectThe document's container. Required with user tokens (the user needs editor access to it).
auth_user_idstringDelete as this user (needs vector:impersonate).
Request
curl -X POST https://api.swarmv.dev/v1/delete \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id": "4021", "metadata": {"container_id": "container:handbook"}}'
Response 202
{
  "status": "accepted"
}

Errors

400Invalid id; with a user token, metadata.container_id is missing.
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing vector:write scope, the record is in another container, or the user can't edit its container.container_limit_exceeded
404With a user token: no such document.
409The document's owner changed while the request ran (it was deleted or claimed by another container). Retry.conflict
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.
503Temporary: the write backlog is full, or the index is being migrated (code migrating) or is frozen (code store_frozen). Retry after the Retry-After header.migratingstore_frozenstore_moved

Get records by id

post/v1/fetch
API key or user tokenscope: vector:read

Returns up to 100 records by id, with their metadata and optionally their vectors. Same visibility as search: records the caller can't see are listed as missing, never as forbidden, so ids in other containers can't be probed. Includes writes that aren't merged yet. Counts as one read.

SDK: fetchRecords() in TypeScript, fetch_records() in Python.

Request body

FieldDescription
ids*array of string (id)up to 100 items
include_metadatabooleandefault true
include_vectorbooleandefault false
auth_user_idstringFetch as this user (needs vector:impersonate). User tokens always fetch as their own user.
Request
curl -X POST https://api.swarmv.dev/v1/fetch \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["4021", "4022"]}'
Response 200
{
  "records": [
    {
      "id": "4021",
      "metadata": {
        "container_id": "container:handbook",
        "text": "Employees get 25 days of paid leave."
      }
    }
  ],
  "missing": [
    "4022"
  ]
}

Errors

400ids missing, empty or not 32-bit integers.
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing vector:read scope, auth_user_id without vector:impersonate, or the user reaches over 1,000 containers.container_limit_exceeded
413More than 100 ids.
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

List records

get/v1/records
API keyscope: vector:read

Pages through the index's records in id order (merged records: writes from the last few seconds may not be listed yet; deleted records are not listed). Backend API keys only, since the list isn't limited to a user's containers. Indexes created before October 2026 answer 404 (code not_clustered).

Query parameters

FieldDescription
afterstring (id)List ids after this one (the previous page's next).
limitintegerPage size.default 50, 1–200
containerstringOnly records in this container.
Request
curl "https://api.swarmv.dev/v1/records?limit=100" \
  -H "Authorization: Bearer $SWARMV_API_KEY"
Response 200
{
  "records": [
    {
      "id": "4021",
      "container": "container:handbook"
    },
    {
      "id": "4022",
      "container": null
    }
  ],
  "next": "4022"
}

Errors

401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403A user token, or a key without vector:read.
404The index uses the older format (code not_clustered).not_clustered
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Build a new index from a bulk import session

post/v1/import/commit
API keyscope: vector:write

Starts building the index from every chunk uploaded with /v1/import?bulk=<session>, in one pass: lists are trained for the whole load and written once, so large loads are searchable much sooner than through merges. Records with the same id keep their newest copy. The build runs in the background; poll GET /v1/import/status. Other writes to the index wait (409 bulk_build_in_progress) until it is done. Backend API keys only.

Request body

FieldDescription
session*string
Request

Errors

400Invalid session, or no chunks uploaded for it (bulk_empty)
409bulk_needs_new_index or bulk_build_in_progress

Progress of a bulk import build

get/v1/import/status
API keyscope: vector:write

State of the build started by /v1/import/commit: building (with step once records are searchable and keyword text is being indexed), done (with records), or failed (with error; commit the session again, or start a new one).

Query parameters

FieldDescription
sessionstring
Request

Errors

404No build for this session

Auth

Create a user token

post/v1/auth/token
API key

Creates a short-lived token (at most 1 hour) that acts as one user: it can only search, fetch and write within the containers that user can access. Call it from your backend with an API key, and give the token, not the key, to agents, MCP servers and browsers. Tokens can't create tokens.

SDK: generateUserToken() in TypeScript, generate_user_token() in Python.

Request body

FieldDescription
user_id*string
expires_inintegerLifetime in seconds; longer values are capped at 3600.default 3600, 1–3600
scopesarray of "vector:read" | "vector:write"A subset of the key's scopes. Defaults to the key's vector scopes. graph:*, vector:impersonate and keys:admin are never allowed in tokens.
Request
curl -X POST https://api.swarmv.dev/v1/auth/token \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "user:dave", "expires_in": 900}'
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs..."
}

Errors

400user_id isn't a user: id, or expires_in isn't a positive integer (plain text).
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Called with a token, or asked for a scope the key doesn't have or that tokens can't hold (plain text).
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Access graph

List relationships

get/v1/graph/edges
API keyscope: graph:read

Pages through your account's relationships, optionally filtered.

SDK: graph.listRelations() in TypeScript, list_relations() in Python.

Query parameters

FieldDescription
subjectstringOnly this subject.
objectstringOnly this object.
relation"member" | "viewer" | "editor" | "parent"Only this relation.
qstringText search: part of a subject, relation or object.
limitintegerPage size.default 50, 1–200
offsetintegerRows to skip.default 0
Request
curl -X GET https://api.swarmv.dev/v1/graph/edges?object=group:engineering \
  -H "Authorization: Bearer $SWARMV_API_KEY"
Response 200
{
  "edges": [
    {
      "subject": "user:dave",
      "relation": "member",
      "object": "group:engineering"
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0
}

Errors

401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:read (or graph:admin) scope, or called with a user token (plain text).
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Add a relationship

post/v1/graph/edge
API keyscope: graph:admin

Adds one relationship, e.g. a user joining a group or a group becoming viewer of a folder. Permissions at the edge update within seconds. Re-sending an existing relationship is harmless and refreshes the affected permissions.

SDK: graph.createRelation() in TypeScript, create_relation() in Python.

Request body

FieldDescription
subject*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
relation*"member" | "viewer" | "editor" | "parent"
object*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
Request
curl -X POST https://api.swarmv.dev/v1/graph/edge \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject": "user:dave", "relation": "member", "object": "group:engineering"}'
Response 200
{
  "success": true,
  "changed": true
}

Errors

400Missing fields, an unknown relation, or a node without a valid prefix (plain text).
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:admin scope, or the plan's relationship limit is reached (code relationship_limit).relationship_limit
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Remove a relationship

delete/v1/graph/edge
API keyscope: graph:admin

Removes one relationship. Access that depended on it ends everywhere within seconds.

SDK: graph.deleteRelation() in TypeScript, delete_relation() in Python.

Request body

FieldDescription
subject*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
relation*"member" | "viewer" | "editor" | "parent"
object*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
Request
curl -X DELETE https://api.swarmv.dev/v1/graph/edge \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject": "user:dave", "relation": "member", "object": "group:engineering"}'
Response 200
{
  "success": true,
  "changed": true
}

Errors

400Missing fields, an unknown relation, or a node without a valid prefix (plain text).
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:admin scope (plain text).
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Check and explain access

post/v1/graph/check
API keyscope: graph:read

Answers whether a subject can view (or edit) an object, and through which chain of relations. Reads the graph directly, so it reflects changes immediately.

SDK: graph.checkAccess() in TypeScript, check_access() in Python.

Request body

FieldDescription
subject*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
object*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
relation"viewer" | "editor"default "viewer"
Request
curl -X POST https://api.swarmv.dev/v1/graph/check \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject": "user:dave", "object": "container:apollo"}'
Response 200
{
  "allowed": true,
  "granted": "viewer",
  "path": [
    {
      "node": "user:dave"
    },
    {
      "node": "group:engineering",
      "relation": "member"
    },
    {
      "node": "folder:handbook",
      "relation": "viewer"
    },
    {
      "node": "container:apollo",
      "relation": "parent"
    }
  ]
}

Errors

400Invalid subject, object or relation.
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:read (or graph:admin) scope (plain text).
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Change many relationships at once

post/v1/graph/edges/batch
API keyscope: graph:adminPro and Enterprise plans

Adds and removes up to 500 relationships in one all-or-nothing step. Pro and Enterprise.

SDK: graph.batch() in TypeScript, batch_relations() in Python.

Headers

FieldDescription
Idempotency-KeystringRetrying with the same key within 24 hours returns the first result instead of applying the change again.up to 128 characters

Request body

FieldDescription
operations*array of Relationship & objectup to 500 items
operations[].subject*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
operations[].relation*"member" | "viewer" | "editor" | "parent"
operations[].object*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
operations[].op*"add" | "remove"
dry_runbooleandefault false
Request
curl -X POST https://api.swarmv.dev/v1/graph/edges/batch \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"operations": [{"op": "add", "subject": "user:ana", "relation": "member", "object": "group:engineering"}]}'
Response 200
{
  "success": true,
  "dry_run": false,
  "added": 1,
  "removed": 1,
  "unchanged": 0
}

Errors

400Invalid operations; index names the first bad one.
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:admin scope, the Basic plan (code plan_feature), or the relationship limit (code relationship_limit). Nothing was changed.plan_featurerelationship_limit
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Make an object's members exactly a list

post/v1/graph/sync
API keyscope: graph:adminPro and Enterprise plans

Sets who has one relation to one object, e.g. the full member list of a group from your directory: missing subjects are added, others removed. Safe to re-run. Pro and Enterprise.

SDK: graph.sync() in TypeScript, sync_relations() in Python.

Headers

FieldDescription
Idempotency-KeystringRetrying with the same key within 24 hours returns the first result instead of applying the change again.up to 128 characters

Request body

FieldDescription
object*stringA node with a type prefix: user:, group:, folder: or container:.up to 256 characters
relation*"member" | "viewer" | "editor" | "parent"
subjects*array of stringThe complete list: subjects not in it lose this relation.up to 10000 items
dry_runbooleandefault false
allow_large_removalbooleanRequired when a sync would remove more than 20% of 10 or more current subjects.default false
Request
curl -X POST https://api.swarmv.dev/v1/graph/sync \
  -H "Authorization: Bearer $SWARMV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"object": "group:engineering", "relation": "member", "subjects": ["user:ana", "user:dave"], "dry_run": true}'
Response 200
{
  "success": true,
  "dry_run": true,
  "current": 2,
  "would_add": 1,
  "would_remove": 1
}

Errors

400Invalid object, relation or subjects.
401Missing, invalid, expired, rotated or revoked key or token (plain text body).
402No active plan (code plan_required), or the Basic plan's monthly reads or writes are used up (code plan_limit).plan_requiredplan_limit
403Missing graph:admin scope, the Basic plan (code plan_feature), or the relationship limit (code relationship_limit).plan_featurerelationship_limit
409The sync would remove more than 20% of the current subjects; resend with allow_large_removal: true (code large_removal).large_removal
429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.

Service

Service health

get/v1/health
No authentication

Public, no key needed. The same data, for people, is at https://swarmv.dev/status. Checks each storage dependency and reports the last synthetic check, which writes a record and reads it back every 5 minutes. 200 when everything is fine, 503 otherwise. Rate-limited per IP; results are cached for 10 seconds.

Request
curl https://api.swarmv.dev/v1/health
Response 200
{
  "status": "ok",
  "checks": {
    "kv": {
      "ok": true,
      "ms": 4
    },
    "r2": {
      "ok": true,
      "ms": 21
    },
    "d1": {
      "ok": true,
      "ms": 9
    },
    "catalog": {
      "ok": true,
      "ms": 6
    }
  },
  "synthetic": {
    "ok": true,
    "at": 1792104837716,
    "write_ms": 41,
    "search_ms": 33
  },
  "time": "2026-10-15T22:54:06.906Z"
}

Errors

429Too many requests for this key (6,000 per minute; plain text). Retry-After says how many seconds until the window resets.
503Something is failing; the body names it.