REST API
Authentication
Create an API key in Settings, API keys, or a connection token in Settings, Connections. Send it as Authorization: Bearer <token> (or X-API-Key). Read keys can call the GET endpoints only. Connection tokens and write keys can call all of them. A key limited to one project only sees that project.
curl https://mc.bregoraxhimusa.dev/api/v1/me -H "Authorization: Bearer $MC_TOKEN"Errors, limits and retries
Errors always look like { "error": { "code": "validation_error", "message": "...", "issues": [...] } }. The code is stable; the message is for people.
Each key gets a request budget per minute. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; a 429 also has Retry-After. Bodies are capped at 256 KB.
Every POST accepts an Idempotency-Key header. Retrying with the same key and body within 24 hours returns the first response with Idempotent-Replayed: true. The same key with a different body is a 422.
Secrets in tool input, commands, log lines and event data (API keys, bearer tokens, private keys, values of variables named like secrets) are replaced with [REDACTED] before anything is stored.
How approvals work
Before a risky tool runs, POST it to /api/v1/approvals. Your workspace rules answer first: allow or deny come back at once. When a rule says ask, or no rule matches, a person gets the request on their phone and in the app. Send wait (up to 60 seconds) to hold the call until they decide, then keep polling GET /api/v1/approvals/{id}?wait=60 until the decision is not pending. Requests nobody answers expire and count as denied.
With onNoMatch: "default" nothing is stored when no rule matches, and the decision is default: let the tool ask locally as it normally would.
Account
/api/v1/meread scopeWho this token is
Returns the key or connection behind the token, its scope and workspace. Use it to check a token works.
Returns
200 The token's identity. Me
| Field | Type | Notes |
|---|---|---|
| kind * | "api_key" | "connection" | |
| id * | string, up to 64 chars | |
| name * | string | |
| scope * | "read" | "write" | |
| tool * | "claude_code" | "cursor" | "chatgpt" | "claude" | "codex" | "gemini_cli" | "n8n" | "other", nullable | |
| workspace * | object | |
| project * | object, nullable | Set when the token is limited to one project. |
curl "https://mc.bregoraxhimusa.dev/api/v1/me" \
-H "Authorization: Bearer $MC_TOKEN"Agents
/api/v1/agentswrite scopeRegister an agent
Creates the agent, or updates it when one with the same externalId exists. Counts as a heartbeat.
Body
| Field | Type | Notes |
|---|---|---|
| externalId * | string, up to 200 chars | Your own stable id for this agent, for example a session id. Registering again with the same id updates the agent. |
| name * | string, up to 120 chars | |
| vendor | "claude_code" | "cursor" | "chatgpt" | "claude" | "codex" | "gemini_cli" | "n8n" | "other" | Defaults to the connection's tool, or other. |
| projectId | string, up to 64 chars | Needed when the workspace has more than one project and the token is not limited to one. |
| machine | string, up to 120 chars | |
| heartbeatTimeoutSec | integer 30 to 86400 | Mark the agent stuck and alert when no heartbeat or event arrives for this long. |
Returns
200 An existing agent was updated. UpsertAgentResult
201 A new agent was created. UpsertAgentResult
| Field | Type | Notes |
|---|---|---|
| agent * | Agent | |
| created * | boolean |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/agents" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"externalId":"session-8f2c","name":"Refactor billing","vendor":"claude_code","heartbeatTimeoutSec":600}'/api/v1/agents/{agent}read scopeGet an agent
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Returns
200 The agent. Agent
| Field | Type | Notes |
|---|---|---|
| id * | string, up to 64 chars | |
| externalId * | string, nullable | |
| name * | string | |
| vendor * | "claude_code" | "cursor" | "chatgpt" | "claude" | "codex" | "gemini_cli" | "n8n" | "other" | The tool the agent runs in. |
| projectId * | string, up to 64 chars | |
| status * | "idle" | "working" | "needs_you" | "stuck" | "done" | "archived" | |
| currentStep * | string, nullable | |
| progressPct * | integer -9007199254740991 to 9007199254740991, nullable | |
| held * | boolean | True while the workspace is over its plan's agent limit. Events from a held agent are not stored. |
| lastHeartbeatAt * | ISO date, nullable | |
| heartbeatTimeoutSec * | integer -9007199254740991 to 9007199254740991, nullable |
curl "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c" \
-H "Authorization: Bearer $MC_TOKEN"/api/v1/agents/{agent}/heartbeatwrite scopeSend a heartbeat
Tells Mission Control the agent is alive. Without one (or an event) for heartbeatTimeoutSec the agent is marked stuck and an alert fires.
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Returns
200 The agent after the heartbeat. Agent
| Field | Type | Notes |
|---|---|---|
| id * | string, up to 64 chars | |
| externalId * | string, nullable | |
| name * | string | |
| vendor * | "claude_code" | "cursor" | "chatgpt" | "claude" | "codex" | "gemini_cli" | "n8n" | "other" | The tool the agent runs in. |
| projectId * | string, up to 64 chars | |
| status * | "idle" | "working" | "needs_you" | "stuck" | "done" | "archived" | |
| currentStep * | string, nullable | |
| progressPct * | integer -9007199254740991 to 9007199254740991, nullable | |
| held * | boolean | True while the workspace is over its plan's agent limit. Events from a held agent are not stored. |
| lastHeartbeatAt * | ISO date, nullable | |
| heartbeatTimeoutSec * | integer -9007199254740991 to 9007199254740991, nullable |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c/heartbeat" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)"Events
/api/v1/agents/{agent}/eventswrite scopeReport events
Up to 100 events in one call: progress, step, file_changed, log, done, stuck or error. Secrets in messages and data are redacted before storing.
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Body
| Field | Type | Notes |
|---|---|---|
| events * | Event[], up to 100 |
Returns
200 How many events were stored. EventBatchResult
| Field | Type | Notes |
|---|---|---|
| stored * | integer -9007199254740991 to 9007199254740991 | |
| held * | boolean |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c/events" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"events":[{"type":"step","step":"Running tests"},{"type":"progress","progressPct":60},{"type":"file_changed","files":["src/billing.ts"]}]}'Costs
/api/v1/agents/{agent}/costswrite scopeLog a cost
Token usage for one model call or a batch of them. Priced from the model price table unless amountUsd is sent.
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Body
| Field | Type | Notes |
|---|---|---|
| model * | string, up to 100 chars | |
| tokensIn | integer 0 to 1000000000 | |
| tokensOut | integer 0 to 1000000000 | |
| cacheReadTokens | integer 0 to 1000000000 | |
| cacheWriteTokens | integer 0 to 1000000000 | Cache writes with the 5 minute TTL, or with no TTL split. |
| cacheWrite1hTokens | integer 0 to 1000000000 | Cache writes with the 1 hour TTL. |
| amountUsd | number 0 to 10000 | The exact amount. When set, the token counts are stored but not priced. |
Returns
200 What was added. CostResult
| Field | Type | Notes |
|---|---|---|
| micros * | integer -9007199254740991 to 9007199254740991 | Cost in millionths of a US dollar. |
| cents * | integer -9007199254740991 to 9007199254740991 | Cents added to the agent's spend now. Sub-cent amounts carry over to the next call. |
| priced * | boolean | False when the model has no known price and amountUsd was not sent. |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c/costs" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"model":"claude-sonnet-5-5","tokensIn":12000,"tokensOut":1800}'Approvals
/api/v1/approvalswrite scopeAsk before a tool runs
Workspace rules decide first: allow and deny answer at once. Otherwise a pending approval is created for a person, unless onNoMatch is default. With wait, the call holds until a decision or the wait ends.
Body
| Field | Type | Notes |
|---|---|---|
| agent * | string, up to 210 chars | The agent id, or "ext:" followed by its externalId. |
| toolName * | string, up to 200 chars | For example Bash, Edit or an MCP tool name. |
| toolInput | object | The tool's arguments. Secrets are redacted before anything is stored. |
| title | string, up to 200 chars | |
| detail | string, up to 5000 chars | |
| risk | "low" | "medium" | "high" | |
| onNoMatch | "ask" | "default" | When no rule matches: "ask" waits for a person, "default" returns decision default and stores nothing, so the tool asks locally. Default "ask". |
| wait | integer 0 to 60 | Seconds to wait for a person's decision before answering, 0 to 60. |
Returns
200 Decided by a rule, or no rule matched with onNoMatch default, or decided during the wait. AskApprovalResult
201 A pending approval was created and is still pending. AskApprovalResult
| Field | Type | Notes |
|---|---|---|
| decision * | "allow" | "deny" | "pending" | "default" | |
| approval * | Approval, nullable | |
| rule * | object, nullable |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/approvals" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"agent":"ext:session-8f2c","toolName":"Bash","toolInput":{"command":"pnpm deploy --prod"},"wait":55}'/api/v1/approvals/{id}read scopeGet an approval, optionally waiting
With wait=N (up to 60) the call returns as soon as a person decides, or after N seconds with the approval still pending.
idThe approval id.waitSeconds to wait for a decision, 0 to 60. Default 0.
Returns
200 The approval. Approval
| Field | Type | Notes |
|---|---|---|
| id * | string, up to 64 chars | |
| status * | "pending" | "approved" | "rejected" | "expired" | "by_rule" | |
| decision * | "allow" | "deny" | "pending" | |
| title * | string | |
| command * | string, nullable | |
| ruleId * | string, nullable | |
| expiresAt * | ISO date | |
| decidedAt * | ISO date, nullable | |
| messages * | object[] | Replies from the approver, oldest first. |
curl "https://mc.bregoraxhimusa.dev/api/v1/approvals/APPROVAL_ID?wait=55" \
-H "Authorization: Bearer $MC_TOKEN"Messages
/api/v1/agents/{agent}/messagesread scopeRead the agent's inbox
Messages people sent from the agent page that the agent has not acknowledged. Reading marks them delivered; ack them once handled.
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Returns
200 Unacknowledged messages, oldest first. Messages
| Field | Type | Notes |
|---|---|---|
| messages * | Message[] |
curl "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c/messages" \
-H "Authorization: Bearer $MC_TOKEN"/api/v1/agents/{agent}/messages/ackwrite scopeAcknowledge messages
agentThe agent id, or "ext:" followed by the externalId you registered it with.
Body
| Field | Type | Notes |
|---|---|---|
| ids * | string, up to 64 chars[], up to 100 |
Returns
200 How many were acknowledged. Unknown ids and ids from other agents are ignored. AckResult
| Field | Type | Notes |
|---|---|---|
| acked * | integer -9007199254740991 to 9007199254740991 |
curl -X POST "https://mc.bregoraxhimusa.dev/api/v1/agents/ext:session-8f2c/messages/ack" \
-H "Authorization: Bearer $MC_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"ids":["msg_id"]}'