Getting started
Conventions
Formats, language, amounts, pages and idempotency.
Format
Requests and responses are JSON. Send Content-Type: application/json with every request that has a body.
Language
Error messages are in Arabic by default, and in English with Accept-Language: en. Error codes never change: act on the code, not on the message.
Amounts and dates
- Amounts in responses are strings with two decimals in riyals, such as "1150.00", so rounding never changes them. Requests accept numbers or strings.
- Quantities take up to 3 decimals, prices up to 2.
- Dates are YYYY-MM-DD, times ISO 8601.
Pages
Lists are paged with page and per_page (up to 100), with a meta object holding the total and the last page:
{
"data": [ … ],
"meta": { "page": 1, "per_page": 25, "total": 240, "last_page": 10 }
}
Idempotency
Send an Idempotency-Key header with a unique value on every create request. Sending the same request again within 24 hours (after a dropped connection, say) returns the first response with Idempotent-Replayed: true, and nothing is created twice. While the first request is still running you get 409 idempotency_busy; a different body under the same key gets 409 idempotency_conflict.
Idempotency-Key: order-10045