Making API Requests

API Request URLs

API calls are made by appending the endpoint URLs to a “base url” which us common across all Toku APIs. To properly format an API request, you need to append the appropriate API name, version number, and endpoint (plus any required payload) to the base URL.

Here is an example:

https://caasapi.tokuworld.com/PhoneNumbers/V1/AvailableTypes

The base URL:

https://caasapi.tokuworld.com 

is appended with the name of the API ("/PhoneNumbers"), the version number ("/V1"), and then the endpoint ("/AvailableTypes").

The next thing that needs to happen is that you need to include the correct information in the header of your API call.

Forming Requests

You can call Toku API functions many different ways. We provide examples using cURL or HTTP requests, in our documentation.

Below is an example showing a cURL call to the Numbers APi, requesting a list of the types of numbers available for provisioning to an account.

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer 327f9a06-7e1d-366f-ba51-2e63aecac3ff' 'https://caasapi.tokuworld.com/PhoneNumbers/V1/AvailableTypes'

In addition, there is a Request Header:

{
  "Accept": "application/json"
}

What is returned by the API, in this case, is something that looks like this:

{
  "resp_code": 0,
  "resp_desc": "success",
  "total_type": 3,
  "types": [
    {
      "type": "1",
      "desc": "Voice only"
    },
    {
      "type": "2",
      "desc": "SMS only"
    },
    {
      "type": "4",
      "desc": "Voice and SMS"
    }
  ]
}

Along with a Response Code:

200

And a Response Header:

{
  "content-type": "application/json"
}

Further examples of usage and typical responses are included in the API reference documentation for each set of Toku APIs.