curl -X POST https://api.ordexs.com/v1/delivery/routing_rules \
-H "Authorization: Bearer $ORDEXS_API_KEY" \
-H "Idempotency-Key: 3f9c1e2a-7b4d-4c8e-9a1f-5d6e7f8a9b0c" \
-H "Content-Type: application/json" \
-d '{
"courier_id": "cour_4e5f6a7b8c9d40e1f2a3b4c5d6e7f8a9",
"type": "region",
"regions": [
"16",
"09",
"35"
]
}'
const res = await fetch('https://api.ordexs.com/v1/delivery/routing_rules', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ORDEXS_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"courier_id": "cour_4e5f6a7b8c9d40e1f2a3b4c5d6e7f8a9",
"type": "region",
"regions": [
"16",
"09",
"35"
]
}),
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`)
<?php
$body = [
'courier_id' => 'cour_4e5f6a7b8c9d40e1f2a3b4c5d6e7f8a9',
'type' => 'region',
'regions' => [
'16',
'09',
'35',
],
];
$ch = curl_init('https://api.ordexs.com/v1/delivery/routing_rules');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ORDEXS_API_KEY'),
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
import os, uuid
import requests
res = requests.post(
"https://api.ordexs.com/v1/delivery/routing_rules",
headers={"Authorization": f"Bearer {os.environ['ORDEXS_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"courier_id": "cour_4e5f6a7b8c9d40e1f2a3b4c5d6e7f8a9",
"type": "region",
"regions": [
"16",
"09",
"35",
],
},
timeout=30,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
{
"id": "rul_9c0d1e2f3a4b45c6d7e8f9a0b1c2d3e4",
"object": "routing_rule",
"courier_id": "cour_4e5f6a7b8c9d40e1f2a3b4c5d6e7f8a9",
"type": "region",
"regions": [
"16",
"09",
"35"
],
"product_ids": [],
"weight_min_grams": null,
"weight_max_grams": null,
"active": true,
"created_at": "2026-10-12T09:00:00Z",
"updated_at": "2026-10-12T09:00:00Z"
}
{
"error": {
"code": "insufficient_scope",
"message": "This API key does not have the \"orders:write\" permission. Edit the key's permissions under Settings → Developers, or use a key that has it.",
"details": {
"required_scope": "orders:write"
},
"request_id": "req_7f3a9c2e41b84d0c9a1e5f6b"
}
}