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: https://cpaas.mittoapi.net/api

X-Authorization: AccessKey d8ac9959r12b43545da9034,

either by parameter

POST https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/media – places the file in the root folder
POST https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/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 https://cpaas.mittoapi.net/api/apps/activate

{
  "reference": "123456789",
  "sourceAddr": "XXXXXXXXXXX",
  "destAddr": "XXXXXXXXXXX",
  "gender": 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 — &.
genderintGender. 2 — 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”
}

Launching the application with repeats

Starting the application with repeats is a process that initiates a call, automatically retrying in case of an unsuccessful outcome, such as a busy line, no answer, failed call, or successful response. The repeat settings allow you to define conditions and parameters for each scenario.

Example

If a call to the subscriber fails due to a busy line (repeatBusy), the system automatically retries after the set interval (repeatBusyInt) until the number of attempts (repeatBusyCount) is exhausted.

Request

POST https://cpaas.mittoapi.net/api/apps/activate

Request body

{
  "reference": "123456789",
  "sourceAddr": "XXXXXXXXXXX",
  "destAddr": "XXXXXXXXXXX",

  "scenarioData": "text=Hello, how are you?",

  "isRepeat": 1,
  "repeatBusy": 1,
  "repeatBusyCount": 10,
  "repeatBusyInt": 30,
  "repeatAnswered": 1,
  "repeatAnsweredCount": 10,
  "repeatAnsweredInt": 35,
  "repeatFailed": 1,
  "repeatFailedCount": 10,
  "repeatFailedInt": 1,
  "repeatNoAnswer": 1,
  "repeatNoAnswerCount": 10,
  "repeatNoAnswerInt": 150
}
ParametersTypeDescription
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 — &.
isRepeatintRepeat permission:
0 — repeats are not made
1 — repeats are made
repeatBusyintRepeat on busy number
repeatAnsweredintRepeat on successful answer
repeatFailedintRepeat on failed call
repeatNoAnswerintRepeat on no answer
repeatBusyCount,
repeatAnsweredCount,
repeatFailedCount,
repeatNoAnswerCount
intNumber of repeats
repeatBusyInt,
repeatAnsweredInt,
repeatFailedInt,
repeatNoAnswerInt
intRepeat call interval (in seconds)

Response

{
    "status": "ok",
    "requestId": "37b873131de218352d63f980cb71b41b"
}

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
appKeyThe API key of the application

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

Script execution error codes

Error valueErrorDescription
1001SCENARIO_NOT_FOUNDAn internal script execution error
indicates that the script that should have been executed does not exist or cannot be found
1002SCENARIO_JSON_PARSER_ERRORAn internal Json script parsing error
can occur if the script has incorrect syntax or structure
1003SCENARIO_VAR_ID_ERRORAn internal error in parsing script variables
may indicate problems with variable identification (not used)
1004SCENARIO_VAR_NAME_ERRORIndicates problems with variable names in the script
may be caused by an incorrect or missing variable name (not used)
1005TRUNK_NOT_FOUNDThe trunk cannot be found according to the specified routing rules
may be caused by incorrect routing settings or the absence of the required trunk
1006REDIRECT_TRUNK_NOT_FOUNDThe trunk cannot be found according to the specified routing rules when forwarding a call
may occur due to errors in the forwarding settings
1007MODIFIERS_ERRORThe error of the call modifiers
indicates that the values of sourceAddr, destAddr, trunk Data were incorrectly changed for this call
1008REDIRECT_MODIFIERS_ERRORCall modifiers error during forwarding
the values of source Addr, dest Addr, trunk Data were incorrectly changed for call forwarding
1009CHANNEL_CREATION_ERRORAn error that occurs when creating a communication channel transmitted from Asterisk
may be caused by problems with the configuration or resources of the system
1010REDIRECT_CHANNEL_CREATION_ERRORAn error when creating a forwarding channel
indicates problems with creating a channel for a forwarded call
1011REDIRECT_BRIDGE_CREATION_ERRORAn error creating a conference bridge during forwarding transmitted from Asterisk
a bridge cannot be created to connect multiple call participants
1012REDIRECT_ADDING_SOURCE_CHANNEL_TO_BRIDGE_ERRORError when adding a forwarded call channel to the bridge, transmitted from Asterisk
the original channel cannot be correctly added to the bridge
1013REDIRECT_ADDING_DEST_CHANNEL_TO_BRIDGE_ERRORError when adding the channel to which calls are forwarded to the bridge transmitted from Asterisk
1014INCOMING_CALL_ANSWER_ERROROccurs if the call was dropped before the script execution started, because the channel no longer existed
when the incoming call was answered with an error from Asterisk
1015PLAYBACK_START_ERRORThe error when playing to the channel comes from Asterisk
1016RECORD_START_ERRORThe error when writing from the channel comes from Asterisk
1017TTS_FAULTA speech synthesis error transmitted from the app-TTS
application
may be caused by problems with speech synthesis or incorrect data for synthesis
1018WRONG_DATA_IN_REQUESTRequest data parsing error
indicates incorrect or missing data in the request
1019NUMBER_NOT_FOUND_IN_POOL_BY_ENDINGSelecting a number from the pool at the end of the number for FlashCall
it may be caused by the absence of the corresponding number in the pool
1020INTERFACE_NAME_EMPTY_ERRORError when selecting a trunk
indicates incorrect or missing trunk configuration data
1021REDIRECT_INTERFACE_NAME_EMPTY_ERRORAn error when selecting a trunk for forwarding due to the absence of an interface name
indicates incorrect or missing trunk configuration data
0Call sent to voidThe completion of a normal scenario
indicates that the call has completed normally, without any problems or errors
1UnallocatedIt can happen when the requested resource does not exist or is currently unavailable
4-5Vendor specific 4-5Vendor-specific error
the specific error value depends on the hardware or service provider
6Channel unaccessibleThe channel is unavailable
indicates that the communication channel required for the call is unavailable
9-13Vendor specific 9-13Vendor-specific error
the specific error value depends on the hardware or service provider
16Normal ClearingNormal termination
the call is completed on the initiative of one of the parties (subscriber or operator) without errors
17Line busyThe user is busy
the number of the called party is busy and the call cannot be completed
18No user responseNo response from the user
the called party does not answer the call during the set waiting time
19No answerThe user was notified, but did not answer
the subscriber was notified of an incoming call (for example, the phone rang), but did not accept it
20Subscriber absentMissing subscriber
indicates that the called subscriber is temporarily unavailable
21Call RejectedThe call is rejected
the called party intentionally rejected the incoming call
22Number changedThe number has been changed
27Destination out of orderThe purpose of the call is out of service
the end equipment or network of the called party is not working or unavailable
28Invalid number formatIncorrect number format
the entered phone number has an incorrect format and cannot be recognized by the network
29Facility rejectedFeature rejected
the requested service or feature is not supported or rejected by the network
31Normal unspecifiedThe usual unspecified
the call ended for the usual reason, which was not explicitly stated
32(Reserved)Reserved for future use
34No circuit availableCircuit/channel overload
there is an overload in the network and the call cannot be processed
36Out of orderFaulty
indicates that the equipment or line is not working properly
38Network out of orderThe network is not working
there has been a network outage, which makes it impossible to end the call
43Access disconnectDisabling access
indicates that network access has been disabled
58Bearer capability not availableLoad-bearing capacity is not available
98BlacklistIndicates that the call was blocked because the number is on the blacklist
99Vad avtoinformator errorIndicates that the call was processed by the auto-informer
100InvalidIe contentsInvalid IE content (Information Element)
indicates an error in the information passed in the element
102Recover on timer expiryRecovery after the timer expires
127FailureInteraction/not specified
199Transaction abortAbort a transaction
the transaction was aborted for some reason
200
No translation for address of such natureIt may be due to the fact that the address is invalid, non-existent or not recognized by the system
201No translation for this specific addressThere is no conversion for this particular address
indicates that there is no routing or conversion for the specified address
212Hop counter violationViolation of the traffic counter
indicates that the allowed number of clicks in the network has been exceeded

Balance check

Request

GET https://cpaas.mittoapi.net/api/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