Skip to main content

REST API quick reference for agents

Checked against ekoDB v0.87.0. Start with canonical formats and semantics for typed envelopes, native objects, filters, TTL, paging and transaction errors. Use the SDK for automatic token exchange and refresh when one is available for the application language.

Authentication and encoding​

Exchange a scoped API key with POST /api/auth/token, JSON body {"api_key":"<key>"}, then use the returned token as Authorization: Bearer <token>. Do not put the API key itself in the bearer header. Refresh via the token exchange when needed; never include keys or JWTs in a prompt, repository, URL or diagnostic output.

For direct JSON requests, send Content-Type: application/json and parse the HTTP status before the body. Percent-encode every variable path segment. Keep the returned opaque record ID intact. Authentication describes registration, grants and token lifetime.

Core routes​

OperationMethod and pathJSON body / result
List collectionsGET /api/collectionsCollection names
Create collectionPOST /api/collections/{collection}Schema; see collection creation
Read schemaGET /api/collections/{collection}Collection metadata; schema is under collection
Change constraintsPUT /api/schemas/{collection}{"constraints":{"field":{...}}}; existing fields only
InsertPOST /api/insert/{collection}Record object; default response is {id}; opt into the full record with ?return_record=true
FindPOST /api/find/{collection}Query object; returns an array of records
Find by IDGET /api/find/{collection}/{id}One record, or 404
UpdatePUT /api/update/{collection}/{id}Record fields to merge, optionally a top-level ttl
Delete recordDELETE /api/delete/{collection}/{id}Default acknowledgement {id, deleted:true}
Delete collectionDELETE /api/collections/{collection}Destructive; missing collection is 404
Count matchesPOST /api/count/{collection}Optional filter; see counting
SearchPOST /api/search/{collection}Search options; returns an object with results, total and timing metadata; see search
Batch insertPOST /api/batch/insert/{collection}{"inserts":[{"data":{...}}]}; each data record can carry ttl
Batch updatePUT /api/batch/update/{collection}{"updates":[{"id":"...","data":{...}}]}; see batch operations
Batch deleteDELETE /api/batch/delete/{collection}{"deletes":[{"id":"..."}]}

The table is an operation selector; read the linked endpoint reference for optional controls. Do not change server-wide return modes just to read an inserted record: use the request option or find it by its returned ID. GET /api/find/{collection} also supports URL query options, but a POST JSON body avoids hand-escaping a filter AST.

For example, the body of a bounded find request is:

{
"filter": { "type": "Condition", "content": { "field": "active", "operator": "Eq", "value": true } },
"sort": [{ "field": "created_seq", "ascending": true }],
"limit": 25
}

Use keyset paging over a stable unique sort field for large collections. Omitted limit uses the 1,000 default; limit: 0 still has an instance ceiling. Chat list routes have their own paging behavior.

KV, functions and transactions​

OperationMethod and pathContract
KV getGET /api/kv/get/{key}Missing key is 404
KV setPOST /api/kv/set/{key}{"value":...,"ttl":300}; TTL is optional
KV deleteDELETE /api/kv/delete/{key}Idempotent 200 when missing
Save functionPOST /api/functionsFunction definition; an existing label is 409
Update functionPUT /api/functions/{id_or_label}Updated function definition
Call functionPOST /api/functions/{id_or_label}Parameter map directly, for example {"active":true}; result contains records
Begin transactionPOST /api/transactionsOptional isolation_level; returns transaction_id
CommitPOST /api/transactions/{id}/commitClassify the response before retrying
Roll backPOST /api/transactions/{id}/rollbackDiscards staged writes

Pass ?transaction_id=<id> on supported record operations and reads to use the transaction's view. A normal request outside that transaction cannot see its staged writes. Commit is a separate operation; sending a transaction ID does not auto-commit. See transactions, KV and functions.

Function filters use the same AST, with "{{param}}" placeholders in the stored definition. Query has no join. Count returns a single count record at records[0].<output_field>; it replaces the working set. A transactional function cannot contain Upsert, LockAcquire or RateLimit.

Error handling​

Only a successful empty query is empty data. On a never-written collection, find returns 200 []; search returns 200 with results: [] and total: 0 in its response object. Missing point reads and collection deletion return 404. Do not turn failed authentication (401), refused access (403), invalid input (400), conflicts (409) or network faults into [].

Preserve the status and server body, whose fields vary by endpoint (error, message, code, and transaction retryable). On the pinned server, retryable commit conflicts are 409; invalid writes are 400 and store faults 500. Older 409 Apply(...) failures require correction rather than blind retry. Clients v0.37.0 do not automatically retry commit calls. See canonical transaction handling and error codes.