API Reference

All tenant API requests require an X-API-Key header. Create an API key from your dashboard. Project is implicit from the key — never in the URL.

Authentication

POST/v1/auth/signup

Create a new end-user account.

{
  "email": "user@example.com",
  "password": "min8chars"
}

Returns user + session_token (mms_...).

POST/v1/auth/login

Authenticate an existing user.

{ "email": "...", "password": "..." }
POST/v1/auth/logout

Invalidate a session. Send the session token as Authorization: Bearer mms_....

GET/v1/auth/me

Get the current user. Requires Authorization: Bearer mms_.... Sessions expire 30 days after sign-in; an expired session gets 401.

POST/v1/auth/users

Create a verified, passwordless user from your server. Requires a plain API key (scoped and session tokens get 403). id is optional (A-Z a-z 0-9 _ -, max 128); otherwise a UUID is generated. A later magic-link sign-in for the same email signs in as this user.

{ "email": "user@example.com", "id": "optional-id" }
→ 201 { "user": { "id", "email", "email_verified": true, "created_at" } }

409 if the email or id is already taken.

POST/v1/auth/magic-link

Start a passwordless sign-in. With "deliver": "return" the token comes back to your server so you can email your own link; otherwise the service sends the email. Pass X-End-User-IP when calling from your server so rate limits apply per user.

{ "email": "user@example.com", "deliver": "return" }
→ { "token": "...", "expires_in": 900 }
GET/v1/auth/verify?token=x

Verify a magic link token. Returns user + session token.

Documents

POST/v1/collections/{name}/documents

Create a document. Body is any JSON object. Optionally include an id field; otherwise one is auto-generated.

GET/v1/collections/{name}/documents/{id}

Get a single document by ID.

PUT/v1/collections/{name}/documents/{id}

Replace a document entirely. Add ?upsert=true to create it if missing instead of returning 404.

PATCH/v1/collections/{name}/documents/{id}

Merge fields into a document. Set a field to null to delete it. Add ?upsert=true to create it if missing; concurrent upserts to different fields never overwrite each other.

PATCH ...?upsert=true  { "done": true }
→ { "id": "...", "status": "patched", "created": true }
DELETE/v1/collections/{name}/documents/{id}

Delete a document.

Query

POST/v1/collections/{name}/query
{
  "filter": {
    "status": "active",
    "age": { "$gte": 21 }
  },
  "sort": [{ "field": "created_at", "order": "desc" }],
  "limit": 20,
  "start_after": "lastDocId"
}

Operators: $eq, $ne, $gt, $gte, $lt, $lte, $in (max 30), $prefix.

Inequality filters work on one field only. Pagination is cursor-based via start_after.

Collections

GET/v1/collections

List all collections in the project.

Scoped Tokens

POST/v1/tokens

Mint a scoped JWT. Requires API key auth (not a scoped token).

{
  "scope": {
    "todos": { "user_id": "abc123" },
    "*": {}
  },
  "ttl": 3600
}

Scope maps collection names to required field filters. Use * for wildcard. Max TTL: 24 hours.

Authentication Model

X-API-Key: mm_... — Identifies the project. Always required.

Authorization: Bearer mms_... — End-user session token (optional, identifies user). Expires after 30 days.

Authorization: Bearer <jwt> — Scoped token (alternative to session, restricts data access).