Skip to main content

Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of telnyx.APIConnectionError is raised. When the API returns a non-success status code (that is, 4xx or 5xx response), a subclass of telnyx.APIStatusError is raised, containing status_code and response properties. All errors inherit from telnyx.APIError.
Error codes are as follows:

Retries

Certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors are all retried by default. You can use the max_retries option to configure or disable retry settings:

Timeouts

By default requests time out after 1 minute. You can configure this with a timeout option, which accepts a float or an httpx.Timeout object:
On timeout, an APITimeoutError is thrown. Note that requests that time out are retried twice by default.