Platform HTTP API

Interaction format

API requests are made over the HTTP protocol. Input and output data structures are transmitted in the request and response body in JSON format.

Authorization

To do this, each request must contain a header or an X-Authorization argument with a connection token in the AccessKey token format,

For example, the title

POST /apps/activate HTTP/1.1

Host: api.unibell.tech

X-Authorization: AccessKey d8ac9959r12b43545da9034,

either by parameter

POST api.unibell.tech/apps/activate?X-Authorization=AccessKey d8ac9959r12b43545da9034

Response format

The JSON scheme of any response contains a string type status parameter with the following values:

Status ValueDescription
okNo errors
invalidAccessKeyErrorInvalid AccessKey
requiredJsonErrorThe request body requires JSON
invalidSchemeErrorInvalid JSON scheme
invalidDataErrorInput data error
prohibitedForAppErrorProhibited for this application
prohibitedForServiceErrorProhibited for this service
rpcErrorCommunication error

For example:

    {
        …
        “status”: “ok”
        ....
    }

Some GET requests support paginated output. The following parameters are used to control the paginated output

ParameterDescription
pageRequested page number
per_pageNumber of elements per page
disable_paginationDisable paginated output

For example,

GET api.unibell.tech/media?page=1&per_page=10

The response to such a request will contain a pagination json object

    {
        …
        "pagination": {
            "totalItems": 2,
            "currentPage": 1,
            "totalPages": 1
        }
        ....
    }

Where

ParameterDescription
totalItemsTotal number of elements
currentPagePage sequence number
totalPagesTotal number of pages

Request format

Media Library Management

A media library is a hierarchical storage of various user files, resembling a file system. Media library storage objects are files and folders. Files can be divided into folders. The library is accessed using Personal Account or this API.

ParameterDescription
totalItemsTotal number of elements
currentPagePage sequence number
totalPagesTotal number of pages

Getting a list of all objects

Request

GET api.unibell.tech/media

Response

    {
        "status":  "ok",
        "pagination": {
            "totalItems":  2,
            "currentPage":  1,
            "totalPages":  1
        },
        "media": [
            {
                "createdDateTime":  "2020-02-12 18:09:10",
                "id":  65,
                "name":  "Hymns",
                "isFolder":  1
            },
            {
                "createdDateTime":  "2020-03-04 13:17:47",
                "id":  74,
                "name":  So young.mp3",
                "isFolder":  0
            }
        ]
    }

media — an array of media library objects containing the following parameters:

ParameterDescription
idUnique identifier of the media resource
nameName
createdDateTimeDate\time of upload
isFolderIndicates that this object is a folder. 1 — yes, 0 — no

Getting a specific object

Request

GET api.unibell.tech/media/id, where id is the unique identifier of the media resource

Response

A list of attached files is returned for folders

    {
        "status": "ok",
        "pagination": {
            "totalPages": 1,
            "totalItems": 2,
            "currentPage": 1
        },
        "media": [
            {
                "isFolder": 0,
                "name": "Audio1.mp3",
                "createdDateTime": "2020-02-12 18:19:05",
                "id": 67
            },
            {
                "isFolder": 0,
                "name": "Audio2.mp3",
                "createdDateTime": "2020-02-12 18:19:18",
                "id": 68
            }
        ]
    } 

For files, the requested file is returned.

Folder creation

Request

POST api.unibell.tech/media

    {
        "name": "asdasd"
    }
ParameterDescription
nameFolder name

Response

   {
        "status": "ok",
        "media": {
            "name": "asdasd2",
            "createdDateTime": "2020-04-06 18:44:45",
            "isFolder": 1,
            "id": 111
        }
    } 

File Upload

Request

POST api.unibell.tech/media – places the file in the root folder
POST api.unibell.tech/media/folder_id – places the file in the specified folder

The file is passed in the request body via Content-Type: multipart/form-data

Response

    {
        "status": "ok",
        "media": {
            "name": "test",
            "createdDateTime": "2020-04-06 18:44:45",
            "isFolder": 0,
            "id": 112
        }
    }

Object rename

Request

PUT api.unibell.tech/media/id, where id is the unique identifier of the media resource

    {
        "name": "asdasd"
    }

Response

    {
        "status": "ok",
        "media": {
            "name": "asdasd",
            "createdDateTime": "2020-04-06 18:44:45",
            "isFolder": 1,
            "id": 111
        }
    } 

Deleting an object

Request

DELETE api.unibell.tech/media/id – where id is the unique identifier of the media resource

Response

    {
        “status”: “ok”
    }

Application Management

Application activation

Performs activation of a pre-created application.

Request

POST api.unibell.tech/apps/activate

    {
"reference": "123456789",
"sourceAddr": "XXXXXXXXXXX",
"destAddr": "XXXXXXXXXXX",
"sex": 1,
"volume": 1,
"language": "xx-XX",
"rate": 1,
"scenarioData": "text=Hello, how are you?"
    }
ParameterTypeDescription
referencestringThe user parameter with which the callback will be called based on the results of the application execution
sourceAddrstringOutgoing number
destAddrstringRecipient’s phone number
scenarioDatastringScript variables for this application. It is a set of parameter=value pairs separated by — &.
sexintGender. 0 — female, 1 — male
volumeintVoice volume (0-2)
rateintThe speed of speaking the text (0-4). (0 is the slowest)
languagestringThe synthesis language.
Available languages:
en-US – English (US)
en-IN – English (Indian)
en-IE – English (Ireland)
en-UA – English (Australian)
en-GB-WLS – English (Welsh)
en-NZ – English (New Zealand)
en-ZA – English (South African)
ar-AE – Arabic (gulf)
nl-NL – Dutch
nl-BE – Dutch (Belgain)
da-DK – Danish
is-IS – Icelandic
es-ES – Spanish (European)
es-US – Spanish (US)
es-MX – Spanish (Mexican)
it-IT – Italian
ca-ES – Catalan
cmn-CN – Chinese (Mandarin)
yue-CN – Chinese (Cantonese)
ko-KR – Korean
de-DE – German
de-AT – German (Austrian)
nb-NO – Norwegian
pl-PL – Polish
pt-PT – Portuguese (European)
pt-BR – Portuguese (Brazillian)
ro-RO – Romanian
ru-RU – Russian
tr-TR – Turkish
cy-GB – Welsh
fi-FI – Finnish
fr-FR – French
fi-CA – French (Canadian)
fr-BE – French (Belgian)
sv-SE – Swedish
ja-JP – Japanese

Response

    {
        “status”: “ok”
    }

During application execution, callbacks can be configured over the HTTP/HTTPS protocol. Callback is configured for two types of events — Start of execution (Start callback) and end of execution (End callback). Basic authorization is supported. Parameters are passed to the request URL.

See the callback versions and what methods are used in them here.

Example,
GET www.host.ru?type=startCallback&reference=324234

Parameters passed to the startCallback

ParameterDescription
referenceUser parameter passed in the activation request
typeThe type of callback request, in this case — startCallback

Parameters passed to endCallback

ParameterDescription
referenceUser parameter passed in the activation request
typeThe type of callback request, in this case — endCallback
stateApplication execution result
errorError code, or 0 — in case of successful execution
durationDuration of the call

where, state is the result of script execution

ValueDescription
STATE_OK2Application completed successfully
STATE_ERR5Error as a result of execution

error — error code

ValueDescription
ERR_NO_ANSWER16The subscriber did not pick up the phone, attempts to dial are exhausted
ERR_BUSY17The subscriber is busy, dial-up attempts have been exhausted
ERR_ALERTING19The subscriber is unavailable
ERR_CONGESTION34Overload of communication channels
ERR_PLAY1001File playback error, file not found, invalid format
ERR_TTS1002, 1017TTS Conversion Error
ERR_ASR1003ASR Conversion error

Balance check

Request

GET api.unibell.tech/balance

Displays a personal account and its balance in JSON format. The personal account is displayed as the one on which the application is located, the key for which is specified in the request authorization

Response

     {
        "personalAccountId": "0000000000",
        "balance": "100.0"
     }
On this page