Gaarsii API v1Gaarsii API v1
Book a delivery from your own checkout Isku xirka rarka iyo iibsiga
Quote a delivery, book it at the quoted price, and follow it to the door — from your shop, your ERP, or whatever you already run. A REST API over HTTPS, JSON in and out, with signed webhooks so you never poll for a delivery that already arrived.
Qiimee gaarsiin, ku dalbo qiimaha la sheegay, kuna raac ilaa albaabka — ku dhex isticmaal nidaamka dukaankaaga. API ku shaqeeya HTTPS, JSON gal iyo bax, iyo webhooks amaan ah.
Two environments, one codebase. The sandbox runs the same build as live. What differs is that its services are opened on no licence and it moves no real money and dispatches no real courier — it is marked as a sandbox in our database, not simulated in a separate mock. Laba deegaan, hal kood. Sandbox-ku wuxuu wadaa isla dhismaha tooska ah. Waxa kala duwan ayaa ah in adeegyadiisa lagu furay iyada oo aan liisan lahayn, lacag dhab ahna ma dhaqaajiyo, qaadena dhab ah ma diro — waxaa lagu calaamadeeyay sandbox xogtayada, laguma been-abuurin meel gooni ah.
Base URLURL-ka aasaasiga ah
https://api.gaarsii.net/api/v1
Content typeNooca xogta
application/json — UTF-8
Getting a keyHelitaanka fure
You generate your own keys in the portal, as many as five at a time. What a person still checks is whether you are a merchant at all — ask once, and after that the keys are yours to make and revoke.
Furayaasha adigaa ka samaysanaya portal-ka, ilaa shan mar kasta. Waxa qof weli hubiyo waa inaad tahay ganacsade — hal mar codso, kadibna furayaashu waa kuwaaga oo aad samayn iyo burburin karto.
Ask for merchant access, onceCodso, adigoo isticmaalaya foomka hoose
Tell us the business, where deliveries will start from, and roughly how many a day. Sandbox requests are turned around fastest.
Noo sheeg ganacsiga, meesha gaarsiintu ka bilaabmayso, iyo tiro qiyaastii ah maalintii. Codsiyada sandbox-ka ayaa si dhaqso ah loo farsameeyaa.
Generate keys yourselfWaxaad heshaa hal fure, hal mar
In the portal, name a key and press generate. It looks like
gsk_<client-id>.<secret>and is shown once — only an Argon2id hash is kept, so nobody can show it to you again. Lost one? Revoke it and generate another.Wuxuu u eg yahay
gsk_<client-id>.<secret>. Client id-gu waa qaybta dadweynaha oo ku aqoonsanaysa; qaybta sirta ah waxaa loo kaydiyaa oo keliya sida Argon2id hash, sidaas darteed mar labaad kuma tusi karno. Kaydso marka aad hesho.Build against the sandboxKu dhis sandbox-ka
Same endpoints, same payloads, same webhooks. When you are ready we issue a live key; nothing in your integration changes but the key and the base URL.
Isla meelaha, isla xogta, isla webhooks. Marka aad diyaar tahay waxaan ku siinaynaa fure toos ah; waxba isku-xidhkaaga kama beddelmayaan furaha iyo URL-ka mooyaane.
The key is a bearer credential. Anyone holding it can book deliveries billed to you. Keep it on your server, never in a browser, a mobile app or a repository. Tell us and we rotate it — rotate issues a new secret against the same client id, so your merchant identity does not change.
Furuhu waa aqoonsi qofka haysta. Qof kasta oo haysta wuxuu dalban karaa gaarsiin lagugu qoro. Ku hay serverkaaga, waligaa ha ku ridin browser, app mobile ah ama kayd kood. Noo sheeg waanan beddelaynaa — rotate wuxuu siinayaa sir cusub isla client id-ga, sidaas darteed aqoonsigaagu ma beddelmo.
AuthenticationXaqiijinta
Send the key in a header on every request. There is no session, no OAuth dance and no token to refresh.
Ku dir furaha madax kasta oo codsi ah. Ma jiro fadhi, ma jiro OAuth, ma jiro token dib loo cusboonaysiiyo.
X-Gaarsii-API-Key: gsk_01J5YQWDSX5MA3N31GYZ32NJQM.<secret> Content-Type: application/json
Keys are bound to one tenant and to a set of scopes. A key that may quote and book cannot read another merchant's orders, and a request for something outside its scope is refused rather than filtered.
Furayaashu waxay ku xidhan yihiin hal ganacsi iyo koox ogolaansho. Wixii ka baxsan ogolaanshaha waa la diidayaa.
IdempotencySifo aan isbeddelin
Every call that creates or changes something requires an Idempotency-Key. Networks fail after the server has already acted, and a retry must not book a second delivery or take a second payment.
Codsi kasta oo wax abuura ama wax beddela waa inuu hal mar oo kaliya sameeyo nidaamka, xitaa haddii dib loo diro.
| CaseXaalad | ResultNatiijo |
|---|---|
| Same key, same bodyFure isku mid, xog isku mid | The original result, replayed. Nothing happens twice.Natiijadii hore, dib loo soo celiyay. Waxba laba jeer ma dhacaan. |
| Same key, different bodyFure isku mid, xog kala duwan | 409 IDEMPOTENCY_KEY_REUSED |
| Missing keyFure maqan | 400 |
Use something unique per logical operation — a ULID or UUID is ideal. 16 to 128 characters, letters, digits and . _ : -.
Hawl kasta oo gaar ah isticmaal aqoonsi (ID) u gaar ah. ULID ama UUID ayaa ku habboon. ID-gu waa inuu ka koobnaadaa 16 ilaa 128 xaraf, waxaana la isticmaali karaa xarfaha, tirooyinka iyo calaamadaha.
QuickstartBilow degdeg ah
Three calls: ask the price, accept it, then follow the parcel. The quote holds the price — booking it is what commits you.
Waxaa jira saddex codsi: marka hore qiimaha weydii, kadib qiimaha aqbal, ugu dambayntiina xirmada la soco. Xigashadu waxay haysaa qiimaha lagu siiyay; dalabku waa tallaabada xaqiijinaysa.
1. Quote a delivery1. Qiimee gaarsiin
# Prices the job. Nothing is booked and nobody is charged. curl -X POST https://api.gaarsii.net/api/v1/merchant/quotes \ -H "X-Gaarsii-API-Key: $GAARSII_KEY" \ -H "Idempotency-Key: 01J5YQWDSX5MA3N31GYZ32NJQM" \ -H "Content-Type: application/json" \ -d '{ "route": { "pickup": { "label": "Bakaara, Muqdisho", "latitude": 2.0469, "longitude": 45.3182 }, "dropoff": { "label": "Hamarweyne, Muqdisho", "latitude": 2.0369, "longitude": 45.3382 } }, "item": { "category": "PARCEL", "description": "Phone case", "declaredWeightKg": 0.4 }, "currency": "USD" }'
2. Book it at that price2. Ku dalbo qiimahaas
curl -X POST https://api.gaarsii.net/api/v1/merchant/orders \ -H "X-Gaarsii-API-Key: $GAARSII_KEY" \ -H "Idempotency-Key: 01J5YQX8N2K7RD4T0PBM9WQ1ZE" \ -H "Content-Type: application/json" \ -d '{ "quoteId": "qte_01J5YQWE…" }'
The order starts at AWAITING_PAYMENT. A courier is dispatched only once payment has cleared — we do not put someone on the road against money that has not arrived.
Dalabku wuxuu ku bilaabmaa xaalad lacag-bixin la sugayo. Qaadaha waxaa la diraa oo keliya marka lacagtu si rasmi ah u soo gasho. Qof looma dirayo iyadoo lacagtu aanay weli iman.
3. Follow it3. Raac
curl https://api.gaarsii.net/api/v1/merchant/orders/{orderId}/tracking \ -H "X-Gaarsii-API-Key: $GAARSII_KEY"
Polling works, but webhooks are better — see below. Poll only as a safety net.
Polling wuu shaqayn karaa, laakiin webhooks ayaa ka fiican. Polling-ka u isticmaal oo keliya sidii hab kayd ah.
EndpointsDhammaadka
All paths are relative to https://api.gaarsii.net/api/v1. Everything here is scoped to your own merchant account.
Dhammaan path-yadu waxay ka bilaabmaan https://api.gaarsii.net/api/v1. Dhammaan xogta iyo hawlaha halkan ku jira waxay ku koobtan yihiin akoonkaaga ganacsi.
| EndpointDhammaadka | What it doesWaxa ay qabato |
|---|---|
| GET/merchant/serviceability | Whether you can deliver between two points, before you quote.In aad gaarsiin karto laba meel dhexdood, ka hor qiimaynta. |
| POST/merchant/quotes | Price a delivery. Returns a quote id and a breakdown.Waxa lagu xisaabinayo qiimaha gaarsiinta |
| GET/merchant/quotes/{quoteId} | Read a quote and whether it is still live.Akhri xigasho iyo inay wali shaqaynayso. |
| POST/merchant/orders | Book a quote. This is the committing call.Xaqiiji oo dalbo gaarsiinta |
| GET/merchant/orders/{orderId} | The order and its current state.Dalabka iyo xaaladdiisa hadda. |
| GET/merchant/orders/{orderId}/tracking | Where it is now, while it is moving.Halka uu hadda joogo, inta uu socdo. |
| GET/merchant/orders/{orderId}/events | Everything that has happened to it, in order.Dhammaan dhacdooyinka dalabka, sida ay u kala horreeyaan. |
| POST/merchant/orders/{orderId}/cancel | Cancel it. What you are refunded depends on how far it had gone.Jooji dalabka. Lacag-celintu waxay ku xirantahay heerka uu maray. |
| POST/merchant/orders/{orderId}/claims | Raise a claim when something arrived wrong, or did not arrive.Samee cabasho marka wax si khaldan u yimaadaan, ama aanay iman. |
| POST/merchant/webhook-endpoints | Register a URL to be told what happened.Diiwaangeli URL lagugu wargelinayo waxa dhacay. |
| POST/merchant/webhook-endpoints/{id}/test | Send yourself a test delivery, to prove the plumbing.Samee gaarsiin tijaabo ah si loo hubiyo isku xirka nidaamka |
| POST/merchant/webhook-deliveries/{id}/redeliver | Replay one you missed while your endpoint was down.Dib u dir xogtii aad seegtay markii endpoint-kaagu damsanaa |
Order lifecycleWareega dalabka
An order moves forward through these states. It never skips and never goes back — if you see a state, everything before it has happened.
Dalabku wuxuu u gudbaa xaaladaha si isku xigta. Ma boodo, dibna ugama noqdo. Haddii aad aragto xaalad gaar ah, waxay ka dhigan tahay in dhammaan kuwii ka horreeyay ay hore u dhaceen.
AWAITING_PAYMENT → booked, money not yet cleared READY_TO_DISPATCH → paid; safe to look for a courier DISPATCHING → being offered to couriers ASSIGNED → a courier accepted EN_ROUTE_TO_PICKUP → on the way to you PICKED_UP → your reference shown, parcel handed over AT_DROPOFF → at the recipient's door DELIVERED → recipient's code accepted. Final.
Two proofs, and the courier holds neither alone. At pickup the courier shows your order reference, so your staff know the right person is collecting. At the door the recipient reads out a code, which is what closes the delivery. A courier cannot produce that code, so DELIVERED means somebody at the address accepted it.
Laba caddayn, qaaduhuna midna keligiis ma haysto. Marka la qaadayo qaaduhu wuxuu tusaa tixraaca dalabkaaga, si shaqaaluhu u ogaadaan in qofka saxda ah uu qaadanayo. Albaabka qaataha ayaa akhriya lambar, taasina waa waxa gaarsiinta xidhaya. Qaaduhu ma abuuri karo lambarkaas, sidaas darteed DELIVERED waxay ka dhigan tahay in qof cinwaanka jooga uu aqbalay.
WebhooksOgeysiis toos ah
Register a URL and we post every state change to it, signed. Reply 2xx quickly and do your work afterwards; we retry with backoff, and anything you miss can be redelivered.
URL-kaaga diiwaangeli, kadib isbeddel kasta oo dalabka ku yimaada waxaan kuugu soo dirnaa, fariinta oo la saxiixay. Si degdeg ah ugu jawaab 2xx, kadibna shaqadaada kale samee. Haddii jawaabtu fashilanto, waan dib u soo dirnaa annagoo kordhinayna waqtiga u dhexeeya. Wixii kaa maqnaada dib ayaa laguugu soo diri karaa.
| EventDhacdo | Sent whenMarka la diro |
|---|---|
| order.created | The booking was accepted.Dalabka waa la aqbalay. |
| order.dispatching | Paid, and being offered to couriers.Waa la bixiyay, qaadayaashana waa la siinayaa. |
| order.assigned | A courier accepted it.Qaade ayaa aqbalay. |
| order.dispatch_expired | Nobody accepted in time. You will want to tell the customer.Cidna ma aqbalin waqtigii loogu talagalay. Waxaad rabi doontaa inaad macmiilka u sheegto. |
| order.delivered | The recipient's code was accepted at the door.Lambarka qaataha waa la aqbalay albaabka. |
| order.cancelled | Cancelled, by you or by us.Dalabka waa la joojiyay |
Verify the signature before you trust the body. Compute the HMAC over the raw, unmodified request bytes — parse the JSON afterwards, not before, or a body that was tampered with will verify against what you re-serialised. Reject anything outside the replay window. Xaqiiji saxiixa ka hor intaadan aamin xogta. Xisaabi HMAC-ga byte-yada codsiga ee aan la beddelin — JSON-ka kadib kala saar, ka hor maaha, haddii kale xog la khalkhal-geliyay way ku xaqiijin doontaa waxa aad dib u qortay. Diid wax kasta oo ka baxsan daaqadda.
Errors and limitsKhaladaadka iyo xaddidaadaha
Errors are JSON with a stable machine-readable code. Branch on the code, never on the message — messages get clearer over time, codes do not change.
Khaladaadku waxay ku yimaadaan qaab JSON ah, waxaana ku jira code joogto ah oo kombiyuutarku fahmi karo. Go'aanka ku salee code-ka, hana ku salayn fariinta, maxaa yeelay fariimaha khaladku way is beddeli karaan. Code-yadu isma beddelaan.
{ "error": { "code": "IDEMPOTENCY_KEY_REUSED",
"message": "That key was used with a different request body." } }
| HTTP | MeansMacnaheedu |
|---|---|
| 400 | The request is wrong. Fix it before retrying.Codsigu waa khalad. Sax ka hor intaadan mar kale dirin. |
| 401 | No key, or a key we do not recognise.Fure lama hayo ama lama aqoonsanin |
| 403 | Your key is real but not allowed to do that.Furaha waa sax, balse lama oggola. |
| 409 | Conflicts with what already happened — usually an idempotency key reused.Waxay khilaafsan tahay xogtii hore. |
| 429 | Too many requests. Back off and retry.Codsiyo aad u badan. Sug oo mar kale isku day. |
| 503 | We are not able to serve right now. Retry with backoff.Adeeggu hadda ma shaqeynayo. Sug oo mar kale isku day. |
Retry 429 and 503 with exponential backoff, reusing the same Idempotency-Key so a retry cannot double-book. Never retry 400 or 403 unchanged.
Dib u isku day 429 iyo 503, adigoo isticmaalaya isla Idempotency-Key si dib-u-isku-daygu labanlaab u dalbin. Waligaa ha ku celin 400 ama 403 iyagoo aan beddelmin.
Request an API keyCodso fure API
Tell us about the business and we issue a sandbox key. You get a client id and a secret, once.
Nooga warran ganacsigaaga, kadib waxaan kuu soo saarnaa Sandbox Key. Marka la ansixiyo, waxaad heli doontaa Client ID iyo Secret.