Carriers and 3PLs: quickstart
For a delivery company or a fulfilment provider (3PL) that wants to reach Naqllah stores: one app prices at checkout, receives the orders routed to it, records its waybill, sends tracking and reports cash on delivery. Run the whole flow on the test store before any real store.
Who this guide is for
- A delivery company: prices the shipment, issues the waybill, sends the tracking steps, collects cash on delivery and pays it to the merchant.
- A fulfilment provider (3PL): receives the order, prepares it, then ships it the same way.
Scopes: shipping.orders to read an order routed to you, shipments.write for every write in this guide, shipping.read to read shipments, and webhooks.read to receive webhooks.
Scopes
The flow, step by step
- Set your rate card for the store with
POST /shipping/rates, or your default card in the developer portal. Checkout prices your option for the shopper from it. - When an order is routed to your app you receive
shipment.requestedwith the order id. - Read what to ship with
GET /orders/{id}/shipping: recipient, address with the Saudi short address, parcel, and the cash to collect. - Record your waybill with
POST /orders/{id}/shipments. The answer carriesresult.shipment_id, the shipment id for the next calls. - Send each tracking step with
POST /shipments/{id}/events, in the orderpicked_up → in_transit → out_for_delivery → delivered. A step never goes back. The merchant and the shopper see every step. - After delivery report the cash collected with
POST /shipments/{id}/cod, kindcollected, then what you paid the merchant, kindremitted. - If the merchant asks to cancel you receive
shipment.cancel_requested; confirm or refuse it withPOST /shipments/{id}/cancel. - If the merchant approves a return you receive
return.approved; record the return waybill withPOST /returns/{id}/shipments.
Answers and errors
Every write needs the Idempotency-Key header; a retry with the same key returns the same answer. 201 means the write is done, 202 means it waits for the merchant. A refusal carries one of these codes:
| Code | Description |
|---|---|
idempotency_key_required | No Idempotency-Key header. |
idempotency_key_reused | The same key was used for a different request. |
invalid_request | A field is missing or malformed. |
not_routed | The order is not routed to your app in this store. |
shipment_exists | The order already has a waybill. |
awb_in_use | The waybill number belongs to another shipment. |
label_not_pdf | The label URL does not return a PDF. |
label_unreachable | The label could not be fetched. |
invalid_status | Unknown tracking status. |
status_backwards | A step back, or a step after a final status. |
not_cod | The shipment is prepaid: no cash on delivery. |
not_delivered | Collection cannot be reported before delivery. |
not_collected | Remittance cannot be reported before collection. |
cod_already_reported | This report is already recorded. |
no_cancel_request | The merchant has not asked to cancel. |
return_not_approved | The return is not approved. |
not_found | No such shipment or order for your app. |
Try it on the test store
Install your app on the test store sandbox, place an order there and route it to your app. Then run the script with TOKEN (your app's token on the test store) and ORDER (the order id from the webhook).
Testing with the test store
#!/usr/bin/env bash
# One fake shipment on Naqllah's test store. Needs curl and jq.
# TOKEN an access token of your app on the test store (shipping.orders + shipments.write)
# ORDER the order_id of the shipment.requested webhook you received (the order is routed to your app)
set -euo pipefail
BASE="https://naqllah.com/api/apps/v1"
: "${TOKEN:?set TOKEN}" "${ORDER:?set ORDER}"
call() { # method path idempotency-key [json]
local args=(-sS -X "$1" "$BASE$2" -H "Authorization: Bearer $TOKEN" -H "Accept: application/json"
-H "Content-Type: application/json" -H "Idempotency-Key: $3")
if [ $# -ge 4 ]; then args+=(--data "$4"); fi
curl "${args[@]}"
}
# 1. your rate card for this store (SAR before VAT; ["*"] = every served city)
call POST /shipping/rates "fake-rates-$ORDER" '{"services":[{"service":"standard","first_kg":1,"first_price":"18.00","extra_kg_price":"2.00","cities":["*"],"eta":{"unit":"days","min":1,"max":3},"cod":{"available":true,"fee":"5.00"}}]}' | jq '.data.status'
# 2. what to ship: recipient, address, parcel, cash to collect
VIEW=$(call GET "/orders/$ORDER/shipping" "fake-view-$ORDER")
echo "$VIEW" | jq '.data | {number, city: .address.city, method: .payment.method, cod_amount: .payment.cod_amount}'
COD=$(echo "$VIEW" | jq -r '.data.payment.cod_amount // empty')
# 3. your waybill (shipment_id is what the next calls use)
SHIP=$(call POST "/orders/$ORDER/shipments" "fake-ship-$ORDER" "{\"awb\":\"FAKE-$ORDER\",\"service\":\"standard\",\"boxes\":1}" | jq -r '.data.result.shipment_id')
echo "shipment $SHIP"
# 4. tracking, forward only; the merchant and the shopper see each step
for STEP in picked_up in_transit out_for_delivery delivered; do
call POST "/shipments/$SHIP/events" "fake-$STEP-$SHIP" "{\"status\":\"$STEP\",\"location\":\"Riyadh\"}" | jq -r '.data.status' | sed "s/^/$STEP: /"
done
# 5. cash on delivery: what you collected, then what you remitted to the merchant
if [ -n "$COD" ] && [ "$COD" != "0.00" ]; then
call POST "/shipments/$SHIP/cod" "fake-cod-in-$SHIP" "{\"kind\":\"collected\",\"amount\":\"$COD\",\"reference\":\"FAKE-COD-$SHIP\"}" | jq '.data.status'
call POST "/shipments/$SHIP/cod" "fake-cod-out-$SHIP" "{\"kind\":\"remitted\",\"amount\":\"$COD\",\"reference\":\"FAKE-TRF-$SHIP\"}" | jq '.data.status'
fi
The script writes on the test store only: no goods and no money move.
Money
- Cash on delivery stays your responsibility until you pay it to the merchant. Your report shows on the merchant's statement and never passes through Naqllah's account.
- The shopper sees one price per shipping option, VAT included, never your cost.
Version v1.0.0 Changelog Service status openapi-v1.json Support