Identifiers, events and the ledger
What the API's identifiers mean, the events you can record, and the one rule every stock event follows: it names the event it came from. Read this before your first write.
Identifiers
DawaTrack uses the GS1 identifiers printed on the pack, so what your scanner reads is what you send.
| Field | GS1 | What it is |
|---|---|---|
gtin | AI (01) | The product: one strength, form and pack. 8, 12, 13 or 14 digits are accepted and stored as 14, zero-padded. The check digit must be right; a GTIN with a wrong one is refused, as it would be a different product. |
batch_number | AI (10) | The lot printed on the pack. On a COMMISSION or SHIP it must fit a DataMatrix: at most 20 characters from GS1's character set. Spaces are removed before it's stored. |
serial_number | AI (21) | One unit of a product, for unit-level traceability. A GTIN and serial are commissioned once, ever. |
expiry_date | AI (17) | The lot's expiry. With the manufacture date it lives on the lot record (below). |
sscc | AI (00) | A case or pallet: 18 digits. Units and smaller cases are packed into one with POST /aggregations/. |
gln | AI (414) | A party's location: 13 digits, check digit checked. |
The lot record
Each GTIN and batch has one lot record holding its expiry and manufacture date. The first event that declares the lot creates it. Later events must agree with it: a different expiry is refused, a date that is missing can be filled in once, and a date already set never changes. Read it with GET /lots/{gtin}/{batch_number}/.
Events
Everything that happens to stock is an event: who did what, to how many units of which lot, and when. Record them with POST /events/, one at a time or up to 1,000 with POST /events/bulk/.
| Event type | Records |
|---|---|
COMMISSION | A manufacturer brings a serialised unit into existence; serial_number is required. |
SHIP | Stock leaves you for a receiver. See Shipments and confirmation. |
RECEIVE | Stock arrives at you. |
TRANSFER | Stock moves between your own sites. |
DISPENSE | A pharmacy hands units to a patient. No patient detail is ever sent. |
QUARANTINE / RELEASE | Stock is held, and later released. |
RETRACT | An event you recorded didn't happen (a document cancelled in your system). Name it in corrects_event; send no quantity and no parent. |
Packing has its own endpoints, which check what they pack: POST /aggregations/ writes an AGGREGATE and POST /aggregations/{sscc}/disaggregate/ a DISAGGREGATE. A few event types are written by DawaTrack itself, never through the API: RECEIVE_LINK, SHIP_ANSWER, RECALL_ACKNOWLEDGMENT and RECEIPT_ANSWER. You'll see them when you read a batch's history.
The parent rule
A stock event names, in parent_event, the event its units came from. That link is what lets a recall follow a lot from the manufacturer to every pharmacy that holds it, so an event with the wrong parent, or none where one is needed, is refused with 400.
| Event | Its parent_event |
|---|---|
COMMISSION | None: it's where a lot starts. |
RECEIVE | The SHIP (or TRANSFER) it received. When the sender isn't on DawaTrack, leave it out and name the sender instead. |
SHIP | The RECEIVE its units came from, when you received this lot on DawaTrack. A manufacturer shipping its own stock names its COMMISSION, an AGGREGATE or DISAGGREGATE, or nothing if the platform hasn't seen the lot before. |
TRANSFER, QUARANTINE | The RECEIVE whose stock it moves or holds, when you received this lot on DawaTrack (or a COMMISSION or DISAGGREGATE). |
DISPENSE | The RECEIVE it was dispensed from (or a COMMISSION or DISAGGREGATE). |
RELEASE | The QUARANTINE it releases. |
The error says which parent was expected, for example: Event type DISPENSE requires a parent_event that names the RECEIVE it was dispensed from. Every write returns the new event's id; keep it, it's the parent of what comes next.
{
"event_type": "RECEIVE",
"gtin": "06164004321562",
"batch_number": "BTH-2026-041",
"quantity": 30,
"parent_event": 81250
}
The ledger is append-only
An event, once recorded, is never changed or deleted, in production or in the sandbox. To undo one you recorded, write a RETRACT naming it; every reader then leaves the retracted event out, and an EPCIS export marks it with its error declaration. To correct a quantity, retract the event and record the right one.
Reading the graph back
GET /batches/{gtin}/{batch_number}/tree/: every party a batch reached, hop by hop.GET /events/{id}/upstream/: the chain an event came from, back to where the lot started.GET /batches/{gtin}/{batch_number}/orphans/: events of the batch not connected to the rest of it, which a recall can't reach. Aim for none.GET /batches/{gtin}/{batch_number}/epcis/: the batch's history as a GS1 EPCIS 2.0 document.
Partner API v1. The API reference is generated from the API's own code.