# Web calls

URL: https://www.callshift.ai/docs/api/web-calls

Calls between one of your agents and a visitor of your website, in their browser. Your server creates the call with your API key, and the page joins it with the @callshift/web package.

## Create a web call

`POST /v1/web-calls`

Bearer API key

Start a call between one of your agents and a visitor of your website, in their browser.

1. Your server creates the web call here, with your API key. Never call this endpoint from the browser: the key would be exposed. 2. Your server hands `accessToken` to the browser. 3. The browser joins the call with `@callshift/web` before `expiresAt`.

The agent is started before this endpoint answers, with its configuration built on our side from `agentId` and `contact`: nothing the browser sends shapes the call. Billing starts when the browser joins. Transfers are not offered during a web call.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Body application/json

- `agentId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`
- `contact` (object): Who is calling. Fills the agent's `contact.*` prompt variables, the same ones campaign prompts use. The contact is not looked up in, nor written to, your CRM.

  - `salutation` (enum<string>) · example `mrs` · allowed: `mr`, `mrs`, `ms`, `miss`
  - `firstName` (string) · example `Ada`
  - `lastName` (string) · example `Lovelace`
  - `email` (string<email>) · example `ada@example.com`
  - `phone` (string) · example `+33612345678`
  - `metadata` (object): At most 16 KB of JSON. Injected into the agent's prompt through the `contact.metadata` variables.
- `metadata` (object): At most 16 KB of JSON. Yours: never shown to the agent, returned as is by `GET /v1/calls`, `GET /v1/calls/{callId}` and the call-ended webhook.

### Responses

**201**

Web call created; the agent is waiting for the browser

- `callId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`
- `accessToken` (string, required): Hand it to the browser, which joins the call with `@callshift/web`. It is opaque: do not decode it.
- `expiresAt` (string<date-time>, required): Two minutes after creation. A call nobody joined by then ends as not reached, and is billed nothing. · example `2026-01-01T10:02:00.000Z`

**400**

Invalid request body

**Validation Error Response**

- `success` (enum<boolean>, required) · allowed: `false`
- `error` (object, required)

  - `name` (enum<string>, required) · allowed: `ZodError`
  - `issues` (object[], required)

    - `code` (string, required) · example `invalid_enum_value`
    - `path` (string | number[], required)
    - `message` (string, required) · example `Invalid email`

**Error Response**

- `error` (string, required)

**401**

Unauthorized

- `error` (string, required)

**402**

The account cannot pay for calls: no active subscription, or not enough credit

- `error` (string, required)

**404**

Agent not found

- `error` (string, required)

**415**

The body was not sent as `application/json`

- `error` (string, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl -X POST "https://api.callshift.ai/v1/web-calls" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "550e8400-e29b-41d4-a716-446655440000",
    "contact": {
      "firstName": "Ada",
      "lastName": "Lovelace",
      "metadata": {
        "plan": "pro"
      }
    },
    "metadata": {
      "orderId": "A-42"
    }
  }'
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/web-calls", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "agentId": "550e8400-e29b-41d4-a716-446655440000",
    "contact": {
      "firstName": "Ada",
      "lastName": "Lovelace",
      "metadata": {
        "plan": "pro"
      }
    },
    "metadata": {
      "orderId": "A-42"
    }
  }),
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://api.callshift.ai/v1/web-calls",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
    json={
        "agentId": "550e8400-e29b-41d4-a716-446655440000",
        "contact": {
            "firstName": "Ada",
            "lastName": "Lovelace",
            "metadata": {
                "plan": "pro",
            },
        },
        "metadata": {
            "orderId": "A-42",
        },
    },
)
print(res.json())
```

**Response**

**201**

```json
{
  "callId": "550e8400-e29b-41d4-a716-446655440000",
  "accessToken": "string",
  "expiresAt": "2026-01-01T10:02:00.000Z"
}
```

**400**

```json
{
  "success": false,
  "error": {
    "name": "ZodError",
    "issues": [
      {
        "code": "invalid_enum_value",
        "path": [
          "contacts",
          0,
          "email"
        ],
        "message": "Invalid email"
      }
    ]
  }
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**402**

```json
{
  "error": "The account cannot pay for calls: no active subscription, or not enough credit"
}
```

**404**

```json
{
  "error": "Agent not found"
}
```

**415**

```json
{
  "error": "The body was not sent as `application/json`"
}
```

**500**

```json
{
  "error": "Internal server error"
}
```
