Serials API
The Serials API manages the complete lifecycle of serial numbers in Shop Planr. A serial number represents a single physical unit being produced — it is created against a specific job and path, advances through that path's ordered process steps, and ultimately reaches one of three terminal states: completed, scrapped, or force-completed.
Domain Concepts
Serial Number Lifecycle
Every serial number follows a predictable lifecycle:
- Creation — Serials are created in batches via
POST /api/serials. Each serial is assigned a sequential identifier (e.g.SN-00001) and placed at step index0(the first process step) with statusin_progress. Step status records are initialized for every step in the path: the first step getsin_progress, all others getpending. - Advancement — As work is completed, serials advance through the path's steps via
POST /api/serials/:id/advance(next step) orPOST /api/serials/:id/advance-to(jump to a specific step). Each advancement updates the serial'scurrentStepIndexand records an audit trail entry. When a serial advances past the final step, it transitions tocompletedstatus withcurrentStepIndex: -1. - Terminal States — A serial reaches one of three endpoints:
- Completed — Advanced through all required steps normally.
status: "completed",currentStepIndex: -1. - Scrapped — Removed from production due to a defect or error.
status: "scrapped"with a mandatory reason code and optional explanation. - Force-completed — Marked as done despite having incomplete required steps.
status: "completed",forceCompleted: true, with an optional reason.
- Completed — Advanced through all required steps normally.
Step Statuses
Each serial maintains a per-step status record (SnStepStatus) for every step in its path. These statuses track the granular state of each step independently of the serial's overall position:
| Status | Meaning |
|---|---|
pending | Step has not been reached yet |
in_progress | Serial is currently at this step |
completed | Step was completed normally |
skipped | Optional step was bypassed during advancement |
deferred | Required step was bypassed but must be completed later |
waived | Deferred step was formally waived by an approver |
Advancement Modes
The path's advancementMode controls how serials move through steps:
strict— Serials can only advance to the immediately next step (N+1). No skipping allowed.flexible— Serials can jump forward, automatically skipping optional steps and deferring required ones.per_step— Like flexible, but each step'sdependencyTypedetermines whether it can be bypassed. Steps withphysicaldependency cannot be skipped unless they are optional or have an active override.
Step Overrides
A step override (SnStepOverride) marks a specific step as effectively optional for a particular serial number. When an override is active, the step can be skipped during advancement even if it would normally be required. Overrides are reversible — they can be deactivated as long as the step hasn't already been skipped or completed.
Waivers
A waiver is a formal approval to permanently excuse a deferred required step. Unlike overrides (which affect future advancement), waivers resolve steps that were already bypassed. Waivers require an approver ID and a reason, and they change the step status from deferred to waived. Only deferred required steps can be waived — optional steps cannot.
Deferred Steps
When a required step is bypassed during advancement (in flexible or per_step mode), it receives deferred status. Deferred steps represent work that still needs to happen, just not in the original sequence. They can be resolved in two ways:
- Completed later via
POST /api/serials/:id/complete-deferred/:stepId— changes status fromdeferredtocompleted. - Waived via
POST /api/serials/:id/waive-step/:stepId— changes status fromdeferredtowaivedwith formal approval.
Certificate Attachments
Certificates (material certs, process certs) can be attached to serial numbers at their current process step. Attachments are idempotent — re-attaching the same certificate at the same step is a no-op. Each attachment records which step the serial was at when the certificate was attached, creating a traceable chain of custody.
Relationship to Jobs and Paths
Serials exist within the hierarchy: Job → Path → Serial Numbers. A job represents the production order, a path defines the manufacturing route (sequence of process steps), and serial numbers are the individual units flowing through that route. Every serial belongs to exactly one job and one path. The job's overall progress is computed by aggregating serial completion data across all of its paths.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/serials | List all serial numbers with enriched data |
GET | /api/serials/:id | Get a single serial with certificate data |
POST | /api/serials | Batch create serial numbers for a job path |
POST | /api/serials/:id/advance | Advance to the next process step |
POST | /api/serials/:id/advance-to | Advance to a specific target step |
POST | /api/serials/:id/scrap | Scrap a serial number |
POST | /api/serials/:id/force-complete | Force-complete bypassing remaining steps |
POST | /api/serials/:id/attach-cert | Attach a certificate at the current step |
GET | /api/serials/:id/cert-attachments | List all certificate attachments |
GET | /api/serials/:id/step-statuses | Get per-step status tracking |
GET | /api/serials/:id/overrides | List step overrides |
POST | /api/serials/:id/overrides | Create a step override |
DELETE | /api/serials/:id/overrides/:stepId | Reverse a step override |
POST | /api/serials/:id/waive-step/:stepId | Waive a deferred step |
POST | /api/serials/:id/complete-deferred/:stepId | Complete a deferred step |
Related APIs
- Jobs API — Production orders that serial numbers belong to
- Paths API — Manufacturing routes that define the step sequence
- Certificates API — Certificate management and creation
- Audit API — Immutable audit trail of all serial lifecycle events