Introduction

With this API you can create or add voice features to your apps while still using your favorite programming language. No knowledge of complex telephone systems is required. You just need a web server and follow simple steps to make it work.


API specification

Test the API on SwaggerHub


Base URL

https://api-prd.kpn.com/communication/apidaze/cpaas


Conceptual model

Conceptual model


Definitions

Callback (WebHook)

A Callback or WebHook is a HTTP POST callback implemented by you, that can be called by another system when an event is triggered on that system to notify you. You will need to make the address of your webhook/callback known on the other system to make it work.

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

API workflow


Features and constraints

Features

  • Event based system that will be triggered during the call flow.
  • Use your own scripting to take action on events in the call flow.
  • Support for sample playing in .wav format.
  • Text to speech support.

Constraints

  • Works with a SIP account.
  • For text to speech currently supported languages are: en-US, fr-FR, it-IT and es-ES.


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.

Setting up management APIs

You have an API for XML scripting and a VoIP SIP API. These REST management APIs expose actions that help your apps to interact with APIdaze’s Telco platform in multiple ways. Voice traffic never flows through these APIs.

XML scripting API

You can set the URL from where Apidaze fetches XML instructions to run on the Apidaze platform. You can write your various scripts there using the Script Reference and then test them.

VoIP SIP API

You can manage your phone numbers, connect directly with other SIP carriers (inbound and outbound), manage your SIP accounts, voicemail boxes and messages, and provision your hardphones.

To start you need to follow the below steps.

Set the URL for your External Script

Your ExternalScript is the core element of your application. It must be accessible by Apidaze at a public HTTP URL. Any PaaS (Platform as a Service) like Heroku can be used here, and you may of course use your own web infrastructure. You can set the URL of your ExternalScript using 'External Script Create' resource of XML Scripting API.

Set up your code

You can set up your code using the below sources:

Script Reference: the XML instructions set to handle your calls

API Reference: the REST based management APIs

Set up your SIP account

Create your SIP account using 'SIP Account Create' resource of VoIP SIP API.

Set up your SIP client

In order to setup your SIP client your need fetch below details using REST APIs. We will use Zoiper as an example SIP Client.

a) Domain/Host: You can get this info using 'SIP Account Status' resource of VoIP SIP API. Ask our support for the key.

b) Username: You can get this info using 'SIP Account List' resource of VoIP SIP API.

c) Password: You can get this info using 'SIP Account List' resource of VoIP SIP API.

d) 'Optional SIP credentials' > 'Use outbound proxy' should be filled with 46.101.153.96:4060. This is a fixed value and you cannot configure it.

e) Account Name: You will see this in your app once your registration is successful.

Your configuration should look like this:

SIP Configuration

High level picture:

SIP Sequence Diagram


How to...

Manage VOIP SIP API requests

List SIP accounts

Get a list of SIP accounts currently set up.

SwaggerHub:

  1. Select GET /sipaccounts.
  2. Click Try it out.
  3. Click Execute.
  4. Check the response code and message.

Postman:

  1. Select (GET) SIP Account List.
  2. Click Send.
  3. Check the response code and message.
^^Response example^^
[
  {
    "id": "string",
    "name": "string",
    "sip": {
      "username": "string",
      "password": "string"
    },
    "callerid": {
      "internal_name": "string",
      "internal_number": "string",
      "external_name": "string",
      "external_number": "string"
    },
    "voicemail": {
      "mwi_account": "string"
    },
    "created_at": "string",
    "updated_at": "string"
  }
]

Create a new SIP account

SwaggerHub:

  1. Select POST /sipaccounts.
  2. Click Try it out.
  3. Edit the parameters by filling out username which will be the username to identify this SIP account. Other optional values are internal_caller_id_number, external_caller_id_number, name and mwi_account.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (POST) SIP Account Create.
  2. Click on the Body section and enter a value for the username variable, which will be the username to identify this SIP account. Other optional values are internal_caller_id_number, external_caller_id_number, name and mwi_account.
  3. Click Send.
  4. Check the response code and message.

Get a specific SIP account

Get the detail of a specific SIP account determined by its ID.

SwaggerHub:

  1. Select GET /sipaccounts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this SIP account.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (GET) SIP Account Read.
  2. Provide the id of the account to read in the parameter id of the URL.
  3. Click Send.
  4. Check the response code and message.

Update a SIP account

Update the values of a single SIP account determined by its ID.

SwaggerHub:

  1. Select PUT /sipaccounts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this SIP account. Other optional values are internal_caller_id_number, external_caller_id_number, name and mwi_account.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (PUT) SIP Account Update.
  2. Click on the Body section and enter a value for the id variable, which will be the id to identify this SIP account. Other optional values are internal_caller_id_number, external_caller_id_number, name and mwi_account.
  3. Click Send.
  4. Check the response code and message.

Delete a SIP account

Deletes a single SIP account determined by its ID.

SwaggerHub:

  1. Select DELETE /sipaccounts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this SIP account.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (DEL) SIP Account Delete.
  2. Provide the id of the account to read in the parameter id of the URL.
  3. Click Send.
  4. Check the response code and message.

Get the status a SIP account

Gets the status of a single SIP account determined by its ID.

SwaggerHub:

  1. Select GET /sipaccounts/{id}/status.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this SIP account.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (GET) SIP Account Status.
  2. Provide the id of the account to read in the parameter id of the URL.
  3. Click Send.
  4. Check the response code and message.

Manage XML scripting API requests

Get a list of external scripts as currently set up.

SwaggerHub:

  1. Select GET /externalscripts.
  2. Click Try it out.
  3. Click Execute.
  4. Check the response code and message.

Postman:

  1. Select (GET) External Script List.
  2. Click Send.
  3. Check the response code and message.
^^Response example^^
[
  {
    "id": "string",
    "name": "string",
    "url": "string",
    "created_at": "string",
    "updated_at": "string"
  }
]

Create new external script

SwaggerHub:

  1. Select POST /externalscripts.
  2. Click Try it out.
  3. Edit the parameters by filling out url which points to the URL where your script is hosted. Other optional values are name.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (POST) External Script Create.
  2. Click on the Body section and enter a value for the url variable, which points to the URL where your script is hosted. Other optional values are name.
  3. Click Send.
  4. Check the response code and message.

Get a specific external script

Get the detail of a specific external script determined by its ID.

SwaggerHub:

  1. Select GET /externalscripts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this external script.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (GET) External Script Read.
  2. Provide the id of the external script to read in the parameter id of the URL.
  3. Click Send.
  4. Check the response code and message.

Update an external script

Update the values of a single external script determined by its ID.

SwaggerHub:

  1. Select PUT /externalscripts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this external script and url, which points to the URL where your script is hosted. Other optional values are name.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (PUT) External Script Update.
  2. Click on the Body section and enter a value for the id variable, which will be the id to identify this external script, as well as url, which points to the URL where your script is hosted. Other optional values are name.
  3. Click Send.
  4. Check the response code and message.

Delete an external script

Deletes a single external script determined by its ID.

SwaggerHub:

  1. Select DELETE /externalscripts/{id}.
  2. Click Try it out.
  3. Edit the parameters by filling out id which will be the id to identify this external script.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (DEL) External Script Delete.
  2. Provide the id which will be the id to identify this external script.
  3. Click Send.
  4. Check the response code and message.

Test an external script

Trigger a single external script determined by its ID.

SwaggerHub:

  1. Select GET externalscripts/test.
  2. Click Try it out.
  3. Edit the parameters by filling out url, which points to the URL where your script is hosted.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (GET) External Script Test.
  2. Provide the id which will be the id to identify this external script.
  3. Click Send.
  4. Check the response code and message.


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.

Mopinion feedback