Shop-Floor MES and ERP Sync API Specification
Define transactional, idempotent event-driven APIs connecting core ERP with plant-floor MES.
Use this template when building mission-critical backend interfaces between Enterprise Resource Planning (ERP) and Manufacturing Execution Systems (MES). It outputs a transactional API specification covering work orders, material tracking, and quality release gates.
Role: Staff Integration & Backend Engineer specializing in manufacturing transactional systems and mission-critical APIs.
Context
- Manufacturing Execution System: {{mes_core_engine}}
- Enterprise Resource Planning platform: {{erp_system_target}}
- Work order transaction volume: {{daily_work_order_volume}} orders/day
- Traceability standard: {{traceability_compliance_level}}
- State store for deduplication: {{idempotency_storage_backend}}
- Maximum sync retry budget: {{sync_failure_retry_limit}} attempts
Task
Author an enterprise-grade backend API specification for bidirectional synchronization between {{erp_system_target}} and {{mes_core_engine}}, guaranteeing exactly-once processing semantics for work orders, bills of materials, and production sign-offs.
Method
- Design the transactional outbox pattern to decouple event production in {{erp_system_target}} from consumption in {{mes_core_engine}}.
- Define the REST and gRPC service contracts for work order dispatch, material consumption, and yield reporting.
- Construct the idempotency key structure and distributed locking strategy using {{idempotency_storage_backend}}.
- Formulate the two-phase commit or saga orchestration workflow for handling split-line production order updates.
- Detail the audit logging schema required to satisfy {{traceability_compliance_level}}.
- Establish error categorization and dead-letter queue (DLQ) retry topologies capped at {{sync_failure_retry_limit}} retries.
- Specify compensation transactions for rollback scenarios when shop-floor execution fails quality validation.
- Outline API rate limiting, mutual authentication, and latency Service Level Objectives (SLOs).
Constraints
- MUST implement strictly idempotent endpoints using persistent correlation IDs.
- MUST NOT drop or reorder state transitions (Planned -> Released -> In-Progress -> Completed).
- Audit log payloads MUST be immutable and cryptographically signed to meet {{traceability_compliance_level}}.
- Response latency for line-side material scan endpoints MUST remain under 120ms at p99.
Output format
- System Interaction Sequence (step-by-step transaction sequence for order lifecycle)
- OpenAPI 3.1 & Protocol Buffer Endpoint Definitions (complete endpoint signatures and payload schemas)
- Idempotency & Concurrency Strategy (key layout, locking mechanics, deduplication window)
- Saga Orchestration & Rollback Matrix (state-by-state failure handling table)
- Compliance & Audit Enforcement Specification (payload hashing and audit fields)
Self-review
- Are all state transitions between {{erp_system_target}} and {{mes_core_engine}} covered with rollback compensation logic?
- Does the deduplication design prevent double-booking of materials under network retries up to {{sync_failure_retry_limit}}?
- Are regulatory mandates from {{traceability_compliance_level}} completely satisfied in the schema definitions?
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.