Handling errors
Parasend answers with the usual HTTP status codes: 2xx worked, 4xx means the request needs to change, 5xx means something went wrong on our side. Every error has the same body:
{
"error": {
"type": "invalid_request",
"code": "recipient_phone_invalid",
"message": "recipient.phone must be in E.164 format (e.g. +3546661234).",
"param": "recipient.phone",
"doc_url": "https://parasend.com/docs/errors/recipient_phone_invalid",
"request_id": "req_01M6P3QD4H8WZ2KX7N1R9T5V3B"
}
}
| Field | What it is |
|---|---|
type | The group the error belongs to (below). |
code | A stable, specific code. Branch on this, never on message. Every code has its own page under error codes. |
message | A sentence for a person to read. It can change. |
param | When one parameter caused it, its name, as a dotted path such as recipient.. |
doc_ | The code's page in these docs: what it means and what to do. |
request_ | The request's ID, also in the Request-Id header. Give it to us when you ask for help. |
A few errors carry more fields, named on their own page.
Error types
| Type | Status | What to do |
|---|---|---|
invalid_ | 400, sometimes 404 | Fix the request. code and param say what is wrong. |
authentication_ | 401 | Check the API key. See authentication. |
permission_ | 403 | The key lacks a permission, or the action is not allowed for this account. |
not_ | 404 | No such object in this mode, or no such route. |
conflict | 409 | The object's state does not allow this now, for example a reminder before the first notice has gone out (remind_). |
payload_ | 413 | The body or file is too large. |
rate_ | 429 | Wait, then try again. See rate limits. |
api_ | 500, 503 | Try again with the same Idempotency-Key. If it keeps happening, contact us with the request_. |
Retrying safely
- Retry
429,500,503and network failures, with exponential backoff. When the answer has aRetry-Afterheader, wait at least that many seconds. - Send the same
Idempotency-Keywhen you retry aPOST. If the first attempt did go through, you get its answer back instead of a second delivery. See idempotency. - Do not retry other
4xxerrors unchanged: they will fail the same way.
Request IDs
Every answer carries a Request-Id header, such as req_. Log it with your own record of the call. You can also send your own Request-Id starting with req_, and Parasend uses it.