Overview
The Agent onboarding API needs one browser visit: the owner opens a link, signs up, and approves the request. Headless onboarding removes that visit entirely. If your agent can approve a payment through its own agent wallet, it can sign up, pay for the first month of the Agent Phone Plan, and receive its API key and phone number, all in the same conversation. The owner’s only manual step is relaying a 6-digit code sent to their phone by text. Two calls, no API key required to start:POST /v1/agent/onboarding/headless/start: send the owner’s phone and email, and get back a session handle. A text with a verification code goes out to the phone immediately.POST /v1/agent/onboarding/headless/complete: send the code back along with a payment approval, and get back the API key, org ID, phone number, and plan.
This is a different path to the same result as the Agent onboarding API, not a replacement for it. Use headless onboarding when your agent can present a payment token from an agent wallet. Use the link-based flow when it can’t, or when the payment is declined.
Prerequisites
- An agent wallet that can approve a single-use payment token (
shared_payment_token, prefixedspt_) for the exact amount you’re charging - The owner’s phone number, to send the verification code to
- The owner present in the conversation to relay that code back
The flow
1
Start the flow
Call
POST /v1/agent/onboarding/headless/start with the owner’s phone, email, and an optional label for your agent. No API key is required, this is how an agent gets one.Response
client_name is optional (up to 64 characters, letters, numbers, spaces, and ._/-). owner_phone must be E.164 (for example +14155551234). owner_email must be a valid email address.This call sends a 6-digit verification code to owner_phone by text and creates nothing else: no account, no organization, no charge. headless_session is valid for expires_in seconds (600, or 10 minutes) and is single-use.2
Get the code from your owner
Ask the owner for the 6-digit code that was just texted to their phone. This is their only manual step in the entire flow.
3
Complete the flow
Call
POST /v1/agent/onboarding/headless/complete with the session, the code, and a payment approval from your agent wallet.Response
payment.shared_payment_token is the only supported payment credential today: the single-use token your agent wallet issued for this charge. This settles the first month of the Agent Phone Plan ($29.99).next_steps is a short list of things your agent should know before its first call. It’s optional on the wire: treat a missing field the same as an empty list.4
Store the key
api_key is returned exactly once. Store it immediately; a repeated /complete call with a spent session returns INVALID_SESSION rather than the key again.If the number isn’t ready yet
provisioning is "ready" when everything is in place, or "pending" when the payment settled but a phone number hasn’t been handed over yet. On "pending", phone_number is null and next_steps includes a line telling your agent to call POST /billing/subscribe_agent_phone with the new API key in a few minutes. That call retries provisioning without charging again, since the plan is already active.
If the payment is declined
A declined payment, a payment that needs extra verification from the owner’s bank, or a payment token that’s already used or rejected all answer the same way:402 CARD_DECLINED. Nothing is created. The response bundles a device-flow fallback so your agent can continue without starting over:
402 CARD_DECLINED
fallback carries everything POST /v1/agent/onboarding/start returns except verification_url. Show verification_url_complete (or user_code) to the owner exactly as you would from that flow, then poll POST /v1/agent/onboarding/poll with device_code until the owner approves. fallback also rides along on 402 PLAN_REQUIRED and 409 ACCOUNT_EXISTS.
Error codes
Both endpoints:/headless/start only:
/headless/complete only:
A code isn’t only ever “wrong”: if the owner takes too long or guesses incorrectly too many times, the session is burned and
/complete answers INVALID_SESSION even with the right code. Start over with a fresh /start call.
Buying credits
An agent can also buy prepaid credits directly, using a payment token from the owner’s agent wallet, no browser involved. This is how an organization without the Agent Phone Plan unlocks international calling: the plan itself is US and Canada only, and buying credits doesn’t change that, but a completed credit purchase clears the same bar international calling requires everywhere else on Bland. Buying credits requires an existing Bland API key. If your agent hasn’t onboarded yet, do that first.POST /v1/agent/credits
Response
amount_usd: from $5 to $100, at most two decimal places.shared_payment_token: the single-usespt_token your agent wallet issued for this purchase.idempotency_key(optional): a UUID. Send the same one to retry the exact same purchase without paying twice.- The body is strict: no other fields are accepted.
balance_update: "pending" rather than reporting a new balance directly.
international_unlocked is true only once the unlock has actually taken effect. It’s false, with a note explaining why, in two cases: your organization is on an active Agent Phone Plan (which stays US and Canada only regardless of balance), or the unlock is still settling (retry in a few minutes).
The buy_credits MCP tool
The same purchase is available as a tool on Bland’s hosted MCP server, scoped to your organization:
Ask the owner to approve the amount in their agent wallet first, then pass the token it gives you. If the tool doesn’t answer within its own timeout, the purchase may still be going through: check the balance before retrying, and if you do retry, send the same
amount_usd, shared_payment_token, and idempotency_key so the same purchase can’t be charged twice.
Who can buy credits
Both surfaces share one policy: the caller must be acting as an organization, as an owner, admin, or operator of it. A personal (non-org) API key, or a member without one of those roles, is refused.Error codes
BothPOST /v1/agent/credits and buy_credits share one policy entry point and refuse for the same reasons with the same messages. The MCP tool has no HTTP status: it surfaces the message text directly, or a generic message for anything unexpected.
Security notes
- The verification code expires in 10 minutes and can only be checked a handful of times before the session is burned. Start over with a fresh
/startcall if it expires. - A session is single-use. Once
/completesucceeds (or the session is spent by a decline), a repeated call returnsINVALID_SESSION. - The API key is scoped to a new organization and can be revoked at any time from Settings > API Keys in the dashboard.
- A declined payment creates nothing: no account, no organization, no charge left behind.
- Treat the returned
api_keyand any payment token like credentials: keep them out of logs and chat transcripts.
Next steps
Agent onboarding API
The link-based flow this one falls back to when payment isn’t available or is declined.
Agent Phone Plan
What’s included, limits, and how to cancel.
Docs for agents: llms.txt