API Documentation

Base URL: https://agentnumber.com/api/v0

Authentication

All API requests require a Bearer token. Get your API key from the dashboard after signing up.

Authorization: Bearer an_live_<your_key>

Quick Start

Three steps to give your agent a phone number:

  1. 1
    Sign up and create an API key

    Sign up at /signup, then create an API key in the dashboard.

  2. 2
    Add credits
    POST /credits/purchase
    {
      "amount_cents": 1000
    }

    $5 per number, $0.05/min outbound, $0.03/min inbound.

  3. 3
    Provision a phone number

    Option A: Managed mode — just provide a system prompt, no server needed:

    POST /numbers (managed)
    {
      "system_prompt": "You are a helpful sales assistant for Acme Corp.",
      "first_message": "Hello, how can I help you?",
      "area_code": "415"
    }

    Option B: Webhook mode — route calls to your own server for full control:

    POST /numbers (webhook)
    {
      "webhook_url": "https://your-agent.com/voice",
      "area_code": "415"
    }

Webhook Format

Your webhook_url receives POST requests in OpenAI-compatible chat completions format:

POST to your webhook_url
{
  "model": "custom",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Hi, I'd like to schedule an appointment." }
  ],
  "stream": true
}

Respond with SSE-streamed chat completion chunks. The text is spoken back via TTS.

Your response (SSE stream)
data: {"choices":[{"delta":{"content":"Sure, I can"}}]}

data: {"choices":[{"delta":{"content":" help with that."}}]}

data: [DONE]

Numbers API

POST/numbers

Provision a new phone number

Request body
{
  "system_prompt": "You are a helpful assistant.",
  "webhook_url": "https://your-agent.com/voice",
  "area_code": "415",
  "voice_id": "cgSgspJ2msm6clMCkdW9",
  "first_message": "Hello!",
  "inbound_mode": "autopilot",
  "metadata": {}
}
GET/numbers

List all your phone numbers

GET/numbers/:id

Get a specific number

PATCH/numbers/:id

Update number config

DELETE/numbers/:id

Release a phone number

Calls API

POST/calls

Make an outbound call

Request body
{
  "from": "num_a1b2c3d4e5f6",
  "to": "+15551234567",
  "metadata": {}
}
GET/calls

List call history

GET/calls/:id

Get call details

GET/calls/:id/transcript

Get call transcript

GET/calls/:id/recording

Get recording URL

SMS API

POST/sms

Send an outbound SMS

Request body
{
  "from": "num_a1b2c3d4e5f6",
  "to": "+15551234567",
  "body": "Hello from my agent!",
  "metadata": {}
}
GET/sms

List SMS messages

GET/sms/:id

Get a single SMS message

Credits API

GET/credits/balance

Check your credit balance

POST/credits/purchase

Purchase credits ($10.00 per pack)

Webhooks API

Register webhooks to receive events. Payloads are HMAC-signed.

POST/webhooks

Register a webhook

GET/webhooks

List webhooks

PATCH/webhooks/:id

Update webhook

DELETE/webhooks/:id

Delete a webhook

Available Events:

call.startedcall.endedcall.transcript.readycall.recording.readysms.sentsms.received

Error Format

Error response
{
  "success": false,
  "error": {
    "message": "Insufficient credits.",
    "code": "insufficient_credits"
  }
}

401 — Invalid or missing API key

400 — Validation error

402 — Insufficient credits

404 — Resource not found

500 — Internal error