Skip to the content
YallaRoute

Help · Developers: API keys and webhooks

Receive events with webhooks

Open Developers, choose Add webhook, enter an https address and pick the events you want, or all of them. Each time one happens, a signed JSON message is posted to that address. An answer in the 2xx range within 6 seconds counts as delivered; anything else is retried four more times over about an hour and a quarter.

Updated

Where
Console, Developers (Webhooks)
Who can do it
Owners
Plans
Webhooks is included in Growth, Scale and Enterprise

In detail

Webhooks save you from asking the API over and over whether anything has changed. Your system is told within seconds of a scan, a delivery or an invoice.

Adding an endpoint

  1. Choose Add webhook on the Developers screen.
  2. Enter the endpoint address. It must use https; plain http is accepted only for localhost while you develop. Addresses with a user name or password in them are refused, and so are private network addresses outside development.
  3. Choose the events, or choose all of them, which also includes any event added later.
  4. Save, then copy the signing secret shown. Store it on your server: it is how you prove that a message came from us. See verify webhook signatures.

A workspace can have up to 20 endpoints. Each sender account can add up to 5 of its own in the sender portal, which hear only about that sender's parcels.

The events

EventSent when
shipment.createdA delivery is booked in the console, the sender portal or through the API.
shipment.collectedThe parcel is scanned as collected from the sender.
shipment.at_hubThe parcel is scanned in at a location.
shipment.out_for_deliveryThe driver starts the run that carries the parcel.
shipment.nearbyThe vehicle comes close to the delivery address.
shipment.deliveredThe driver records proof of delivery.
shipment.failedThe driver records that the delivery could not be made.
shipment.rescheduledStaff or the recipient move the delivery to another window.
shipment.returnedA return to sender is arranged.
shipment.cancelledThe booking is cancelled before the parcel goes out.
run.started, run.finishedA driver leaves on a run, or completes it.
exception.opened, exception.resolvedSomething needs a person's attention, or has been dealt with.
cod.collectedA driver takes payment at the door.
return.requestedA return is requested for a delivered parcel.
invoice.issuedAn invoice is issued to a sender account.

How a delivery is made

Each event is a POST with a JSON body and these headers: X-YallaRoute-Event (the event name), X-YallaRoute-Delivery (the delivery number, also shown in the delivery log) and X-YallaRoute-Signature. Endpoints on the current body format also get X-YallaRoute-Version, naming that format. The body carries the event's id, its type, the time it happened and its data. Redirects are not followed, so give the final address.

If your endpoint does not answer 2xx within 6 seconds, the delivery is tried again after 30 seconds, 2 minutes, 10 minutes and 1 hour, then marked failed. Retries go out while the server is busy with other requests, so on a quiet workspace one can be a little later than planned.

Testing, pausing and sending again

  • Send a test event: posts a signed example of any event and shows the answer. The example is marked "test": true. Test events are sent even while the endpoint is paused.
  • Pause an endpoint to stop deliveries without losing its settings, and resume it later.
  • Send again any past delivery from the delivery log. It goes as a new delivery with the same event and data.

Writing a good receiver

  • Check the signature before doing anything else.
  • Answer 2xx quickly and do the work afterwards, so a slow job never causes a retry.
  • Store the ids of events you have handled and skip repeats: a retry can deliver the same event twice.
  • Do not rely on order. Two events about one parcel can arrive either way round; compare their times.

Try it in your own workspace

A new workspace has the Scale features for its first 14 days. Open one and follow this article with your own data.