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.

Shell
teseladb admin apikey create --user shop-api

An example

Shell
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 routeMongoDB command
GET /databaseslistDatabases
GET /databases/{db}/collectionslistCollections
POST /databases/{db}/collections/{coll}/findfind
POST /databases/{db}/collections/{coll}/aggregateaggregate
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 · insertManyinsert
POST /databases/{db}/collections/{coll}/updateOne · updateManyupdate
POST /databases/{db}/collections/{coll}/deleteOne · deleteManydelete
POST /databases/{db}/collections/{coll}/bulkWritebulkWrite
GET · POST /databases/{db}/collections/{coll}/indexeslistIndexes, createIndexes
GET · POST /databases/{db}/collections/{coll}/changeStream$changeStream, as SSE events
POST /databases/{db}/commandany command
GET · DELETE /cursors/{id}getMore, killCursors
POST /transactionstransaction with several operations
GET · POST /apiKeysAPI keys
GET /openapi.jsonOpenAPI 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.