Idempotency
Retry any order without ever paying or provisioning twice.
Pass a reference on POST /orders: any string up to 64 characters, unique per key. If you retry with the same reference, you get back the same order. You are never double-charged and nothing is provisioned twice. Leave it out and the server generates one.
Two requests at once
If a second request with the same reference arrives while the first is still being processed, it returns 409 duplicate_in_progress. Wait a moment and retry the same reference; it resolves to the order once it has been saved.
curl -X POST https://naara.app/api/v1/orders \
-H "Authorization: Bearer $NAARA_KEY" \
-H "Content-Type: application/json" \
-d '{"type":"esim","plan_id":12,"reference":"your-order-abc123"}'
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client(['base_uri' => 'https://naara.app/api/v1/']);
$response = $client->post('orders', [
'headers' => ['Authorization' => 'Bearer ' . getenv('NAARA_KEY')],
'json' => ['type' => 'esim', 'plan_id' => 12, 'reference' => 'your-order-abc123'],
]);
echo $response->getBody();
const res = await fetch("https://naara.app/api/v1/orders", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NAARA_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ type: "esim", plan_id: 12, reference: "your-order-abc123" }),
});
console.log(await res.json());
import os
import requests
res = requests.post(
"https://naara.app/api/v1/orders",
headers={"Authorization": f"Bearer {os.environ['NAARA_KEY']}"},
json={"type": "esim", "plan_id": 12, "reference": "your-order-abc123"},
)
print(res.json())
{
"error": "duplicate_in_progress"
}