Skip to content

Any language (HTTP)

Every SDK method is one HTTP call:

POST https://<host>/v1/db/<dbId>/<action>
Authorization: Bearer kid_…:sk_…
Content-Type: application/json
{ "collection": "clients", …the method's arguments… }

Take <host>, <dbId> and the key kid_…:sk_… from your connection string (drivedb://<key>@<host>/<dbId>). The REST reference lists every action and its JSON body, and openapi.json describes the whole API for tools such as Postman or OpenAPI code generators.

Terminal window
# Insert
curl https://your-app-domain/v1/db/$DB/insertOne \
-H "Authorization: Bearer $DRIVEDB_KEY" -H "Content-Type: application/json" \
-d '{"collection":"clients","document":{"name":"Ada","status":"Lead"}}'
# Update
curl https://your-app-domain/v1/db/$DB/updateOne \
-H "Authorization: Bearer $DRIVEDB_KEY" -H "Content-Type: application/json" \
-d '{"collection":"clients","filter":{"name":"Ada"},"update":{"$set":{"status":"Won"}}}'
# Aggregate
curl https://your-app-domain/v1/db/$DB/aggregate \
-H "Authorization: Bearer $DRIVEDB_KEY" -H "Content-Type: application/json" \
-d '{"collection":"clients","pipeline":[{"$group":{"_id":"$status","n":{"$sum":1}}}]}'
import os, requests
API = f"https://your-app-domain/v1/db/{os.environ['DB']}"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['DRIVEDB_KEY']}"
def call(action, **body):
r = session.post(f"{API}/{action}", json=body, timeout=30)
if not r.ok:
error = r.json()["error"]
raise RuntimeError(f"{error['code']}: {error['message']}")
return r.json()
docs = call("find", collection="clients", filter={"dealValue": {"$gte": 1000}}, sort={"dealValue": -1})
<?php
$ch = curl_init("https://your-app-domain/v1/db/{$db}/find");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('DRIVEDB_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['collection' => 'clients', 'filter' => ['status' => 'Won']]),
]);
$result = json_decode(curl_exec($ch), true);
fetch (JavaScript, no SDK)
// No SDK needed: every method is a POST with a JSON body.
const API = process.env.DRIVEDB_API!; // https://<host>/v1/db/<dbId>
const KEY = process.env.DRIVEDB_KEY!; // kid_…:sk_…
async function call(action: string, body: Record<string, unknown>) {
const response = await fetch(`${API}/${action}`, {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
return data;
}
const { insertedId } = await call('insertOne', {
collection: 'clients',
document: { name: 'From fetch', status: 'Lead' },
});
const { documents } = await call('find', {
collection: 'clients',
filter: { status: 'Lead' },
sort: { dealValue: -1 },
limit: 10,
});
console.log(insertedId, documents.length);

Success is 200 with the method’s result as JSON, e.g. {"insertedId":"r3kq8z1m2x7v"} or {"documents":[…],"hasMore":false}. Errors have a matching status and this body:

{
"error": {
"code": "ValidationError",
"message": "Field \"email\" expects an email address.",
"details": { "field": "email" }
}
}

429 and 503 include a Retry-After header (seconds).

JSON has no date type: send dates as ISO strings ("2026-03-01" or "2026-03-01T09:30:00Z"), or as {"$date": "2026-03-01T09:30:00Z"} when a new field should become a date field. Regular expressions are {"$regex": "^ad", "$options": "i"}.

Made by Faeiz Furqan