> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinnest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Call

> Start a new voice call — web session or outbound phone call.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.thinnest.ai/v2/calls \
    -H "Authorization: Bearer $THINNESTAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "type": "web",
    "agent_id": "ag_5d2678fd_e556"
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.thinnest.ai/v2/calls"
  headers = {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
  }

  payload = {
    "type": "web",
    "agent_id": "ag_5d2678fd_e556"
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.thinnest.ai/v2/calls", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
    "type": "web",
    "agent_id": "ag_5d2678fd_e556"
  }),
  });

  const data = await response.json();
  console.log(data);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      payload := []byte(`{
    "type": "web",
    "agent_id": "ag_5d2678fd_e556"
  }`)
      req, _ := http.NewRequest("POST", "https://api.thinnest.ai/v2/calls", bytes.NewBuffer(payload))
      req.Header.Set("Authorization", "Bearer YOUR_THINNESTAI_API_KEY")
      req.Header.Set("Content-Type", "application/json")

      resp, err := http.DefaultClient.Do(req)
      if err != nil { panic(err) }
      defer resp.Body.Close()
      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

***

## Request Body

<ParamField body="type" type="string" default="web">
  Call type: web (browser) or outbound (phone)
</ParamField>

<ParamField body="agent_id" type="string" required>
  Agent public ID (ag\_\*)
</ParamField>

<ParamField body="phone_number_id" type="integer">
  Phone number to call from
</ParamField>

<ParamField body="customer.number" type="string">
  Customer phone (E.164)
</ParamField>

<ParamField body="customer.name" type="string">
  Customer display name
</ParamField>

<ParamField body="voice_config" type="object" default="Agent default">
  Override STT/TTS config
</ParamField>

***

## Web Call

Creates a browser-based voice session. Returns a LiveKit token for the client to connect.

```json theme={null}
{
  "type": "web",
  "agent_id": "ag_5d2678fd_e556",
  "voice_config": {
    "stt_provider": "deepgram",
    "tts_provider": "cartesia"
  }
}
```

### Response `201`

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "demo-abc123",
    "type": "web",
    "status": "active",
    "agent_id": "ag_5d2678fd_e556",
    "token": "eyJhbGciOiJIUzI1...",
    "livekit_url": "wss://api.thinnest.ai/livekit",
    "room_name": "voice-ag_5d2678fd-abc123",
    "expires_in": 300
  }
  ```
</ResponseExample>

***

## Outbound Phone Call

Initiates an outbound phone call via Twilio/Vobiz SIP.

```json theme={null}
{
  "type": "outbound",
  "agent_id": "ag_5d2678fd_e556",
  "phone_number_id": 12,
  "customer": {
    "number": "+919876543210",
    "name": "Rahul"
  }
}
```

### Response `201`

```json theme={null}
{
  "id": 78,
  "type": "outbound",
  "status": "connecting",
  "agent_id": "ag_5d2678fd_e556",
  "customer": {
    "number": "+919876543210",
    "name": "Rahul"
  },
  "room_name": "voice-ag_5d2678fd-def456"
}
```

***

## Errors

| Code  | Description                       |
| ----- | --------------------------------- |
| `402` | Insufficient balance              |
| `422` | Missing agent\_id or invalid type |
| `429` | Rate limit exceeded (5 calls/min) |
