MOC Submission Pipeline
These endpoints handle the six-step MOC approval workflow. Each endpoint corresponds to a specific stage in the MOC lifecycle.
All submission endpoints are located at src/app/api/submit/.
POST /api/submit/originator
Submits or updates the Originator form (Part A).
Authentication: Required
File: src/app/api/submit/originator/route.ts
Request body:
{
"moc_id": "...",
"originator_form": {
"implementer-name": { "value": { "_id": "userId", "name": "..." } },
"description-of-change": { "value": "<p>...</p>" },
"reason-for-change": { "value": "Safety improvement" },
"department-of-change": { "value": "Engineering" },
"affected-departments": { "value": ["Fleet", "Operations"] }
}
}
Side effects:
- Creates or updates the originator form document
- Adds the implementer to
all_userson the MOC - Sets
implementer_idon the MOC - Pushes an audit log entry
POST /api/submit/implementer
Submits the Implementer/Assessment form (Part B). Handles both approval and decline paths.
Authentication: Required (must be the assigned implementer)
File: src/app/api/submit/implementer/route.ts
Request body:
{
"moc_id": "...",
"implementer_form": {
"approver-name": { "value": { "_id": "userId" } },
"hseq-name": { "value": { "_id": "userId" } },
"details-assessed": { "value": "yes" },
"necessary-justified": { "value": "yes" },
"decline-reason": { "value": "" }
}
}
Approval path (both assessments are "yes"):
- MOC status advances to
"c"(HSEQ Review) - Assigns HSEQ and Approver users
- Sends emails to HSEQ department, assigned HSEQ user, approver, and all MOC users
Decline path (either assessment is "no"):
- MOC status set to
"decline" - Creates a decline object with
stage: "b"and the decline reason - Sends decline notification emails to originator and all MOC users
POST /api/submit/hseq
Submits the HSEQ Review form (Part C). Handles approval or return-to-implementer.
Authentication: Required (must have department === "hseq" and MOC must be at status === "c")
File: src/app/api/submit/hseq/route.ts
Request body:
{
"moc_id": "...",
"hseq_form": {
"hseq-change-adequately": { "value": "yes" },
"hseq-justification-satisfactory": { "value": "yes" },
"hseq-risk-assessment-covered": { "value": "yes" },
"decline-reason": { "value": "" }
}
}
Approval path (all three checks are "yes"):
- MOC status advances to
"d"(Approver) - Emails sent to approver, originator, and implementer
Return path (any check is "no"):
- MOC status reverts to
"b"(sent back to Implementer for revision) - Emails sent to implementer and originator
POST /api/submit/approver
Submits the Approver form (Part D). Handles approval or decline.
Authentication: Required (must be the assigned approver and MOC at status === "d")
File: src/app/api/submit/approver/route.ts
Request body:
{
"moc_id": "...",
"approver_form": {
"approver-changes-reviewed": { "value": "yes" },
"approver-moc-approved": { "value": "yes" },
"decline-reason": { "value": "" }
}
}
Approval path:
- MOC status advances to
"e"(Implementation) - Emails sent to originator, implementer, and HSEQ user
Decline path (approver-moc-approved === "no"):
- MOC status set to
"decline" - Creates decline object
- Notification emails sent
POST /api/submit/implementation
Submits the Implementation form (Part E). Handles completion, deviations, and extensions.
Authentication: Required (must be the assigned implementer)
File: src/app/api/submit/implementation/route.ts
Request body:
{
"moc_id": "...",
"implementation": {
"deviation-during-implementation": { "value": "no" },
"moc-require-extension": { "value": "no" },
"moc-circulated": { "value": "yes" },
"implementation-as-planned": { "value": "yes" },
"completion-date": { "value": "2026-03-15" }
}
}
Standard completion (no deviation, no extension):
- MOC status advances to
"f"(Verification) - Completion emails sent to all stakeholders
Deviation or extension requested:
- MOC status reverts to
"b" - Creates
extentionsAndDeviationstracking object on the MOC - Notification emails sent to approver and HSEQ user
POST /api/submit/deviation-extention
Marks a specific deviation or extension as resolved on a MOC.
Authentication: Required
File: src/app/api/submit/deviation-extention/route.ts
Request body:
{
"moc_id": "...",
"deviationExtentionId": "...",
"value": { ... },
"type": "deviation"
}
Type options: "deviation" or "extension"
When both deviation and extension (if applicable) are marked as resolved, the MOC automatically advances to status: "f".
POST /api/submit/verifier
Submits the Verification form (Part F). This is the final step that closes the MOC.
Authentication: Required (must be the assigned HSEQ user)
File: src/app/api/submit/verifier/route.ts
Request body:
{
"moc_id": "...",
"verifier_form": {
"action-plan-correct": { "value": "yes" },
"manuals-changed": { "value": "yes" },
"trainings-complete": { "value": "yes" },
"feedback-complete": { "value": "yes" },
"moc-effective": { "value": "yes" },
"close-moc": { "value": "yes" }
}
}
On submission:
- Creates or updates the verifier form document
- Sets MOC
status: "f"andcompleted: true - Sends completion emails to originator, implementer, HSEQ user, and approver
Status Transition Summary
| From | To | Trigger |
|---|---|---|
a | b | Originator assigns implementer |
b | c | Implementer approves (Part B) |
b | decline | Implementer declines |
c | d | HSEQ approves (Part C) |
c | b | HSEQ returns to implementer |
d | e | Approver approves (Part D) |
d | decline | Approver declines |
e | f | Implementation complete (Part E) |
e | b | Deviation or extension requested |
f | completed | Verifier closes MOC (Part F) |