How to Give an AI Agent a Phone Number (One API Call, Then Calls and Texts)
A step-by-step walkthrough, with real API responses, of creating an agent, giving it a phone number, receiving its first text and placing its first call.

To give an AI agent a phone number, you need three things: a number that can send and receive calls and texts, a way for those calls and texts to reach your agent, and a way for your agent to answer. On AgentPhone that is one API call to create the agent, one to buy and attach the number, and a webhook. This walkthrough does it end to end. Every response below is real output from a fresh account we created on November 12, 2026, with IDs left in so you can see the shapes.
New accounts start with $5 of credit, which covers a number ($3 for the first month) and about 100 texts.
Step 0: get an API key
Sign up at agentphone.ai with Google, GitHub or an email code, then open Settings and click New Key. Keys look like sk_live_... and are shown once.
export AGENTPHONE_API_KEY="sk_live_..."export AGENTPHONE_BASE_URL="https://api.agentphone.ai"
If you would rather not write any code, skip to the MCP section at the end. Your coding agent can do every step below by itself.
Step 1: create an agent
An agent is the thing that owns numbers and conversations. Pick a voice mode now. hosted means AgentPhone runs the voice conversation from a system prompt, which is the fastest way to hear something. webhook means every call turn goes to your server.
curl "$AGENTPHONE_BASE_URL/v1/agents" \-H "Authorization: Bearer $AGENTPHONE_API_KEY" \-H "Content-Type: application/json" \-d '{"name":"Support Bot","voiceMode":"hosted","systemPrompt":"You are a helpful support assistant.","beginMessage":"Hello! How can I help?"}'
The real response, trimmed:
{"id": "cmwdww6t15joz9tdelohw1ai9","name": "Support Bot","voiceMode": "hosted","enableMessaging": true,"modelTier": "balanced","systemPrompt": "You are a helpful support assistant.","beginMessage": "Hello! How can I help?","voicemailMessage": "Hey, sorry I missed you. I'll try you again later.","sttMode": "fast","interruptionSensitivity": 0.8,"language": "en-US","createdAt": "2026-11-12T18:59:14.677000Z","numbers": []}
You get sensible defaults for voicemail, interruption handling and speech recognition, and you can change any of them later with PATCH /v1/agents/{id}. You can also switch between hosted and webhook mode at any time without downtime.
Step 2: buy a number and attach it
One call buys a US number and attaches it to the agent.
curl "$AGENTPHONE_BASE_URL/v1/numbers" \-H "Authorization: Bearer $AGENTPHONE_API_KEY" \-H "Content-Type: application/json" \-d '{"country":"US","agentId":"cmwdww6t15joz9tdelohw1ai9"}'
{"id": "cmwdwwb8g5k129tde3cifylfg","phoneNumber": "+14155550199","country": "US","status": "active","type": "sms","agentId": "cmwdww6t15joz9tdelohw1ai9","outboundSms": "registration_required","voiceRouting": { "method": "agent" },"inboundCallsEnabled": true,"createdAt": "2026-11-12T18:59:20.416000Z"}
The number was live about six seconds after the agent was created. Keep both values: id goes in API paths, phoneNumber is what people text or call. Pass areaCode if you want a specific one, or country: "CA" for Canada.
Note outboundSms: "registration_required". Receiving texts works immediately. Sending texts to US numbers needs 10DLC carrier registration first, which we cover in our 10DLC guide.
Step 3: receive the first text
We texted the new number from a phone: "Hi, is this the support line?" Then we read the number's messages:
curl "$AGENTPHONE_BASE_URL/v1/numbers/cmwdwwb8g5k129tde3cifylfg/messages?limit=10" \-H "Authorization: Bearer $AGENTPHONE_API_KEY"
{"data": [{"id": "cmwdwwijd0xx0635v1voo8gex","from_": "+14155550123","to": "+14155550199","body": "Hi, is this the support line?","direction": "inbound","channel": "sms","status": "received","receivedAt": "2026-11-12T18:59:29.879000Z"}],"hasMore": false}
That proves inbound works before you write any server code.
Step 4: connect a webhook
Point the account (or a single agent) at your server:
curl "$AGENTPHONE_BASE_URL/v1/webhooks" \-H "Authorization: Bearer $AGENTPHONE_API_KEY" \-H "Content-Type: application/json" \-d '{"url":"https://your-server.example/webhook","contextLimit":10}'
The response includes a secret. Save it and use it to verify the X-Webhook-Signature header on every request. Then we sent a second text, and this is the exact event our server received a fraction of a second later:
{"event": "agent.message","channel": "sms","timestamp": "2026-11-12T19:00:21.190127Z","agentId": "cmwdww6t15joz9tdelohw1ai9","data": {"messageId": "cmwdwxm1t0yat635vb09g0b23","conversationId": "cmwdwwij40xwz635vp17p1gjx","numberId": "cmwdwwb8g5k129tde3cifylfg","from": "+14155550123","to": "+14155550199","message": "Can I move my appointment to Friday at 3pm?","mediaUrls": [],"direction": "inbound","receivedAt": "2026-11-12T19:00:21.088000Z"},"conversationState": null,"recentHistory": [{ "messageId": "cmwdwwijd0xx0635v1voo8gex", "content": "Hi, is this the support line?", "direction": "inbound", "channel": "sms", "at": "2026-11-12T18:59:29.879000Z" },{ "messageId": "cmwdwxm1t0yat635vb09g0b23", "content": "Can I move my appointment to Friday at 3pm?", "direction": "inbound", "channel": "sms", "at": "2026-11-12T19:00:21.088000Z" }]}
It came with headers X-Webhook-Event: agent.message, a timestamp and an HMAC signature. The recentHistory array is the part agents love. Your model gets the conversation so far on every event, set by contextLimit.
The same event shape arrives for voice calls (with channel: "voice" and a transcript), iMessage, WhatsApp and RCS. One handler covers all of them.
Step 5: reply
Your server replies by calling POST /v1/messages. Returning text from a text webhook does not send anything.
curl "$AGENTPHONE_BASE_URL/v1/messages" \-H "Authorization: Bearer $AGENTPHONE_API_KEY" \-H "Content-Type: application/json" \-d '{"number_id":"cmwdwwb8g5k129tde3cifylfg","to_number":"+14155550123","body":"Friday at 3pm works. You are booked."}'
On our fresh number this returned a clear 403 explaining that US outbound SMS needs 10DLC registration first, and that Canadian and other non-US destinations do not. Once the number shows outboundSms: "enabled", the same call sends. If you need to reply to US customers today, an iMessage line does not need 10DLC.
Step 6: place the first call
Calls work the same way. With a hosted agent you just say who to call:
curl -X POST "$AGENTPHONE_BASE_URL/v1/calls" \-H "Authorization: Bearer $AGENTPHONE_API_KEY" \-H "Content-Type: application/json" \-d '{"agentId":"cmwdww6t15joz9tdelohw1ai9","toNumber":"+15559876543","initialGreeting":"Hi, this is the Northside Dental assistant calling to confirm your appointment."}'
One thing we hit: outbound calling needs a funded account, not just signup credit. Our first attempt returned 402 with "Add funds on the Billing page to place outbound calls." Add a card and the call goes through. Inbound calls to the number work right away, and the hosted agent answers with its beginMessage.
In webhook mode, each caller turn arrives at your server as a transcript and you return {"text": "..."}, or stream newline-delimited JSON chunks so the caller hears "One moment" while your model works. AgentPhone handles speech recognition, text-to-speech and turn-taking. Calls cost 13¢ a minute with your webhook and 22¢ hosted, billed per second.
The no-code path: MCP
If your agent already runs in Claude Code, Cursor, ChatGPT or another MCP client, it can do all of the above itself. Add the hosted MCP server:
claude mcp add --transport http agentphone https://mcp.agentphone.ai/mcp
Sign in through the browser when prompted (or pass --header "Authorization: Bearer YOUR_API_KEY"). Then ask: "Buy me a phone number in the 415 area code and text me when it's ready." In Cursor, add https://mcp.agentphone.ai/mcp under mcpServers in ~/.cursor/mcp.json. Desktop clients can also run it locally with npx -y agentphone-mcp.
Cleanup
Numbers renew until you release them. Deleting an agent does not release its numbers. Release with DELETE /v1/numbers/{id} or from the dashboard when you are done testing.
FAQ
How much does it cost to give an AI agent a phone number? $3 per number per month for US or Canadian numbers. Calls are 13¢ a minute with your own agent, 22¢ hosted. SMS is 2¢ per segment in either direction. New accounts get $5 free.
Can the agent receive texts without 10DLC registration? Yes. Inbound SMS works immediately. Only outbound SMS to US numbers needs registration.
Can I use my own LLM? Yes. Use webhook mode and your server decides every reply, for calls and texts.
Does it work with Claude Code and Cursor? Yes, through the MCP server at https://mcp.agentphone.ai/mcp.
Can the number do iMessage? iMessage uses a separate line type. See our iMessage API guide.
Next: read the quickstart and MCP docs, or get your $5 credit and try it now.


