Error handling

The API returns HTTP error codes according to the type of the error:

  • 400 error codes are used for client related issues
  • 500 error codes indicate server side issues

JSON error representation

403 status codes are returned with the following JSON error:

1{
2 "error_code" : 1104,
3 "error_token": "Forbidden",
4 "message": "You do not have the necessary permissions to access this entry point. Please contact your administrator."
5}

400 error codes come with a consumable JSON error representation:

1{
2 "error_code" : 1406,
3 "error_token" : "NotAllowed",
4 "message" : "Updating of own organisation not allowed.",
5}

Some error codes like ValidationFailed can contain multiple error messages embedded:

1{
2 "error_code" : 1400,
3 "error_token" : "InputValidationFailed",
4 "message" : "Input validation failed",
5 "errors" : [
6 {
7 "error_code" : 1403,
8 "error_token" : "InvalidFormat",
9 "message" : "User - Username has invalid format: expecting String."
10 },
11 {
12 "error_code" : 1402,
13 "error_token" : "Required",
14 "message" : "User - organisation is required."
15 }
16 ]
17}

List of error codes

Generic error codes

There are several error categories that have general applicability within API and aren’t specific to any particular resource.

CategoryHTTP
Status
Error
Code
Error
Token
Description
and parameters
Authentication4011101InvalidCredentials
Authentication4011102InvalidToken
Authentication4011103TokenExpired
Authentication4031104Forbidden
Authentication4291105TooManyRequests
Navigation4041201NotFound{resource} with id {id} not found
Paging4221301InvalidQueryCriteriaSearch criteria {criteria} is invalid
Paging4221302InvalidSortCriteriaSort criteria {criteria} is invalid
Validation4221400InputValidationFailed
Validation4221401InvalidReferenceInvalid reference to {resource} with id {id}
Validation4221402Required{Object} - {field} is required
Validation4221403InvalidFormat{Object} - {field} has invalid format: Expecting {String/Number/Object}
Validation4221404OutOfRange{Object} - {field} out of range ({range})
Validation4091405Duplicated{Object} - {field} already exists
Validation4001406NotAllowed{Action} not allowed
Validation4091407CannotBeDeleted{Object} still referenced
Validation4221408InvalidValue{Object} - {field} is invalid: {value}
Validation4221409UnknownPropertyUnknown Property: {property}
Validation4221410InvalidJsonInvalid request: {reason}
Rate Limit4291501TooManyRequestsToo many requests
Unavailable4041601UnavailableNo {resource} available
Connectivity4041901UnknownSubscriberUnknown Subscriber for Endpoint with id {id}*
Connectivity4041904UnknownLocationUnknown Location for Endpoint with id {id}*

Connectivity errors

This section provides additional information about endpoint connectivity errors with HTTP 404 status codes are returned.

Unknown Subscriber Error
This error indicates that the subscriber isn’t registered in the HLR. This can occur if the IMSI doesn’t belong to emnify, the IMSI isn’t assigned to any SIM, the SIM isn’t activated or is suspended, etc.

Unknown Location Error
This error is used when the service request is made for a subscriber without valid location data (that is, no location information is present in the HLR; this can occur if the IMSI is detached or didn’t respond to paging).

External Network Error
This error is used when the source of the error is external to the system, for example, timeout on a Network Request towards VPLMN.

Network Element Not Available Error
This error indicates no network element available to process the service request.

Data Missing
An example of missing data would be a missing optional parameter required by the context.

Unexpected Data Value
Invalid data, for example, an invalid MSISDN or IMSI.

Resource-specific errors

Errors that are specific to a particular resource and operation being performed are described in resource section.

Most of the errors in this category return 409 Conflict HTTP status code.

For example, trying to activate an endpoint that has no SIM card associated causes the following error:

1409 Conflict
1{
2 "error_code" : 2101,
3 "error_token" : "UnableToActivate",
4 "message" : "Unable to activate",
5 "description" : "No SIM."
6}

Resource specific errors are segmented as follows:

Code rangeResource
2100-2199Endpoint
2200-2299SIM
2300-2399Service profiles
2400-2499Traffic limits
2500-2599User
2600-2699Tariff
2700-2799IP Address Space

Warning: Responses with different root causes may share an error code and token. Be sure to check the error message to determine the exact cause.

For example, the Create IP address space call has two possible reasons for returning a 422: The requested IP address space isn’t allowed or overlaps with a reserved range. These scenarios are both considered out of range, so each response contains an OutOfRange error token and 2701 error code. The message indicates the cause of the error.