Base URL
Two ways to authenticate
The API accepts two bearer-token schemes, and most operations accept either one:Personal API key
A
byk_-prefixed personal API key. A user-principal credential, resolved to a tenant (organization) by org context. Used by the CLI, SDKs, and most direct API calls.Supabase session JWT
A Supabase-issued session JWT. Required for organization administration, invites, and API-key management — these reject personal API keys outright.
What needs which
Sandbox, session, exec, file, and preview operations accept apersonalApiKey. Organization administration (listing/creating/renaming organizations, managing members), invitations, and API-key management are JWT-only — they explicitly refuse personal API keys, because they’re dashboard-facing operations where a signed-in browser session is doing the asking, not an automated client.
Device-login’s mint and poll steps (below) are unauthenticated entirely — the token they hand you is the credential at that point, there’s nothing to bear a bearer token for yet.
Organization context
- Omitted — resolves to the caller’s personal organization.
- Malformed —
400. - Well-formed but the caller isn’t a member —
404, not403. The API doesn’t confirm an organization exists to a non-member.
Environment variables
The CLI and SDKs read these environment variables:The CLI also accepts
--endpoint/BONYA_ENDPOINT to point at a non-default deployment — see CLI configuration. The SDKs always talk to https://api.bonya.ai and don’t document an endpoint override.Getting a key: device login
bonya login uses a three-leg device-login flow: mint a token, approve it in a browser against your already-signed-in dashboard session, then poll until it’s approved. No password ever passes through the CLI.
1
Mint a device-login token
POST /v1/device-login — unauthenticated, no request body.Returns a DeviceLoginMintResponse:string
required
The
byd_-prefixed device-login token. It’s also embedded in verification_url.string
required
The dashboard URL the CLI opens a browser to.
integer
required
Seconds until the token expires unapproved.
integer
required
Recommended seconds to wait between poll calls.
2
Approve in the browser
The CLI opens A successful approval returns
verification_url. The signed-in dashboard session calls POST /v1/device-login/approve with the token, authenticated with the browser’s own Supabase JWT — this is a JWT-only, JWT-provisioning operation, since it’s the already-signed-in session vouching for a login it didn’t itself start.Request body (DeviceLoginApproveRequest):string
required
The
byd_ device-login token from the verification URL.204 with no body.3
Poll for the API key
POST /v1/device-login/poll — unauthenticated; the token itself is the credential. Same request body shape as approve ({ "token": "byd_..." }).Always returns 200 with a DeviceLoginPollResponse:string
required
One of
pending, approved, or expired.string
Present only once — on the single poll response that first observes
approved.string
The approving user’s email. Present alongside
api_key.404. Poll every interval seconds (from the mint response) until status is approved or expired.Using the key
BONYA_API_KEY from the environment by default, or accepts an explicit override in code.
Managing API keys
Personal API keys themselves are managed over the JWT-only surface — a key can never be used to manage keys:GET /v1/api-keys— list your keys (prefix and last 4 characters only; JWT required).POST /v1/api-keys— create a new key. Thesecretis shown exactly once in the response.DELETE /v1/api-keys/{key_id}— revoke a key.