Response Result

The PBX returns the results in JSON format.

Success response example

A successful response returns a code of 0 and a message of SUCCESS. For some API responses, the response also returns relevant parameters. The HTTP status code for a successful response is 200 OK.

HTTP/1.1 200 OK
{
    "errcode": 0,
    "errmsg": "SUCCESS",
}

Error response example

An error response provides detailed information including error code, error message, and the wrong or duplicated parameter value, which can help developer to quickly address the error, modify the request and try again.

You can check the detailed description of error prompt in Error Code and Error Message.

Error response example – get access token

The response indicates the authentication failure, and the invalid_param_list field prompts the wrong parameter – the user name or password is wrong.

{
    "errcode": -1,
    "errmsg": "FAILURE",
    "invalid_param_list": [
        {
            "field": "username or password",
            "value": "error"
        }
    ]
}

Error response example – add an outbound route

The response indicates the failure caused by parameter error, and the invalid_param_list field prompts the wrong parameter – the required parameter name is missed.

{
    "errcode": 40002,
    "errmsg": "PARAMETER ERROR",
    "invalid_param_list": [
        {
            "field": "name",
            "validation_type": "required"
        }
    ]
}

Error response example – add an extension

The response indicates the failure caused by duplicated key value, and the duplicate_field_list field prompts the duplicated field – the email address of the new extension is duplicated with the one of the existing extension 1011.

{
    "errcode": 40003,
    "errmsg": "DUPLICATE KEY VALUE",
    "submsg": "Extension create fail for duplicate fields",
    "duplicate_field_list": [
        {
            "field": "email_addr",
            "value": "example@126.com",
            "external_source": "extension",
            "external_source_name": "1011"
        }
    ]
}