REST API

REST API overview

Base URL, authentication, errors and conventions.

The MCP server and the dashboard both use this API. Call it from scripts, CI or anything that speaks HTTP.

https://api.briq.cloud/v1

Breaking changes get a new version in the path; new fields do not.

Authentication

Send an API key, created on the dashboard's API keys page, as a Bearer token:

curl https://api.briq.cloud/v1/briqs -H "Authorization: Bearer $BRIQ_API_KEY"

Access tokens of signed-in MCP clients work too, under the policy approved for that client. Account and team routes use the dashboard session.

Sandbox credentials are minted through a person session, not the API keys picker. Their bq_sbox_… bearer permits only the listed operations on one immutable sandbox. It cannot list briqs or use hosted MCP. Client support differs; check the guide's support matrix.

Conventions

  • JSON in and out, camelCase field names (costCentsSoFar, sleepsAt).
  • Money is in euro cents, with decimals for sub-cent amounts.
  • Timestamps are ISO 8601, UTC.
  • Every response about a briq includes costCentsSoFar and sleepsAt.
  • sleep is a string with a unit: "30m", "3h", "7d", or "never". A number there is refused with the string to send instead.

Errors

{ "error": { "code": "policy_violation", "message": "size medium not allowed by key policy", "details": null, "requestId": "req-example" } }

Responses carry an x-request-id header. Middleware error envelopes repeat it as error.requestId. Send your own x-request-id and it is kept. Quote the ID when you ask us about a call. Direct protocol responses can omit envelope fields; keep the response header too.

CodeHTTPWhen
validation400Invalid body, query, region, file or command input; details may explain the constraint
validation413Request body, command or response exceeds a size limit
validation426Shell or exec stream requires a WebSocket upgrade
unauthorized401Missing, expired or revoked credentials
forbidden403Credential, team membership or session origin does not allow this call
plan_limit403The team's plan does not allow the size or resource count
policy_violation402The agent's policy forbids it (size, registry, sleep)
quota_exceeded402Concurrency limit or daily cap reached
quota_exceeded429Rate limit; see retry-after
payment_required402The team has insufficient credits to start the requested work
not_found404Route, resource or readable file was not found
no_regional_route404POST /v1/briqs/{id}/access only: the briq has no regional route. Run its commands through POST /v1/briqs/{id}/exec
invalid_state409Not possible in the briq's current state
idempotency_in_progress409The first request with this Idempotency-Key is still running
idempotency_mismatch422The Idempotency-Key was used for a different request
provider_error502Infrastructure operation failed; some billing failures also use this code
provider_error503Temporary capacity shortage or infrastructure unavailable; the operation's outcome may be unknown
internal500Unexpected server error; report the request ID

Read Error recovery before retrying a failed write or a pending create. Other protocol-level errors can preserve their own HTTP status and body. Sandbox operation errors use fixed messages without details. Policy, plan, credit and availability refusals become 409 invalid_state.

Rate limits follow the team's plan. Requests, creations and exec calls count per credential in a one-minute window; exec streams count open ones per team.

HobbyProTeam
Requests per minute, exec calls included900450015000
Creations per minute (create, fork, stack up)3050200
Open exec streams1650200

Exec status checks allow 600 per minute per credential; system charts allow 30 per minute per team. Support and billing routes have separate limits. A 429 includes retry-after in seconds.

Retries

Send an Idempotency-Key with a request that creates briqs. If the connection drops, send the same request with the same key: it creates nothing twice.

curl https://api.briq.cloud/v1/briqs \
  -H "Authorization: Bearer $BRIQ_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "recipe": "postgres" }'

Send the same call again with the same key and body, and you get the first answer: same status, same body, plus the header Idempotent-Replayed: true.

  • The key is any string up to 255 characters. Use a random UUID, new for each call.
  • It works on POST /v1/briqs, POST /v1/briqs/:id/fork, POST /v1/stacks/:id/fork and POST /v1/stacks/up.
  • A key is kept for 24 hours, per team. A success is kept, and so is a server error (5xx), which may follow a create made in part. The same key gives the same answer. Check existing resources before using a new key: that starts a new operation. After other errors (such as 402 or 429), the same key can run the call again once the refusal is resolved.
  • A repeat gets the first answer as it was, even if the briq was destroyed or changed since, and a call that did not wait (wait: false) repeats its creating snapshot. The credential's limits are not checked again: nothing runs.
  • The same key with another body or path is a 422 idempotency_mismatch.
  • While the first request is running, a repeat waits for it for up to two minutes, then returns a 409 idempotency_in_progress. Send it again.
  • Without the header, a repeat runs again: a second create of the same name is a 409.

The SDK, the CLI and the MCP tools send a key on every create and send the call again with the same key when no answer comes.

Audit

Every authenticated call writes an audit row: credential, action, target, duration, and the client (via, agentName, agentVersion, userAgent). Files, and an exec's stdin, are recorded by size, never their content; env vars by name, never their value; and passwords in a command (--password=…, PGPASSWORD=…, a URL's password) are masked. Read it with GET /v1/audit (?agent=claude-code, ?key=) or on the dashboard.

OpenAPI

/v1/openapi.json describes every endpoint; point any OpenAPI generator at it for a typed client.

Interactive terminals

GET /v1/briqs/{id}/shell upgrades to a WebSocket for a human terminal. Authenticate with an Authorization: Bearer header; cookie authentication is not accepted. The query accepts cols and rows (1–1000, defaults 80 and 24), and term (default xterm). The command is sh -i. Sessions last at most one hour; timeout terminates the command and closes the session. The CLI exits nonzero on timeout and never reconnects automatically. The Node SDK's shellHandshake returns the API URL and headers for a WebSocket client.

Frames are binary, up to 1 MiB, with a channel byte: 0 stdin, 1 stdout, 2 stderr, 3 command end (JSON exit_code, or a generic error), 4 resize (JSON cols and rows), and 255 with payload 0 for stdin EOF. Compression and subprotocols are not supported. A socket close without command end is a failure. The CLI handles raw input, resizing and terminal cleanup: Interactive shell.

On this page

Free to try

Try briq, on us.

Every new account starts with €10 of credits. No card.

Start building

How can we help?

Message to the briq team