# Maystro Delivery

Maystro Delivery is a national courier with strong presence across Algerian wilayas. The integration is one of the simplest: a single API token is all you need.

## What you need

* One value, labelled **Authentication Token** in the credential modal, issued from your Maystro merchant dashboard. Maystro authenticates with `Authorization: Token <value>` — it is not a Bearer token.

If your account doesn't expose API access, contact Maystro to enable it.

## Linking Maystro in DZBuild

1. Open **[`/dashboard/link-shipping`](https://dzbuild.com/dashboard/link-shipping)** and find the **Maystro** tile.
2. Click **Lier / ربط**.
3. Paste your **Authentication Token** in the single credential field.
4. Click **Tester la connexion** (« اختبار الاتصال »). DZBuild calls Maystro live and confirms the token works.
5. Click **Lier et enregistrer** (« ربط وحفظ »).

Per-wilaya prices are edited on the separate page [`/dashboard/shipping`](https://dzbuild.com/dashboard/shipping).

## What gets synced

* The list of **wilayas** Maystro serves.
* **Communes** per wilaya.
* **Home + desk rates** per wilaya — see below.
* The **stop-desk list** for the [Stop Desk picker](https://dzbuild.com/docs/couriers/stop-desk.md).

### Rates

Maystro rates **are** syncable. **Sync rates from provider** reads Maystro's own delivery pricing for each wilaya and fills in both the home and the desk price.

One caveat worth knowing: Maystro prices per **commune**, not per wilaya, so DZBuild approximates each wilaya with its centre commune. A wilaya whose centre commune returns no pricing stays at 0 — set those by hand on [`/dashboard/shipping`](https://dzbuild.com/dashboard/shipping).

### Desks

Maystro's desk list is read from each wilaya's centre commune. Only when the centre commune has no desk does DZBuild check the wilaya's other communes. A desk in an outlying commune of a wilaya whose centre commune already has a desk is therefore not listed, and clicking **Actualiser** does not change that. Desk delivery itself stays available in every wilaya where Maystro prices a desk.

Only Maystro's own stop desks are listed; partner pickup points are not supported.

## What happens when an order ships

DZBuild posts the order to Maystro with the customer's name, phone and address, the destination wilaya, the commune as **Maystro's numeric commune ID**, the product list, your order number as `external_order_id`, and `product_price` — which is the **order total**, not the subtotal.

Two things Maystro does *not* receive:

* **Weight** is not sent to Maystro at all.
* **No desk id.** Desk delivery is expressed only by `delivery_type: 2` (1 = home, 3 = pickup point). Maystro's API takes no desk field, so when the customer picked a desk DZBuild sends that desk's commune with the desk flag, which routes the parcel to a commune that has a desk.

The commune ID is resolved from DZBuild's synced commune data and then a live lookup; if it can't be resolved the send fails with « لم يتم العثور على البلدية … ».

Maystro returns a **tracking number** (saved on the order) and a label URL.

Printing the Maystro label

No dashboard button opens Maystro's label URL — clicking **Print label** on a Maystro order prints DZBuild's own HTML bordereau. Print Maystro's official bordereau from the Maystro portal.

## Common errors and fixes

| Symptom                                        | Likely cause                                                 | Fix                                                                                                      |
| ---------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| The connection test fails immediately          | Wrong or expired token                                       | Copy a fresh Authentication Token from Maystro and paste it again.                                       |
| `لم يتم العثور على البلدية …`                  | The commune on the order has no Maystro commune ID           | Correct the commune on the order, or click **Actualiser** on the tile to re-sync Maystro's commune list. |
| Some wilayas still show a 0 rate after syncing | Maystro returned no pricing for that wilaya's centre commune | Set those wilayas manually on [`/dashboard/shipping`](https://dzbuild.com/dashboard/shipping).           |

## Tips

* The connection test reads Maystro's wilaya list, so it works on an account with no shipments yet. As long as DZBuild shows green, the token is valid.
* After syncing rates, review the table on [`/dashboard/shipping`](https://dzbuild.com/dashboard/shipping) — the centre-commune approximation can sit slightly above or below what you actually pay in outlying communes.
* Maystro is a good complement to Yalidine if you want a backup courier for specific zones.
