Skip to main content

Production status

Where every piece is, right now.

GET /api/v1/integration/production-status​

curl -H "X-API-Key: mgi_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
https://your-server/api/v1/integration/production-status

Response​

{
"codes": [
{
"barcode": "ABC-001",
"lotQuantity": 4,
"orderRef": "0001",
"status": "IN_PROGRESS",
"quantityDone": 0,
"stages": [
{
"sequence": 1,
"service": "SERVICE_A",
"machineName": "MACHINE 01",
"status": "DONE",
"startedAt": "2026-09-18T11:02:00Z",
"finishedAt": "2026-09-18T11:47:00Z",
"scheduledFor": "2026-09-18T08:00:00Z",
"quantityCompleted": 4,
"quantityInProgress": 0,
"quantityWaiting": 0,
"batchId": 101
},
{
"sequence": 2,
"service": "SERVICE_B",
"machineName": "MACHINE 02",
"status": "PARTIAL",
"startedAt": "2026-09-18T13:20:00Z",
"finishedAt": null,
"scheduledFor": "2026-09-18T13:00:00Z",
"quantityCompleted": 2,
"quantityInProgress": 1,
"quantityWaiting": 1,
"batchId": 102
},
{
"sequence": 3,
"service": "SERVICE_C",
"machineName": "MACHINE 03",
"status": "WAITING",
"startedAt": null,
"finishedAt": null,
"scheduledFor": "2026-09-19T09:00:00Z",
"quantityCompleted": 0,
"quantityInProgress": 0,
"quantityWaiting": 4,
"batchId": null
}
]
}
],
"totalCodes": 1,
"truncated": false,
"daysAfterCompletion": 7,
"serverUtc": "2026-09-18T14:02:11Z"
}

Fields​

FieldMeaning
codes[]One entry per barcode you sent
totalCodesHow many came back
truncatedtrue when the code ceiling was reached — filter by orderRef
daysAfterCompletionHow long a finished code keeps appearing
serverUtcServer clock, to compare against yours

Per code:

FieldMeaning
barcodeThe code you sent. Always the lot root, never an internal fraction
lotQuantityQuantity ordered. Immutable — it does not change when a lot is split
statusSummary: the situation of the first stage that has not closed
quantityDoneUnits that completed the whole route
stages[]The route, in order

Per stage:

FieldMeaning
sequencePosition in the route
service · machineNameThe operation and where it runs
startedAtWhen the first unit entered. null if none has
finishedAtFilled only when the whole lot has passed
scheduledForThe earliest planned start among the parts of the lot that have a schedule (a planned start and finish), in UTC. null while none has one. Informative only: the situation does not come from it
quantityCompleted · quantityInProgress · quantityWaitingThe three quantities. They always add up to lotQuantity
batchIdThe physical batch (oven load, glass sheet) the units went through, when there is one

It is a snapshot, not a log​

This is the thing to understand before writing any code against it.

The response is the complete current state, not a list of things that happened since you last asked. There is no cursor, no offset, and no acknowledgement to send back.

What follows from that:

  • Overwrite what you had. Do not append, do not merge. The answer already is the whole picture.
  • Missing a cycle costs nothing. Your reader was down for an hour? The next call gives you the current state. Nothing queued up and nothing was lost.
  • Polling is idempotent. Reading twice changes nothing on our side.

A log would have been easier for us to build and much harder for you to consume — you would need to track what you had already seen, and one missed event would leave you permanently wrong. A snapshot cannot drift.

The three quantities​

A piece ordered with lotQuantity > 1 can be split across stages — part cut, part still waiting. In the example above, the second stage has 2 done, 1 in the furnace and 1 waiting.

Without the middle one, "in the machine" and "not started yet" would both read as zero progress — which is exactly the question a production planner calls about.

The situations a stage can be in​

SituationMeaning
WAITINGNot started, scheduled, and on time
LATENot started, and late: the scheduled stage will finish after the date it has to be ready (or the clock is already past it); the unscheduled stage, with the piece's deadline already past
UNSCHEDULEDNot started, and not scheduled yet, with the piece's deadline still ahead
IN_PROGRESSUnits in the machine now
PARTIALPart of the lot passed, and the rest is in no machine
DONEFinished
OUTSOURCEDSent to an external supplier
SHIPPEDShipped
CANCELLEDCancelled

LATE and PARTIAL exist as their own names on purpose. Both would otherwise hide behind WAITING, and both are the ones that generate a phone call.

How WAITING, LATE and UNSCHEDULED are decided​

This is the same rule the plant uses internally, applied at the moment you ask:

  • A scheduled stage has a date by which it must be ready: the piece's deadline minus what is still left of the route after it. It is LATE when its planned finish — or now, if now is already past the planned finish and the stage has not started — comes after that date. A planned start in the past is not enough on its own.
  • A stage with no schedule yet is UNSCHEDULED while the piece's deadline is still ahead, and LATE after it. This is the normal state of waiting work: the plant schedules in detail only the next hours (up to 24, set by the plant), and a piece enters the detail when its turn comes. Stages the planner does not schedule (assembly, shipping, work at a supplier not yet sent) also show as UNSCHEDULED. It is not a problem: it means "queued, no time yet".
  • The piece's deadline is the earliest of the DueDate you sent, the departure of the load it is in and — when that load has a dock slot booked — the time by which loading must be finished. A ply of a laminated or insulated unit takes the unit's deadline when it comes before its own.
  • The deadline of a stage with no schedule is the one the planner wrote at its last run (normally seconds to minutes ago). A piece that has just arrived, or a stage that has just been created (a replacement, a split lot), shows UNSCHEDULED until that run, even if its DueDate has already passed.
  • A split lot: LATE if any part that has not started is late — even while another part is in the machine, has already passed or is at the supplier, so the late part does not hide behind IN_PROGRESS, PARTIAL or OUTSOURCED; UNSCHEDULED only if no part that has not started has a schedule; WAITING otherwise.
  • There is no "at risk" situation in the contract: what the plant calls at risk internally is reported as WAITING.

UNSCHEDULED was added together with this rule, in the version listed in the changelog. Before it, LATE meant "the planned start has passed" and came out 3 hours early, and scheduledFor showed an instant 3 hours earlier than the real one (the plant's local time was sent with a Z). If you added 3 hours to scheduledFor to compensate, stop. Treat unknown situations as informative, not as errors.

The code is always the one you sent​

Whatever you used as barcode is what comes back. We do not translate it, prefix it, or replace it with an internal id.

If a piece was split during production — a lot partly cut, a broken piece replaced — the fractions are consolidated back under the code you know. Our internal identifiers stay internal.

Filtering​

ParameterEffectExample
orderRefOnly that order?orderRef=0001
daysAfterCompletionHow many days finished codes keep appearing?daysAfterCompletion=3
codeLimitCeiling on the number of codes returned?codeLimit=500
curl -H "X-API-Key: mgi_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"https://your-server/api/v1/integration/production-status?orderRef=0001"

Finished codes keep showing up for a few days by design, so that a reader which was down for a cycle does not lose the closing of an order.

When truncated comes back true, you hit the ceiling. Filter by orderRef rather than raising it.

What this does not cover​

It reports what the shop floor has recorded. It is not a financial document, not a delivery confirmation, and it does not report anything that happens after shipping.