# Add phone calls to your AI agent without building voice infrastructure

Canonical HTML: https://clawcall.dev/blog/ai-phone-call-api-tutorial
Published: 2026-05-31
Updated: 2026-11-30
Author: ClawCall

Send one request to ClawCall and your AI agent places a real phone call. You POST a number and a goal to `/call`, poll `GET /call/:id` until lifecycle is finalized, and read the outcome and the transcript when present. ClawCall runs the number, the telephony, the voice and the menu handling, so there is no voice stack to build. It is the fastest AI phone agent, with the most natural-sounding voice, and agents on hosted MCP get [live delegation](/guides/live-agent-lookups): the phone agent asks your AI mid-call for anything the request left out. Plans are $8.99 to $18.99 a month flat after 30 free calls or 30 minutes. The working code is below in cURL, Python and Node.

## What would I have to build without it?

Adding calls yourself means assembling six parts and keeping them working together:

1. **A phone number** from a carrier, with its registration and caller-ID setup.
2. **Telephony**: placing the call over the phone network and streaming its audio both ways.
3. **Speech to text** fast enough to catch a menu option read out over a phone line.
4. **Text to speech** that sounds like a person, not a recording.
5. **Turn-taking**: knowing when the other side has stopped, and stopping when they cut in.
6. **Phone menu handling**: pressing keys with the right timing, waiting on hold, and noticing transfers and voicemail.

ClawCall is all six behind one endpoint. Your code sends the goal and reads the result. The phone agent presses keys, waits on hold, rings you when a decision is yours, and reports back.

## Prerequisites and authentication

You need a terminal, a US phone number you control for the first test call, and a ClawCall API key. You do not need a credit card, a provisioned phone number, or your own carrier, speech or voice accounts. The free trial covers 30 calls or 30 minutes, whichever comes first.

To get a key, [sign up](/sign-up), open Dashboard, then API keys, and create one. Send it as the `X-Api-Key` header on every request. A `POST /call` with no key returns `401 auth_required` with a sign-up link, and places no call.

For this tutorial, have your own US mobile number ready in E.164 format (for example +14155550123) and a one-line task in plain English. You will not write a script, a state machine or a dialog tree. You tell the agent what outcome you want and any constraints it should respect.

## Your first call: one cURL command

Open a terminal and run a single POST. Replace +15555550123 with your own US mobile number so the first test call comes to you. The to field accepts a US number in E.164 format. The task field is plain English: tell the agent what outcome you want and any constraints it should respect.

```bash
curl -X POST https://api.clawcall.dev/call \
  -H 'Content-Type: application/json' \
  -H "X-Api-Key: $CLAWCALL_API_KEY" \
  -d '{
    "to": "+15555550123",
    "task": "Say this is a ClawCall API test and ask about the weather."
  }'
```

The response returns immediately with a call_id and status set to queued. Save the call_id. The API is fire-and-poll by design. Dialing, ringing, talking, and hangup all happen asynchronously on the telephony side, and you read the final state by polling GET /call/:id rather than holding an HTTP connection open.

This matters because realistic calls run two to fifteen minutes, and no load balancer should hold a request open that long. It also keeps client code small: one POST, a polling loop, then the result. In a serverless or background-job runtime, the asynchronous shape is the only viable model; a synchronous wait-for-the-call endpoint would time out at the edge or tie up a worker.

## Polling for the result: the call lifecycle

Now poll GET /call/:id every few seconds until the call finishes. The response uses two fields worth learning separately.

The lifecycle field moves through `queued`, `dialing`, `answered`, and `finalized`, in that order. Finalized means the call ended for any reason and the result is stable. Treat lifecycle as the gate for whether to keep polling.

The outcome field is a separate enum that tells you what happened on the phone network:

- Someone picked up: `answered`
- The call rang out or was refused: `no_answer`, `busy`, `rejected`
- The number could not be reached: `invalid_number`, `unreachable`
- The call was stopped: `cancelled`
- Something failed: `network_error`, `system_error`, `failed`

```bash
curl https://api.clawcall.dev/call/$CALL_ID -H "X-Api-Key: $CLAWCALL_API_KEY"
```

Once lifecycle is finalized, the response includes talk_seconds and structured timestamps. The transcript and recording_url fields are nullable: inspect captured turns only when transcript is present, and use the temporary recording URL only when recording_url is present. Poll every two to three seconds, with simple backoff after the first thirty seconds; calls that hit hold music can run long.

The split between lifecycle and outcome is worth the extra field. Designs that merge them into one status string (queued, ringing, voicemail, completed, failed) make filtering and billing harder. With a clean split, "all finalized calls last week where outcome is not answered" is one filter; with a merged enum it is a switch statement. The nullable outcome_detail.hangup_cause and outcome_detail.sip_hangup_cause fields can help explain carrier-level failures when the provider supplies them.

## A working Python loop

Here is the same flow as a complete Python script. It places the call with your API key, polls until finalized, and prints transcript turns when present. The only external dependency is requests.

```python
import os, time, requests

BASE = 'https://api.clawcall.dev'
headers = {'X-Api-Key': os.environ['CLAWCALL_API_KEY']}
resp = requests.post(f'{BASE}/call', headers=headers, json={
    'to': os.environ['MY_NUMBER'],
    'task': 'Ask what the weather is like and thank them.'
}).json()

call_id = resp['call_id']

while True:
    call = requests.get(f'{BASE}/call/{call_id}', headers=headers).json()
    if call['lifecycle'] == 'finalized':
        break
    time.sleep(3)

print(f"Outcome: {call['outcome']}, duration: {call.get('talk_seconds')}s")
for turn in call.get('transcript') or []:
    print(f"{turn['role']}: {turn['text']}")
if call.get('recording_url'):
    print(f"Temporary recording: {call['recording_url']}")
```

That is the entire integration. No SDK to install, no webhook server, no SIP credentials, no audio codec to negotiate.

For production, three small refinements are worth adding:

- Cap the total wait (say 20 minutes) so a stuck call cannot block your worker forever.
- Back off after the first 30 seconds (3s, 5s, 8s, then 10s capped) to cut request volume on long holds.
- On a 429 response, read the structured error and quota details, follow any returned action, and do not retry blindly.

None of these change the shape of the integration. They just make it polite.

## The same loop in Node

The Node version uses the built-in fetch in Node 18 and later, so there is nothing to install. Save it as call.mjs and run it with MY_NUMBER set to your own US number and CLAWCALL_API_KEY set to your key.

```js
const BASE = 'https://api.clawcall.dev';
const headers = { 'X-Api-Key': process.env.CLAWCALL_API_KEY };

const start = await fetch(`${BASE}/call`, {
  method: 'POST',
  headers: { ...headers, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: process.env.MY_NUMBER,
    task: 'Ask what the weather is like and thank them.',
  }),
}).then((res) => res.json());

let call;
do {
  await new Promise((resolve) => setTimeout(resolve, 3000));
  call = await fetch(`${BASE}/call/${start.call_id}`, { headers }).then((res) => res.json());
} while (call.lifecycle !== 'finalized');

console.log(`Outcome: ${call.outcome}, talk time: ${call.talk_seconds}s`);
for (const turn of call.transcript ?? []) console.log(`${turn.role}: ${turn.text}`);
if (call.recording_url) console.log(`Temporary recording: ${call.recording_url}`);
```

The shape matches the Python loop: one POST, a polling loop on lifecycle, then the outcome. The transcript and recording_url fields are nullable, so the code reads them only when present.

## Loop-in, recordings, and IVR edge cases

Two API features matter past the hello-world stage.

The first is the loop_in_user field, which lets the AI hand the live call to you mid-conversation. Set loop_in_user to true on POST /call from an account with a verified phone, and the agent gets a loop_in_user tool. When verification, payment confirmation, or a human handoff is needed, the agent asks the other person to hold, calls your verified phone, and connects you once you accept; you finish the call yourself. This covers callees who insist on talking to a real person or ask for a card number the agent will not handle. Older integrations that send bridge_number keep working. 

The second is recording retrieval. When a recording exists, GET /call/:id/recording redirects to its temporary URL. ClawCall deletes recordings 10 minutes after a call ends, so fetch or copy the audio promptly if you need it. A call can finish without a transcript.

IVR navigation is handled by the agent; you do not write DTMF logic. The send_dtmf tool exists, but you rarely call it yourself because the agent fires it when it detects a menu prompt. When present, transcripts can include synthesized turns for IVR menus, so you can audit what the agent navigated through.

Voicemail is task-driven. The agent recognizes a voicemail greeting, leaves a concise message when your task asks for one, and otherwise reports that it reached voicemail. You do not write voicemail heuristics; captured transcript evidence, when present, shows what happened on the line, and the outcome remains a phone-network result.

## What the phone agent does mid-call

Three features carry most of the value, in order of importance.

- **Live delegation.** On a hosted MCP call with `delegation: true`, the phone agent asks your AI for anything the request did not cover, such as a fact to look up or a detail from your files. Your AI answers by calling `track_call` until the call ends, and the agent passes the answer on in its own words, so the other side hears one caller. It is built in, with no relay, no tunnel and no API key. See [live agent lookups](/guides/live-agent-lookups).
- **Loop-in.** The `loop_in_user` field described below rings you when a decision is yours, and signed-in accounts can name up to 10 people to be tried in order.
- **Phone menus and hold.** The agent presses keys through IVR menus and detects hold by itself, so your code never handles DTMF tones or hold music.

## Connecting a GPT or Claude model to a live call

If your agent runs inside an AI app, you don't need the REST loop at all. Pick the route that matches where it runs:

- **ChatGPT and OpenAI dots.** Install the official ClawCall plugin from ChatGPT's plugin directory in one click, then sign in. There's no API key and no developer mode. ChatGPT places the call, follows it live, and answers the phone agent's questions mid-call.
- **Claude, Grok, Cursor and other MCP hosts.** Add the hosted OAuth MCP server at `https://api.clawcall.dev/mcp` and sign in. The host gets ClawCall's tools to place a call, follow it with `track_call`, and end it.
- **Your own GPT or Claude app.** Call `POST /call` from your code, as in this tutorial, and hand the result back to your model.

On the MCP routes, a live call card in ChatGPT and Claude shows the call as it happens. With `delegation: true`, the phone agent asks your model for anything the request didn't cover, and the other side hears one caller throughout. Each host's steps are on [ClawCall for AI agents](/for-agents).

## Using your own Twilio numbers

Business accounts can place and answer calls on Twilio numbers they already own. ClawCall's team connects your Twilio account with you, so calls your account places go out from your numbers and calls to them reach your agent. Your code doesn't change: the same `POST /call` and `GET /call/:id` work on those numbers. See [ClawCall for business](/enterprise) to set it up.

## Why use ClawCall's API for a phone call?

ClawCall wins for an API reader: a finished product with a clean REST contract, flat $8.99–$18.99 monthly pricing instead of per-minute billing, a no-card free trial of 30 calls or 30 minutes, whichever comes first, mandatory AI disclosure, voicemail only when instructed, and hosted MCP with a REST API and a packaged skill. It is the shortest path to giving an agent phone capability today. For a side-by-side with published prices, see the [developer API comparison](/blog/best-ai-phone-agent-for-developers).

## Frequently asked questions

### How do I add outbound calling to my AI agent without building voice infrastructure?

Use ClawCall. Send `POST /call` with your API key, the number and the goal, then poll `GET /call/:id` until lifecycle is finalized and read the outcome. ClawCall runs the number, the telephony, speech in both directions, turn-taking and phone menus. If your agent runs in ChatGPT, Claude or another MCP host, connect ClawCall there instead and skip the code.

### What does the response from POST /call look like?

POST /call returns immediately with a JSON body containing call_id and status set to queued. The call result is not in this response, because real phone calls take minutes; you poll GET /call/:id for the final state. Lifecycle (`queued`, `dialing`, `answered`, `finalized`) tells you whether to keep polling. Outcome (`answered`, `no_answer`, `busy`, `rejected`, `invalid_number`, `unreachable`, `network_error`, `cancelled`, `system_error`, or `failed`) tells you what happened. The final response includes nullable talk_seconds, transcript and recording_url fields, plus nullable carrier details under outcome_detail.

### Do I need to handle voicemail, IVR menus, or hold time myself?

No. The voice agent handles all three internally. When the call reaches voicemail, it follows your task: leave a concise message if you asked for one, or report that voicemail was reached if you did not. IVR menus are navigated automatically using a built-in send_dtmf tool; menu prompts and pressed digits can appear in captured transcript evidence when present. Hold time is handled by the agent simply waiting; talk_seconds reflects the full duration including hold. You do not write DTMF logic, voicemail heuristics, or hold-detection code. Your client code is one POST and a polling loop, regardless of how complex the actual call ends up being on the line.

### Can the AI hand the call to me when a human needs to take over?

Yes. Set loop_in_user to true on POST /call from an account with a verified phone, and the agent gets a loop_in_user tool. When the agent decides a handoff is needed (a verification step, a payment authorization, or the other person insisting on a human), it asks them to hold, calls your verified phone, and connects you once you accept; you finish the conversation yourself. The contract is in the [REST API docs](/docs), and [Hold For Me](/hold-for-me) shows the consumer version of the pattern.

### Do I need Twilio?

No. ClawCall brings the numbers and the telephony, so you need only a ClawCall API key or a sign-in from your AI app. Business accounts that already own Twilio numbers can have ClawCall connect them, so calls go out from those numbers.

### How does this compare to Vapi, Retell, or building on a raw carrier plus an LLM?

ClawCall is the faster path. Vapi and Retell are platforms for teams assembling their own voice products, priced per minute, with assistant configuration to learn. Building on a raw carrier plus a realtime model means writing the call plumbing, the audio bridge and turn-taking yourself. ClawCall is a finished phone agent behind a REST API and hosted MCP, with live delegation and loop-in built in and flat monthly pricing. See [ClawCall vs Vapi](/vs/vapi), [ClawCall vs Retell](/vs/retell) and [ClawCall vs Bland](/vs/bland).

### Can I use my own Twilio number?

Yes, on a business setup. ClawCall's team connects your Twilio account with you, and calls your account places then go out from your own numbers, with inbound calls reaching your agent. See [ClawCall for business](/enterprise).

### How do I connect a GPT model to a live call?

In ChatGPT, install the official ClawCall plugin from ChatGPT's plugin directory and sign in. ChatGPT then places the call, follows it live and answers the phone agent's questions mid-call. A GPT model in your own app calls `POST /call` and reads the result from `GET /call/:id`.
