Your API key for authentication.
Body
A single phone number to configure. Must be in E.164 format (e.g., +14150000000). Use either phone_number or phone_numbers, not both.
An array of phone numbers to configure (up to 100). Must be in E.164 format. Use either phone_number or phone_numbers, not both.
An array of direction objects. Each specifies either inbound or outbound routing configuration.
Inbound Direction Object
Authentication mode: "ip" (default) or "register". When set to "register", you must also provide register_auth.
directions[].register_auth
Required when auth_mode is "register". Contains username (string) and password (string, min 8 characters).
directions[].sip_endpoint
Your SIP server address for inbound call forwarding (optional). Format: sip:host or host.
Custom SIP header mappings. See header configuration examples below.
Connection options: port (number), transport ("udp", "tcp", or "tls"), secure_media (boolean), sip_username (string), sip_password (string).
Outbound Direction Object
directions[].sip_endpoint
Your SIP provider’s endpoint. Must be a valid SIP URI (e.g., sip:your.provider.com).
Custom SIP header mappings.
Connection options: port (number), transport ("udp", "tcp", or "tls"), secure_media (boolean), sip_username (string), sip_password (string).
Response
Array of successfully configured phone numbers.
Array of phone numbers that failed to configure, with error reasons.
register_password_for_pbx
Only returned when using registration-based auth. This is the derived password you must configure in your PBX.
Headers allow you to map SIP headers to Bland pathway variables and vice versa.
Example Request (Outbound with Headers)
curl -X POST https://api.bland.ai/v1/sip/attach \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+14150000000",
"directions": [
{
"type": "inbound",
"headers": {
"direction": "inbound",
"headers": [
{ "type": "custom", "key": "X-Cool-Guy", "value": "First_Name" },
{ "type": "custom", "key": "Account_Type", "value": "VIP", "passthrough": true },
{ "type": "uui", "target": "CustomerId", "purpose": "bland", "encoding": "hex", "content": "id" }
]
}
},
{
"type": "outbound",
"sip_endpoint": "sip:your.provider.com",
"options": {
"port": 5061,
"transport": "tls",
"secure_media": true,
"sip_username": "bland",
"sip_password": "password"
},
"headers": {
"direction": "outbound",
"headers": [
{ "type": "custom", "key": "Favorite_Color", "value": "X-Favorite-Color" },
{ "type": "custom", "key": "x-custom-id", "value": "12345", "passthrough": true },
{ "type": "uui", "target": "CustomerKV", "purpose": "bland", "content": "customerid_1234", "encoding": "hex" }
]
}
}
],
"service": "sip"
}'
Example Request (Batch Attach)
curl -X POST https://api.bland.ai/v1/sip/attach \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"phone_numbers": ["+14150000001", "+14150000002", "+14150000003"],
"directions": [
{
"type": "outbound",
"sip_endpoint": "sip:trunk.provider.com",
"options": {
"transport": "tls",
"secure_media": true
}
}
],
"service": "sip"
}'
{
"data": {
"configured": ["+14150000001", "+14150000002", "+14150000003"],
"failed": []
},
"errors": null
}