Skip to main content

Authentication & Rate Limits

The Agent Provisioning API has two trust zones:

API keys & scopes

brs_live_ keys are organization-scoped — the consumer brings its own Brainstormer org + key, and all provisioned agents and their cost bill to that org. Pass the key as a bearer token:
Keys carry scopes. The provisioning endpoints require agents:write. A key missing the required scope is rejected by the gateway:
403 — missing scope
Select a key’s scopes when you generate it in the Developer Portal (/developer → pick an application → Generate Key). New keys default to chat and kb:read; tick agents:write to allow provisioning. A key’s granted scopes are listed alongside it in the key table.

No secrets in the browser (READ FIRST)

A browser must never hold a brs_live_ key. Provisioning is a cost-incurring write (scrape + LLM + embeddings), so it is authorized by a secret your server controls — never shipped to end users.
The only supported v1 integration is Pattern A — client backend proxy:
The asymmetry that makes this safe: chat never needs a secret — it is the anonymous, slug-based surface, embeddable front-end-only. Only the provisioning write is gated, and that’s the part your backend handles. See the quickstart for a Next.js reference.
A publishable, origin-scoped browser session token (Pattern B) for backend-less consumers is deferred — not in v1.

Cloudflare Turnstile (bot protection)

from-url accepts a Cloudflare Turnstile token, verified server-side. When the platform is configured with a TURNSTILE_SECRET_KEY, the token is required.
  1. Render the Turnstile widget in the browser; obtain a token per submit.
  2. Relay the token to your backend.
  3. Include it as turnstileToken on the from-url request body.
A missing or invalid token returns 400 turnstile_failed synchronously. (A later bot-check rejection inside the build surfaces as a failed event with error code turnstile_failed.)

Rate limits — 429 + Retry-After

from-url is rate-limited on two axes: Over-limit requests return 429 with a Retry-After header (in seconds). Back off and retry after that delay.
Backend — honor Retry-After
Rate limits hit inside a running build (rather than on submit) surface as a failed event with error code rate_limited (retryable: true).

Idempotency

Send an Idempotency-Key header (a UUID you generate) on from-url so a double-submit — a retried network request, a double-clicked button — returns the same build instead of spawning a second one.
Combined with handle dedup (a fresh existing published agent for the same normalized handle is reused and returned ready instantly), repeat submits are safe, fast, and free. See Build lifecycle.

Error reference

For the in-build error model (plan_limit, insufficient_credits, scrape_failed, …) with retryable semantics, see the ProvisioningErrorCode table.