Manufacturing and Production API Quickstart Guide
Welcome to the Stateset Manufacturing and Production Quickstart Guide. This document provides developers and technical users with instructions for utilizing the Stateset API to manage core manufacturing processes. Learn how to configure your environment, model production data (Products, BOMs), plan and execute production runs (Work Orders, Manufacturing Orders), and manage associated inventory movements. Following this guide will enable you to integrate Stateset into your manufacturing workflows, enhancing operational efficiency, data accuracy, and cost control.Table of Contents
- Introduction
- Prerequisites
- Getting Started: SDK Setup
- Core Manufacturing Concepts
- API Workflow: End-to-End Manufacturing Process
- Optimizing Manufacturing Processes with API Data
- Real-Time Monitoring and System Integration
- Error Handling and Logging Strategies
- Troubleshooting Common Manufacturing API Issues
- Support Resources
- Conclusion
Introduction
Stateset offers a comprehensive API designed to manage the complexities of modern manufacturing operations. This guide focuses on the practical application of the API for common workflows, including defining manufacturable items, planning production schedules, tracking execution progress, and maintaining accurate inventory records. By leveraging the Stateset API, you can automate processes, improve data visibility, and enable data-driven optimization. Key Learning Objectives:- Configure the Stateset Node.js SDK for secure API interaction.
- Understand fundamental manufacturing entities within Stateset (Products, BOMs, WOs, MOs, Inventory).
- Utilize API endpoints to create, update, and manage manufacturing data throughout the production lifecycle.
- Identify opportunities to use API data for process optimization (e.g., OEE, waste analysis).
- Implement robust error handling and logging for reliable integration.
Prerequisites
- Node.js (version 16 or higher recommended).
- An active Stateset account and a generated API Key with appropriate permissions for manufacturing resources.
- Basic understanding of Javascript (
async
/await
), REST APIs, and JSON data structures. - Familiarity with core manufacturing concepts (BOMs, Work Orders, Inventory Management).
Getting Started: SDK Setup
Ensure your development environment is configured to interact with the Stateset API.1. Install the Stateset Node.js SDK
Add the official SDK package to your Node.js project using npm or yarn.2. Securely Configure API Key
Store your Stateset API key securely, preferably using environment variables. Avoid embedding keys directly in source code.3. Initialize the Stateset Client
Instantiate the SDK client in your application code, providing the API key.Core Manufacturing Concepts
Understanding these entities within the Stateset context is crucial for effective API usage.- Product: Represents a distinct item that can be manufactured or sold (e.g., finished good, subassembly). Identified by attributes like
sku
,name
. - Bill of Materials (BOM): Defines the “recipe” for manufacturing a specific
Product
. Lists requiredcomponents
(other Products or raw materials identified byitem_id
) and theirquantity
andunit
of measure. Often version-controlled. - Work Order (WO): An authorization to produce a specific
quantity
of aProduct
by a certain date. References the relevantBOM
and specifies production details likepriority
and targetsite
. Acts as the high-level production plan. - Manufacturing Order (MO): Represents the execution of a
Work Order
or a portion of it. Tracks the actual production run, including start/end times,status
(e.g.,planned
,in_progress
,completed
), resources used, and materials consumed. It’s the operational record of production. Often linked back to the sourceWork Order
viawork_order_id
. - Picks: The operational task of retrieving specific
inventory_item_id
s (representing actual stock) from storage locations to fulfill the material requirements of anMO
. Tracks requested vs. picked quantities. - Inventory (
inventory_item_id
vsitem_id
/part_number
):item_id
orpart_number
: Represents the type of item (e.g., ‘RESISTOR-10K’). Corresponds to aProduct
or raw material definition.inventory_item_id
(or similar concept): Represents a specific batch/lot/instance of that item in stock, often with its own location, quantity, and cost layer. Picks operate on these specific inventory units. Inventory movements update the quantity of specificinventory_item_id
s.
- Cycle Counts: Periodic verification of physical inventory quantities against system records (
inventory
resource) to ensure data accuracy. - Waste & Scrap: Records materials consumed during production that did not become part of the finished good, enabling analysis of production efficiency.
- Machines: Represents production equipment. Tracking usage (
logRuntime
) andMaintenance
is vital for OEE and reliability. - Kitting: Process of pre-assembling components into a single kit (
item_id
) for easier consumption during final assembly. Managed via BOMs and Inventory.
API Workflow: End-to-End Manufacturing Process
This section demonstrates using the Stateset API to manage a typical manufacturing flow.Step 1: Defining Products and Bills of Materials (BOMs)
Establish the foundation by defining what you manufacture and how.A. Create a Product
Define the item to be manufactured.sku
or id
will be used to link BOMs and Orders.
B. Create a Bill of Materials (BOM)
Define the components required to make the Product.item_id
for components refers to other Product
SKUs or raw material identifiers.
Step 2: Planning Production (Work Orders)
Authorize and schedule production runs.A. Create a Work Order
Generate an order to produce a specific quantity of a Product.Step 3: Executing Production (Manufacturing Orders & Activities)
Track the actual manufacturing process based on the planned Work Order.A. Create a Manufacturing Order
Initiate the tracking for the actual production run, linking it to the Work Order.B. Track Production Activities (Machine Time, Waste)
Record resource usage and material losses during the MO execution.C. Complete the Manufacturing Order
Mark the production run as finished and record the output quantity.Step 4: Managing Inventory Movements (Picks, Consumption, Receipts)
Accurately track materials moving into, through, and out of production.A. Create and Complete Picks
Manage the process of retrieving components from inventory for the MO.inventory_item_id
(specific stock) and item_id
(general part number) is vital here.
B. Record Finished Goods Receipt (Implied/Separate Step)
Increase inventory for the product manufactured upon MO completion. This might be an automatic side-effect ofcompleteManufacturingOrder
or require a separate inventory transaction.
unit_cost
for these finished goods is a critical accounting step often involving cost roll-ups from the MO.
Step 5: Maintaining Inventory Accuracy (Cycle Counts)
Ensure inventory data remains accurate through regular checks.A. Schedule and Record Cycle Counts
Initiate and record the results of periodic inventory counts.Optimizing Manufacturing Processes with API Data
The data captured via the Stateset API is invaluable for process improvement. Analyze this data to:- Calculate Overall Equipment Effectiveness (OEE): Use machine runtime logs (
logMachineRuntime
), MO planned vs. actual times, and MOquantity_completed
vs.quantity_planned
(considering scrap) to measure Availability, Performance, and Quality.- Availability = Actual Runtime / Planned Production Time
- Performance = (Ideal Cycle Time * Total Pieces Produced) / Actual Runtime
- Quality = Good Pieces (Completed Qty - Scrap Qty) / Total Pieces Produced
- OEE = Availability * Performance * Quality
- Analyze Waste and Scrap: Aggregate
wasteAndScrap
records by reason code, item, machine, or operator to identify root causes of material loss and target areas for process improvement or training. - Optimize Production Scheduling: Analyze historical MO completion times, lead times derived from WO/MO dates, and resource (machine/labor) utilization data to improve future scheduling accuracy and resource allocation.
- Implement Predictive Maintenance: Analyze machine runtime hours, cycle counts, and potentially sensor data (if integrated) to predict maintenance needs before failures occur, reducing unplanned downtime.
- Refine BOM Accuracy: Compare actual component consumption (derived from completed Picks and adjusted for scrap) against theoretical BOM quantities to identify inaccuracies in the Bill of Materials.
Real-Time Monitoring and System Integration
Leverage real-time data flow for operational visibility and system synchronization.- Webhooks: Configure Stateset Webhooks to receive real-time notifications for critical manufacturing events. Examples:
manufacturingorder.completed
: Trigger downstream processes like FG inventory receipt, shipping notifications, or ERP updates.inventory.quantity.low
: Alert purchasing or planning when component stock drops below a threshold.pick.completed
: Update shop floor dashboards or trigger material movement confirmations.machine.status.changed
: Monitor equipment state changes for immediate visibility.
- Dashboarding: Feed API data (MO status, queue lengths, OEE metrics, waste levels) into Business Intelligence (BI) tools or custom dashboards for real-time operational monitoring by supervisors and managers.
- ERP/MES Integration: Synchronize Stateset data (inventory levels, WO/MO status, costs) with your primary ERP or Manufacturing Execution System (MES) to maintain data consistency across platforms. Use the API for bi-directional updates where appropriate.
Error Handling and Logging Strategies
Implement robust error handling and logging for reliable manufacturing system integration.- Specific API Error Handling: Catch errors from SDK calls. Inspect
error.response.status
(HTTP status code) anderror.response.data
(API error details) to determine the cause (e.g., 400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Rate Limited, 5xx Server Error). - Input Validation: Validate data before making API calls to prevent unnecessary errors (check required fields, data types, formats).
- Retry Logic: Implement exponential backoff strategies for transient errors (e.g., 429, 503). Do not retry client errors (4xx) without correcting the request.
- Idempotency: For critical operations like creating orders or inventory movements, utilize idempotency keys if supported by the API, or implement application-level checks to prevent duplicate transactions.
- Centralized Logging: Log detailed information for both successful operations and errors (timestamp, operation name, input identifiers, outcome, error message, stack trace, API response details) to a dedicated logging service (e.g., Datadog, Splunk, ELK Stack) for monitoring, alerting, and debugging.
- Transactionality (Application Level): For multi-step workflows (e.g., completing MO -> receiving FG inventory), consider application-level patterns (like sagas or compensating transactions) to handle failures gracefully if the API doesn’t support atomic transactions across multiple calls.
Troubleshooting Common Manufacturing API Issues
Address frequent problems encountered when integrating manufacturing workflows.- Authentication Errors (401/403):
- Solution: Verify API key validity, environment variable loading, and key permissions for manufacturing-related resources (
product
,workorder
,inventory
, etc.).
- Solution: Verify API key validity, environment variable loading, and key permissions for manufacturing-related resources (
- Not Found Errors (404):
- Solution: Double-check IDs used in requests (
productId
,bomId
,woId
,moId
,inventory_item_id
). Ensure the referenced resource exists and hasn’t been deleted. Check for typos.
- Solution: Double-check IDs used in requests (
- Validation Errors (400):
- Solution: Examine
error.response.data
for details. Confirm required fields are present, data types match API expectations (number vs. string), dates are in ISO 8601 format, and enum values (status
,type
) are valid. Check quantity/unit consistency.
- Solution: Examine
- Inventory Discrepancies:
- Solution: Audit the workflow logic: Are picks correctly deducting inventory? Is waste recording linked to an inventory adjustment? Are FG receipts correctly adding inventory? Use Cycle Counts to identify and investigate differences. Ensure correct
inventory_item_id
s are used.
- Solution: Audit the workflow logic: Are picks correctly deducting inventory? Is waste recording linked to an inventory adjustment? Are FG receipts correctly adding inventory? Use Cycle Counts to identify and investigate differences. Ensure correct
- Incorrect Production Costs:
- Solution: Verify component costs used in calculations. Ensure labor and overhead tracking/allocation logic is correct. Check BOM accuracy. Confirm waste quantities are factored in appropriately.
- Race Conditions/Concurrency Issues:
- Solution: If multiple processes might update the same resource (e.g., inventory quantity), use optimistic locking mechanisms (if supported by API via ETags/versions) or structure workflows to minimize concurrent updates on the same item. Ensure idempotency for creation events.
Support Resources
Consult these resources for additional help and information:- API Documentation: docs.stateset.com/api (Verify and update link)
- Developer Community/Forum: community.stateset.io (Verify and update link)
- Support Contact: support@stateset.com (Verify and update email)
- Tutorials & Examples: learn.stateset.io (Verify and update link)