Errors

The Treasure API returns detailed error responses in various scenarios to provide control to integrating clients on how they handle cases in which an action cannot be completed as requested. This can range in reason from an invalid request structure (i.e. a field that is the wrong type), to an operation that can’t be completed due to rules and constraints on when an action can be taken (e.g. trying to request wire instructions when the account is not open), to temporary system unavailability (e.g. cloud service disruptions).

The structure for these errors is defined below, as well as a table with Error Codes, related HTTP status codes, message, and a description of what the error means.

Error Structure

  • "error_code" (String): A code returned to indicate which error occurred.

  • "error_message" (String): Message describing the error.

  • "details" (Array):

  • "target_type" (Enum): Describes what part of the request the target is referring to, if provided. Possible values:

    • "HTTP_REQUEST_PATH"
    • "HTTP_REQUEST_BODY"
    • "HTTP_REQUEST_QUERY_STRING"
    • "HTTP_REQUEST_HEADER"
    • "target" (String): Describes what part of the request this detail is referring to.
    • "message" (String): Developer-targeted message describing the error detail.
    • "reason_code" (String): Code returned to indicate the reason for the error detail.

Example response:

{ "error_message": "Invalid parameter(s)", "error_code": "INVALID_PARAMS", "details": [ { "target_type": "HTTP_REQUEST_BODY", "target": "some_unexpected_field", "message": "Unexpected parameter", "reason_code": "PARAM_IS_UNEXPECTED" } ] }

Error Codes

Treasure Error Code HTTP Code Message & Notes
INVALID_PARAMS 400 Invalid parameter(s).
INVALID_PATH 400 The path requested is invalid.
NOT_AUTHORIZED 403 You are not authorized to access this resource.
SERVICE_TEMPORARILY_UNAVAILABLE 503 Service is temporarily unavailable. Please retry your request later.
THROTTLE_EXCEEDED 429 There were too many requests, please wait a moment and try again.
UNEXPECTED_ERROR 500 There was an unknown error.
UNSUPPORTED_MEDIA_TYPE 415 The media type is not supported.
SIMULATION_STATE_TRANSITION_IMPOSSIBLE 409 Invalid state transition from %s to %s
INVALID_PORTFOLIO_SETTINGS 400 The portfolio settings provided are not valid.
ACCOUNT_NOT_OPEN 400 The account is not open.
FEATURE_NOT_SUPPORTED 400 That capability is not supported.