REST API Documentation

Introduction

Here the functions of the VoIPstudio API are described, which will give you access to all basic VoIPstudio resources.

General

The REST API enables VoIPstudio customers access to a wide range of resources. Our API has predictable, resource-orientated URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application. JSON is returned by all API responses, including errors.

Endpoints

The base URL for the API id:

https://l7api.com/v1.1/voipstudio/

Authentication

For secure Communications you can create an API Key to be used for the API Authorization

Communications between customer applications and VoIPstudio's API are secured through HTTP basic authentication over SSL.

Before sending requests to the API you must first login using your email address and password or create an API Key to be used for authorization. After successful authentication the API will return a unique user_id and user_token that should be used to login.

E-mail and Password

Login request using e-mail and password:

  curl -H "Content-Type: application/json" -X POST -d '{"email":"jsmith@example.com","password":"$ecretPas$$"}' https://l7api.com/v1.1/voipstudio/login

Example request:

POST /v1.1/voipstudio/login HTTP/1.1
User-Agent: curl/7.26.0
Host: l7api.com
Accept: */*
Content-Type: application/json
Content-Length: 55
Connection: close

{"email":"jsmith@example.com","password":"$ecretPas$$"}

Example of successful response:

  {
    "message":"Login success",
    "user_token":"8e9bc12575e639c993ba5dd8a0e7ce2250211b9a",
    "user_id":123456
  }

REST API Key

Follow steps below to add API Key for a user. Once persistent API Key is created, there is no need to login with email/password every time.

  1. Go to Administration panel.
  2. Open Users grid.
  3. Click "Edit" icon in right column.
  4. Open "Advanced" tab.
  5. Enter a name for your API Key, this can be anything you like. For example a name of your application that will use this API Key.
  6. Click "Add" button.
  7. Click "Wrench" icon and select "Show Details" to view the actual "API Key" generated.

Add API Key

Figure 1.1 Add API Key.

Making requests

Authentication to the API is performed via HTTP Basic Auth. This type of authentication should be a straightforward operation in most popular programming languages. Incoming requests handled by our API are expected to have a Authorization header with a base64 encoded value built from user_id and user_token returned from a successful "login" response, or user_id and created API Key. To get base64 value of Authorization, Base64 encode your user_id and user_token separated by a colon.

Authorization header is expected in the below format:

Authorization: Basic base64('user_id:user_token')

or

Authorization: Basic base64('user_id:API_Key')

Example of authenticated request:

using user_token returned by POST /login

curl -H "Content-Type: application/json" -H "Authorization: Basic base64('user_id:user_token')"  https://l7api.com/v1.1/voipstudio/cdrs

or using API_Key

curl -H "Content-Type: application/json" -H "Authorization: Basic base64('user_id:API_Key')"  https://l7api.com/v1.1/voipstudio/cdrs

or short form using curl parameter -u, --user <user:password>:

curl -u user_id:user_token -H "Content-Type: application/json" https://l7api.com/v1.1/voipstudio/cdrs

or using API_Key

curl -u user_id:API_Key -H "Content-Type: application/json" https://l7api.com/v1.1/voipstudio/cdrs

HTTP responses

VoIPstudio REST API uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that has failed given the information provided (e.g., a required parameter was omitted, etc.), and codes in the 5xx range indicate a server error.

Each successful response, depending on HTTP method, contains the following properties:

  • GET collection of resources:

    • data - an array of resources data
    • total - total number of resources
  • GET single resource:

    • data - resources data
    • links - links to related resources

Each error response contains the following properties:

  • message - general error message
  • errors - an array of error messages

Pager

For data collection endpoints such as GET https://l7api.com/v1.1/voipstudio/cdrs pager can be used to return a specific number of records from a given page in the data set. To apply pager please append the following parameters to the URL ?page=N&limit=Z where N is a page number and Z is the number of records to be returned (maximum 5000).

Filters

To filter data, the filter parameter can be passed as a URL query string. The value of filter parameter has to be JSON encoded string in the format shown below:

[
   {"property":"_PROPERTY_NAME_","operator":"_OPERATOR_","value":"_SEARCH_VALUE_"},
   {"property":"_PROPERTY_NAME_","operator":"_OPERATOR_","value":"_SEARCH_VALUE_"}
   ...
]

The three tokens above _PROPERTY_NAME_, _OPERATOR_ and _VALUE_TO_SEARCH_ should be interpreted as below:

  • _PROPERTY_NAME_ this can be any property that belongs to particular endpoint object. See "Resources" section below for detailed explanation of data model for each endpoint.

  • _OPERATOR_ can be one of:

    • eq or = when looking for records with "property" value equal to _SEARCH_VALUE_
    • ne, neq, <> or != when looking for records with "property" value NOT equal to _SEARCH_VALUE_
    • lt or < when looking for records with "property" value less than _SEARCH_VALUE_
    • lte or <= when looking for records with "property" value less than or equal _SEARCH_VALUE_
    • gt or > when looking for records with "property" value greater than _SEARCH_VALUE_
    • gte or >= when looking for records with "property" value greater than or equal _SEARCH_VALUE_
    • in when looking for records with "property" value included in _SEARCH_VALUE_ (Note: search value needs to be passed as an array, eg: [ "foo", "bar" ])
    • like when looking for records with "property" value matching pattern of _SEARCH_VALUE_
    • notlike when looking for records with "property" value NOT matching pattern of _SEARCH_VALUE_
  • _SEARCH_VALUE_ the value you want to search for

Example of request to /cdrs endpoint searching for incoming calls (dst_id property equals user Id) to user Id 123456 after 1st Sep. 2018:

curl -u user_id:API_Key -H "Content-Type: application/json"
  https://l7api.com/v1.1/voipstudio/cdrs?filter=[
   {"property":"dst_id","operator":"eq","value":"123456"},
   {"property":"calldate","operator":"gt","value":"2018-09-01 00:00:00"}
  ]

Grouping

group_by parameter is available for grouping records by specific property: ``GET https://l7api.com/v1.1/voipstudio/cdrs?group_by=src`. This parameter should be passed as URL query string.

Click to Chat