Skip to main content

Error Response Format

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "English message",
    "message_es": "Mensaje en español",
    "details": { ... },
    "requestId": "req_abc123"
  }
}

Authentication Errors (401/403)

CodeHTTPDescription
AUTH_MISSING_API_KEY401No API key provided in X-API-Key header
AUTH_INVALID_API_KEY401API key is invalid, expired, or revoked
AUTH_KEY_DISABLED401API key has been disabled
AUTH_COUNTRY_NOT_ALLOWED403API key not authorized for destination country
AUTH_IP_NOT_ALLOWED403Request IP not in API key’s whitelist
AUTH_INSUFFICIENT_PERMISSIONS403API key lacks required permissions

Validation Errors (400)

General Validation

CodeDescription
VALIDATION_FAILEDOne or more fields failed validation
VALIDATION_REQUIRED_FIELDRequired field is missing
VALIDATION_INVALID_FORMATField format is invalid
VALIDATION_MAX_LENGTHField exceeds maximum length
VALIDATION_MIN_LENGTHField below minimum length
VALIDATION_INVALID_VALUEField value is not in allowed set

Address Validation

CodeDescription
VALIDATION_ADDRESSGeneral address validation failure
VALIDATION_COUNTRY_CODEInvalid ISO 3166-1 alpha-2 country code
VALIDATION_STATE_CODEInvalid state/province code
VALIDATION_POSTAL_CODEInvalid postal code format
VALIDATION_POSTAL_MISMATCHPostal code doesn’t match region

Identity Validation

CodeDescription
VALIDATION_NATIONAL_IDInvalid national ID format
VALIDATION_CEDULAInvalid Ecuadorian Cédula
VALIDATION_RUCInvalid Ecuadorian RUC
VALIDATION_RFCInvalid Mexican RFC
VALIDATION_DNIInvalid Peruvian DNI
VALIDATION_RUTInvalid Chilean RUT

Contact Validation

CodeDescription
VALIDATION_PHONEInvalid phone number format
VALIDATION_EMAILInvalid email format
VALIDATION_EMAIL_DOMAINSuspicious email domain (typo detected)

Parcel Validation

CodeDescription
VALIDATION_WEIGHTWeight out of allowed range
VALIDATION_DIMENSIONSDimensions out of allowed range
VALIDATION_VALUEDeclared value out of range
VALIDATION_CHECKSUMProduct checksum doesn’t match declared value

Order Errors (404/409)

CodeHTTPDescription
PARCEL_NOT_FOUND404Tracking number doesn’t exist
PARCEL_DUPLICATE_TRACKING409Tracking number already in use
PARCEL_ALREADY_VOIDED409Order has already been cancelled
PARCEL_IN_TRANSIT409Cannot modify order in transit
PARCEL_DELIVERED409Cannot modify delivered order
PARCEL_ASSIGNED409Parcel already assigned to a manifest

Manifest Errors (400/409)

CodeHTTPDescription
MANIFEST_NOT_FOUND404Manifest/AWB not found
MANIFEST_LOCKED409Manifest already submitted and locked
MANIFEST_AWB_DUPLICATE409AWB number already exists
MANIFEST_VALIDATION_FAILED400Country-specific validation failed
MANIFEST_EMPTY400Manifest has no parcels

Label Errors (404/409)

CodeHTTPDescription
LABEL_NOT_FOUND404Label not found for tracking number
LABEL_NOT_GENERATED409Label not yet generated
LABEL_GENERATION_FAILED500Label generation failed

Rate Limiting (429)

CodeDescription
RATE_LIMIT_EXCEEDEDRequest rate limit exceeded
RATE_LIMIT_DAILYDaily request quota exceeded
Response includes retryAfter field:
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests",
    "retryAfter": 30
  }
}

Idempotency Errors (409)

CodeDescription
IDEMPOTENCY_CONFLICTSame key used with different payload
IDEMPOTENCY_IN_PROGRESSRequest with this key is still processing

Server Errors (500)

CodeDescription
INTERNAL_ERRORUnexpected server error
SERVICE_UNAVAILABLEService temporarily unavailable
DATABASE_ERRORDatabase operation failed
CARRIER_ERRORCarrier API error

Handling Errors

Retryable Errors

These errors can be retried with exponential backoff:
  • RATE_LIMIT_EXCEEDED
  • SERVICE_UNAVAILABLE
  • INTERNAL_ERROR (after delay)
  • IDEMPOTENCY_IN_PROGRESS (after short delay)

Non-Retryable Errors

These errors require code changes or user action:
  • AUTH_* errors
  • VALIDATION_* errors
  • *_NOT_FOUND errors
  • *_DUPLICATE_* errors
  • *_LOCKED errors

Example Error Handler

function shouldRetry(error) {
  const retryableCodes = [
    'RATE_LIMIT_EXCEEDED',
    'SERVICE_UNAVAILABLE',
    'INTERNAL_ERROR',
    'IDEMPOTENCY_IN_PROGRESS'
  ];
  
  return retryableCodes.includes(error.code);
}