# Create SIP inbound trunk

> POST https://api.nabrah.ai/api/ext/sip-inbound

Group: SIP inbound. Page: https://www.nabrah.ai/en/docs/api-reference/sip-inbound/create-sip-inbound-trunk

Creates a new inbound SIP trunk for the project tied to your API key, so external SIP/phone calls can be terminated into Nabrah and routed to an agent. You supply a display name, the phone number(s) the trunk should accept, an optional allow-list of source IP addresses, and the SIP digest credentials your provider will use to authenticate. The credentials are stored per-project. On success the API returns the created trunk including its generated `id`, which you use to fetch or delete the trunk later. Authenticate with the `X-API-Key` header.

## Connection fields

Provide these exactly as defined in the request body.

- **name**: Human-readable label for the trunk, shown in the dashboard and in list responses.
- **numbers**: The phone number(s) this inbound trunk accepts calls on, in E.164 format (e.g. +14155552671). Calls arriving on these numbers are answered by Nabrah.
- **allowed_addresses**: Optional allow-list of source SIP/IP addresses permitted to deliver calls to this trunk. Restricts which hosts your provider may signal from; leave empty to accept any authenticated source.
- **auth_username / auth_password**: SIP digest credentials your provider presents when delivering inbound calls. Stored and scoped to the project that owns the API key.
- **pbx_type**: Identifies the SIP/PBX backend the trunk is provisioned against.

## After creation

Capture the returned `id`; it is the `sip_id` path parameter for GET /api/ext/sip-inbound/{sip_id} and DELETE /api/ext/sip-inbound/{sip_id}.

## Authorization

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

## Body (application/json)

### Example: Inbound trunk

Create an inbound SIP trunk with digest credentials and a source allow-list.

```json
{
  "name": "Support line (US)",
  "numbers": "+14155552671",
  "allowed_addresses": [
    "203.0.113.10"
  ],
  "auth_username": "nabrah_inbound_us",
  "auth_password": "s3cure-Inbound-Pass!",
  "pbx_type": "lk"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "name": "string",
  "numbers": "string",
  "id": "00000000-0000-4000-8000-000000000000",
  "project_id": "00000000-0000-4000-8000-000000000000",
  "created_by_email": "string",
  "allowed_addresses": [
    "string"
  ],
  "auth_username": "string",
  "auth_password": "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/sip-inbound' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Support line (US)",
  "numbers": "+14155552671",
  "allowed_addresses": [
    "203.0.113.10"
  ],
  "auth_username": "nabrah_inbound_us",
  "auth_password": "s3cure-Inbound-Pass!",
  "pbx_type": "lk"
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/sip-inbound"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "name": "Support line (US)",
    "numbers": "+14155552671",
    "allowed_addresses": [
        "203.0.113.10"
    ],
    "auth_username": "nabrah_inbound_us",
    "auth_password": "s3cure-Inbound-Pass!",
    "pbx_type": "lk"
}

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/sip-inbound", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Support line (US)",
    "numbers": "+14155552671",
    "allowed_addresses": [
      "203.0.113.10"
    ],
    "auth_username": "nabrah_inbound_us",
    "auth_password": "s3cure-Inbound-Pass!",
    "pbx_type": "lk"
  }),
});

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

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "name": "Support line (US)",
  "numbers": "+14155552671",
  "allowed_addresses": [
    "203.0.113.10"
  ],
  "auth_username": "nabrah_inbound_us",
  "auth_password": "s3cure-Inbound-Pass!",
  "pbx_type": "lk"
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/sip-inbound", 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))
}
```
