{"openapi":"3.1.0","info":{"title":"briefkasten cloud API","version":"1","description":"The control plane of briefkasten cloud. The same operations are MCP tools at /mcp. Auth: `Authorization: Bearer bk_at_…` (CLI session) or `bk_pat_…` (API token)."},"servers":[{"url":"https://briefkasten.fabrik.computer"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"bk_pat_… or bk_at_…","description":"An API token: `briefkasten token create --name docs --scope manage`, or Tokens in the dashboard (/app/tokens)."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object"}},"required":["code","message"]}}}}},"paths":{"/api/v1/auth/methods":{"get":{"operationId":"auth.methods","summary":"How this instance lets you sign in","tags":["auth"],"security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"instance":{"type":"string","const":"cloud"},"methods":{"type":"array","items":{"type":"string","enum":["email_code","device_code","token"]}},"endpoints":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"legal":{"type":"object","properties":{"terms_url":{"type":"string"},"privacy_url":{"type":"string"},"terms_version":{"type":"string"},"privacy_version":{"type":"string"}},"required":["terms_url","privacy_url","terms_version","privacy_version"],"additionalProperties":false,"description":"what a new account accepts: pass accept_terms (with these versions) to auth.email.verify"}},"required":["instance","methods","endpoints","legal"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/auth/email/start":{"post":{"operationId":"auth.email.start","summary":"Mail a one-time sign-in code","tags":["auth"],"description":"Step one of `briefkasten login me@example.com`. The answer is the same for known and unknown addresses; the account is created on the first verified code.","security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"login_id":{"type":"string"},"email":{"type":"string"},"expires_in":{"type":"number"},"message":{"type":"string"}},"required":["login_id","email","expires_in","message"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","maxLength":254}},"required":["email"]}}}}}},"/api/v1/auth/email/verify":{"post":{"operationId":"auth.email.verify","summary":"Exchange the mailed code for tokens","tags":["auth"],"description":"Creates the account on its first verified code, which needs `accept_terms: true` (and, best, the `terms_version` and `privacy_version` the person was shown; `auth.methods` lists them). Without it a new account is refused with `terms_not_accepted` and the code stays valid: ask, then send the same code again. Existing accounts don't need it.","security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"access_token":{"type":"string"},"token_type":{"type":"string","const":"Bearer"},"expires_in":{"type":"number"},"refresh_token":{"type":"string"},"session_id":{"type":"string"},"status":{"type":"string","const":"signed_in"},"account":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"created":{"type":"boolean"}},"required":["id","email","created"],"additionalProperties":false},"tenant":{"type":"string"},"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"],"additionalProperties":false},"welcome":{"type":"string"},"legal":{"type":"object","properties":{"terms_url":{"type":"string"},"privacy_url":{"type":"string"},"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted":{"anyOf":[{"type":"object","properties":{"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted_at":{"type":"string"}},"required":["terms_version","privacy_version","accepted_at"],"additionalProperties":false},{"type":"null"}]},"needs_acceptance":{"type":"boolean","description":"the current terms are not accepted yet: show them and ask (POST /api/v1/account/legal/accept)"}},"required":["terms_url","privacy_url","terms_version","privacy_version","accepted","needs_acceptance"],"additionalProperties":false}},"required":["access_token","token_type","expires_in","refresh_token","session_id","status","account","tenant","plan","welcome","legal"],"additionalProperties":false},{"type":"object","properties":{"status":{"type":"string","const":"mfa_required"},"mfa_token":{"type":"string"},"expires_in":{"type":"number"},"methods":{"type":"array","items":{"type":"string","enum":["totp","recovery_code"]}}},"required":["status","mfa_token","expires_in","methods"],"additionalProperties":false}]}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"login_id":{"type":"string","maxLength":64},"code":{"type":"string","maxLength":32},"client_name":{"default":"briefkasten CLI","type":"string","minLength":1,"maxLength":120},"accept_terms":{"description":"the person accepts the terms of use and the privacy policy; required when the code creates an account","type":"boolean"},"terms_version":{"description":"the terms version the person was shown; refused with terms_version_mismatch if not the current one","type":"string","maxLength":32},"privacy_version":{"description":"the privacy policy version the person was shown","type":"string","maxLength":32}},"required":["login_id","code"]}}}}}},"/api/v1/auth/mfa":{"post":{"operationId":"auth.mfa","summary":"Finish a sign-in with a second factor","tags":["auth"],"security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"token_type":{"type":"string","const":"Bearer"},"expires_in":{"type":"number"},"refresh_token":{"type":"string"},"session_id":{"type":"string"},"status":{"type":"string","const":"signed_in"},"account":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"created":{"type":"boolean"}},"required":["id","email","created"],"additionalProperties":false},"tenant":{"type":"string"},"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"],"additionalProperties":false},"welcome":{"type":"string"},"legal":{"type":"object","properties":{"terms_url":{"type":"string"},"privacy_url":{"type":"string"},"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted":{"anyOf":[{"type":"object","properties":{"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted_at":{"type":"string"}},"required":["terms_version","privacy_version","accepted_at"],"additionalProperties":false},{"type":"null"}]},"needs_acceptance":{"type":"boolean","description":"the current terms are not accepted yet: show them and ask (POST /api/v1/account/legal/accept)"}},"required":["terms_url","privacy_url","terms_version","privacy_version","accepted","needs_acceptance"],"additionalProperties":false}},"required":["access_token","token_type","expires_in","refresh_token","session_id","status","account","tenant","plan","welcome","legal"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"mfa_token":{"type":"string","maxLength":80},"code":{"type":"string","maxLength":32}},"required":["mfa_token","code"]}}}}}},"/api/v1/auth/device":{"post":{"operationId":"auth.device","summary":"Start a device sign-in (RFC 8628 device authorization request)","tags":["auth"],"security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"device_code":{"type":"string"},"user_code":{"type":"string"},"verification_uri":{"type":"string"},"verification_uri_complete":{"type":"string"},"expires_in":{"type":"number"},"interval":{"type":"number"}},"required":["device_code","user_code","verification_uri","verification_uri_complete","expires_in","interval"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"client_name":{"default":"briefkasten CLI","type":"string","minLength":1,"maxLength":120}}}}}}}},"/api/v1/auth/token":{"post":{"operationId":"auth.token","summary":"Token endpoint: refresh (rotating) or device-code grant","tags":["auth"],"description":"Errors follow RFC 6749 §5.2 / RFC 8628 §3.5: `authorization_pending`, `slow_down`, `access_denied`, `expired_token`, `invalid_grant`.","security":[],"x-briefkasten-auth":"public","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"token_type":{"type":"string","const":"Bearer"},"expires_in":{"type":"number"},"refresh_token":{"type":"string"},"session_id":{"type":"string"}},"required":["access_token","token_type","expires_in","refresh_token","session_id"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/auth/logout":{"post":{"operationId":"auth.logout","summary":"End the current session","tags":["auth"],"x-briefkasten-auth":"user","x-mcp-tool":"auth_logout","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/whoami":{"get":{"operationId":"whoami","summary":"Who this token is: account, tenant, plan and limits","tags":["account"],"x-briefkasten-auth":"user","x-mcp-tool":"whoami","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"instance":{"type":"object","properties":{"kind":{"type":"string","const":"cloud"},"mode":{"type":"string","const":"multi","description":"the gateway mode the hosted service runs"},"domain":{"type":"string"},"url":{"type":"string"},"hooksUrl":{"type":"string"}},"required":["kind","mode","domain","url","hooksUrl"],"additionalProperties":false},"account":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"mfa":{"type":"boolean"},"admin":{"type":"boolean"}},"required":["id","email","mfa","admin"],"additionalProperties":false},"tenant":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["active","suspended"]}},"required":["id","status"],"additionalProperties":false},"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"],"additionalProperties":false},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"billing":{"type":"boolean","description":"this target offers `briefkasten billing …`"},"principal":{"type":"object","properties":{"kind":{"type":"string","enum":["web","cli","impersonation","token"]},"scopes":{"type":"array","items":{"type":"string"}},"readOnly":{"type":"boolean"}},"required":["kind","scopes","readOnly"],"additionalProperties":false},"legal":{"type":"object","properties":{"terms_url":{"type":"string"},"privacy_url":{"type":"string"},"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted":{"anyOf":[{"type":"object","properties":{"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted_at":{"type":"string"}},"required":["terms_version","privacy_version","accepted_at"],"additionalProperties":false},{"type":"null"}]},"needs_acceptance":{"type":"boolean","description":"the current terms are not accepted yet: show them and ask (POST /api/v1/account/legal/accept)"}},"required":["terms_url","privacy_url","terms_version","privacy_version","accepted","needs_acceptance"],"additionalProperties":false}},"required":["instance","account","tenant","plan","limits","billing","principal","legal"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/account/legal/accept":{"post":{"operationId":"account.legal.accept","summary":"Accept the current terms of use and privacy policy","tags":["account"],"description":"For an account whose `whoami.legal.needs_acceptance` is true (the terms changed since it accepted them). Pass the versions the person was shown.","x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"account_legal_accept","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"terms_url":{"type":"string"},"privacy_url":{"type":"string"},"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted":{"anyOf":[{"type":"object","properties":{"terms_version":{"type":"string"},"privacy_version":{"type":"string"},"accepted_at":{"type":"string"}},"required":["terms_version","privacy_version","accepted_at"],"additionalProperties":false},{"type":"null"}]},"needs_acceptance":{"type":"boolean","description":"the current terms are not accepted yet: show them and ask (POST /api/v1/account/legal/accept)"}},"required":["terms_url","privacy_url","terms_version","privacy_version","accepted","needs_acceptance"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"terms_version":{"type":"string","maxLength":32},"privacy_version":{"type":"string","maxLength":32}},"required":["terms_version","privacy_version"]}}}}}},"/api/v1/account/delete":{"post":{"operationId":"account.delete","summary":"Delete the account, its tenant, config and events (irreversible)","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"account_delete","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean","const":true}},"required":["deleted"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"confirmEmail":{"type":"string","maxLength":254},"code":{"type":"string","maxLength":32}},"required":["confirmEmail"]}}}}}},"/api/v1/sessions":{"get":{"operationId":"sessions.list","summary":"Signed-in browsers and CLIs","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"sessions_list","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["web","cli","impersonation"]},"name":{"type":"string"},"ip":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastUsedAt":{"type":"string","description":"ISO 8601 timestamp"},"expiresAt":{"type":"string","description":"ISO 8601 timestamp"},"mfa":{"type":"boolean"},"current":{"type":"boolean"}},"required":["id","kind","name","ip","userAgent","createdAt","lastUsedAt","expiresAt","mfa","current"],"additionalProperties":false}}},"required":["sessions"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sessions/{id}":{"delete":{"operationId":"sessions.revoke","summary":"Sign a session out","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"sessions_revoke","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/mfa":{"get":{"operationId":"mfa.status","summary":"Two-factor status","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_status","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"totp":{"type":"boolean"},"enabledAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"recoveryCodesLeft":{"type":"number"},"sessionVerifiedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]}},"required":["totp","enabledAt","recoveryCodesLeft","sessionVerifiedAt"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/mfa/totp/setup":{"post":{"operationId":"mfa.totp.setup","summary":"Start authenticator-app setup: a secret and an otpauth:// URL","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_totp_setup","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"secret":{"type":"string"},"otpauthUrl":{"type":"string"},"expiresIn":{"type":"number"}},"required":["secret","otpauthUrl","expiresIn"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/mfa/totp/enable":{"post":{"operationId":"mfa.totp.enable","summary":"Confirm setup with a code; answers recovery codes once","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_totp_enable","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"recoveryCodes":{"type":"array","items":{"type":"string"}}},"required":["recoveryCodes"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":32}},"required":["code"]}}}}}},"/api/v1/mfa/totp/disable":{"post":{"operationId":"mfa.totp.disable","summary":"Turn two-factor off (needs a current code)","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_totp_disable","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":32}},"required":["code"]}}}}}},"/api/v1/mfa/recovery-codes":{"post":{"operationId":"mfa.recovery.regenerate","summary":"Replace the recovery codes (needs a current code)","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_recovery_regenerate","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"recoveryCodes":{"type":"array","items":{"type":"string"}}},"required":["recoveryCodes"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":32}},"required":["code"]}}}}}},"/api/v1/mfa/step-up":{"post":{"operationId":"mfa.stepUp","summary":"Prove a second factor for this session (admin actions)","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"mfa_stepUp","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"mfaAt":{"type":"string","description":"ISO 8601 timestamp"}},"required":["mfaAt"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":32}},"required":["code"]}}}}}},"/api/v1/device/{userCode}":{"get":{"operationId":"device.lookup","summary":"What a pending device sign-in is (before approving it)","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"device_lookup","parameters":[{"name":"userCode","in":"path","required":true,"schema":{"type":"string","maxLength":16}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"userCode":{"type":"string"},"clientName":{"type":"string"},"ip":{"type":["string","null"]},"requestedAt":{"type":"string","description":"ISO 8601 timestamp"}},"required":["userCode","clientName","ip","requestedAt"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"device.decide","summary":"Approve or deny a device sign-in","tags":["account"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"device_decide","parameters":[{"name":"userCode","in":"path","required":true,"schema":{"type":"string","maxLength":16}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"approved":{"type":"boolean"}},"required":["approved"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"approve":{"type":"boolean"}},"required":["userCode","approve"]}}}}}},"/api/v1/tokens":{"get":{"operationId":"tokens.list","summary":"Management tokens (CI, servers) and subscriber tokens (clients that connect out)","tags":["tokens"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"tokens_list","parameters":[{"name":"kind","in":"query","schema":{"type":"string","enum":["management","subscriber"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"tokens":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","const":"management"},"name":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","billing"]}},"prefix":{"type":"string"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastUsedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"expiresAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]}},"required":["id","kind","name","scopes","prefix","createdAt","lastUsedAt","expiresAt"],"additionalProperties":false},{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","const":"subscriber"},"name":{"type":"string"},"project":{"type":["string","null"]},"prefix":{"type":"string"},"filters":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastUsedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]}},"required":["id","kind","name","project","prefix","filters","createdAt","lastUsedAt"],"additionalProperties":false}]}}},"required":["tokens"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"tokens.create","summary":"Create a token; the secret is answered once","tags":["tokens"],"description":"`kind: management` makes a scoped API token for CI/servers (`BRIEFKASTEN_TOKEN`; needs a signed-in session). `kind: subscriber` makes a token a client uses to connect out and receive events.","x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"tokens_create","parameters":[],"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","const":"management"},"name":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","billing"]}},"prefix":{"type":"string"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastUsedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"expiresAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"token":{"type":"string"}},"required":["id","kind","name","scopes","prefix","createdAt","lastUsedAt","expiresAt","token"],"additionalProperties":false},{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","const":"subscriber"},"name":{"type":"string"},"project":{"type":["string","null"]},"prefix":{"type":"string"},"filters":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastUsedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"token":{"type":"string"},"streamUrl":{"type":"string"},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["id","kind","name","project","prefix","filters","createdAt","lastUsedAt","token","streamUrl","config"],"additionalProperties":false}]}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/tokens/{id}":{"delete":{"operationId":"tokens.revoke","summary":"Revoke a token","tags":["tokens"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"tokens_revoke","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects":{"get":{"operationId":"projects.list","summary":"List projects","tags":["projects"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"projects_list","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"projects":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"sources":{"type":"number"},"routes":{"type":"number"}},"required":["name","createdAt","sources","routes"],"additionalProperties":false}}},"required":["projects"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"projects.create","summary":"Create a project","tags":["projects"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"projects_create","parameters":[],"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["name","createdAt","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}},"required":["name"]}}}}}},"/api/v1/projects/{project}":{"delete":{"operationId":"projects.delete","summary":"Delete a project with its sources and routes","tags":["projects"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"projects_delete","parameters":[{"name":"project","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean","const":true},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["deleted","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project}/sources":{"get":{"operationId":"sources.list","summary":"List a project's sources","tags":["sources"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"sources_list","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string","enum":["github","linear","nightwatch","posthog","sentry","generic"]},"options":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"hookUrl":{"type":"string","description":"paste this into the provider's webhook settings"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"secretRotatedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]}},"required":["name","project","adapter","options","hookUrl","createdAt","secretRotatedAt"],"additionalProperties":false}}},"required":["sources"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"sources.create","summary":"Add a webhook source; answers its hook URL and (once) its secret","tags":["sources"],"description":"github, posthog and generic get a generated secret. linear, sentry and nightwatch generate their own: pass it as `secret`.","x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"sources_create","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string","enum":["github","linear","nightwatch","posthog","sentry","generic"]},"options":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"hookUrl":{"type":"string","description":"paste this into the provider's webhook settings"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"secretRotatedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"secret":{"description":"shown once","type":["string","null"]},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["name","project","adapter","options","hookUrl","createdAt","secretRotatedAt","secret","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"},"adapter":{"type":"string","enum":["github","linear","nightwatch","posthog","sentry","generic"]},"options":{"default":{},"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"secret":{"type":"string","minLength":8,"maxLength":256}},"required":["adapter"]}}}}}},"/api/v1/projects/{project}/sources/{source}":{"patch":{"operationId":"sources.update","summary":"Change a source's options or rotate its secret","tags":["sources"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"sources_update","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}},{"name":"source","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string","enum":["github","linear","nightwatch","posthog","sentry","generic"]},"options":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"hookUrl":{"type":"string","description":"paste this into the provider's webhook settings"},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"secretRotatedAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"secret":{"type":["string","null"]},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["name","project","adapter","options","hookUrl","createdAt","secretRotatedAt","secret","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"options":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},"rotateSecret":{"type":"boolean"},"secret":{"type":"string","minLength":8,"maxLength":256}},"required":["source"]}}}}},"delete":{"operationId":"sources.delete","summary":"Remove a source","tags":["sources"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"sources_delete","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}},{"name":"source","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean","const":true},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["deleted","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project}/sources/{source}/test":{"post":{"operationId":"sources.test","summary":"Send a sample delivery through a source, marked as a test","tags":["sources"],"description":"Injects a realistic delivery of the source's adapter (`event`, default its first sample; see `GET /api/v1/adapters`), signed with the source's secret. It is verified, kept, routed and streamed like a real delivery, with `test: true`.","x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"sources_test","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}},{"name":"source","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"event":{"type":"object","properties":{"id":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string"},"source":{"type":"string"},"event":{"type":"string"},"target":{"type":["string","null"]},"at":{"type":"string"},"sizeBytes":{"type":"integer","minimum":0,"maximum":9007199254740991},"verification":{"type":"object","properties":{"ok":{"type":"boolean"},"method":{"type":"string"},"reason":{"type":["string","null"]}},"required":["ok","method","reason"],"additionalProperties":false},"held":{"type":"boolean"},"test":{"type":"boolean"},"deliveries":{"type":"object","properties":{"delivered":{"type":"integer","minimum":0,"maximum":9007199254740991},"failed":{"type":"integer","minimum":0,"maximum":9007199254740991},"pending":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["delivered","failed","pending"],"additionalProperties":false},"latencyMs":{"anyOf":[{"type":"number","minimum":0},{"type":"null"}]}},"required":["id","project","adapter","source","event","target","at","sizeBytes","verification","held","test","deliveries","latencyMs"],"additionalProperties":false}},"required":["event"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"event":{"type":"string","minLength":1,"maxLength":100}},"required":["source"]}}}}}},"/api/v1/adapters":{"get":{"operationId":"adapters.list","summary":"The adapters a source can use, with their sample events","tags":["sources"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"adapters_list","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"adapters":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["github","linear","nightwatch","posthog","sentry","generic"]},"name":{"type":"string"},"samples":{"type":"array","items":{"type":"object","properties":{"event":{"type":"string"},"title":{"type":"string"}},"required":["event","title"],"additionalProperties":false}}},"required":["id","name","samples"],"additionalProperties":false}}},"required":["adapters"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project}/routes":{"get":{"operationId":"routes.get","summary":"Which events go to which subscribers","tags":["routes"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"routes_get","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"routes":{"type":"array","items":{"type":"object","properties":{"match":{"type":"object","properties":{"source":{"type":"string","maxLength":200},"event":{"type":"string","maxLength":200},"target":{"type":"string","maxLength":200}},"additionalProperties":false},"to":{"maxItems":50,"type":"array","items":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}},"required":["match","to"],"additionalProperties":false}}},"required":["routes"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"routes.put","summary":"Replace a project's routes","tags":["routes"],"x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"routes_put","parameters":[{"name":"project","in":"path","required":true,"schema":{"default":"default","description":"the project (default: default, which every tenant has)","type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"routes":{"type":"array","items":{"type":"object","properties":{"match":{"type":"object","properties":{"source":{"type":"string","maxLength":200},"event":{"type":"string","maxLength":200},"target":{"type":"string","maxLength":200}},"additionalProperties":false},"to":{"maxItems":50,"type":"array","items":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}},"required":["match","to"],"additionalProperties":false}},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["routes","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"routes":{"maxItems":100,"type":"array","items":{"type":"object","properties":{"match":{"type":"object","properties":{"source":{"type":"string","maxLength":200},"event":{"type":"string","maxLength":200},"target":{"type":"string","maxLength":200}}},"to":{"maxItems":50,"type":"array","items":{"type":"string","minLength":1,"maxLength":48,"pattern":"^[a-z0-9][a-z0-9-]*$"}}},"required":["match","to"]}}},"required":["routes"]}}}}}},"/api/v1/events":{"get":{"operationId":"events.list","summary":"Event history, newest first","tags":["events"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"events_list","parameters":[{"name":"project","in":"query","schema":{"type":"string","maxLength":48}},{"name":"source","in":"query","schema":{"type":"string","maxLength":48}},{"name":"event","in":"query","schema":{"type":"string","maxLength":100}},{"name":"since","in":"query","schema":{"type":"string","maxLength":64}},{"name":"before","in":"query","schema":{"type":"string","maxLength":64}},{"name":"verified","in":"query","schema":{"type":"string","enum":["true","false"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string"},"source":{"type":"string"},"event":{"type":"string"},"target":{"type":["string","null"]},"at":{"type":"string"},"sizeBytes":{"type":"integer","minimum":0,"maximum":9007199254740991},"verification":{"type":"object","properties":{"ok":{"type":"boolean"},"method":{"type":"string"},"reason":{"type":["string","null"]}},"required":["ok","method","reason"],"additionalProperties":false},"held":{"type":"boolean"},"test":{"type":"boolean"},"deliveries":{"type":"object","properties":{"delivered":{"type":"integer","minimum":0,"maximum":9007199254740991},"failed":{"type":"integer","minimum":0,"maximum":9007199254740991},"pending":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["delivered","failed","pending"],"additionalProperties":false},"latencyMs":{"anyOf":[{"type":"number","minimum":0},{"type":"null"}]}},"required":["id","project","adapter","source","event","target","at","sizeBytes","verification","held","test","deliveries","latencyMs"],"additionalProperties":false}},"next":{"type":["string","null"]}},"required":["events","next"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/events/{id}":{"get":{"operationId":"events.get","summary":"One event: headers, body, verification, deliveries","tags":["events"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"events_get","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":64}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"project":{"type":"string"},"adapter":{"type":"string"},"source":{"type":"string"},"event":{"type":"string"},"target":{"type":["string","null"]},"at":{"type":"string"},"sizeBytes":{"type":"integer","minimum":0,"maximum":9007199254740991},"verification":{"type":"object","properties":{"ok":{"type":"boolean"},"method":{"type":"string"},"reason":{"type":["string","null"]}},"required":["ok","method","reason"],"additionalProperties":false},"held":{"type":"boolean"},"test":{"type":"boolean"},"deliveries":{"type":"object","properties":{"delivered":{"type":"integer","minimum":0,"maximum":9007199254740991},"failed":{"type":"integer","minimum":0,"maximum":9007199254740991},"pending":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["delivered","failed","pending"],"additionalProperties":false},"latencyMs":{"anyOf":[{"type":"number","minimum":0},{"type":"null"}]},"headers":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"body":{},"deliveryLog":{"type":"array","items":{"type":"object","properties":{"subscriber":{"type":"string"},"attempt":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"at":{"type":"string"},"status":{"type":"string","enum":["delivered","failed","pending"]},"latencyMs":{"anyOf":[{"type":"number","minimum":0},{"type":"null"}]},"error":{"type":["string","null"]},"redelivery":{"type":"boolean"}},"required":["subscriber","attempt","at","status","latencyMs","error","redelivery"],"additionalProperties":false}}},"required":["id","project","adapter","source","event","target","at","sizeBytes","verification","held","test","deliveries","latencyMs","headers","body","deliveryLog"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/events/{id}/redeliver":{"post":{"operationId":"events.redeliver","summary":"Deliver an event again (to every subscriber, or one)","tags":["events"],"description":"`queued` is how many connected subscribers it went to; 0 means none is connected right now (not an error): a server that connects later collects the event with `since`.","x-briefkasten-auth":"user","x-briefkasten-scope":"write","x-mcp-tool":"events_redeliver","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":64}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"queued":{"type":"number"},"message":{"type":"string"}},"required":["queued","message"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subscriber":{"type":"string","maxLength":48}},"required":["id"]}}}}}},"/api/v1/usage":{"get":{"operationId":"usage.get","summary":"Metered usage, by day/hour or by project/source/event","tags":["usage"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"usage_get","parameters":[{"name":"from","in":"query","schema":{"description":"default: 7 days ago","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"to","in":"query","schema":{"description":"default: now","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"by","in":"query","schema":{"default":"day","type":"string","enum":["hour","day","project","source","event"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"by":{"type":"string","enum":["hour","day","project","source","event"]},"from":{"type":"string"},"to":{"type":"string"},"rows":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}},"required":["by","from","to","rows"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/analytics/series":{"get":{"operationId":"analytics.series","summary":"Events, failure rates and latency over time","tags":["analytics"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"analytics_series","parameters":[{"name":"from","in":"query","schema":{"description":"default: 7 days ago","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"to","in":"query","schema":{"description":"default: now","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"granularity","in":"query","schema":{"default":"hour","type":"string","enum":["hour","day"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"granularity":{"type":"string","enum":["hour","day"]},"from":{"type":"string"},"to":{"type":"string"},"points":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":["string","number","null"]}}},"totals":{"anyOf":[{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":["number","null"]}},{"type":"null"}]}},"required":["granularity","from","to","points","totals"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/analytics/breakdown":{"get":{"operationId":"analytics.breakdown","summary":"Totals per project, source or event type, with a daily series each","tags":["analytics"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"analytics_breakdown","parameters":[{"name":"from","in":"query","schema":{"description":"default: 7 days ago","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"to","in":"query","schema":{"description":"default: now","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"by","in":"query","schema":{"default":"source","type":"string","enum":["project","source","event"]}},{"name":"limit","in":"query","schema":{"default":20,"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"by":{"type":"string","enum":["project","source","event"]},"from":{"type":"string"},"to":{"type":"string"},"rows":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}},"required":["by","from","to","rows"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/billing":{"get":{"operationId":"billing.get","summary":"Plan, limits and this month's usage","tags":["billing"],"x-briefkasten-auth":"user","x-briefkasten-scope":"billing","x-mcp-tool":"billing_get","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"priceMonthlyCents":{"type":"number"},"currency":{"type":"string"},"purchasable":{"type":"boolean"},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"public":{"type":"boolean"}},"required":["id","name","description","priceMonthlyCents","currency","purchasable","limits","public"],"additionalProperties":false},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"period":{"type":"string"},"usage":{"type":"object","properties":{"events":{"type":"number"},"eventsPercent":{"type":["number","null"]},"sources":{"type":"number"},"subscribers":{"type":"number"}},"required":["events","eventsPercent","sources","subscribers"],"additionalProperties":false},"payments":{"type":"object","properties":{"enabled":{"type":"boolean"},"provider":{"type":"string"},"hasCustomer":{"type":"boolean"}},"required":["enabled","provider","hasCustomer"],"additionalProperties":false},"note":{"type":["string","null"]}},"required":["plan","limits","period","usage","payments","note"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/billing/plans":{"get":{"operationId":"billing.plans","summary":"The plans on offer","tags":["billing"],"security":[],"x-briefkasten-auth":"public","x-mcp-tool":"billing_plans","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"plans":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"priceMonthlyCents":{"type":"number"},"currency":{"type":"string"},"purchasable":{"type":"boolean"},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"public":{"type":"boolean"}},"required":["id","name","description","priceMonthlyCents","currency","purchasable","limits","public"],"additionalProperties":false}}},"required":["plans"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/billing/checkout":{"post":{"operationId":"billing.checkout","summary":"A checkout link for a plan","tags":["billing"],"description":"Answers `nothing_to_buy` while every plan is free.","x-briefkasten-auth":"user","x-briefkasten-scope":"billing","x-mcp-tool":"billing_checkout","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"open this in a browser; safe to hand to the person"}},"required":["url"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","maxLength":32}},"required":["plan"]}}}}}},"/api/v1/billing/portal":{"post":{"operationId":"billing.portal","summary":"A link to the payment provider's customer portal (invoices, card)","tags":["billing"],"x-briefkasten-auth":"user","x-briefkasten-scope":"billing","x-mcp-tool":"billing_portal","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"open this in a browser; safe to hand to the person"}},"required":["url"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/notifications":{"get":{"operationId":"notifications.list","summary":"In-app notifications, newest first","tags":["notifications"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"notifications_list","parameters":[{"name":"limit","in":"query","schema":{"default":30,"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"unread":{"type":"number"},"notifications":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"title":{"type":"string"},"body":{"type":"string"},"at":{"type":"string","description":"ISO 8601 timestamp"},"read":{"type":"boolean"}},"required":["id","type","title","body","at","read"],"additionalProperties":false}}},"required":["unread","notifications"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/notifications/read":{"post":{"operationId":"notifications.read","summary":"Mark one notification, or all, as read","tags":["notifications"],"x-briefkasten-auth":"user","x-briefkasten-scope":"read","x-mcp-tool":"notifications_read","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"marked":{"type":"number"}},"required":["marked"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"default":"all","type":"string","maxLength":40}}}}}}}},"/api/v1/notifications/preferences":{"get":{"operationId":"notifications.preferences","summary":"Which notifications arrive on which channels","tags":["notifications"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"notifications_preferences","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"types":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["login_code","new_session","mfa_enabled","mfa_disabled","recovery_codes_regenerated","budget_threshold","plan_changed","payment_failed","account_suspended"]},"label":{"type":"string"},"fixed":{"type":"boolean"},"channels":{"type":"array","items":{"type":"string","enum":["email","in_app","slack","webhook"]}}},"required":["type","label","fixed","channels"],"additionalProperties":false}},"channels":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["email","in_app","slack","webhook"]},"available":{"type":"boolean"}},"required":["id","available"],"additionalProperties":false}}},"required":["types","channels"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/notifications/preferences/{type}":{"put":{"operationId":"notifications.preferences.set","summary":"Choose the channels for one notification type","tags":["notifications"],"x-briefkasten-auth":"user","x-briefkasten-scope":"account","x-mcp-tool":"notifications_preferences_set","parameters":[{"name":"type","in":"path","required":true,"schema":{"type":"string","enum":["login_code","new_session","mfa_enabled","mfa_disabled","recovery_codes_regenerated","budget_threshold","plan_changed","payment_failed","account_suspended"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["login_code","new_session","mfa_enabled","mfa_disabled","recovery_codes_regenerated","budget_threshold","plan_changed","payment_failed","account_suspended"]},"channels":{"type":"array","items":{"type":"string","enum":["email","in_app","slack","webhook"]}}},"required":["type","channels"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"channels":{"maxItems":4,"type":"array","items":{"type":"string","enum":["email","in_app","slack","webhook"]}}},"required":["type","channels"]}}}}}},"/api/v1/admin/tenants":{"get":{"operationId":"admin.tenants.list","summary":"Tenants, newest first","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_list","parameters":[{"name":"search","in":"query","schema":{"type":"string","maxLength":254}},{"name":"status","in":"query","schema":{"type":"string","enum":["active","suspended"]}},{"name":"limit","in":"query","schema":{"default":50,"type":"integer","minimum":1,"maximum":200}},{"name":"offset","in":"query","schema":{"default":0,"type":"integer","minimum":0,"maximum":9007199254740991}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"tenants":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"owner":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"}},"required":["id","email"],"additionalProperties":false},"plan":{"type":"string"},"status":{"type":"string","enum":["active","suspended"]},"suspendedReason":{"type":["string","null"]},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastLoginAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"firstEventAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"lastEventAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"eventsThisMonth":{"type":"number"},"sources":{"type":"number"},"configSynced":{"type":"boolean"},"hasOverrides":{"type":"boolean"}},"required":["id","owner","plan","status","suspendedReason","createdAt","lastLoginAt","firstEventAt","lastEventAt","eventsThisMonth","sources","configSynced","hasOverrides"],"additionalProperties":false}}},"required":["tenants"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/tenants/{id}":{"get":{"operationId":"admin.tenants.get","summary":"One tenant: plan, limits, overrides, projects, sign-up signals","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_get","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"owner":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"}},"required":["id","email"],"additionalProperties":false},"status":{"type":"string","enum":["active","suspended"]},"suspendedReason":{"type":["string","null"]},"createdAt":{"type":"string","description":"ISO 8601 timestamp"},"lastLoginAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"firstEventAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"lastEventAt":{"anyOf":[{"type":"string","description":"ISO 8601 timestamp"},{"type":"null"}]},"eventsThisMonth":{"type":"number"},"sources":{"type":"number"},"configSynced":{"type":"boolean"},"hasOverrides":{"type":"boolean"},"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"priceMonthlyCents":{"type":"number"},"currency":{"type":"string"},"purchasable":{"type":"boolean"},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"public":{"type":"boolean"}},"required":["id","name","description","priceMonthlyCents","currency","purchasable","limits","public"],"additionalProperties":false},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"overrides":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"additionalProperties":false},"configVersion":{"type":"number"},"configPushedVersion":{"type":"number"},"projects":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"sources":{"type":"number"}},"required":["name","sources"],"additionalProperties":false}},"signup":{"anyOf":[{"type":"object","properties":{"ip":{"type":["string","null"]},"asn":{"type":["number","null"]},"country":{"type":["string","null"]},"emailDomain":{"type":"string"},"disposable":{"type":"boolean"}},"required":["ip","asn","country","emailDomain","disposable"],"additionalProperties":false},{"type":"null"}]}},"required":["id","owner","status","suspendedReason","createdAt","lastLoginAt","firstEventAt","lastEventAt","eventsThisMonth","sources","configSynced","hasOverrides","plan","limits","overrides","configVersion","configPushedVersion","projects","signup"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/tenants/{id}/suspend":{"post":{"operationId":"admin.tenants.suspend","summary":"Suspend a tenant: the gateway refuses its hooks and streams","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_suspend","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","const":"suspended"},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["status","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":3,"maxLength":300}},"required":["id","reason"]}}}}}},"/api/v1/admin/tenants/{id}/unsuspend":{"post":{"operationId":"admin.tenants.unsuspend","summary":"Lift a suspension","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_unsuspend","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","const":"active"},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["status","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/tenants/{id}/limits":{"put":{"operationId":"admin.tenants.limits","summary":"Override a tenant's limits (on top of its plan); {} clears","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_limits","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"overrides":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"additionalProperties":false},"config":{"type":"object","properties":{"version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"synced":{"type":"boolean"}},"required":["version","synced"],"additionalProperties":false,"description":"the desired-config version this change produced, and whether the data plane has it yet"}},"required":["limits","overrides","config"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"overrides":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}}}},"required":["id","overrides"]}}}}}},"/api/v1/admin/tenants/{id}/plan":{"put":{"operationId":"admin.tenants.plan","summary":"Move a tenant to a plan","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_tenants_plan","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string"}},"required":["plan"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","maxLength":32}},"required":["id","plan"]}}}}}},"/api/v1/admin/tenants/{id}/impersonate":{"post":{"operationId":"admin.tenants.impersonate","summary":"Open a 30-minute read-only view of a tenant's dashboard","tags":["admin"],"x-briefkasten-auth":"admin","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","maxLength":40}}],"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"sessionId":{"type":"string"},"cookie":{"type":"string"}},"required":["sessionId","cookie"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":3,"maxLength":300}},"required":["id","reason"]}}}}}},"/api/v1/admin/plans":{"get":{"operationId":"admin.plans.list","summary":"Every plan, including hidden ones","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_plans_list","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"plans":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"priceMonthlyCents":{"type":"number"},"currency":{"type":"string"},"purchasable":{"type":"boolean"},"limits":{"type":"object","properties":{"eventsPerMonth":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"sources":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"subscribers":{"anyOf":[{"type":"integer","minimum":0,"maximum":9007199254740991},{"type":"null"}]},"retentionDays":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"ratePerSourcePerMinute":{"anyOf":[{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},{"type":"null"}]},"overLimit":{"type":"string","enum":["hold","refuse"]}},"required":["eventsPerMonth","sources","subscribers","retentionDays","ratePerSourcePerMinute","overLimit"],"additionalProperties":false},"public":{"type":"boolean"}},"required":["id","name","description","priceMonthlyCents","currency","purchasable","limits","public"],"additionalProperties":false}}},"required":["plans"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/audit":{"get":{"operationId":"admin.audit","summary":"The audit log, newest first","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_audit","parameters":[{"name":"tenant","in":"query","schema":{"type":"string","maxLength":40}},{"name":"account","in":"query","schema":{"type":"string","maxLength":40}},{"name":"action","in":"query","schema":{"type":"string","maxLength":60}},{"name":"before","in":"query","schema":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}},{"name":"limit","in":"query","schema":{"default":100,"type":"integer","minimum":1,"maximum":500}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"entries":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string","description":"ISO 8601 timestamp"},"actor":{"type":"object","properties":{"kind":{"type":"string"},"accountId":{"type":["string","null"]}},"required":["kind","accountId"],"additionalProperties":false},"action":{"type":"string"},"target":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string"},"id":{"type":"string"}},"required":["kind","id"],"additionalProperties":false},{"type":"null"}]},"tenantId":{"type":["string","null"]},"ip":{"type":["string","null"]},"details":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":["string","number","boolean","null"]}}},"required":["id","at","actor","action","target","tenantId","ip","details"],"additionalProperties":false}}},"required":["entries"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/analytics/throughput":{"get":{"operationId":"admin.analytics.throughput","summary":"Events across every tenant over time","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_analytics_throughput","parameters":[{"name":"granularity","in":"query","schema":{"default":"day","type":"string","enum":["hour","day"]}},{"name":"days","in":"query","schema":{"default":30,"type":"integer","minimum":1,"maximum":365}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"granularity":{"type":"string","enum":["hour","day"]},"from":{"type":"string"},"to":{"type":"string"},"points":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}},"totals":{"anyOf":[{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}},{"type":"null"}]}},"required":["granularity","from","to","points","totals"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/analytics/top":{"get":{"operationId":"admin.analytics.top","summary":"Top talkers: tenants by events","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_analytics_top","parameters":[{"name":"days","in":"query","schema":{"default":30,"type":"integer","minimum":1,"maximum":365}},{"name":"limit","in":"query","schema":{"default":20,"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"tenants":{"type":"array","items":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}},"required":["tenants"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/analytics/abuse":{"get":{"operationId":"admin.analytics.abuse","summary":"Abuse signals: verification spikes, rate-limit hits, sign-up bursts, disposable domains","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_analytics_abuse","parameters":[{"name":"hours","in":"query","schema":{"default":24,"type":"integer","minimum":1,"maximum":720}},{"name":"minEvents","in":"query","schema":{"default":50,"type":"integer","minimum":1,"maximum":9007199254740991}},{"name":"failureRate","in":"query","schema":{"default":0.3,"type":"number","minimum":0,"maximum":1}},{"name":"burst","in":"query","schema":{"default":5,"type":"integer","minimum":2,"maximum":9007199254740991}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/analytics/funnel":{"get":{"operationId":"admin.analytics.funnel","summary":"signup → first source → first event → active","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_analytics_funnel","parameters":[{"name":"days","in":"query","schema":{"default":30,"type":"integer","minimum":1,"maximum":365}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/admin/sync":{"post":{"operationId":"admin.sync","summary":"Run the scheduled sync now: push lagging configs, pull usage (`days` back, to backfill)","tags":["admin"],"x-briefkasten-auth":"admin","x-mcp-tool":"admin_sync","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"configs":{"type":"object","properties":{"pushed":{"type":"number"},"failed":{"type":"number"}},"required":["pushed","failed"],"additionalProperties":false},"usage":{"type":"object","properties":{"rows":{"type":"number"},"tenants":{"type":"number"}},"required":["rows","tenants"],"additionalProperties":false}},"required":["configs","usage"],"additionalProperties":false}}}},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"days":{"default":2,"type":"integer","minimum":1,"maximum":35}}}}}}}}}}