Requests & responses
Headers, the response envelope, pagination, sorting and search.
Request headers
| Header | When | Value |
|---|---|---|
Authorization | Every protected request | Bearer <your API key> |
Content-Type | Requests with a body | application/json |
Accept | Recommended | application/json |
Idempotency-Key | Optional, on POST /messages | A unique string per send so a retry can't send twice. See Safe retries. |
Request bodies are JSON encoded as UTF-8. Query-string parameters are used only on GET requests.
Response envelope
Every response — success or failure — has the same top-level shape, so you can handle them all in one place:
Envelope fields
successbooleanrequiredtrue when the request did what you asked.status_codeintegerrequiredThe HTTP status code, repeated in the body.
status_textstringrequiredThe HTTP reason phrase, e.g.
Created.messagestringrequiredA short, human-readable summary. Its wording may change; don't parse it.
dataobject | array | nulloptionalThe result, on success. Some writes return null.
errorstringoptionalA stable, machine-readable code, on failure. See Errors.
Success
200 OK
{
"success": true,
"status_code": 200,
"status_text": "OK",
"message": "message has been fetched",
"data": {
"id": "…"
}
}Failure
400 Bad Request
{
"success": false,
"status_code": 400,
"status_text": "Bad Request",
"message": "messages must contain at least 1 item",
"error": "validation_error"
}Pagination
List endpoints return one page at a time. Ask for a page with query parameters:
Query parameters
pageintegeroptionaldefault: 1Page number, starting at 1.
limitintegeroptionaldefault: 10Records per page, up to 1000.
The records are in data.data; the rest of data tells you where you are. Keep requesting next_page until has_next_page is false.
Paginated data
200 OK
{
"success": true,
"status_code": 200,
"status_text": "OK",
"message": "messages have been fetched",
"data": {
"data": [
"…"
],
"total": 342,
"page": 2,
"limit": 20,
"total_pages": 18,
"has_next_page": true,
"has_previous_page": true,
"next_page": 3,
"previous_page": 1
}
}Sorting & search
Query parameters
sort_bystringoptionaldefault: created_atThe field to sort by. Each list endpoint documents which fields it allows.
sort_dirstringoptionaldefault: descasc or desc.searchstringrequiredOn
/search endpoints only: the text to look for. Filters and pagination still apply.Example
GET /messages?page=1&limit=50&sort_by=created_at&sort_dir=desc&status=deliveredHTTP status codes
| Code | Meaning |
|---|---|
| 200 | OK — the request succeeded. |
| 201 | Created — a resource (messages, sender name, purchase) was created. |
| 400 | Bad request — validation failed or the action isn't possible. Check error. |
| 401 | Unauthorized — missing or invalid API key, or the account can't send. |
| 403 | Forbidden — the key is valid but may not touch this resource. |
| 404 | Not found — no such resource, or it isn't yours. |
| 405 | Method not allowed — wrong HTTP method for this path. |
| 429 | Too many requests — slow down and retry after the Retry-After seconds. |
| 500 | Server error — something failed on our side. Safe to retry later (with an Idempotency-Key for sends). |