Skip to content

API keys

Most people never call these routes: Developer settings in the app uses them for you. They are listed so you know what the page does.

MethodPathAuthWhat
POST/api/v1/api-keysSessionCreate a key
GET/api/v1/api-keysSessionList keys (no secrets)
DELETE/api/v1/api-keys/{id}SessionRevoke a key
POST/api/v1/api-keys

Create a key. The full key is in this response only. At most 10 active keys per account; the 11th returns 400. Session only: this route reads the signed-in browser cookie on www.brainpercent.app. A Bearer key is refused with 401.

Request body

NameTypeRequiredDescription
namestringRequired1 to 100 characters
permissionsstring[]OptionalAny of read, write, delete, or render. A picture key holds render only (the key form calls it Pictures only): it can ONLY make pictures through the /renders routes, reads nothing else and gets 403 on every other endpoint. Default ["read"].
scopesstring[]OptionalAny of articles, social, projects, user. Only projects is enforced today. Default all four.
expires_in_daysintegerOptional1 to 365. Omit for a key that does not expire.
Request
// Run on https://www.brainpercent.app while signed in.
const res = await fetch('/api/v1/api-keys', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: 'My server', permissions: ['read', 'write'] }),
});
const { data } = await res.json();
console.log(data.key); // shown once
201Response
{
  "success": true,
  "data": {
    "id": "12084af0-825d-488e-86d8-343a80fc590a",
    "name": "My server",
    "key": "bp_eafc3cf0c78…(64 hex characters)",
    "key_prefix": "bp_eafc3cf0c78...",
    "permissions": [
      "read",
      "write"
    ],
    "scopes": [
      "articles",
      "social",
      "projects",
      "user"
    ],
    "created_at": "2026-10-29T15:34:48.441663+00:00",
    "expires_at": null
  }
}
GET/api/v1/api-keys

List every key on the account, newest first, including revoked ones (is_active false). Only the display prefix is returned, never the key. Session only: this route reads the signed-in browser cookie on www.brainpercent.app. A Bearer key is refused with 401.

Request
const { data } = await fetch('/api/v1/api-keys').then((r) => r.json());
data.forEach((k) => console.log(k.name, k.key_prefix, k.is_active));
200Response
{
  "success": true,
  "data": [
    {
      "id": "12084af0-825d-488e-86d8-343a80fc590a",
      "name": "My server",
      "key_prefix": "bp_eafc3cf0c78...",
      "permissions": [
        "read",
        "write"
      ],
      "scopes": [
        "articles",
        "social",
        "projects",
        "user"
      ],
      "created_at": "2026-10-29T15:34:48.441663+00:00",
      "last_used_at": "2026-10-29T15:46:25.102+00:00",
      "expires_at": null,
      "is_active": true
    }
  ]
}
DELETE/api/v1/api-keys/:id

Revoke a key. It stops working on the next request, for REST and MCP alike. Revoking cannot be undone. An id that is not one of your keys returns 404; revoking an already revoked key returns 200 again. Session only: this route reads the signed-in browser cookie on www.brainpercent.app. A Bearer key is refused with 401.

Request
await fetch('/api/v1/api-keys/12084af0-825d-488e-86d8-343a80fc590a', {
  method: 'DELETE',
}).then((r) => r.json());
200Response
{
  "success": true,
  "message": "API key revoked"
}

Errors on these routes

StatusBodyWhen
400{ "error": "Invalid JSON body" }Body is not JSON
400{ "error": "Validation failed", "details": [...] }Bad name, permission, scope or expiry
400{ "error": "Maximum 10 API keys allowed per user" }Ten active keys already
401{ "error": "Authentication required" }Not signed in (a Bearer key does not count)
404{ "error": "API key not found or already revoked" }Revoke on an id that is not yours