# Create web call

> POST https://api.nabrah.ai/api/ext/web/make-web-call

Group: Web calls. Page: https://www.nabrah.ai/en/docs/api-reference/web-calls/create-web-call

Create a web call: start a browser/WebRTC voice session with an agent and receive a connection token. Designed to be called from your frontend so a user can talk to the agent directly in the browser. Provide the agent_id and optionally an identity for the participant, prompt variables, and free-form extra_data; the returned token is used by your WebRTC client to join the live audio session. This is the canonical web-call endpoint; /api/ext/make-web-call is an equivalent alias kept for backward compatibility.

## Request fields

- **agent_id**: UUID of the agent that will answer the web call. Fetch agents with GET /api/ext/agent. Fields: `agent_id`.
- **identity**: Optional participant identity for the realtime session — useful to associate the connection with a known user. Fields: `identity`.
- **variables**: Optional key/value map of template variables exposed to the agent's prompt during the session. Fields: `variables`.
- **extra_data**: Optional free-form data injected into the call context. Fields: `extra_data`.

## Response

- **token**: Connection token returned for joining the live voice session from a browser/WebRTC client. Short-lived; mint a new one per session. Fields: `token`.

## Related

- **/api/ext/make-web-call**: Identical backward-compatible alias. Prefer this canonical path (/api/ext/web/make-web-call).
- **GET /api/ext/call/{call_id}**: After the session, the web call appears as a call record retrievable by its id.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (application/json)

### Example: Minimal

Start a web call with just an agent.

```json
{
  "agent_id": "00000000-0000-4000-8000-000000000000"
}
```

### Example: Full

Web call with participant identity, variables, and extra context.

```json
{
  "agent_id": "00000000-0000-4000-8000-000000000000",
  "identity": "user-12345",
  "variables": {
    "customer_name": "Ahmed"
  },
  "extra_data": "Logged-in user, premium tier"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "token": "string"
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/web/make-web-call' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "agent_id": "00000000-0000-4000-8000-000000000000"
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/web/make-web-call"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "agent_id": "00000000-0000-4000-8000-000000000000"
}

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

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/web/make-web-call", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "agent_id": "00000000-0000-4000-8000-000000000000"
  }),
});

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

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "agent_id": "00000000-0000-4000-8000-000000000000"
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/web/make-web-call", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
