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
| Operation | Method and path | JSON body / result |
|---|---|---|
| List collections | GET /api/collections | Collection names |
| Create collection | POST /api/collections/{collection} | Schema; see collection creation |
| Read schema | GET /api/collections/{collection} | Collection metadata; schema is under collection |
| Change constraints | PUT /api/schemas/{collection} | {"constraints":{"field":{...}}}; existing fields only |
| Insert | POST /api/insert/{collection} | Record object; default response is {id}; opt into the full record with ?return_record=true |
| Find | POST /api/find/{collection} | Query object; returns an array of records |
| Find by ID | GET /api/find/{collection}/{id} | One record, or 404 |
| Update | PUT /api/update/{collection}/{id} | Record fields to merge, optionally a top-level ttl |
| Delete record | DELETE /api/delete/{collection}/{id} | Default acknowledgement {id, deleted:true} |
| Delete collection | DELETE /api/collections/{collection} | Destructive; missing collection is 404 |
| Count matches | POST /api/count/{collection} | Optional filter; see counting |
| Search | POST /api/search/{collection} | Search options; returns an object with results, total and timing metadata; see search |
| Batch insert | POST /api/batch/insert/{collection} | {"inserts":[{"data":{...}}]}; each data record can carry ttl |
| Batch update | PUT /api/batch/update/{collection} | {"updates":[{"id":"...","data":{...}}]}; see batch operations |
| Batch delete | DELETE /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
| Operation | Method and path | Contract |
|---|---|---|
| KV get | GET /api/kv/get/{key} | Missing key is 404 |
| KV set | POST /api/kv/set/{key} | {"value":...,"ttl":300}; TTL is optional |
| KV delete | DELETE /api/kv/delete/{key} | Idempotent 200 when missing |
| Save function | POST /api/functions | Function definition; an existing label is 409 |
| Update function | PUT /api/functions/{id_or_label} | Updated function definition |
| Call function | POST /api/functions/{id_or_label} | Parameter map directly, for example {"active":true}; result contains records |
| Begin transaction | POST /api/transactions | Optional isolation_level; returns transaction_id |
| Commit | POST /api/transactions/{id}/commit | Classify the response before retrying |
| Roll back | POST /api/transactions/{id}/rollback | Discards 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.