Create a single shipment
Creates one shipment, its details, its consignee record, and — for reverse shipments — an ad-hoc pickup location, all inside a single database transaction.
Request shape
The body has three top-level keys: shipment (the flat shipment payload),
cmpService (the operation), and subAccountId (the owning merchant).
An optional locationId selects an explicit warehouse/pickup location.
Flat vs legacy nested payload
The preferred shape is flat: consignee fields (consigneeName, consigneePhone,
districtId, address parts) live directly on the shipment object.
The legacy contact object is still accepted and is normalised to the flat layout
by the server — new integrations should use the flat shape.
Flow type — DELIVERY vs REVERSE
- DELIVERY: goods go from the warehouse to the customer.
businessLocationIdis the merchant warehouse;deliveryBranchIdis resolved from the district's city. - REVERSE: the customer's flat data is saved twice — as the shipment's
consignee (the party the courier collects from, exactly as in DELIVERY)
and as an ad-hoc pickup origin.
businessLocationIdis the merchant warehouse, andreturnLocationIdresolves to it as the destination the returned goods travel back to.
Address resolution pyramid
- If
streetNameorbuildingNumberis present → the server buildsaddressTextfrom the structured parts (auto-detecting Arabic vs English). - Otherwise → the client-supplied
addressTextis used as-is.
newAddressText is a separate optional field stored as a secondary address on the
consignee. It does not affect the pyramid above.
Destination geography — districtId only
districtId is the single source of truth for the destination. The server derives the
city and the governorate from it, so cityId and governorateId must not be sent —
a request carrying either is rejected. This makes a contradicting combination
impossible: branch routing comes from the district's city and the SLA/TAT rule from
its governorate, so previously the two could disagree.
Server-derived fields — do not send
cityId,governorateId— derived fromdistrictId; sending either is rejected.businessLocationId— always set to the merchant warehouse.- Branch ids (
deliveryBranchId,toBranchId,currentBranchId,fromBranchId) — computed from the destination city and the warehouse. awb— auto-generated when omitted; if supplied it must be free/unused.
Required fields
| Field | Rule |
|---|---|
consigneeName | Always required. |
consigneePhone | Always required — E.164 format, e.g. +201001234567. |
districtId | Always required — the server derives cityId and governorateId from it. |
productId | Always required — selects the price plan used to charge the shipment. |
addressText | Required unless streetName or buildingNumber is provided. |
Request
Responses
201 Created
Shipment created — returns the generated AWB.
400 Bad Request
Validation or business-rule error.
401 Unauthorized
Unauthorized.
404 Not Found
Sub-account, pickup location, or product not found.
500 Internal Server Error
Internal Server Error.