# Start a call

`POST` `https://goblins-call-api.onrender.com/v1/calls`

Creates a call, sends the agent into a room and returns what your app needs to join it. The agent greets the caller once they are in.

Works with a [workspace API key](https://www.cracklehq.com/docs/authentication) or the agent’s own key.

## Body

- `agentId` (string, required): The agent that takes the call. May be left out with an agent’s own key, which already names it.
- `variables` (object, optional): Values for the `{{variables}}` in the agent’s instructions, greeting and tools. Keys and values are strings. A variable left out takes its default.
- `language` (string, optional, default the agent’s language): The language this one call is held in: a language `id` from the catalog or its `iso` code, such as `ta`. Letter case and a region are ignored, so `ta-IN` is Tamil too. A language other than Hindi or English needs an agent whose `voice.provider` speaks it (`cartesia` for every listed language, `sarvam` for the ones it has voices in) and whose `stt.provider` is `openai` or `sarvam`. Left out, or the same as the agent’s language, the call runs exactly as the agent is saved. See the Calls guide.
- `participant.identity` (string, optional, 1–128 chars; default user): Your identifier for the caller. Returned as `participantIdentity` and written into the join token.
- `participant.name` (string, optional, up to 128 chars): A display name for the caller.
- `participant.ttlSeconds` (integer, optional, 60–86,400; default 3,600): How long the join token can be used to enter the room.
- `metadata` (object, optional): Any JSON of your own, such as an order or session ID. Kept on the call and sent back in every webhook for it.
- `webhooks` (object[], optional, up to 5): Destinations for this call’s events only. Each has `url`, `events` and an optional `secret` of at least 16 characters.
- `roomName` (string, optional, letters, digits, _ and -; up to 128): A room name of your own. Your workspace ID is put in front of it. One is generated when left out.
- `config` (object, optional): Overrides for this one call, on top of the agent’s settings. Only the `prompt`, `vad`, `turn` and `call` sections may be set: see the Calls guide.

## Response

- `callId` (string): The call’s ID, for every later request about it.
- `livekitUrl` (string): The address your app connects to.
- `token` (string): A join token for this room and this participant only. This, not your API key, is what you hand to a browser or phone.
- `language` (string): The call’s language as an ISO code, such as `ta`. Returned only when the request sent `language`; the call keeps it as `metadata.language`.

## Errors

- `400` `AGENT_REQUIRED`: No `agentId` was sent with a workspace key.
- `400`: The body failed validation. `details` lists each field and what is wrong with it.
- `400` `UNSUPPORTED_LANGUAGE`: `language` cannot be used for this call. The response carries a `reason`: `unknown` when it is not a language the platform lists, and then `languages` holds the codes it does; `voice` when the agent’s voice or transcription cannot follow it.
- `402` `INSUFFICIENT_BALANCE`: The workspace balance is zero or below. The response carries `balance` and `currency`.
- `403` `CONFIG_FIELD_NOT_ALLOWED`: `config` tried to set something outside `prompt`, `vad`, `turn` and `call`. `fields` lists what was refused.
- `404` `AGENT_NOT_FOUND`: No agent in your workspace has that ID.
- `429` `RATE_LIMITED`: Too many calls started in a minute. Wait `retryAfterSeconds` and try again.
- `429` `WORKSPACE_CONCURRENCY_LIMIT_REACHED`: Your workspace is already on as many calls as its plan allows at once.
- `429` `CONCURRENCY_LIMIT_REACHED`: The platform is at capacity. Retry shortly.

Every request can also answer `401`, `429` and `500`: see [Errors](https://www.cracklehq.com/docs/errors).

## Notes

- A call nobody joins is not billed.
- When the balance would run out mid-call, the call is ended at that point instead of going into debt.
- A call ends after 24 hours at the latest, with the reason `max-duration`.

Request:

cURL:

```bash
curl -X POST "https://goblins-call-api.onrender.com/v1/calls" \
  -H "Authorization: Bearer $CRACKLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agentId": "ua_3f9a1c2b",
  "participant": {
    "identity": "customer_123"
  },
  "variables": {
    "customer_name": "Divya"
  },
  "metadata": {
    "orderId": "A-1042"
  }
}'
```

Node.js:

```js
const response = await fetch('https://goblins-call-api.onrender.com/v1/calls', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CRACKLE_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    agentId: 'ua_3f9a1c2b',
    participant: {
      identity: 'customer_123',
    },
    variables: {
      customer_name: 'Divya',
    },
    metadata: {
      orderId: 'A-1042',
    },
  }),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
```

Python:

```python
import os
import requests

response = requests.post(
    "https://goblins-call-api.onrender.com/v1/calls",
    headers={"Authorization": f"Bearer {os.environ['CRACKLE_API_KEY']}"},
    json={
        "agentId": "ua_3f9a1c2b",
        "participant": {
            "identity": "customer_123",
        },
        "variables": {
            "customer_name": "Divya",
        },
        "metadata": {
            "orderId": "A-1042",
        },
    },
    timeout=30,
)
response.raise_for_status()
data = response.json()
```

Response · 201 Created:

```json
{
  "callId": "8f1c2c1e-7b1a-4e0a-9c55-2f6f0d3b1a90",
  "roomName": "call_8f1c2c1e7b1a",
  "livekitUrl": "wss://…",
  "token": "eyJhbGciOiJIUzI1NiJ9…",
  "participantIdentity": "customer_123"
}
```

Source: https://www.cracklehq.com/docs/reference/calls/start
