Errors

Every error has a stable code and a readable message.

Embed
Preview of the card
<a href="https://trackified.net/docs/errors"><img src="https://trackified.net/docs/_api/public/orgs/e2a7773e-db9e-41cb-bd59-bd248745cac3/spaces/9d63a5d4-feb0-4803-84a5-dc68639362a6/pages/3987d966-878f-4984-a799-9344f6967e64/social-card.svg?v=3e7ae33eec8b" alt="Errors" width="600" height="315"></a>

Errors return JSON with a stable code you can branch on and a message written for people:

{ "error": { "code": "unauthorized", "message": "missing or invalid API key", "request_id": "req_..." } }

Status

Code

What to do

400

bad_request

Fix the request body or query; the message names the field. A bulk create over your plan's batch size also returns 400.

401

unauthorized

The API key is missing, wrong or revoked.

402

quota_exceeded

You've used this month's trackings. Upgrade, or wait for the next month.

404

not_found

No tracking, webhook or key with that id on your account.

409

idempotency_in_progress

A create with this Idempotency-Key is still running. Retry in a few seconds.

409

idempotency_key_reused

The tracking this Idempotency-Key created has since been stopped. Use a new key.

422

carrier_not_supported

We don't track that carrier yet. We record the request, and it moves that carrier up our build queue.

422

carrier_not_detected

We can't tell the carrier from the number alone. Send carrier explicitly, or call GET /v1/carriers/detect?number= to see the candidates.

422

idempotency_key_reused

This Idempotency-Key was already used with a different body. Use a new key.

429

rate_limited

Too many requests. Wait for the Retry-After seconds, then retry.

Anything in the 5xx range is on our side: retry with backoff, and include the request_id if you contact us.

Errors in the libraries

Each library turns these into typed errors. They all share a base class that carries the HTTP status, the code, the message and the request_id.

Status

TypeScript

Python

Go

Ruby

PHP

400, 422

ValidationError

ValidationError

*ValidationError

ValidationError

ValidationError

401

AuthenticationError

AuthenticationError

*AuthenticationError

AuthenticationError

AuthenticationError

403

PermissionError

PermissionError

*PermissionError

PermissionError

PermissionError

404

NotFoundError

NotFoundError

*NotFoundError

NotFoundError

NotFoundError

429

RateLimitError

RateLimitError

*RateLimitError

RateLimitError

RateLimitError

5xx

APIError

APIError

*APIError

APIError

APIError

No response

ConnectionError

ConnectionError

*ConnectionError

ConnectionError

ConnectionError

402

QuotaExceededError

QuotaExceededError

*QuotaExceededError

QuotaExceededError

QuotaExceededError

409

ConflictError

ConflictError

*ConflictError

ConflictError

ConflictError

QuotaExceededError and ConflictError are new in 0.2; in 0.1, branch on code for 402 and 409. Each library page shows the error handling for that language.

Timeouts

A ConnectionError has a code: connection when the request never reached us, timeout when no answer came in time. After a timeout the outcome is unknown: a create may have gone through. Retry it with the same Idempotency-Key, and you get the first tracking back instead of a second one. The libraries' own retries do this for you.

Retrying a create safely

Send an Idempotency-Key header on POST /v1/trackings. A retry with the same key and body returns the tracking the first request created instead of adding a second one. The libraries do this for you. See Pagination, retries and idempotency.

Watching your quota

GET /v1/account/usage returns trackings_used, trackings_limit and trackings_remaining for the current month (UTC), with period_end saying when it resets. Check it before a create fails with 402 quota_exceeded. See Rate limits and plans.

Updated