# Armada API v2 — complete documentation Source: https://docs.armadadelivery.com/v2/overview.md # Armada API v2 Create deliveries, manage pickup branches and track order updates from your application. **Base URL:** `https://api.armadadelivery.com` ## Start building 1. [Quickstart](https://docs.armadadelivery.com/v2/quickstart.md) — install an SDK and make your first request. 2. [API reference](https://docs.armadadelivery.com/v2/reference.md) — endpoints, request fields and responses. 3. [Webhooks](https://docs.armadadelivery.com/v2/webhooks.md) — receive delivery and location updates. Use an API key and secret from **Automated Ordering** in the business app. Each key belongs to one merchant and has its own permissions. The SDKs sign requests automatically. ## Integration notes - [Authentication](https://docs.armadadelivery.com/v2/authentication.md): headers and request signing for custom clients. - [Test mode](https://docs.armadadelivery.com/v2/test-mode.md): simulate a delivery before going live. - [Errors](https://docs.armadadelivery.com/v2/errors.md): handle failed requests and retries. - [SDKs and CLI](https://docs.armadadelivery.com/v2/sdks.md): Node, PHP, Go and command-line tools. ## Machine-readable documentation - [OpenAPI 3.1](https://docs.armadadelivery.com/openapi/v2.yaml): request and response schemas. - [Documentation index](https://docs.armadadelivery.com/llms.txt): links to Markdown guides and the specification. - [Complete documentation](https://docs.armadadelivery.com/llms-full.txt): all guides and the OpenAPI specification in one text file. Every guide has a **View Markdown** link. These files are generated from the same source as the website. --- Source: https://docs.armadadelivery.com/v2/quickstart.md # Quickstart Create an API key, install the Node SDK and read your wallet balance. ## 1. Create an API key Open [Automated Ordering](https://business.armadadelivery.com/automated-ordering) and create a key. New keys start with **Test mode on** and **all permissions enabled**. For this first request, keep only `wallet:read`, clear the other permissions and click **Save changes**. Copy the key and secret. ```sh export ARMADA_API_KEY=main_your_key export ARMADA_API_SECRET=your_secret ``` Keep both values on your server. Use [SDKs and CLI](https://docs.armadadelivery.com/v2/sdks.md) for PHP, Go or command-line installation. ## 2. Install the SDK ```sh npm i github:armadadelivery/armada-node#v0.1.0-beta.0 ``` ## 3. Make a request Save this as `wallet.mjs` and run `node wallet.mjs`. ```javascript import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET }); const { data: wallet } = await armada.wallet.get(); console.log(wallet.balance, wallet.currency); ``` The SDK adds the authentication headers. For a `401`, check the credentials and system clock. See [Authentication](https://docs.armadadelivery.com/v2/authentication.md). ## 4. Create a test delivery Create a separate key and keep **Test mode on**. Keep the permissions below, clear the others and click **Save changes**: | Permission | Used for | | ----------------- | ---------------------------------- | | `wallet:read` | Run the wallet check with this key | | `branch:read` | Find your pickup branch | | `delivery:write` | Create a delivery | | `delivery:read` | Check its status | | `delivery:cancel` | Cancel it | Set the environment variables to this test key and create the client again using step 3. List pickup branches: ```javascript const { data: branchPage } = await armada.branches.list(); console.table(branchPage.branches.map(({ id, name }) => ({ id, name }))); ``` The response is `{ branches: [...] }`; the first branch ID is `branchPage.branches[0].id`. Choose the intended pickup branch. The API returns 30 branches per page by default; see the [branch reference](https://docs.armadadelivery.com/v2/reference.md) if it is not on the first page. Replace `YOUR_BRANCH_ID` and the sample destination below with your branch and a contact you control. Pickup and drop-off must be different locations. To check callbacks, set this key's **Order update webhook** URL, select **Canceled** and **Completed**, then click **Save changes** before creating the delivery. Use the [webhook guide](https://docs.armadadelivery.com/v2/webhooks.md) to verify notifications through signed API reads. ```javascript const { data: order } = await armada.deliveries.create({ reference: 'test-' + Date.now(), payment: { amount: 4.5, type: 'paid' }, origin_format: 'branch_format', origin: { branch_id: 'YOUR_BRANCH_ID' }, destination_format: 'location_format', destination: { contact_name: 'Test Customer', contact_phone: '+96590000000', latitude: 29.3759, longitude: 47.9774, first_line: 'Salmiya, Block 5, Street 3' } }); console.log(order.code, order.status, order.test_mode); ``` Keep the returned `code` and confirm `test_mode` is `true`. Allow up to 90 seconds for the simulation to complete. See [Test mode](https://docs.armadadelivery.com/v2/test-mode.md) for the lifecycle stages. If creation times out, check whether the order was created before sending it again. Reusing `reference` can create another delivery. ## 5. Read or cancel the delivery Add these calls below the create example to read and cancel the same test delivery: ```javascript const { data: current } = await armada.deliveries.get(order.code); console.log(current.status); const { data: canceled } = await armada.deliveries.cancel(order.code, 'Integration test'); console.log(canceled.status); // canceled ``` Cancel while the test delivery is `dispatched`, `accepted` or `en_route`. A completed delivery returns `400`; create a fresh test delivery to test again. Repeating cancellation of an already canceled delivery returns its current state. With Canceled selected in the saved settings, expect topic `order.updated` with `status: "canceled"`. See [Webhooks](https://docs.armadadelivery.com/v2/webhooks.md) for receiver setup and delivery behavior. ## 6. Go live Create a separate production key, keep only your integration's required permissions and configure its production webhook URLs and statuses. New keys start in Test mode, so turn **Test mode off** and click **Save changes** before using this key for customer orders. Switch your server to the production key and secret. Map its new `x-armada-key-id` at your receiver. On the first intended live delivery, confirm `test_mode: false`; changing the key does not convert previously created test orders. Next: [API reference](https://docs.armadadelivery.com/v2/reference.md) and [delivery behavior](https://docs.armadadelivery.com/v2/deliveries.md). --- Source: https://docs.armadadelivery.com/v2/authentication.md # Authentication Authenticate with an API key and secret. The official SDKs sign requests automatically. Use the following headers when building a custom client. ## Headers | Header | Value | | -------------------- | ------------------------------------------------ | | `Authorization` | `Key ` | | `x-armada-timestamp` | Current Unix time in milliseconds | | `x-armada-signature` | Lowercase hex HMAC-SHA256 of the request payload | | `Content-Type` | `application/json` for requests with a JSON body | ## Computing the signature ```text payload = timestamp + "." + method + "." + path + "." + body signature = hex(HMAC-SHA256(secret, payload)) ``` - `method`: uppercase, such as `GET` or `POST`. - `path`: pathname and exact query string, excluding the origin. - `body`: the exact UTF-8 bytes sent. Use an empty string when there is no body. - `timestamp`: must be within 30 seconds of the server's clock. Sign immediately before sending. Encode the signature as lowercase hexadecimal. Uppercase hex is rejected. This Node example signs and sends a wallet request without an SDK: ```javascript import { createHmac } from 'node:crypto'; const method = 'GET'; const path = '/v2/wallet'; const body = ''; const timestamp = String(Date.now()); const signature = createHmac('sha256', process.env.ARMADA_API_SECRET) .update(`${timestamp}.${method}.${path}.${body}`) .digest('hex'); const response = await fetch(`https://api.armadadelivery.com${path}`, { method, headers: { Authorization: `Key ${process.env.ARMADA_API_KEY}`, 'x-armada-timestamp': timestamp, 'x-armada-signature': signature } }); if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`); console.log(await response.json()); ``` ## Test vector Use these fixed inputs to test a signing implementation locally. The timestamp is intentionally fixed and cannot be used for a live request. ```json { "secret": "00000000-0000-0000-0000-000000000000", "timestamp": "1776182400000", "method": "POST", "path": "/v2/deliveries", "body": "{\"reference\":\"order-1\",\"payment\":{\"amount\":4.5,\"type\":\"paid\"}}", "signature": "834a2a959cb0faba10124884ae728535c9c1cf29a44cb6fbfc39405d583c236f" } ``` ## Troubleshooting For `401`, check the key and secret, clock, query string and body bytes. Serialize JSON once; sign and send that same string. For `403`, check the endpoint's permission and the response message. ## Replace credentials Create a new key to replace your credentials: 1. Create a new key in **Automated Ordering**. It starts in Test mode with all permissions and empty webhook settings. 2. Configure only the required permissions, the intended Test mode setting, callback URLs and statuses, then click **Save changes**. 3. Switch your server to the new key and secret, and add its new `x-armada-key-id` to your receiver's mapping. 4. Keep the old key until its outstanding deliveries and callbacks are finished, then delete it. Keep credentials on your server. Webhook settings do not transfer automatically to a replacement key. --- Source: https://docs.armadadelivery.com/v2/sdks.md # SDKs and CLI The SDKs handle request signing. Install directly from GitHub. Set the API base URL explicitly, as shown below. The pinned Node and Go SDKs default to a non-production URL. ## Node ```sh npm i github:armadadelivery/armada-node#v0.1.0-beta.0 ``` ```javascript import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET }); const { data } = await armada.wallet.get(); console.log(data); ``` The examples use JavaScript. For TypeScript integrations, use the OpenAPI schemas to define branch inputs and delivery and wallet response types, including `test_mode` and snake-case delivery fields. ## PHP ```sh composer config repositories.armada vcs https://github.com/armadadelivery/armada-php composer require armada/sdk:dev-main ``` ```php 'https://api.armadadelivery.com', 'apiKey' => getenv('ARMADA_API_KEY'), 'apiSecret' => getenv('ARMADA_API_SECRET'), ]); $response = $armada->get('/v2/wallet'); echo $response->getBody(); ``` ## Go ```sh go get github.com/armadadelivery/sdk-go@v0.1.0-beta.0 ``` ```go package main import ( "context" "fmt" "os" armada "github.com/armadadelivery/sdk-go" ) func main() { client := armada.NewClient(armada.Options{ BaseURL: "https://api.armadadelivery.com", APIKey: os.Getenv("ARMADA_API_KEY"), APISecret: os.Getenv("ARMADA_API_SECRET"), }) response, err := client.Get(context.Background(), "/v2/wallet", nil) if err != nil { panic(err) } var wallet struct { Balance float64; Currency string } if err := armada.DecodeJSON(response, &wallet); err != nil { panic(err) } fmt.Println(wallet.Balance, wallet.Currency) } ``` ## CLI ```sh npm i -g github:armadadelivery/armada-cli#v0.1.0-beta.0 export ARMADA_API_KEY=main_your_key export ARMADA_API_SECRET=your_secret export ARMADA_API_BASE=https://api.armadadelivery.com armada wallet ``` Use [Authentication](https://docs.armadadelivery.com/v2/authentication.md) when implementing a client without an SDK. SDKs are installed from the versions above; check their repository release notes before upgrading. --- Source: https://docs.armadadelivery.com/v2/test-mode.md # Test mode Test mode simulates a delivery through the same v2 API and base URL used for live deliveries. ## Setup In [Automated Ordering](https://business.armadadelivery.com/automated-ordering), use a separate key for testing. New keys start with **Test mode on** and all permissions enabled. Keep Test mode on, clear unneeded permissions and click **Save changes** before creating a delivery. Confirm `test_mode: true` in the response. Changing the key setting affects new orders only. Use an existing branch and contacts you control. Test deliveries appear in your order history with `test_mode: true`. ## Lifecycle Allow up to 90 seconds for the simulated lifecycle: | Stage | Scheduled delay | | ------------ | --------------------------------------- | | `dispatched` | Bot driver assigned after creation | | `accepted` | 30 seconds after dispatch; trip created | | `en_route` | Another 30 seconds | | `completed` | Another 30 seconds | Configured status callbacks use `order.updated`. The bot is removed after the simulation; the order and trip records remain. ## Test cancellation Enable `delivery:cancel` and `delivery:read` on the test key and save it. Create a fresh test delivery, then send `POST /v2/deliveries/{code}/cancel` during `dispatched`, `accepted` or `en_route`. The body is optional: ```json { "reason": "Integration test" } ``` Expect `200` with `status: "canceled"` and `test_mode: true`. Cancellation stops the simulation without adding cancellation fees or debiting the wallet. Repeating the cancel request keeps the first cancellation reason. A completed delivery returns `400`; a `409` means the delivery changed during cancellation, so read its state before retrying. For a callback, save your **Order update webhook** URL with **Canceled** selected. Expect topic `order.updated` and `status: "canceled"`. **Send delivery test** only sends a fixed connectivity sample; it does not run or cancel a delivery. See [Webhooks](https://docs.armadadelivery.com/v2/webhooks.md). ## Checking results Retrieve the delivery using its `code` to check the current status. After a timeout, read its state before retrying a request. Use `test_mode` to filter test deliveries in your reports. See the [quickstart](https://docs.armadadelivery.com/v2/quickstart.md) for SDK creation and cancellation examples. ## Going live Use a separate production key. Configure its permissions and callbacks, turn **Test mode off** and click **Save changes** before sending live traffic. Confirm `test_mode: false` on the first intended live delivery. Existing test deliveries remain test deliveries. --- Source: https://docs.armadadelivery.com/v2/deliveries.md # Deliveries Create, retrieve, cancel and estimate deliveries. See the [API reference](https://docs.armadadelivery.com/v2/reference.md) for request fields and response schemas. ## Permissions and identifiers | Operation | Permission | Path identifier | | ----------------------------- | ----------------- | --------------- | | Create | `delivery:write` | None | | Retrieve | `delivery:read` | Delivery `code` | | Cancel | `delivery:cancel` | Delivery `code` | | Estimate fee (both endpoints) | `delivery:write` | None | Store the delivery `code` returned by creation. Use it for lookup, cancellation and webhook matching. ## Create a delivery Use `POST /v2/deliveries`. The [quickstart](https://docs.armadadelivery.com/v2/quickstart.md) includes a complete Node example. Choose `origin_format` and `destination_format`, then supply their matching fields. Pickup from an existing branch uses `branch_format` and `origin.branch_id`. Location-based destinations require `contact_name`, `contact_phone`, `latitude` and `longitude`; `first_line` is optional. Set `reference` to your order reference. Each successful create request creates a new delivery, including requests that reuse the same reference. After a timeout, confirm the outcome before submitting another request. ## Retrieve a delivery Use `GET /v2/deliveries/{id}` with the code of a delivery created through this API. Statuses include `pending`, `dispatched`, `accepted`, `waiting_pack`, `en_route`, `completed`, `failed` and `canceled`. Other statuses can occur, including backup-driver states; handle unrecognized values without discarding the response. ```json { "code": "D000000001", "status": "pending", "test_mode": false, "amount": 4.5, "created_at": "2026-04-16T18:12:03.117Z", "currency": "KWD", "delivery_fee": 2, "customer": { "name": "Example customer", "phone": "+96590000000", "address": "Salmiya, Kuwait", "latitude": 29.3759, "longitude": 47.9774 }, "driver": { "name": "", "phone": "", "latitude": null, "longitude": null }, "logistics": { "estimated_distance": 4820, "estimated_duration": 743, "tracking_url": "https://example.invalid/tracking/customer-link", "pickup_qr_url": "https://example.invalid/pickup/qr" } } ``` ## Cancel a delivery Use `POST /v2/deliveries/{id}/cancel` with the delivery **code**. Enable `delivery:cancel`. The JSON body is optional: ```json { "reason": "Customer requested cancellation" } ``` A successful cancellation returns `200` and the delivery representation with `status: "canceled"`. Repeating cancellation of a canceled delivery preserves its first reason. An already failed delivery is returned unchanged. | Result | Meaning and next step | | ------ | --------------------------------------------------------------------------------------------------------- | | `200` | Inspect `status` in the returned delivery. | | `400` | The current state or cancellation policy prevents the operation; a completed delivery cannot be canceled. | | `409` | A test delivery changed during cancellation. Read it and retry only if it still needs cancellation. | Live deliveries follow the merchant's cancellation and penalty policy. [Simulated test deliveries](https://docs.armadadelivery.com/v2/test-mode.md) can be canceled at `dispatched`, `accepted` and `en_route`; the simulator stops advancing a canceled delivery. To receive the update, select **Canceled** in the key's saved webhook settings. The topic is `order.updated` with `status: "canceled"`. After a timeout or other error, retrieve the delivery to confirm its state before retrying. ## Estimate a delivery Use `branch_format` with `origin.branch_id`, or `location_format` with origin coordinates. The destination must use `location_format`. Contact details are not required for estimates. ```json { "origin_format": "branch_format", "origin": { "branch_id": "YOUR_BRANCH_ID" }, "destination_format": "location_format", "destination": { "latitude": 29.3759, "longitude": 47.9774 } } ``` | Endpoint | Response fields | | ------------------------------------- | -------------------------------------------------------------- | | `POST /v2/deliveries/estimate` | `delivery_fee`, `estimated_pickup_at`, `estimated_delivery_at` | | `POST /v2/deliveries/estimate/static` | `deliveryFee`, `durationToPickup`, `totalDeliveryDuration` | The first endpoint returns timestamps, which can be `null` when an ETA is unavailable. The static endpoint returns durations in seconds using a fixed pickup allowance. Both calculate the fee using the route and merchant pricing. Estimates do not create a delivery. ## Failed deliveries Read the delivery's current state before taking further action. Contact Armada to arrange another delivery after a failure. For status notifications, configure [webhooks](https://docs.armadadelivery.com/v2/webhooks.md). --- Source: https://docs.armadadelivery.com/v2/branches.md # Branches Branches identify a merchant's pickup locations. Use a branch's `id` as `origin.branch_id` when creating a delivery. ## Create a branch Enable `branch:write` on the API key and send `POST /v2/branches`: ```json { "name": "Main branch", "phone": "+96590000000", "latitude": 29.3359, "longitude": 48.0758 } ``` Coordinates are top-level `latitude` and `longitude` fields. Store the returned `id` for later requests. ## Operations | Method | Path | Action | Permission | | -------- | ------------------- | ----------------- | --------------- | | `GET` | `/v2/branches` | List branches | `branch:read` | | `POST` | `/v2/branches` | Create a branch | `branch:write` | | `GET` | `/v2/branches/{id}` | Retrieve a branch | `branch:read` | | `PUT` | `/v2/branches/{id}` | Update a branch | `branch:update` | | `DELETE` | `/v2/branches/{id}` | Delete a branch | `branch:delete` | Branches belong to the merchant associated with the API key. When updating, send only changed fields; resubmitting the current branch name returns `400`. See the [API reference](https://docs.armadadelivery.com/v2/reference.md) for request fields and responses. --- Source: https://docs.armadadelivery.com/v2/wallet.md # Wallet Use `GET /v2/wallet` to read the merchant's balance. The key needs `wallet:read`. ```javascript const { data: wallet } = await armada.wallet.get(); console.log(wallet.balance, wallet.currency); ``` Create the `armada` client as shown in the [quickstart](https://docs.armadadelivery.com/v2/quickstart.md). The response includes `balance`, `currency` and `warning_balance_level`. Configure low-balance callbacks in **Automated Ordering**; they use the same field names. See the [API reference](https://docs.armadadelivery.com/v2/reference.md) for the complete response and [Webhooks](https://docs.armadadelivery.com/v2/webhooks.md) for balance notifications. --- Source: https://docs.armadadelivery.com/v2/invoices.md # Invoices Use `GET /v2/invoices` to list the merchant's invoices and `GET /v2/invoices/{id}` to retrieve one. The key needs `invoices:read`. The list response contains `page`, `perPage`, `total` and `invoices`. Use an invoice's `_id` as the path identifier when retrieving it. ```javascript const { data } = await armada.invoices.list({ page: 1, perPage: 20 }); if (data.invoices.length) { const invoice = await armada.invoices.get(data.invoices[0]._id); console.log(invoice.data); } ``` Invoice `type` and `status` values are lowercase, such as `regular` and `issued`. Date fields are ISO-8601 timestamps. Use the fields defined in the [API reference](https://docs.armadadelivery.com/v2/reference.md) for filters, pagination and responses. The list's `status` parameter selects a group. Read each invoice's own `status` to determine payment state; the `paid` group includes `pending` invoices. Invoice records and wallet balance are separate resources. Use [Wallet](https://docs.armadadelivery.com/v2/wallet.md) to read the current balance. --- Source: https://docs.armadadelivery.com/v2/webhooks.md # Webhooks Receive delivery updates, driver locations and wallet balance notifications at your callback URLs. ## Configuration 1. Open [Automated Ordering](https://business.armadadelivery.com/automated-ordering) and select the key used to create the delivery. 2. Set its **Order update webhook** URL and select the statuses your receiver needs, including **Canceled** or **Completed** when testing those flows. Location and wallet callbacks have separate settings. 3. Click **Save changes**. Callback delivery and the test button use the saved settings. Creation always sends an initial `pending` callback. The selectable statuses are Accepted, En route, Completed, Failed and Canceled. After creation, a non-empty selection filters updates; an empty selection sends every status, including `dispatched`. Each key belongs to one merchant. Use `x-armada-key-id` to map a callback to your saved key configuration. Keep your delivery-code-to-branch mapping when creating an order. ## Events | Topic | Payload | | ------------------------ | ------------------------------------------------- | | `order.updated` | Delivery response; inspect `code` and `status` | | `order.location.updated` | Delivery `code` and `location` | | `wallet.balance_low` | `balance`, `warning_balance_level` and `currency` | ### Order updated ```json { "code": "D000000001", "status": "pending", "test_mode": false, "amount": 4.5, "created_at": "2026-04-16T18:12:03.117Z", "currency": "KWD", "delivery_fee": 2, "customer": { "name": "Example customer", "phone": "+96590000000", "address": "Salmiya, Kuwait", "latitude": 29.3759, "longitude": 47.9774 }, "driver": { "name": "", "phone": "", "latitude": null, "longitude": null }, "logistics": { "estimated_distance": 4820, "estimated_duration": 743, "tracking_url": "https://example.invalid/tracking/customer-link", "pickup_qr_url": "https://example.invalid/pickup/qr" } } ``` The same topic is used for all configured delivery statuses. Driver fields may be empty; retrieve the delivery for current details. ### Location updated ```json { "code": "D000000001", "status": "en_route", "location": { "latitude": 29.3421, "longitude": 47.9558 } } ``` Save a location callback URL and interval to receive updates while a delivery is `en_route`. To disable updates for future deliveries, clear the URL and save. Contact Armada to stop location updates for active deliveries. ### Wallet balance low ```json { "balance": 4.25, "warning_balance_level": 5, "currency": "KWD" } ``` The payload uses the key's warning threshold when configured. Use `GET /v2/wallet` for the current balance and wallet warning threshold. ## Headers | Header | Meaning | | ------------------------ | ------------------------------------------- | | `x-armada-webhook-topic` | Event topic | | `x-armada-webhook-id` | Header identifier beginning with `wh_` | | `x-armada-key-id` | API key record ID, not the credential value | | `x-armada-key-type` | `v2` | | `x-armada-api-version` | `v2` | | `x-armada-timestamp` | ISO-8601 header creation time | | `User-Agent` | `Armada Automated Ordering` | Location callbacks can reuse their initial webhook ID and timestamp. Do not discard them solely because that ID has already been seen. ## Receiver authentication Verify notifications through your signed API client before updating your application. For delivery and location notifications, fetch `GET /v2/deliveries/{id}` using the delivery code. For wallet notifications, fetch `GET /v2/wallet`. Apply the returned API state. Callbacks are unsigned; their metadata headers identify the topic and key. [Request signing](https://docs.armadadelivery.com/v2/authentication.md) authenticates your API reads. Enable `delivery:read` for delivery and location verification, and `wallet:read` for wallet verification. ## Processing Validate and store the event, then return `2xx` promptly. Verify and process it asynchronously. When an order-update URL is saved, delivery creation waits for the initial `pending` callback response. Route stored events by topic and make handlers safe to run more than once: ```javascript // Run after payload validation, storage and HTTP acknowledgment. async function routeWebhook(topic, body) { switch (topic) { case 'order.updated': case 'order.location.updated': { const { data } = await armada.deliveries.get(body.code); return onDeliveryState(data); } case 'wallet.balance_low': { const { data } = await armada.wallet.get(); return onWalletBalance(data); } default: return; } } ``` Use the signed client from the [quickstart](https://docs.armadadelivery.com/v2/quickstart.md) and supply `onDeliveryState` and `onWalletBalance` in your application. Order-update callbacks use a single delivery attempt. Handle out-of-order events and use `GET /v2/deliveries/{id}` to reconcile the current state after a missing callback. ## Test your receiver **Send delivery test** posts a fixed `TEST123` / `pending` sample to the saved delivery URL to check connectivity. Click **Save changes** before using it. The connectivity sample has no `test_mode` field or associated delivery record. Create a test delivery to validate payload handling and API verification. To test lifecycle events, [create a test-mode delivery](https://docs.armadadelivery.com/v2/test-mode.md) with that key: | Test | Action | Expected callback | | ------------ | ----------------------------------------------------------------------------- | -------------------------------------------- | | Cancellation | Save **Canceled**, create a fresh test delivery and cancel before completion. | Topic `order.updated`, `status: "canceled"` | | Completion | Save **Completed**, create a fresh test delivery and let it finish. | Topic `order.updated`, `status: "completed"` | If a callback is missing, check the saved URL and status selection, then read the delivery's current state. --- Source: https://docs.armadadelivery.com/v2/errors.md # Errors Use the HTTP status to handle errors. Error details are returned as JSON objects, JSON strings or plain text. JSON objects can include `message`, `error` or `internalCode`. | Status | Action | | ------ | ---------------------------------------------------------------------------------------------------------- | | `400` | Check the input, account requirements and current delivery state. Completed deliveries cannot be canceled. | | `401` | Check credentials, timestamp and [signature](https://docs.armadadelivery.com/v2/authentication.md). | | `403` | Check the endpoint's key permission and the response's validation message. | | `404` | Check the resource identifier and the key's access. | | `409` | A test delivery changed during cancellation. Read its state before retrying. | | `5xx` | Retry reads with bounded backoff. Check write outcomes before resubmitting. | ## Retrying requests Read requests can be retried after transient network errors or `5xx`, with a limited number of attempts and increasing delay. Delivery creation is not automatically deduplicated by `reference`. After a timeout or error, check the saved delivery code or resolve the outcome with Armada before creating another order. ## Support Send the endpoint, time, HTTP status and delivery code to Armada support. Exclude API keys and secrets. --- Source: https://docs.armadadelivery.com/v2/reference.md # API reference Base URL: `https://api.armadadelivery.com` Use an API key and secret. The SDKs handle request signing; see [Authentication](https://docs.armadadelivery.com/v2/authentication.md) for custom clients. - **POST /v2/deliveries** — Create a delivery - **GET /v2/deliveries/{id}** — Retrieve a delivery - **POST /v2/deliveries/{id}/cancel** — Cancel a delivery - **POST /v2/deliveries/estimate** — Estimate a delivery fee - **POST /v2/deliveries/estimate/static** — Estimate a delivery fee with a fixed pickup allowance - **GET /v2/branches** — List branches - **POST /v2/branches** — Create a branch - **GET /v2/branches/{id}** — Get a branch - **PUT /v2/branches/{id}** — Update a branch - **DELETE /v2/branches/{id}** — Delete a branch - **GET /v2/wallet** — Get wallet balance - **GET /v2/invoices** — List invoices - **GET /v2/invoices/{id}** — Get an invoice ## Complete OpenAPI specification ```yaml openapi: 3.1.0 info: title: Armada Automated Ordering API version: 2.0.0 summary: Merchant-authenticated v2 API for creating and tracking Armada deliveries. description: | Create deliveries, manage pickup branches and read wallet and invoice records. Each API key belongs to one merchant. The SDK examples handle request signing. Start with the [quickstart](https://docs.armadadelivery.com/v2/quickstart/) or [authentication guide](https://docs.armadadelivery.com/v2/authentication/). contact: name: Armada API support email: support@armadadelivery.com url: https://docs.armadadelivery.com license: name: Proprietary identifier: LicenseRef-Armada-Proprietary servers: - url: https://api.armadadelivery.com description: API for live and simulated deliveries. See /v2/test-mode/ for test key setup. security: - ApiKeyAuth: [] TimestampAuth: [] SignatureAuth: [] tags: - name: Deliveries description: Create, track, cancel and estimate deliveries. - name: Branches description: Manage the merchant's pickup locations. - name: Wallet description: Inspect the prepaid wallet balance. - name: Invoices description: Consult generated invoices. paths: /v2/deliveries: post: tags: [ Deliveries ] summary: Create a delivery description: |- Requires `delivery:write`. Each successful create request creates a new delivery, including requests that reuse the same reference. After a timeout, confirm the outcome before resubmitting. With a delivery webhook URL saved, creation waits for its initial pending callback response. Return 2xx promptly from the receiver. See [Webhooks](https://docs.armadadelivery.com/v2/webhooks.md) for receiver authentication and event handling. operationId: createDelivery requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/DeliveryRequest' } example: reference: YOUR_UNIQUE_ORDER_REFERENCE payment: amount: 4.5 type: paid origin_format: branch_format origin: branch_id: YOUR_BRANCH_ID destination_format: location_format destination: contact_name: Test Customer contact_phone: "+96590000000" latitude: 29.3759 longitude: 47.9774 first_line: Salmiya, Block 5, Street 3 responses: '200': description: Delivery created. content: application/json: schema: { $ref: '#/components/schemas/Delivery' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.deliveries.create({ "reference": "YOUR_UNIQUE_ORDER_REFERENCE", "payment": { "amount": 4.5, "type": "paid" }, "origin_format": "branch_format", "origin": { "branch_id": "YOUR_BRANCH_ID" }, "destination_format": "location_format", "destination": { "contact_name": "Test Customer", "contact_phone": "+96590000000", "latitude": 29.3759, "longitude": 47.9774, "first_line": "Salmiya, Block 5, Street 3" } }); console.log(data); /v2/deliveries/{id}: parameters: - { $ref: '#/components/parameters/DeliveryCode' } get: tags: [ Deliveries ] summary: Retrieve a delivery operationId: getDelivery responses: '200': description: OK content: { application/json: { schema: { $ref: '#/components/schemas/Delivery' } } } '404': { $ref: '#/components/responses/NotFound' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.deliveries.get('D000000001'); console.log(data); description: |- Requires `delivery:read`. Retrieve a delivery created through this API using its returned code. /v2/deliveries/{id}/cancel: parameters: - { $ref: '#/components/parameters/DeliveryCode' } post: tags: [ Deliveries ] summary: Cancel a delivery description: |- Requires `delivery:cancel`. Use the delivery code as the path identifier. Cancellation depends on order and trip state and the merchant's cancellation policy. Simulated test deliveries can be canceled at dispatched, accepted and en_route. Cancellation stops the simulator for that delivery. An optional reason is kept on the first cancellation. Repeated cancellation of a canceled delivery, or cancellation of an already failed delivery, returns its current state. Completed deliveries return 400. A test-mode 409 means the delivery changed during cancellation; retrieve it before retrying. After a timeout or error, retrieve the delivery to confirm its current state. operationId: cancelDelivery requestBody: required: false content: application/json: schema: type: object properties: reason: { type: string, description: 'Optional free-text cancellation reason.' } example: reason: Customer requested cancellation responses: '200': description: Current delivery representation. A canceled delivery has status canceled; an already failed delivery is returned unchanged. content: { application/json: { schema: { $ref: '#/components/schemas/Delivery' } } } '404': description: Delivery code not found. content: { application/json: { schema: { type: string }, example: 'Entity not found !' } } '400': { $ref: '#/components/responses/BadRequest' } '409': description: Test delivery changed during cancellation. Retrieve it and retry only if it still needs cancellation. content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.deliveries.cancel('D000000001', 'Customer requested cancellation'); console.log(data); /v2/deliveries/estimate: post: tags: [ Deliveries ] summary: Estimate a delivery fee operationId: estimateDelivery requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/EstimateRequest' } example: origin_format: branch_format origin: branch_id: YOUR_BRANCH_ID destination_format: location_format destination: latitude: 29.3759 longitude: 47.9774 responses: '200': description: Estimate returned. content: { application/json: { schema: { $ref: '#/components/schemas/LiveEstimate' } } } '400': { $ref: '#/components/responses/BadRequest' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.deliveries.estimate({ "origin_format": "branch_format", "origin": { "branch_id": "YOUR_BRANCH_ID" }, "destination_format": "location_format", "destination": { "latitude": 29.3759, "longitude": 47.9774 } }); console.log(data); description: |- Requires `delivery:write`. Returns the fee and estimated pickup and delivery timestamps. Both timestamps can be null when an ETA is unavailable. The destination uses location_format; contact details are not required for estimates. /v2/deliveries/estimate/static: post: tags: [ Deliveries ] summary: Estimate a delivery fee with a fixed pickup allowance operationId: estimateDeliveryStatic requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/EstimateRequest' } example: origin_format: branch_format origin: branch_id: YOUR_BRANCH_ID destination_format: location_format destination: latitude: 29.3759 longitude: 47.9774 responses: '200': description: Estimate returned. content: { application/json: { schema: { $ref: '#/components/schemas/StaticEstimate' } } } '400': { $ref: '#/components/responses/BadRequest' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.deliveries.estimateStatic({ "origin_format": "branch_format", "origin": { "branch_id": "YOUR_BRANCH_ID" }, "destination_format": "location_format", "destination": { "latitude": 29.3759, "longitude": 47.9774 } }); console.log(data); description: |- Requires `delivery:write`. Returns durations in seconds using a fixed pickup allowance. Fee calculation uses the route and merchant pricing. Field names differ from the live estimate. /v2/branches: get: tags: [ Branches ] summary: List branches operationId: listBranches parameters: - { name: page, in: query, schema: { type: integer, minimum: 1, default: 1 } } - { name: limit, in: query, schema: { type: integer, minimum: 1, default: 30 } } - { name: sort_by, in: query, schema: { type: string, enum: [ created_at, name ], default: created_at } } - { name: sort_order, in: query, schema: { type: string, enum: [ asc, desc ], default: desc } } responses: '200': description: OK content: application/json: schema: type: object properties: branches: type: array items: { $ref: '#/components/schemas/Branch' } page: { type: integer } limit: { type: integer } sort_by: { type: string } sort_order: { type: string } total_pages: { type: integer } total_count: { type: integer } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.branches.list(); console.log(data); description: Requires `branch:read`. post: tags: [ Branches ] summary: Create a branch operationId: createBranch requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/BranchInput' } example: name: Main branch phone: "+96590000000" latitude: 29.3359 longitude: 48.0758 responses: '200': description: Branch created. content: { application/json: { schema: { $ref: '#/components/schemas/Branch' } } } '400': { $ref: '#/components/responses/BadRequest' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.branches.create({ "name": "Main branch", "phone": "+96590000000", "latitude": 29.3359, "longitude": 48.0758 }); console.log(data); description: Requires `branch:write`. /v2/branches/{id}: parameters: - { $ref: '#/components/parameters/BranchId' } get: tags: [ Branches ] summary: Get a branch operationId: getBranch responses: '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Branch' } } } } '404': { $ref: '#/components/responses/NotFound' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.branches.get('YOUR_BRANCH_ID'); console.log(data); description: Requires `branch:read`. put: tags: [ Branches ] summary: Update a branch description: |- Requires `branch:update`. Partial update. Send latitude and longitude together when changing coordinates; the address is resolved from those coordinates. Send only changed fields; resubmitting the current branch name returns 400. operationId: updateBranch requestBody: required: true content: { application/json: { schema: { $ref: '#/components/schemas/BranchUpdate' }, example: { name: Updated branch, latitude: 29.3359, longitude: 48.0758 } } } responses: '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Branch' } } } } '400': { $ref: '#/components/responses/BadRequest' } '404': { $ref: '#/components/responses/NotFound' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.branches.update('YOUR_BRANCH_ID', { "name": "Updated branch", "latitude": 29.3359, "longitude": 48.0758 }); console.log(data); delete: tags: [ Branches ] summary: Delete a branch operationId: deleteBranch responses: '204': { description: Deleted } '404': { $ref: '#/components/responses/NotFound' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.branches.delete('YOUR_BRANCH_ID'); console.log(data); description: Requires `branch:delete`. /v2/wallet: get: tags: [ Wallet ] summary: Get wallet balance operationId: getWallet responses: '200': description: OK content: { application/json: { schema: { $ref: '#/components/schemas/Wallet' } } } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.wallet.get(); console.log(data); description: Requires `wallet:read`. /v2/invoices: get: tags: [ Invoices ] summary: List invoices operationId: listInvoices parameters: - { name: page, in: query, schema: { type: integer, minimum: 1, default: 1 } } - { name: perPage, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 20 } } - name: status in: query description: |- Selects a group; read each invoice's status to determine payment state. - unpaid: issued or sent, for regular and wallet types. - paid: paid or pending, for regular and wallet types. - topup: paid, pending, canceled or authorized, for tap_wallet invoices. - all (default): issued, sent, pending or paid, across invoice types. schema: { type: string, enum: [ unpaid, paid, topup, all ], default: all } - { name: periodBegin, in: query, schema: { type: string, format: date } } - { name: periodEnd, in: query, schema: { type: string, format: date } } responses: '200': description: OK content: application/json: schema: type: object properties: page: { type: integer } perPage: { type: integer } total: { type: integer } invoices: type: array items: { $ref: '#/components/schemas/Invoice' } '403': { $ref: '#/components/responses/Forbidden' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.invoices.list({ page: 1, perPage: 10 }); console.log(data); description: |- Requires `invoices:read`. Use an invoice's _id to retrieve it. Only documented fields are part of the public contract; ignore additional fields. /v2/invoices/{id}: parameters: - name: id in: path required: true schema: { type: string, pattern: '^[a-f0-9]{24}$' } get: tags: [ Invoices ] summary: Get an invoice operationId: getInvoice responses: '200': description: OK content: { application/json: { schema: { $ref: '#/components/schemas/Invoice' } } } '404': { $ref: '#/components/responses/NotFound' } x-codeSamples: - lang: JavaScript label: Node SDK source: | import { ArmadaClient } from '@armada/sdk'; const armada = new ArmadaClient({ baseUrl: 'https://api.armadadelivery.com', apiKey: process.env.ARMADA_API_KEY, apiSecret: process.env.ARMADA_API_SECRET, }); const { data } = await armada.invoices.get('YOUR_INVOICE_ID'); console.log(data); description: Requires `invoices:read`. webhooks: orderUpdated: post: summary: order.updated description: | Delivery status notification. Before updating your application, verify current state through a signed GET /v2/deliveries/{id} request. Callbacks are unsigned and use a single delivery attempt. Handle out-of-order arrival. See the [webhook guide](https://docs.armadadelivery.com/v2/webhooks.md#receiver-authentication). security: [] parameters: - { $ref: '#/components/parameters/WebhookTopic' } - { $ref: '#/components/parameters/WebhookKeyId' } - { $ref: '#/components/parameters/WebhookId' } - { $ref: '#/components/parameters/WebhookTimestamp' } requestBody: required: true content: { application/json: { schema: { $ref: '#/components/schemas/Delivery' } } } responses: '2XX': { description: Receiver accepted the callback. Persist it before acknowledgment. } orderLocationUpdated: post: summary: order.location.updated description: Location notification while en_route. Multiple updates can share an initial webhook ID and timestamp. Verify current delivery state through a signed GET /v2/deliveries/{id} request. security: [] parameters: - { $ref: '#/components/parameters/WebhookTopic' } - { $ref: '#/components/parameters/WebhookKeyId' } - { $ref: '#/components/parameters/WebhookId' } - { $ref: '#/components/parameters/WebhookTimestamp' } requestBody: required: true content: { application/json: { schema: { $ref: '#/components/schemas/LocationWebhook' } } } responses: '2XX': { description: Receiver accepted the callback. } walletBalanceLow: post: summary: wallet.balance_low description: Low-balance notification. The warning_balance_level uses the key's threshold when configured. Verify the current balance and wallet warning threshold through a signed GET /v2/wallet request. security: [] parameters: - { $ref: '#/components/parameters/WebhookTopic' } - { $ref: '#/components/parameters/WebhookKeyId' } - { $ref: '#/components/parameters/WebhookId' } - { $ref: '#/components/parameters/WebhookTimestamp' } requestBody: required: true content: { application/json: { schema: { $ref: '#/components/schemas/WalletWebhook' } } } responses: '2XX': { description: Receiver accepted the callback. } components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: Authorization description: |- `Authorization: Key ` combined with the timestamp and HMAC-SHA256 signature headers. See [Authentication](https://docs.armadadelivery.com/v2/authentication.md) for a complete signing example. TimestampAuth: type: apiKey in: header name: x-armada-timestamp description: Milliseconds since epoch as a decimal string, within 30 seconds of server time. SignatureAuth: type: apiKey in: header name: x-armada-signature description: Lowercase hex HMAC-SHA256 of timestamp.method.path.rawBody. Use the uppercase HTTP method, the pathname with its exact query string, and the exact UTF-8 body bytes (empty string when absent). Recompute for each API request. parameters: WebhookTopic: name: x-armada-webhook-topic in: header required: true schema: { type: string, enum: [ order.updated, order.location.updated, wallet.balance_low ] } WebhookKeyId: name: x-armada-key-id in: header required: true description: API key record identifier used to match a callback to your saved key configuration. schema: { type: string } WebhookId: name: x-armada-webhook-id in: header required: true description: Header identifier prefixed wh_. Location updates can share an identifier. schema: { type: string } WebhookTimestamp: name: x-armada-timestamp in: header required: true description: Header-generation time. Recurrent jobs can reuse initial headers. schema: { type: string, format: date-time } DeliveryCode: name: id in: path required: true description: Code returned when creating a delivery through this API. schema: { type: string, example: D000000001 } BranchId: name: id in: path required: true schema: { type: string, pattern: '^[a-f0-9]{24}$' } responses: BadRequest: description: Invalid input, unmet account requirements or an operation not allowed in the current state. content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } Unauthorized: description: Missing or invalid credentials / signature. content: application/json: { schema: { $ref: '#/components/schemas/Error' } } text/plain: { schema: { type: string } } Forbidden: description: API key lacks the required permission. content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } NotFound: description: Resource not found. content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } schemas: Error: description: Error bodies vary by operation. Check the HTTP status first; no field is present in every response. oneOf: - type: object properties: error: { type: string, description: Error code when supplied. } internalCode: { type: [ string, number ], description: Error code when supplied. } message: { type: string, description: Error description when supplied. } violations: { type: object, description: Validation details when supplied. } - type: string Payment: type: object required: [ amount, type ] properties: amount: { type: number, exclusiveMinimum: 0 } type: { type: string, enum: [ paid, cash ] } LocationAddress: type: object required: [ contact_name, contact_phone, latitude, longitude ] properties: contact_name: { type: string } contact_phone: { type: string } latitude: { type: number } longitude: { type: number } first_line: { type: string } floor: { type: string } apartment: { type: string } instructions: { type: string } OriginLocationAddress: allOf: - { $ref: '#/components/schemas/LocationAddress' } - type: object properties: branch_id: type: string pattern: '^[a-fA-F0-9]{24}$' description: Non-deleted branch belonging to the authenticated merchant. Required when the merchant has multiple branches; otherwise exactly one non-deleted branch must exist. KuwaitAddress: type: object required: [ contact_name, contact_phone, area, block, street, building ] properties: contact_name: { type: string } contact_phone: { type: string } area: { type: string } block: { type: string } street: { type: string } building: { type: string } floor: { type: string } apartment: { type: string } instructions: { type: string } BahrainAddress: { $ref: '#/components/schemas/KuwaitAddress' } KsaAddress: type: object required: [ contact_name, contact_phone, city, street, district, building ] properties: contact_name: { type: string } contact_phone: { type: string } city: { type: string } street: { type: string } district: { type: string } building: { type: string } floor: { type: string } apartment: { type: string } instructions: { type: string } KsaShortAddress: type: object required: [ contact_name, contact_phone, short_address ] properties: contact_name: { type: string } contact_phone: { type: string } short_address: { type: string } instructions: { type: string } BranchOrigin: type: object required: [ branch_id ] properties: branch_id: { type: string, pattern: '^[a-f0-9]{24}$' } DeliveryRequest: type: object required: [ reference, payment, origin_format, destination_format, origin, destination ] properties: reference: { type: string, description: 'Partner order reference. Each successful create request creates a new delivery, including requests that reuse this reference.' } payment: { $ref: '#/components/schemas/Payment' } origin_format: { type: string, enum: [ location_format, branch_format ] } origin: anyOf: - $ref: '#/components/schemas/BranchOrigin' - $ref: '#/components/schemas/OriginLocationAddress' destination_format: { type: string, enum: [ location_format, kuwait_format, bahrain_format, ksa_format, ksa_short_format ] } destination: anyOf: - $ref: '#/components/schemas/LocationAddress' - $ref: '#/components/schemas/KuwaitAddress' - $ref: '#/components/schemas/BahrainAddress' - $ref: '#/components/schemas/KsaAddress' - $ref: '#/components/schemas/KsaShortAddress' EstimateRequest: type: object required: [ origin_format, destination_format, origin, destination ] properties: origin_format: { type: string, enum: [ location_format, branch_format ] } origin: anyOf: - $ref: '#/components/schemas/BranchOrigin' - $ref: '#/components/schemas/EstimateLocation' destination_format: { type: string, enum: [ location_format ] } destination: $ref: '#/components/schemas/EstimateLocation' EstimateLocation: type: object required: [ latitude, longitude ] properties: latitude: { type: number } longitude: { type: number } LiveEstimate: type: object required: [ delivery_fee, estimated_pickup_at, estimated_delivery_at ] properties: delivery_fee: { type: number, description: Estimated fee in the merchant's currency. } estimated_pickup_at: { type: [ string, 'null' ], format: date-time } estimated_delivery_at: { type: [ string, 'null' ], format: date-time } StaticEstimate: type: object required: [ deliveryFee, durationToPickup, totalDeliveryDuration ] properties: deliveryFee: { type: number, description: Estimated fee in the merchant's currency. } durationToPickup: { type: number, description: Pickup allowance in seconds. } totalDeliveryDuration: { type: number, description: Total duration including pickup allowance in seconds. } Delivery: type: object properties: status: type: string description: Current order status. Typical progression is pending, dispatched, accepted, waiting_pack, en_route, completed. Preparation, payment and backup-driver states can also occur; handle other statuses without discarding the response. code: { type: string } test_mode: { type: boolean } amount: { type: number } created_at: { type: string, format: date-time } currency: { type: string } delivery_fee: { type: number } customer: type: object properties: name: { type: string } phone: { type: string } address: { type: string } latitude: { type: [ 'number', 'null' ] } longitude: { type: [ 'number', 'null' ] } driver: type: object properties: name: { type: string } phone: { type: string } latitude: { type: [ 'number', 'null' ] } longitude: { type: [ 'number', 'null' ] } logistics: type: object properties: estimated_distance: { type: number, description: Meters. } estimated_duration: { type: number, description: Seconds. } tracking_url: { type: string, format: uri } pickup_qr_url: { type: string, format: uri } example: code: D000000001 status: pending test_mode: false amount: 4.5 created_at: 2026-04-16T18:12:03.117Z currency: KWD delivery_fee: 2 customer: name: Example customer phone: "+96590000000" address: Salmiya, Kuwait latitude: 29.3759 longitude: 47.9774 driver: name: "" phone: "" latitude: null longitude: null logistics: estimated_distance: 4820 estimated_duration: 743 tracking_url: https://example.invalid/tracking/customer-link pickup_qr_url: https://example.invalid/pickup/qr BranchInput: type: object required: [ name, phone, latitude, longitude ] properties: name: { type: string, minLength: 2, maxLength: 75 } phone: { type: string, pattern: '^[\d+]{7,15}$' } latitude: { type: number, description: Pickup latitude. Must resolve with longitude to a supported address. } longitude: { type: number, description: Pickup longitude. The API derives the address from the coordinates. } BranchUpdate: type: object dependentRequired: latitude: [ longitude ] longitude: [ latitude ] properties: name: { type: string, minLength: 2, maxLength: 75 } phone: { type: string, pattern: '^[\d+]{7,15}$' } latitude: { type: number } longitude: { type: number } Branch: type: object properties: id: { type: string } name: { type: string } phone: { type: string } address: { type: string } latitude: { type: [ 'number', 'null' ] } longitude: { type: [ 'number', 'null' ] } created_at: { type: string, format: date-time } LocationWebhook: type: object required: [ code, status, location ] properties: code: { type: string } status: { type: string } location: type: object properties: latitude: { type: [ number, string, 'null' ] } longitude: { type: [ number, string, 'null' ] } WalletWebhook: type: object required: [ balance, warning_balance_level, currency ] properties: balance: { type: number } warning_balance_level: { type: number } currency: { type: string } Wallet: type: object properties: balance: { type: number } currency: { type: string } warning_balance_level: { type: [ 'number', 'null' ] } Invoice: type: object description: Merchant invoice fields for integration use. properties: _id: { type: string, pattern: '^[a-f0-9]{24}$', description: Invoice identifier used to retrieve this invoice. } invoiceNo: { type: string } type: type: string enum: [ regular, customer_order, wallet, topup_wallet, refund_wallet, refund, tap_wallet ] status: type: string enum: [ issued, sent, pending, authorized, paid, canceled, validation, refunded ] amount: { type: number } currency: { type: string } ordersCount: { type: integer } deliveryTripsCount: { type: integer } periodBegin: { type: string, format: date-time } periodEnd: { type: string, format: date-time } dueOn: { type: string, format: date-time } createdAt: { type: string, format: date-time } ```