REST API
An HTTPS API with OpenAPI 3.1 that turns each route into a MongoDB command.
Every node serves a REST API at https://<node>:27080/v1. Each route builds the equivalent MongoDB command, with the
same role-based authorization, the same error codes and the same auditing as the wire protocol. The OpenAPI 3.1
document is at /v1/openapi.json.
Authentication
With an API key in the Authorization: Bearer header, a client certificate or an OIDC token. A key is created for a
user, carries a subset of its roles and expires after 90 days by default; it is shown only once.
teseladb admin apikey create --user shop-apiAn example
curl -s https://node-01:27080/v1/databases/shop/collections/orders/find \
--cacert ./ca.pem \
-H "Authorization: Bearer $TESELADB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filter": {"total": {"$gt": 100}}, "limit": 10}'Bodies are relaxed Extended JSON v2. A query returns the first batch and a cursor you follow with
GET /v1/cursors/{id}. Errors follow application/problem+json with MongoDB's code and codeName.
Routes
| Method and route | MongoDB command |
|---|---|
GET /databases | listDatabases |
GET /databases/{db}/collections | listCollections |
POST /databases/{db}/collections/{coll}/find | find |
POST /databases/{db}/collections/{coll}/aggregate | aggregate |
GET /databases/{db}/collections/{coll}/documents/{id} | find by _id |
PUT · PATCH · DELETE /databases/{db}/collections/{coll}/documents/{id} | update or delete by _id |
POST /databases/{db}/collections/{coll}/insertOne · insertMany | insert |
POST /databases/{db}/collections/{coll}/updateOne · updateMany | update |
POST /databases/{db}/collections/{coll}/deleteOne · deleteMany | delete |
POST /databases/{db}/collections/{coll}/bulkWrite | bulkWrite |
GET · POST /databases/{db}/collections/{coll}/indexes | listIndexes, createIndexes |
GET · POST /databases/{db}/collections/{coll}/changeStream | $changeStream, as SSE events |
POST /databases/{db}/command | any command |
GET · DELETE /cursors/{id} | getMore, killCursors |
POST /transactions | transaction with several operations |
GET · POST /apiKeys | API keys |
GET /openapi.json | OpenAPI 3.1 document |
Idempotency and consistency
A write with the Idempotency-Key header is not applied twice even if you repeat it. Each response carries
TeselaDB-Operation-Time; send it in TeselaDB-After-Cluster-Time to read after that operation.