API
Database overview
The Database stores JSON documents for your bot. You read and write it over the public API with a key that has the read:data or write:data scope. Create the key as described in the Public API guide.
Spaces, collections and documents
- A space is the owner of the data: a Discord server (
guilds), a Discord user (users) or the bot itself (bot-space).spaceIdis the Discord server id, the Discord user id, or an id you choose for the bot space. - A collection groups documents in a space. Its name matches
[a-z0-9_][a-z0-9_.-]{0,63}. - A document is a JSON object with an id of 1 to 128 bytes.
Every route comes in three variants that only differ by the space segment of the path:
| Space | Path prefix |
|---|---|
| Discord server | /v1/bots/{botId}/guilds/{spaceId} |
| Discord user | /v1/bots/{botId}/users/{spaceId} |
| Bot | /v1/bots/{botId}/bot-space/{spaceId} |
The examples of this section use the server variant.
Scopes
| Scope | Allows |
|---|---|
read:data |
Read, list, query, aggregate, usage, export |
write:data |
Create, replace, merge and delete documents, atomic operations, batches, collection settings, erasing a person |
Routes at a glance
| Route | Scope | Page |
|---|---|---|
GET /v1/bots/{botId}/collections |
read:data |
Collections and settings |
GET/PUT/PATCH/DELETE .../collections/{collection}/docs/{docId} |
read or write | Documents |
GET .../collections/{collection}/docs |
read:data |
Documents |
POST .../collections/{collection}/query and /aggregate |
read:data |
Queries and aggregates |
POST .../docs/{docId}/ops and POST .../batch |
write:data |
Atomic operations and batches |
PUT .../collections/{collection} |
write:data |
Collections and settings |
GET /v1/bots/{botId}/data/usage and /data/export |
read:data |
Collections and settings |
DELETE /v1/bots/{botId}/subjects/{userId} |
write:data |
Collections and settings |
Document object
| Field | Type | Description |
|---|---|---|
space |
object | kind (guild, bot or user) and id |
collection |
string | Collection name |
id |
string | Document id |
data |
object | The document. Keys starting with $ and __proto__ are refused |
rev |
integer | Incremented at every write |
size_bytes |
integer | Stored size |
created_at, updated_at |
string | ISO 8601 timestamps |
expires_at |
string | Present when the document has a time to live |
Example document object
{
"space": { "kind": "guild", "id": "123456789012345678" },
"collection": "profiles",
"id": "234567890123456789",
"data": { "xp": 1250, "level": 7, "badges": ["early"] },
"rev": 4,
"size_bytes": 71,
"created_at": "2026-11-19T20:12:59Z",
"updated_at": "2026-11-19T22:30:00Z"
}