Introduction
Nexmo is now called Vonage, but there are still references to Nexmo in our URLs, code snippets and message templates.
The Phone Numbers API lets you get, select and manage programmable virtual phone numbers to use with Vonage's other APIs.
API specification
Base URL
https://api-prd.kpn.com/communication/nexmo/phone-numbers
Conceptual model
Definitions
Virtual number
A virtual number is a telephone number without a directly associated telephone line. Usually, these numbers are programmed to forward incoming calls to one of the pre-set telephone numbers, chosen by the client: fixed, mobile or VoIP.
SIP
The Session Initiation Protocol (SIP) is used for signaling and controlling multimedia communication sessions in applications of Internet telephony for voice and video calls, in private IP telephone systems, in instant messaging over Internet Protocol (IP) networks as well as mobile phone calling over LTE (VoLTE).
API workflow
Features and constraints
Features
- Administer your number through this API.
- Instant provisioning through code.
- Search for available numbers.
Constraints
- To check which countries are supported, please check the Vonage help page.
Getting started
Make sure you've read What's in it for you for more info on how to register and start testing APIs.
Authentication
The API follows the KPN Store API Authentication Standard to secure the API. It includes the use of OAuth 2.0 client_id and client_secret to receive an access token.
Go to the Authentication tab on top of this page to find out how to:
- Authenticate to an API using cURL.
- Authenticate to an API on Swaggerhub.
- Import Open API Specifications (OAS), also called Swagger files into Postman.
How to...
List owned numbers
Retrieve all the inbound numbers associated with your account.
The following table shows the parameters you use in the request:
Parameter | Description | Required |
---|---|---|
index |
Page index Default: 1 |
No |
size |
Page size Max: 100 Default: 10 |
No |
pattern |
A matching pattern | No |
search_pattern |
Strategy for matching pattern. Expected values: 0 (starts with, default), 1 (anywhere), 2 (ends with). |
No |
SwaggerHub:
- Select
GET /account/numbers
. - Click Try it out'.
- Edit the parameters by filling out
Index
,size
,pattern
andsearch_pattern
. - Click 'Execute'.
- Check the response code and message.
Postman:
- Select
(GET) List owned numbers
. - Click the
Params
section of the request and provide values for the following keys:Index
,size
,pattern
andsearch_pattern
. - Click 'Send'.
- Check the response code and message.
^^Response example^^
{
"count": 1,
"numbers": [
{
"country": "GB",
"msisdn": "447700900000",
"moHttpUrl": "https://example.com/mo",
"type": "mobile-lvn",
"features": [
"VOICE",
"SMS"
],
"voiceCallbackType": "app",
"voiceCallbackValue": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
},
]
}
The response contains the following keys and values:
Key | Value |
---|---|
count |
The total amount of numbers owned by account. |
numbers |
A paginated array of numbers and their details. |
Search available numbers
Retrieve inbound numbers that are available for a given country.
The following table shows the parameters you use in the request:
Parameter | Description | Required |
---|---|---|
country |
The two-character country code in ISO 3166-1 alpha-2 format. |
Yes |
pattern |
A number pattern to search for. | No |
search_pattern |
Strategy for matching pattern. Expected values: 0 (starts with, default), 1 (anywhere), 2 (ends with). |
No |
type |
The type of number to search for. Accepted values: landline , landline-toll-free and mobile-lvn . |
No |
features |
Available features are SMS and VOICE. For both features, use a comma-separated value SMS,VOICE. | No |
size |
Page size Max: 100 Default: 10 |
No |
index |
Page index Default: 1 |
No |
SwaggerHub:
- Select
GET /number/search
. - Click 'Try it out'.
- Edit the parameters by filling out
country
. Other parameters are not required but advised to get more tailored results. - Click 'Execute'.
- Check the response code and message.
Postman:
- Select
(GET) Search available numbers
. - Click the
Params
section of the request and provide values forcountry
. Other parameters from the above table are not required but advised to get more tailored results. - Click 'Send'.
- Check the response code and message.
^^Response example^^
{
"count": 1234,
"numbers": [
{
"country": "GB",
"msisdn": "447700900000",
"cost": "1.25",
"type": "mobile-lvn",
"features": [
"VOICE",
"SMS",
]
},
...
]
}
The response contains the following keys and values:
Key | Value |
---|---|
count |
The total amount of numbers available in the pool. |
numbers |
A paginated array of available numbers and their details. |
Buy a number
Request to purchase a specific inbound number.
The following table shows the parameters you use in the request:
Parameter | Description | Required |
---|---|---|
country |
The two-character country code in ISO 3166-1 alpha-2 format. |
Yes |
msisdn |
An available inbound virtual number. For example, 447700900000 . |
Yes |
SwaggerHub:
- Select
POST /number/buy
. - Click 'Try it out'.
- Edit the parameters by filling out
country
andmsisdn
. - Click 'Execute'.
- Check the response code and message.
Postman:
- Select
(POST) Buy a number
. - Click the
Body
section of the request and provide values forcountry
andmsisdn
. - Click 'Send'.
- Check the response code and message.
^^Result example^^
{
"error-code":"200",
"error-code-label":"success"
}
Cancel a number
Cancel your subscription for a specific inbound number.
The following shows the parameters you use in the request:
Parameter | Description | Required |
---|---|---|
country |
The two-character country code in ISO 3166-1 alpha-2 format. |
Yes |
msisdn |
One of your inbound numbers. For example, 447700900000 . |
Yes |
SwaggerHub:
- Select
POST /number/cancel
. - Click 'Try it out'.
- Edit the parameters by filling out
country
andmsisdn
. - Click 'Execute'.
- Check the response code and message.
Postman:
- Select
(POST) Cancel a number
. - Click the
Body
section of the request and provide values forcountry
andmsisdn
. - Click 'Send'.
- Check the response code and message.
^^Response example^^
{
"error-code":"200",
"error-code-label":"success"
}
Update a number
Change the behavior of a number that you own.
The following shows the parameters you use in the request:
Parameter | Description | Required |
---|---|---|
country |
The two character country code in ISO 3166-1 alpha-2 format. |
Yes |
msisdn |
An available inbound virtual number. For example, 447700900000 . |
Yes |
moHttpUrl |
An URL-encoded URI to the webhook endpoint that handles inbound messages. Your webhook endpoint must be active before you make this request, Vonage makes a GET request to your endpoint and checks that it returns a 200 OK response. Set to empty string to clear. |
No |
moSmppSysType |
The associated system type for your SMPP client. For example inbound . |
No |
voiceCallbackType |
The voice webhook type. Possible values are sip , tel , or app |
No |
voiceCallbackValue |
A SIP URI, telephone number or Application ID | No |
voiceStatusCallback |
A webhook URI for Vonage to send a request to when a call ends. | No |
voiceCallbackValue
has to be used together with thevoiceCallbackType
parameter.
SwaggerHub:
- Select
POST /number/update
. - Click 'Try it out'.
- Edit the parameters by filling out
country
andmsisdn
. Also edit the other parameters, as mentioned in the above table, to your needs. - Click 'Execute'.
- Check the response code and message.
Postman:
- Select
(POST) Update a number
. - Click the
Body
section of the request and provide values forcountry
andmsisdn
. Also edit the other parameters in the body, as mentioned in the above table, to your needs. - Click 'Send'.
- Check the response code and message.
^^Response example^^
{
"error-code":"200",
"error-code-label":"success"
}
Return codes
Code | Description |
---|---|
200 | Success. |
201 | Created. |
202 | Accepted. |
302 | Found. Link in location header. |
400 | Bad request. |
401 | Unauthorized. |
403 | Forbidden. |
404 | Not found. |
405 | Method not allowed. |
412 | Precondition failed. |
429 | Too many requests. |
500 | Internal server error. |
502 | Bad gateway. |
503 | Service unavailable. |
HTTP response headers
The following tables display the standard response headers that are returned with each API response:
Standard response field name | Description |
---|---|
sunset | This field will be populated with the deprecation details. By default the value is n/a. |
api-version | Indicates the API version you have used. |
quota-interval | Used to specify an integer (for example, 1, 2, 5, 60, and so on) that will be paired with the quota-time-unit you specify (minute, hour, day, week, or month) to determine a time period during which the quota use is calculated. For example, an interval of 24 with a quota-time-unit of hour means that the quota will be calculated over the course of 24 hours. |
quota-limit | Number of API calls an user can make within a given time period. If this limit is exceeded, the user will be throttled and API requests will fail. |
quota-reset-UTC | All quota times are set to the Coordinated Universal Time (UTC) time zone. |
quota-time-unit | Used to specify the unit of time applicable to the quota. For example, an interval of 24 with a quota-time-unit of hour means that the quota will be calculated over the course of 24 hours. |
quota-used | Number of API calls made within the quota. |
strict-transport-security | The HTTP Strict-Transport-Security (HSTS) response header lets a website tell browsers that it should only be accessed using HTTPS, instead of using HTTP. All present and future subdomains will be HTTPS for a maximum of 1 year and access is blocked to pages or sub domains that can only be served over HTTP including HSTS preload lists of web browsers. Strict-Transport-Security: max-age=31536000; includeSubDomains; preload. |
Access control field name | Description |
access-control-allow-credentials | Tells browsers whether to expose the response to frontend JavaScript when the request's credentials mode (Request.credentials) is include. When a request's credentials mode (Request.credentials) is include, browsers will only expose the response to frontend JavaScript if the Access-Control-Allow-Credentials value is true. Boolean. |
access-control-allow-origin | Indicates whether the response can be shared with requesting code from the given origin. |
access-control-allow-headers | Used in response to a pre-flight request which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request. |
access-control-max-age | Indicates how long the results of a pre-flight request (that is the information contained in the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers) can be cached. |
access-control-allow-methods | Indicates which HTTP methods are allowed on a particular endpoint for cross-origin requests.For example: GET, PUT, POST, DELETE. |
content-length | The Content-Length entity header indicates the size of the entity-body, in bytes, sent to the recipient. |
content-type | The Content-Type entity header the client what the content type of the returned content actually is. |