Comprehensive error handling is essential for building robust integrations with the Tonder API. This guide covers error response formats, common error scenarios, and HTTP status codes.

Error Response Format

All errors follow a consistent format:
{
  "error": {
    "code": "validation_error",
    "message": "Amount must be greater than 0",
    "type": "request_error",
    "details": {
      "field": "amount",
      "received_value": -10.00
    }
  },
  "request_id": "req_abc123"
}
Where:
FieldTypeDescription
error.codestringSpecific error code
error.messagestringHuman-readable error message
error.typestringError category
error.detailsobjectAdditional error context
request_idstringUnique request identifier for support

HTTP Status Codes

Here are the HTTP status codes that you may receive in the response:

Success Codes

CodeCategoryDescriptionAction
200SuccessRequest successfulContinue
201SuccessTransaction createdContinue
202SuccessTransaction accepted (async processing)Monitor status

Client Error Codes

CodeCategoryDescriptionAction
400Client ErrorInvalid request formatFix request
401Client ErrorAuthentication failedCheck credentials
402Client ErrorPayment required/declinedTry different method
404Client ErrorResource not foundCheck ID
422Client ErrorValidation failedFix data
429Client ErrorRate limit exceededRetry with backoff

Server Error Codes

CodeCategoryDescriptionAction
500Server ErrorInternal server errorRetry request
502Server ErrorBad gatewayRetry request
503Server ErrorService unavailableRetry later

Common Error Categories

Errors can belong to the following categories:

Authentication Errors

CodeDescriptionSolution
invalid_api_keyAPI key not foundCheck API key
invalid_authenticationHMAC signature invalid or authentication failedVerify signature calculation and field mappings
authentication_requiredMissing authentication headersInclude required authentication headers

Validation Errors

CodeDescriptionSolution
missing_fieldRequired field missingInclude required field
invalid_amountAmount out of rangeUse valid amount (0.01 - 15,000,000)
invalid_currencyCurrency not supportedUse supported currency
invalid_emailEmail format invalidUse valid email format

Payment Errors

CodeDescriptionSolution
card_declinedCard declined by issuerTry different card
insufficient_fundsNot enough fundsTry different payment method
expired_cardCard has expiredUse valid card
invalid_cardCard number invalidCheck card details
processing_errorTemporary processing errorRetry request

Withdrawal Errors

CodeDescriptionSolution
invalid_clabeCLABE number invalidVerify CLABE format
institution_not_foundBank code not foundUse valid institution code
insufficient_balanceNot enough balanceCheck account balance
beneficiary_blockedBeneficiary account blockedContact bank

Basic Error Handling

Here are some examples of how to handle errors in different programming languages:

Common Troubleshooting

Here are some common troubleshooting checks for different error scenarios:

Next Steps