Skip to main content

Handling errors

Error response structure, errors overview

Requests made to our APIs can result in several different error responses. The following document describes a list of error values with a map to the most common recovery tactic to use.

Error Responses​

TEOS API is using HTTP status codes as a highest level of response codes. Following status codes can be returned by TEOS API:

  • HTTP 4xx - error on the client side
    • HTTP 400 - request body error(incorrect parameters, failed preconditions)
    • HTTP 401/403 - error with authentication/authorization
    • HTTP 404 - error in resource URI
  • HTTP 500 - internal server error

The following json-structure represents a common error response body resulting from a failed API request:

{
"code": "21000",
"message": "One or more preconditions failed",
"target": "assets('090299f8f5d95aea86f280001')/destroyunits",
"details": [
{
"code": "1006",
"message": "not enough sparks on the balance. Address: 0xe0450ce1e2ef73b15514ae6a003b90d0ebac8835, required amount: 50, actual amount: 0",
"arguments": {
"signerAddress": "0xe0450ce1e2ef73b15514ae6a003b90d0ebac8835",
"requiredAmount": "50",
"actualAmount": "0"
}
}
],
"clTraceId": "12a56f61-54f8-44fd-9f74-d0d2bbd942f6"
}

Where

  • code: high-level error code
  • message: a message, describing the issue
  • target: the path requested
  • details: depending on the error, may be present or not. They specify the details of the error.
    • code: the subcode of the issue
    • message: a message, describing the details of the issue
    • arguments: if a message contains any data (strings, decimals etc), that need to be used for i18n of the error message, this field contains the names and the values of the data
  • clTraceId: Internal support identifier. When reporting a bug related to a TEOS API call, include the clTraceId to help us find log data for debugging.

Error codes 1xxxx indicate non-business logic related issues with input (auth issues, issues with parsing input data, rate limiting etc.). These errors are mostly 'technical', related to the problems in the TEOS API consumer's code.

Error codes 2xxxx indicate business logic related issues with input (failed preconditions, validations etc.).

HTTP statusCodeDetails.CodeMessage
40111001UserId was not found in provided authentication data
40012001There were OData validation errors
40012002Input binding failed
40021000One or more preconditions failed
400210001001Asset with uinque Id '{uniqueAssetId}' does not exist
400210001002the user '{userId}' does not own asset ('uniqueAssetId') issuer's address '{assetIssuerAddress}'
400210001003invalid units amount provided (must be positive integer): '{providedAmount}'
400210001004spark factor is not defined for the asset '{uniqueAssetId}'
400210001005the user '{userId}' does not own signer address '{signerAddress}'
400210001006not enough sparks on the balance. Address: {signerAddress}, uniqueAssetId: {uniqueAssetId}, required amount: {requiredAmount}, actual amount: {actualAmount}
400210001007the instance is configured to operate on assets from ledger {configuredLedgerId}, but the requested asset '{uniqueAssetId}' is from ledger {assetLedgerId}
400210001008The source asset with Id '{sourceUniqueAssetId}' is already linked to asset with id '{targetUniqueAssetId}'
400210001009The source asset with Id '{sourceUniqueAssetId}' is not linked to asset with id '{targetUniqueAssetId}'
40022000One or more validations failed
400220002001Either asset name or issuer address should be provided in search request
400220002002Issuer address value should be 40 or 42 symbol long
400220002003Valid language code should be provided for asset
400220002004Valid jurisdiction should be provided for asset
400220002005Asset's unit of measure is not valid
400220002006Asset's spark factor is not valid
400220002007Asset's asset class is not valid
400220002008The number of sections in asset custom definition item's SectionsPathNames differs from SectionsPath
400220002009Offered asset unqueId must be specified in request
400220002010Desired asset unqueId must be specified in request
400220002011Desired and offered assets unqueIds must differ
400220002012Either offered or desired amount of sparks must be specified in request but not both
400220002013Signer address must be specified
400220002014Input amount must be a positive integer
400220002015Array of supply ids must contain at least one supply id
400220002016Array of target unique asset ids must not be empty
400220002017User can delete only his own data
40023000<Sdk error code>:<Sdk error message>