Skip to main content

Trunks

Create, list, view, update and delete the trunks on your Superfone account.

Authentication Required

Requires an API key, or the session of the account owner or a manager. See Authentication.

The TypeScript examples use the types in TypeScript types. Replace pbx.example.com with your SIP server and 101 with your trunk ID.

Create a trunk​

Create a trunk on your account. The trunk is active straight away and takes calls once you have attached at least one number.

HTTP request​

POST /sf-trunks

Request body​

FieldTypeRequiredDefaultDescriptionValidation
customer_sip_hoststringYes-Public hostname or IPv4 address of your SIP server. We deliver inbound calls hereSee Allowed SIP hosts
customer_sip_portintegerNo5060Port of your SIP server1 to 65535
customer_sip_transportstringNoudpTransport for calls to your SIP server. Accepts udp, tcp or tls. udp and tcp are supported today, tls is not. See Transportudp, tcp or tls
customer_sip_fallback_hoststring | nullNonullPublic hostname or IPv4 address of a second SIP server. We try it when your primary server is down. See Fallback destinationSee Allowed SIP hosts
customer_sip_fallback_portinteger | nullNo5060 when a fallback host is setPort of your fallback server1 to 65535. Needs a fallback host
customer_sip_fallback_transportstring | nullNonullTransport for calls to your fallback server. null uses the same transport as your primary serverudp, tcp, tls or null. Needs a fallback host
call_recordingboolean | nullNonulltrue or false sets call recording for the trunk. null follows the call recording setting of each numbertrue, false or null

Fields not in this table are ignored. That includes status, which only Superfone can set, and the trunk limits, which you set with Update a trunk.

Allowed SIP hosts​

customer_sip_host and customer_sip_fallback_host must be a public IPv4 address or a fully qualified hostname such as pbx.example.com. A hostname can use letters, digits, hyphens and dots. We remove spaces from the start and end of the value.

We refuse:

  • IPv6 addresses,
  • private addresses: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16,
  • loopback (127.0.0.0/8), link-local (169.254.0.0/16) and shared CGNAT (100.64.0.0/10) addresses,
  • 0.0.0.0/8, and every address from 224.0.0.0 up,
  • Superfone's own addresses, and any name under sft.superfone.co.in.

The same rules apply when you update either host.

When you give a hostname, we look it up for each call and respect its DNS TTL. A change to your DNS record reaches us once the old record expires.

Fallback destination​

A fallback is optional. It is a second SIP server that takes calls when your primary server is down.

We always deliver a call to your primary server first. We try the fallback once, and only when the primary is down:

  • your primary does not respond within about 5 seconds, or
  • your primary replies with a 5xx error.

We do not try the fallback when your primary rang and nobody answered, or when it rejected the call, for example busy, declined, or any other 4xx or 6xx reply. Unanswered calls ring for up to 60 seconds in total.

To set a fallback, send customer_sip_fallback_host when you create or update the trunk. The port defaults to 5060. The transport defaults to the same transport as your primary server.

  • A fallback port or transport without a fallback host returns 400.
  • A fallback with the same host, port and transport as the primary returns 400.
  • To remove the fallback, update the trunk with customer_sip_fallback_host set to null. This also clears the fallback port and transport.
curl -X PATCH https://prod-api.superfone.co.in/superfone/sf-trunks/101 \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"customer_sip_fallback_host": "pbx-backup.example.com",
"customer_sip_fallback_port": 5060
}'

Code examples​

curl -X POST https://prod-api.superfone.co.in/superfone/sf-trunks \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"customer_sip_host": "pbx.example.com",
"customer_sip_port": 5060,
"customer_sip_transport": "udp"
}'

Success response​

Status Code: 200 OK

{
"data": {
"sf_trunk": {
"id": 101,
"label": "a1b2c3d4",
"org_id": 12345,
"customer_sip_host": "pbx.example.com",
"customer_sip_port": 5060,
"customer_sip_transport": "udp",
"customer_sip_fallback_host": null,
"customer_sip_fallback_port": null,
"customer_sip_fallback_transport": null,
"cps_limit": null,
"cps_burst": null,
"concurrent_limit": null,
"status": "active",
"call_recording": null,
"created_at": "2026-02-02T10:30:00.000Z",
"updated_at": "2026-02-02T10:30:00.000Z",
"fqdn": "a1b2c3d4.sft.superfone.co.in"
}
},
"message": "success"
}

data.sf_trunk is a trunk object. Keep the label and fqdn. Your PBX sends outbound calls to the FQDN.

A new trunk has no limits of its own. Its calls draw on your organisation's limits. See Trunk limits.

Error responses​

Status CodeMessageWhen It Occurs
400Requiredcustomer_sip_host is missing
400customer_sip_host must be a public hostname or IPv4 addressThe host is not allowed
400Number must be less than or equal to 65535The port is above 65535. A port below 1 gets Number must be greater than or equal to 1
400Invalid enum value. Expected 'udp' | 'tcp' | 'tls', received '<value>'The transport is not one of the three values
400customer_sip_fallback_host must be a public hostname or IPv4 addressThe fallback host is not allowed
400customer_sip_fallback_port and customer_sip_fallback_transport require customer_sip_fallback_hostA fallback port or transport is sent without a fallback host
400The fallback SIP destination must differ from the primary (same host, port and transport)The fallback has the same host, port and transport as the primary
401UnAuthorized, Please Provide Valid API KeyThe API key is not valid
401UnAuthorized, Please LoginNo valid session
403Only owners and managers can perform this actionYou are signed in with a session, but not as the owner or a manager of the account
500Failed to create SF trunkSomething failed on our side

Example error response​

{
"message": "customer_sip_host must be a public hostname or IPv4 address"
}

List trunks​

List every trunk on your account, newest first. If you have none, sf_trunks is an empty array.

HTTP request​

GET /sf-trunks

Code examples​

curl https://prod-api.superfone.co.in/superfone/sf-trunks \
-H "X-API-Key: your_api_key_here"

Success response​

Status Code: 200 OK

{
"data": {
"sf_trunks": [
{
"id": 101,
"label": "a1b2c3d4",
"org_id": 12345,
"customer_sip_host": "pbx.example.com",
"customer_sip_port": 5060,
"customer_sip_transport": "udp",
"customer_sip_fallback_host": null,
"customer_sip_fallback_port": null,
"customer_sip_fallback_transport": null,
"cps_limit": 10,
"cps_burst": 20,
"concurrent_limit": 30,
"status": "active",
"call_recording": null,
"created_at": "2026-02-02T10:30:00.000Z",
"updated_at": "2026-02-02T11:05:00.000Z",
"fqdn": "a1b2c3d4.sft.superfone.co.in"
}
]
},
"message": "success"
}

Each item in data.sf_trunks is a trunk object. The list does not include numbers. Get a trunk to see its numbers.

Error responses​

Status CodeMessageWhen It Occurs
401UnAuthorized, Please Provide Valid API KeyThe API key is not valid
401UnAuthorized, Please LoginNo valid session
403Only owners and managers can perform this actionYou are signed in with a session, but not as the owner or a manager of the account

Get a trunk​

Get one trunk and the numbers attached to it.

HTTP request​

GET /sf-trunks/:id

Path parameters​

ParameterTypeRequiredDescription
idintegerYesThe trunk ID

Code examples​

curl https://prod-api.superfone.co.in/superfone/sf-trunks/101 \
-H "X-API-Key: your_api_key_here"

Success response​

Status Code: 200 OK

{
"data": {
"sf_trunk": {
"id": 101,
"label": "a1b2c3d4",
"org_id": 12345,
"customer_sip_host": "pbx.example.com",
"customer_sip_port": 5060,
"customer_sip_transport": "udp",
"customer_sip_fallback_host": null,
"customer_sip_fallback_port": null,
"customer_sip_fallback_transport": null,
"cps_limit": 10,
"cps_burst": 20,
"concurrent_limit": 30,
"status": "active",
"call_recording": null,
"created_at": "2026-02-02T10:30:00.000Z",
"updated_at": "2026-02-02T11:05:00.000Z",
"fqdn": "a1b2c3d4.sft.superfone.co.in"
},
"numbers": ["+91XXXXXXXXXX", "+91YYYYYYYYYY"]
},
"message": "success"
}

Response fields​

FieldTypeDescription
data.sf_trunkobjectThe trunk object
data.numbersstring[]Numbers attached to the trunk, in E.164 format, in the order they were attached. Empty if none are attached

Error responses​

Status CodeMessageWhen It Occurs
400Invalid SF trunk idid is not a positive whole number
401UnAuthorized, Please Provide Valid API KeyThe API key is not valid
401UnAuthorized, Please LoginNo valid session
403Only owners and managers can perform this actionYou are signed in with a session, but not as the owner or a manager of the account
404SF trunk not foundNo trunk with this ID on your account

Update a trunk​

Change where we deliver inbound calls, the fallback destination, the trunk's call recording setting, or its limits. Send only the fields you want to change. Fields you leave out keep their current value.

HTTP request​

PATCH /sf-trunks/:id

Path parameters​

ParameterTypeRequiredDescription
idintegerYesThe trunk ID

Request body​

FieldTypeRequiredDescriptionValidation
customer_sip_hoststringNoPublic hostname or IPv4 address of your SIP serverSee Allowed SIP hosts
customer_sip_portintegerNoPort of your SIP server1 to 65535
customer_sip_transportstringNoTransport for calls to your SIP server. Accepts udp, tcp or tls. udp and tcp are supported today, tls is not. See Transportudp, tcp or tls
customer_sip_fallback_hoststring | nullNoPublic hostname or IPv4 address of your fallback server. Send null to remove the fallback. See Fallback destinationSee Allowed SIP hosts
customer_sip_fallback_portinteger | nullNoPort of your fallback server. 5060 when a fallback host is set1 to 65535. Needs a fallback host
customer_sip_fallback_transportstring | nullNoTransport for calls to your fallback server. null uses the same transport as your primary serverudp, tcp, tls or null. Needs a fallback host
call_recordingboolean | nullNotrue or false sets call recording for the trunk. Send null to go back to following each number's settingtrue, false or null
concurrent_limitinteger | nullNoThe trunk's own limit on calls in progress at once. Send null to remove itPositive integer or null. Cannot exceed your organisation's limit
cps_limitinteger | nullNoThe trunk's own limit on new calls per second. Send null to remove itPositive integer or null. Cannot exceed your organisation's limit
cps_burstinteger | nullNoThe trunk's own peak CPS. Send null to remove itPositive integer or null. At least cps_limit when both are set. Cannot exceed your organisation's limit

The recording setting is per trunk, not per number. It covers every number attached to the trunk, in both directions.

You cannot change the status. If you send status, we ignore it and keep the current value. Email hello@superfone.in to change it.

Trunk limits​

Org-limits release

Trunk limits you can set ship with the org-limits release.

concurrent_limit, cps_limit and cps_burst cap this trunk below your organisation's limits. Each is null by default, which means only the organisation limits apply. Inbound and outbound calls count together.

A trunk limit cannot be higher than your organisation's. Read your organisation's limits with Get Call Limits. To raise them, email hello@superfone.in. See Limits and billing.

Code examples​

curl -X PATCH https://prod-api.superfone.co.in/superfone/sf-trunks/101 \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"customer_sip_host": "pbx2.example.com",
"customer_sip_port": 5080
}'

Success response​

Status Code: 200 OK

{
"data": {
"sf_trunk": {
"id": 101,
"label": "a1b2c3d4",
"org_id": 12345,
"customer_sip_host": "pbx2.example.com",
"customer_sip_port": 5080,
"customer_sip_transport": "udp",
"customer_sip_fallback_host": null,
"customer_sip_fallback_port": null,
"customer_sip_fallback_transport": null,
"cps_limit": 10,
"cps_burst": 20,
"concurrent_limit": 30,
"status": "active",
"call_recording": null,
"created_at": "2026-02-02T10:30:00.000Z",
"updated_at": "2026-02-03T09:15:00.000Z",
"fqdn": "a1b2c3d4.sft.superfone.co.in"
}
},
"message": "success"
}

data.sf_trunk is the trunk object after the change. The label and fqdn never change, so your PBX keeps sending outbound calls to the same address.

Error responses​

Status CodeMessageWhen It Occurs
400Invalid SF trunk idid is not a positive whole number
400customer_sip_host must be a public hostname or IPv4 addressThe host is not allowed
400customer_sip_fallback_host must be a public hostname or IPv4 addressThe fallback host is not allowed
400customer_sip_fallback_port and customer_sip_fallback_transport require customer_sip_fallback_hostA fallback port or transport is sent but the trunk has no fallback host
400The fallback SIP destination must differ from the primary (same host, port and transport)The fallback has the same host, port and transport as the primary
400<field> cannot exceed your organisation limit of <n>concurrent_limit, cps_limit or cps_burst is higher than your organisation's limit. <n> is the organisation's limit
400A validation message, for example Expected number, received stringAnother field has the wrong type or is out of range, or cps_burst is below cps_limit
401UnAuthorized, Please Provide Valid API KeyThe API key is not valid
401UnAuthorized, Please LoginNo valid session
403Only owners and managers can perform this actionYou are signed in with a session, but not as the owner or a manager of the account
404SF trunk not foundNo trunk with this ID on your account

Delete a trunk​

Delete a trunk and detach all its numbers.

Permanent action

You cannot undo a delete. The trunk's numbers go back to working like any other Superfone number, and you can attach them to another trunk. A trunk you create later gets a new label and FQDN, so you will need to update your PBX.

HTTP request​

DELETE /sf-trunks/:id

Path parameters​

ParameterTypeRequiredDescription
idintegerYesThe trunk ID

Code examples​

curl -X DELETE https://prod-api.superfone.co.in/superfone/sf-trunks/101 \
-H "X-API-Key: your_api_key_here"

Success response​

Status Code: 200 OK

{
"data": {
"deleted": true
},
"message": "success"
}
FieldTypeDescription
data.deletedbooleanAlways true on success

After the delete, GET /sf-trunks/101 returns 404 with SF trunk not found.

Error responses​

Status CodeMessageWhen It Occurs
400Invalid SF trunk idid is not a positive whole number
401UnAuthorized, Please Provide Valid API KeyThe API key is not valid
401UnAuthorized, Please LoginNo valid session
403Only owners and managers can perform this actionYou are signed in with a session, but not as the owner or a manager of the account
404SF trunk not foundNo trunk with this ID on your account, or it was already deleted

Next Steps​