Skip to content
Docs

API for agents’ own code

For agents that write their own code instead of using MCP tools. The code calls a system's ordinary REST API through Backa, and every change it makes lands in your audit log with Rollback.

Address

https://api.backa.ai/v1/<system>/<the system's own path>

Send exactly the request you would send to the system, with the same method, query and JSON body. You get the system's own answer back. For example, HubSpot's /crm/v3/objects/contacts becomes:

GET https://api.backa.ai/v1/hubspot/crm/v3/objects/contacts?limit=10
Authorization: Bearer <token>

Systems

SystemIdThe path after the id
GitHubgithubREST API paths, such as /repos/acme/web/issues
HubSpothubspotPaths on api.hubapi.com, such as /crm/v3/objects/deals
SalesforcesalesforcePaths on your instance, such as /services/data/v62.0/sobjects/Account
NotionnotionPaths on api.notion.com, such as /v1/pages
SlackslackWeb API methods, such as /chat.postMessage
JirajiraPaths on your Jira site, such as /rest/api/3/issue
StripestripePaths on api.stripe.com, such as /v1/coupons

The system has to be connected in Backa first. Backa adds the system's sign-in on the way out, so the agent never has it. The rest of Backa's systems work over MCP.

Sign in with a code

The agent signs itself in. It asks for a code, you approve it in Backa, and it gets a token. Nobody copies a key.

  1. Ask for a code. client_name is the name you will see in Backa.
    POST https://api.backa.ai/oauth/device
    Content-Type: application/x-www-form-urlencoded
    
    client_name=Sales sync script
    The answer has device_code, user_code, verification_uri_complete, expires_in (600 seconds) and interval (5 seconds).
  2. Show the person user_code and the link verification_uri_complete. They sign in to Backa, check that the code matches, pick a workspace and slide to allow.
  3. Meanwhile, ask for the token every 5 seconds:
    POST https://api.backa.ai/oauth/token
    Content-Type: application/x-www-form-urlencoded
    
    grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=<device_code>&client_id=<client_id>
    Until the person has answered, this returns authorization_pending. slow_down means ask less often, access_denied that they said no, and expired_token that the code ran out and you start again.
  4. The answer has access_token, valid for an hour, and refresh_token. Send Authorization: Bearer <access_token> on every call. When it runs out, get a new one with grant_type=refresh_token.

The agent then shows up under Agents in Backa with the name it gave. Remove it there and its tokens stop working at once.

Reads

GET calls pass straight through and answer exactly what the system answers. Nothing is written to the audit log.

Changes

Every change goes through the same steps as over MCP: your policies, the outbound queue and the anomaly detection. What happens depends on the change:

The changeWhat happensAnswer
One Backa knows how to roll backRuns at once, with Rollback in the audit logThe system's own status and body
An email, message or commentWaits in the outbound queue for a short while, then goes out202 with an actionId
One Backa doesn't know yetWaits for a person to approve it in the audit log202 with an actionId
Blocked by a ruleDoesn't run403

A change that ran carries these headers next to the system's answer:

  • Backa-Action: the change's id in the audit log.
  • Backa-Status: applied, held, awaiting-approval and so on (see Answers).
  • Backa-Undo-Until: when the rollback window closes.
  • Backa-Status-Url: where to ask how it went.

Waiting for a decision

When a change answers 202, nothing has happened yet. Don't send it again. Ask what became of it instead:

GET https://api.backa.ai/v1/actions/<actionId>?wait=30

wait holds the answer open for up to 40 seconds, until something happens. Then status tells you whether it was applied, rejected or expired, and result carries the system's answer, such as the new record's id. A change waiting for approval lapses after a while if nobody decides.

Retries

Send an Idempotency-Key header with each change, any unique string. If the network drops and you send the same call again with the same key, Backa returns the first answer with Backa-Replayed: true and writes nothing twice. Keys are kept for 24 hours. The same key with a different body answers idempotency_conflict.

POST https://api.backa.ai/v1/github/repos/acme/web/issues
Authorization: Bearer <token>
Idempotency-Key: 7f3a9c2e-issue-login-bug
Content-Type: application/json

{ "title": "Login button does nothing on Safari" }

Dry run

Add Backa-Dry-Run: true to a change to see what it would do, without doing it. Nothing is sent to the system or written to the audit log. The answer is a preview:

{ "preview": {
    "wouldRun": "runs",
    "summary": "Change deal 9182 in HubSpot",
    "fields": [{ "name": "amount", "before": "4200", "after": "5100" }],
    "undoable": true,
    "undoWindowDays": 30,
    "warnings": []
} }

wouldRun is runs, needs-approval, held or blocked. To make the change, send the same call again without the header.

Answers

Backa's own answers, for a change that waits or when you ask about one, look like this:

{ "backa": {
    "actionId": "act_…",
    "status": "held",
    "system": "slack",
    "summary": "Post a message in #sales",
    "undoable": true,
    "heldUntil": "2026-11-23T10:14:00Z",
    "journal": "https://app.backa.ai/w/…",
    "statusUrl": "https://api.backa.ai/v1/actions/act_…"
} }

status is one of applied, held (in the outbound queue), awaiting-approval, blocked, failed, undone, rejected, expired or canceled. These are the same answers agents get over MCP.

Errors

When Backa itself says no, the answer is:

{ "error": {
    "code": "not_connected",
    "message": "Jira isn't connected in this workspace.",
    "retryable": false,
    "fix": "Ask the person to connect Jira under Systems in Backa."
} }

Try again only when retryable is true, after retryAfterSeconds. fix says what has to change first, often something to tell the person. Errors from the system itself come back as the system sent them.

CodeMeans
invalid_tokenThe token is missing, expired or removed. Refresh it, or sign in again.
unknown_systemThe id after /v1/ isn't one of the systems above.
not_connectedThe system isn't connected in this workspace.
blocked, pausedA policy blocks it, or the agent is suspended. That is the person's choice: tell them, don't work around it.
app_not_allowed, system_not_allowedThe workspace only allows certain agents or systems.
rate_limitedMore than 600 calls a minute. Retryable.
unavailableBacka or the system can't be reached right now. Retryable.
idempotency_conflict, in_progressThe key was used with another body, or its first call is still running (retryable).
bad_path, bad_bodyBacka couldn't read the path or the body.

Roll back

Changes made through the API are rolled back like any other: from the audit log, with Point-in-time rollback, or by an agent over MCP with backa_undo. Rollback checks that nobody has changed the thing since, and stops if they have.