# Place a call from code

Source: https://aicallstudio.com/developers/place-a-call

Ring one person now with an AI agent or an AI team: the request, the values your script uses, every reason a call is refused, and how to follow the call to its outcome.

## Before you start

- A live key with the calls:write scope, and calls:read to read the outcome. [API keys, scopes and the sandbox key](/developers/keys-and-scopes) covers making one.
- An agent or a team that is live, with a phone line to call from.

## Steps

1. **Choose who speaks and who is rung**: Send exactly one of agent_id or team_id: the AI agent or the AI team that speaks. Send the person as phone, a 10-digit Indian mobile starting with 6 to 9 and without +91, or as contact_id, and the contact's own number is rung.

List your agents for their ids. Each one says whether it takes real calls now. (endpoint: `GET /api/v1/agents`)
2. **Send the values your script uses**: variables fills your agent's script for this person: {"amount": "12,500", "due_date": "5 December"} fills {amount} and {due_date}. Send up to 30. Each name is lower-case letters, digits and _, starting with a letter, and each value is up to 500 characters. They are saved on the contact as its fields, so the next call has them too.

Send the person's name as name, not as a variable. A number that is not a contact yet is saved as one under that name, and a known contact keeps its own. A few names are filled from the contact itself and are refused as variables: name, customer_name, first_name, phone, email, greeting_time and time_greeting.
3. **Place the call**: The answer, with the status dialing, means ringing has started, not that anyone picked up. Keep its room: it names this call attempt. Send an Idempotency-Key header, so a request your code retries never rings the person twice.

This is a real call, billed like any other. (endpoint: `POST /api/calls/dial`)
4. **Follow it with webhooks**: With a webhook, call.started arrives when the person picks up, and call.completed when the call has ended and its outcome is known: its status, outcome, score, summary and transcript. An outgoing call that nobody answered sends call.no_answer, and one that could not be connected at all sends call.failed. Both of those carry the room from step 3.

[Webhooks](/developers/webhooks) has every event, its sample and the signature check. (event: `call.completed`)
5. **Or ask for the outcome**: Without a webhook, list your calls with the room from step 3: the call carries its status, outcome, lead score and summary. Fetch it by id for the transcript, the details it captured and the recording's link, which needs the recordings:read scope. (endpoint: `GET /api/v1/calls`)

## Why was my call refused?

Each answer's detail says which reason it was.
422: the body is wrong. Both or neither of agent_id and team_id, no phone or contact_id, a number that is not a 10-digit mobile starting with 6 to 9, or a variable outside the rules.
402: the plan has no calls left, or does not include this agent's voice tier.
403: the person cannot be called. The number is on your Do-Not-Call or Do-Not-Disturb list, the contact has not consented to calls, or it is outside your calling window. A key without calls:write, or a sandbox key, answers 403 too.
404: the agent, team or contact was not found, or is switched off.
409: the call cannot start now. Your plan's calls-at-once limit, the agent's own limit, the agent's calling hours, a draft or paused agent, or no phone line to call from. The same request may succeed later.
502: the call could not be started and nobody was rung. Try again with the same Idempotency-Key.
503: calling is halted for a moment by the platform. Try again shortly.

## Can I book the call for later?

Yes, as a call-back: POST /api/v1/callbacks books an AI call to one person at a set time, with the same contact_id or phone, and agent_id or team_id. The usual checks run when the time comes, a call-back that falls outside the calling hours moves to the next opening, and it can be cancelled until it rings. It shows in the Workspace's call-backs list. The [API reference](/docs/api) has its fields.

## How many calls can I place at once?

As many as your plan's calls-at-once limit, and each agent's own limit. One request rings one person, and a request past a limit answers 409: it is refused, not queued. To ring a list of people, add them to a campaign, which rings them inside its own schedule and limits.

## Costs and what to watch

- Every call the API places is a real call to a real person, billed from your wallet like any other call, at your plan's rates. Try it on your own number first.
- Outbound calls are placed only inside the calling hours, 9 am to 9 pm IST at the widest. A request outside them is refused, not queued.
- A write sent again without an Idempotency-Key is a new request: a retried call without one can ring the person twice.

## Questions

### Which phone numbers can the API call?

Indian mobile numbers: 10 digits starting with 6 to 9, sent without +91, or a contact by its id. The number must not be on your Do-Not-Call or Do-Not-Disturb list, and the call must fall inside your calling window.

### Does the answer to a dial request say whether the person picked up?

No. It means ringing has started. Whether they answered, and how the call went, arrives with the call.started and call.completed webhooks, and in the calls list.

Every endpoint, field and error: https://aicallstudio.com/docs/api