Skip to main content

Numbers

Calls reach your SIP server only for numbers attached to your trunk, and your PBX can only call out from those numbers. This page covers finding numbers you can attach, attaching them and detaching them.

Authentication Required

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

One number, one owner

A number is on one trunk or one SFVoPI app at a time. Attaching a number that is on another trunk or an SFVoPI app fails with an error. We never move a number from one trunk or app to another for you. See One number, one owner.

Replace 101 with your trunk ID and +91XXXXXXXXXX with your own numbers.

Get available numbers​

List the numbers you can attach to a trunk. A number is listed when it:

  • is a Superfone number on your account,
  • is in service,
  • is not linked to an SFVoPI app, and
  • is not attached to any trunk.

HTTP request​

GET /sf-trunks/available-numbers

Code examples​

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

Success response​

Status Code: 200 OK

{
"data": {
"numbers": [
{
"id": 5001,
"voip_number": "+91XXXXXXXXXX",
"provider": "carrier_a",
"status": "paid"
},
{
"id": 5002,
"voip_number": "+91YYYYYYYYYY",
"provider": "carrier_b",
"status": "trial_active"
}
]
},
"message": "success"
}

Response fields​

FieldTypeDescription
data.numbersarrayNumbers you can attach, sorted by number. Empty if there are none
data.numbers[].idnumberThe number's ID. The other SF Trunk endpoints take the number itself, not this ID
data.numbers[].voip_numberstringThe number in E.164 format. Send this value when you attach
data.numbers[].providerstringInternal carrier identifier. Treat it as opaque. Values may change without notice
data.numbers[].statusstringThe number's service state, paid or trial_active. Numbers that are not in service are not listed

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

Attach numbers​

Attach one or more of your numbers to a trunk. All the numbers on a trunk share its capacity limits.

HTTP request​

POST /sf-trunks/:id/numbers

Path parameters​

ParameterTypeRequiredDescription
idintegerYesThe trunk ID

Request body​

FieldTypeRequiredDefaultDescriptionValidation
voip_numbersstring[]Yes-Numbers to attach, in E.164 format, for example +91XXXXXXXXXXAt least one number. A number listed twice is attached once

The request is all or nothing. If any number fails a check, the request fails and none of the numbers are attached. The error message names the numbers that failed. Remove or fix them and send the request again.

Attaching is idempotent. A number that is already attached to this trunk stays attached and is not added again, and the request does not fail because of it. You can safely retry a request, for example after a timeout. Either way, data.numbers in the response lists every number on the trunk.

Code examples​

curl -X POST https://prod-api.superfone.co.in/superfone/sf-trunks/101/numbers \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"voip_numbers":["+91XXXXXXXXXX","+91YYYYYYYYYY"]}'

Success response​

Status Code: 200 OK

{
"data": {
"numbers": ["+91XXXXXXXXXX", "+91YYYYYYYYYY"]
},
"message": "success"
}
FieldTypeDescription
data.numbersstring[]Every number now attached to the trunk, in the order they were attached. This includes numbers attached by earlier requests, not only the ones you just sent

Errors when attaching​

Status CodeMessageWhen It Occurs
400Requiredvoip_numbers is missing
400Array must contain at least 1 element(s)voip_numbers is empty
400Invalid voip_number: <number>A number is not a valid phone number. Write it in E.164 format, for example +91XXXXXXXXXX
400Number(s) not allocated to this org: <numbers>A number is not a Superfone number on your account
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
409Number(s) already linked to a VoPI app: <numbers>A number is linked to an SFVoPI app. Unlink it from the app first
409Number(s) linked to an SFVoPI app (inactive); unlink them from the app first: <numbers>A number has an inactive SFVoPI app link. Unlink it from the app first
409Number(s) already attached to another SF trunk: <numbers>A number is attached to another trunk. Detach it from that trunk first
409Number(s) not in a serviceable state: <numbers>A number is not in service, for example on hold or refunded. Email hello@superfone.in

When numbers in one request fail different checks, the response reports one check at a time. Fix the numbers it names and send the request again.

Example error response​

{
"message": "Number(s) already attached to another SF trunk: +91XXXXXXXXXX"
}

Detach a number​

Detach one number from a trunk. The number goes back to working like any other Superfone number, and you can attach it to a trunk again.

HTTP request​

DELETE /sf-trunks/:id/numbers/:number

Path parameters​

ParameterTypeRequiredDescription
idintegerYesThe trunk ID
numberstringYesThe number to detach, in E.164 format, for example +91XXXXXXXXXX. URL-encode the + as %2B

No request body required.

Code examples​

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

Success response​

Status Code: 200 OK

{
"data": {
"detached": true
},
"message": "success"
}
FieldTypeDescription
data.detachedbooleanAlways true on success

Error responses​

Status CodeMessageWhen It Occurs
400Invalid voip_number: <number>The number in the path is not a valid phone number
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
404Number is not attached to this SF trunkThe number is not attached to this trunk

URL encoding​

Phone numbers start with +. Encode it in the path:

OriginalURL-Encoded
+91XXXXXXXXXX%2B91XXXXXXXXXX
  • JavaScript/TypeScript: encodeURIComponent('+91XXXXXXXXXX')
  • Python: urllib.parse.quote('+91XXXXXXXXXX', safe='')

One number, one owner​

A number has exactly one owner at a time: one trunk or one SFVoPI app.

  • Attaching a number that is linked to an SFVoPI app, even through an inactive link, or attached to another trunk, fails with 409 and names the number.
  • Attaching a number that is already on this trunk is not treated as a conflict. It stays attached. See Attach numbers.
  • Linking a trunk number to an SFVoPI app fails the same way, with 409 and VoIP number is already attached to an SF trunk: <number>.
  • We never move a number for you. To move one, detach it from its trunk or unlink it from its app, then attach it where you want it.
  • Deleting a trunk detaches all its numbers.

Next Steps​