Docs β€Ί Guides

Daily routes (pharmacy, meal kits)

Send a day of single deliveries; Dragonfly builds the routes.

This guide is for merchants with many single deliveries a day, such as pharmacies, meal-kit and grocery runs. Your system sends each delivery as it's ready, and Dragonfly builds and dispatches the day's optimized routes. Your account is set to Dragonfly routing.

The daily rhythm

WhenWhoWhat
Through the day / night beforeYour systemPOST /v1/orders: one order per patient or customer, with the delivery window.
Before your cutoffDragonflyBuilds the routes for the delivery day and assigns drivers.
Route start (e.g. 10:30)DriverPicks up all bags at your location.
During the routeDragonfly β†’ youWebhooks per order: picked up, delivered (with photo/signature), or failed.

1. Send each delivery

bash
curl -s https://api.trydragonfly.com/v1/orders \
  -H "Authorization: Bearer $DRAGONFLY_API_KEY" -H 'content-type: application/json' -d '{
  "externalId": "RX-2026-004471",
  "pickup": { "address": "870 Market St, Suite 1028, San Francisco, CA 94102", "contactName": "Pharmacy counter", "contactPhone": "+14155550100" },
  "dropoff": {
    "address": "742 Evergreen Ter, Alameda, CA 94501",
    "contactName": "M. Chen",
    "contactPhone": "+14155550123",
    "contactEmail": "[email protected]",
    "windowStart": "2026-10-09T11:00:00-07:00",
    "windowEnd": "2026-10-09T17:00:00-07:00",
    "notes": "Leave with the front desk if no answer",
    "requiresSignature": true,
    "minimumAge": 18,
    "items": [{ "name": "Rx bag #4471", "quantity": 1 }],
    "checklistRequired": true
  }
}'

Response: "dispatchedTo": "dragonfly_routing", "status": "PENDING".

2. Follow each order

Subscribe once:

bash
curl -s https://api.trydragonfly.com/v1/webhooks -H "Authorization: Bearer $DRAGONFLY_API_KEY" -H 'content-type: application/json' \
  -d '{ "url": "https://pharmacy.example.com/hooks/dragonfly", "events": ["delivery.*"] }'

Each order then follows its own stop: ASSIGNED when its route gets a driver, PICKED_UP when the route leaves, DELIVERED (with photo, signature and ID result) or FAILED (with the reason).

3. Changes and cancellations

  • Before routing: POST /v1/orders/{externalId}/cancel works.
  • After routing: the order is on a driver's route. The cancel endpoint answers 409; call or email support and dispatch pulls it.
  • Address change: cancel and resend with a new externalId (e.g. RX-2026-004471-b) before routing, or contact support after.

Tips

  • Send the window the patient was promised. It decides which day's routes the order joins.
  • Use your prescription or order number as externalId.
  • Put the bag count in quantity or items, so the driver can verify the pickup.

Something unclear or missing? Tell us.