POST Report usage
For a usage app: report units used in the store, once per Idempotency-Key. A report that would take the month past the store's cap is refused with 402; nothing over the cap is ever billed.
/usage/records
- Scope
store.read- Full address
https://naqllah.com/api/apps/v1/usage/records- Rate limit
- 120 a minute per store, 1200 a minute across all stores
- The merchant reads
- Read basic store details: name, currency and language
Request
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyrequired |
header | string · 8–80 |
A unique key of 8 to 80 characters per operation: the same request with the same key returns the same answer. |
Request body
| Field | Type | Notes |
|---|---|---|
quantityrequired |
integer |
1 to 100000 |
note |
string |
— |
{
"carrier": "carrier_code"
}
Samples
Each sample reads the access token from the environment variable NAQLLAH_ACCESS_TOKEN.
curl -X POST "https://naqllah.com/api/apps/v1/usage/records" \
-H "Authorization: Bearer $NAQLLAH_ACCESS_TOKEN" \
-H "Idempotency-Key: order-5521-waybill-1" \
-H "Content-Type: application/json" \
-d '{"carrier":"carrier_code"}'
<?php
$ch = curl_init('https://naqllah.com/api/apps/v1/usage/records');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('NAQLLAH_ACCESS_TOKEN'),
'Accept: application/json',
'Idempotency-Key: order-5521-waybill-1',
'Content-Type: application/json',
],
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode(['carrier' => 'carrier_code']),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json = json_decode($body, true);
if ($status >= 400) {
throw new RuntimeException($json['error'] ?? 'http_' . $status);
}
$data = $json['data'];
// Node.js 18+ (fetch is built in)
const res = await fetch('https://naqllah.com/api/apps/v1/usage/records', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.NAQLLAH_ACCESS_TOKEN}`,
Accept: 'application/json',
'Idempotency-Key': 'order-5521-waybill-1',
'Content-Type': 'application/json',
},
body: JSON.stringify({"carrier":"carrier_code"}),
});
const json = await res.json();
if (!res.ok) throw new Error(json.error);
const { data } = json;
import os
import requests
res = requests.post(
"https://naqllah.com/api/apps/v1/usage/records",
headers={
"Authorization": f"Bearer {os.environ['NAQLLAH_ACCESS_TOKEN']}",
"Accept": "application/json",
"Idempotency-Key": "order-5521-waybill-1",
},
json={"carrier":"carrier_code"},
timeout=10,
)
body = res.json()
if res.status_code >= 400:
raise RuntimeError(body["error"])
data = body["data"]
Response
On success the answer is 201 with this body. The example uses sample data.
| Field | Type | Notes |
|---|---|---|
data |
object |
— |
data.id |
integer |
— |
data.quantity |
integer |
— |
data.amount |
string |
SAR, two decimals, as text |
data.month |
string |
— |
data.usage |
object |
— |
data.usage.month |
string |
— |
data.usage.unit |
string |
— |
data.usage.unit_price |
string |
SAR, two decimals, as text |
data.usage.used |
string |
SAR, two decimals, as text |
data.usage.cap |
string |
SAR, two decimals, as text |
data.usage.remaining |
string |
SAR, two decimals, as text |
data.usage.currency |
string |
— |
data.usage.vat_excluded |
boolean |
— |
{
"data": {
"id": 5120,
"quantity": 12,
"amount": "1.80",
"month": "2026-11",
"usage": {
"month": "2026-11",
"unit": "رسالة واتساب",
"unit_price": "0.15",
"used": "42.60",
"cap": "200.00",
"remaining": "157.40",
"currency": "SAR",
"vat_excluded": true
}
}
}
Errors
| HTTP | Code | Meaning |
|---|---|---|
| 400 | idempotency_key_required | Send an Idempotency-Key header (8 to 80 characters). |
| 401 | invalid_token | The access token is invalid or expired. |
| 401 | not_installed | The app is not installed on this store. |
| 402 | payment_required | The app's subscription on this store is unpaid. |
| 403 | app_suspended | The app or the developer account is suspended. |
| 403 | insufficient_scope | The merchant has not granted this permission to the app. |
| 409 | idempotency_key_reused | The same Idempotency-Key was used for a different request. |
| 422 | invalid_request | The request is not valid. |
| 429 | rate_limited | The app is over its request limit. Try again shortly. |
Idempotency
Every request of this endpoint needs an Idempotency-Key header: a key of 8 to 80 characters (letters, digits and . _ : -) that names this one operation.
- Sending the same request again with the same key returns the first answer and does nothing new; retry safely after a network failure.
- The same key with a different body is refused with
409 idempotency_key_reused. - A missing or malformed key is refused with
400 idempotency_key_required. - Keys are kept per install: two stores never collide.
This is an action. The merchant chose at install how it runs: at once, at once with notice, or only under conditions. Read status in the answer: done, running, failed or refused.
Rate limits
120 requests a minute per store, and 1200 requests a minute for your app across all stores. Over the limit you get 429 with Retry-After. Every answer carries X-RateLimit-Limit and X-RateLimit-Remaining.
Try it
Fill in the request and see the answer this endpoint gives.
Version v1.0.0 Changelog Service status openapi-v1.json Support