Errors

The Txtly API uses standard HTTP status codes and returns consistent error responses. All errors include a status code, error name, and descriptive message.

Error Format

All error responses follow this format:

{
  "status_code": 400,
  "name": "validation_error",
  "message": "Request validation failed"
}

Error Codes

Here are the possible error codes and their meanings:

StatusError NameDescription
400validation_errorRequest validation failed. Check your request parameters.
401authentication_errorMissing or invalid API key.
403authorization_errorYour API key doesn't have permission for this action.
404not_foundThe requested resource was not found.
409conflictThe request conflicts with existing data (e.g., duplicate email).
422unprocessable_entityThe request is well-formed but contains invalid data.
429rate_limit_exceededToo many requests. Please slow down and retry after some time.
500internal_errorAn internal server error occurred. Our team has been notified.

Example Error Response

When you try to send an email with missing required fields:

{
  "status_code": 400,
  "name": "validation_error",
  "message": "Validation failed",
  "errors": {
    "to": ["Email address is required"],
    "from": ["Sender email is required"]
  }
}

Handling Errors

Always check the status code and error name in your application to handle errors appropriately. For 429 (rate limit) errors, implement exponential backoff before retrying.