نقلة
Docs menuCarriers and 3PLs: quickstart

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

  1. 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.
  2. When an order is routed to your app you receive shipment.requested with the order id.
  3. Read what to ship with GET /orders/{id}/shipping: recipient, address with the Saudi short address, parcel, and the cash to collect.
  4. Record your waybill with POST /orders/{id}/shipments. The answer carries result.shipment_id, the shipment id for the next calls.
  5. Send each tracking step with POST /shipments/{id}/events, in the order picked_up → in_transit → out_for_delivery → delivered. A step never goes back. The merchant and the shopper see every step.
  6. After delivery report the cash collected with POST /shipments/{id}/cod, kind collected, then what you paid the merchant, kind remitted.
  7. If the merchant asks to cancel you receive shipment.cancel_requested; confirm or refuse it with POST /shipments/{id}/cancel.
  8. If the merchant approves a return you receive return.approved; record the return waybill with POST /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:

CodeDescription
idempotency_key_requiredNo Idempotency-Key header.
idempotency_key_reusedThe same key was used for a different request.
invalid_requestA field is missing or malformed.
not_routedThe order is not routed to your app in this store.
shipment_existsThe order already has a waybill.
awb_in_useThe waybill number belongs to another shipment.
label_not_pdfThe label URL does not return a PDF.
label_unreachableThe label could not be fetched.
invalid_statusUnknown tracking status.
status_backwardsA step back, or a step after a final status.
not_codThe shipment is prepaid: no cash on delivery.
not_deliveredCollection cannot be reported before delivery.
not_collectedRemittance cannot be reported before collection.
cod_already_reportedThis report is already recorded.
no_cancel_requestThe merchant has not asked to cancel.
return_not_approvedThe return is not approved.
not_foundNo 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

fake-shipment.sh · bash
#!/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