Orders Integration Guide
This guide explains how to integrate the Order system. An order represents a confirmed customer order containing line items (articles), delivery tracking, and billing information.
Quick Start
Section titled “Quick Start”Essential Workflow
Section titled “Essential Workflow”- Create Order:
POST /orderswith company, project, and initial items - Add Items:
POST /order-itemsto add articles to the order - Track Delivery: Update
trackingId,expectedDeliveryDate, andactualDeliveryDate - Monitor Status: Track order state through status workflow (e.g., pending → processing → shipped → delivered)
- Sync to ERP: Use
externalIdfield for bidirectional synchronization with ERP systems
Key Endpoints
Section titled “Key Endpoints”| Endpoint | Returns | Use Case |
|---|---|---|
POST /orders | Order | Create customer order |
GET /orders/:id | Complete order + items | Get all order data |
POST /order-items | OrderItem | Add line item to order |
GET /orders | Order list | List orders with filtering |
PATCH /orders/:id | Updated order | Update order details |
Core Entities Overview
Section titled “Core Entities Overview”1. Order
Section titled “1. Order”Root entity representing a confirmed customer order with billing and delivery tracking.
Key Properties: id, externalId, billedAmount, trackingId, orderDate, expectedDeliveryDate, actualDeliveryDate
Status Tracking:
- Orders can have customizable statuses (e.g., pending, processing, shipped, delivered, cancelled)
- Status workflow managed via Status entity
Main Relationships:
items→ OrderItem[] (One-to-Many, required)company→ Company,project→ Projectstatus→ Status,currency→ CurrencyshippingAddress→ Address,createdBy→ Userfiles→ File[],comments→ Comment[],customFields→ CustomFieldValue[]
2. OrderItem
Section titled “2. OrderItem”Line item within an order, typically references catalog articles.
What It Contains:
- Product Reference: Links to Article for product details
- Pricing: Unit price, quantity, total price
- Units: Measurement unit (kg, m, pcs, etc.)
- Hierarchy: Parent-child relationships for complex order structures
Item Types:
- Article: References a predefined catalog product (primary use case)
- Article may be linked to a BriefElement for manufacturing specifications
- Article may exist as standalone inventory item
Hierarchical Structure:
OrderItems can be structured hierarchically for complex orders:
- Parent OrderItem → Represents a grouped product or kit
- Children OrderItems → Individual components within the group
Example structure:
Order └── OrderItem (parent) → Product Bundle ├── OrderItem (child) → Component A ├── OrderItem (child) → Component B └── OrderItem (child) → Component C └── OrderItem → Standalone ProductKey Properties: id, orderId, articleId, quantity, unitPrice, totalPrice, unit, position
Main Relationships:
order→ Order (Many-to-One)article→ Article (Many-to-One)parent/children→ OrderItem (for hierarchical items)createdBy→ User,comment→ Comment
3. Article
Section titled “3. Article”Predefined product that can be added to orders, linked to production specifications.
What It Contains:
- Product Details: Name, code, description, pricing
- Inventory: Stock status and quantity
- Production Specs: Link to BriefElement for manufacturing details
- ERP Integration: External ID for synchronization
Key Properties: id, code, name, price, stocked, quantity, briefElementId, externalId
Main Relationships:
company→ Company (Many-to-One, required)briefElement→ BriefElement (Many-to-One)orderItems→ OrderItem[] (One-to-Many)quoteItems→ QuoteItem[] (One-to-Many)files→ File[] (preview, CAD files, documents)
Entity Relationships
Section titled “Entity Relationships”Company → Project → Order → OrderItem → Article → BriefElementKey Relationships:
Section titled “Key Relationships:”- Order Structure: Company → Project → Order → OrderItems
- Product Reference: OrderItem → Article → BriefElement (for manufacturing specs)
- Hierarchical Orders: OrderItem → Parent/Children OrderItems
- ERP Sync: Orders and Articles use
externalIdfor external system integration
API Endpoints
Section titled “API Endpoints”Order Management
Section titled “Order Management”Create Order
Section titled “Create Order”Creates a new order with company, project, and billing information.
Request Example:
{ "companyId": "uuid-company", "projectId": "uuid-project", "statusId": "uuid-status", "billedAmount": 1500.00, "currencyId": "uuid-currency", "orderDate": "2024-01-15T10:00:00Z", "expectedDeliveryDate": "2024-02-15T10:00:00Z", "shippingAddressId": "uuid-address", "externalId": "ERP-ORDER-12345"}Response: Order entity with id and timestamps
Get Order with Items
Section titled “Get Order with Items”Retrieves complete order information including all line items.
Response Example:
{ "id": "uuid-order", "externalId": "ERP-ORDER-12345", "billedAmount": 1500.00, "trackingId": "TRACK-123456", "orderDate": "2024-01-15T10:00:00Z", "expectedDeliveryDate": "2024-02-15T10:00:00Z", "actualDeliveryDate": null, "company": { "id": "uuid", "name": "Acme Corp" }, "project": { "id": "uuid", "name": "Q1 Production" }, "status": { "id": "uuid", "internalLabel": "Processing" }, "items": [ { "id": "uuid-item-1", "articleId": "uuid-article", "quantity": 1000, "unitPrice": 1.50, "totalPrice": 1500.00, "unit": "pcs", "position": 1, "article": { "id": "uuid-article", "code": "ART-001", "name": "Custom Box" } } ]}OrderItem Management
Section titled “OrderItem Management”Add Order Item
Section titled “Add Order Item”Adds a new line item to an existing order.
Request Example:
{ "orderId": "uuid-order", "articleId": "uuid-article", "quantity": 500, "unitPrice": 2.00, "totalPrice": 1000.00, "unit": "pcs", "position": 2}Response: Created OrderItem entity
Update Order Item
Section titled “Update Order Item”Updates an existing order item (quantity, pricing, etc.).
Order Queries
Section titled “Order Queries”List Orders
Section titled “List Orders”Retrieves orders with filtering and pagination.
Query Parameters:
page: Page number (default: 1)limit: Items per page (default: 10)companyId: Filter by companyprojectId: Filter by projectstatusId: Filter by status (comma-separated for multiple)externalId: Filter by ERP external IDorderDateStart,orderDateEnd: Filter by order date rangeexpectedDeliveryDateStart,expectedDeliveryDateEnd: Filter by expected deliveryactualDeliveryDateStart,actualDeliveryDateEnd: Filter by actual deliverysort: Sort field (e.g.,orderDate,updatedAt)order: Sort direction (ASCorDESC)
Example Request:
GET /orders?companyId=uuid&statusId=uuid-processing,uuid-shipped&page=1&limit=50&sort=orderDate&order=DESCWorkflow Examples
Section titled “Workflow Examples”Example 1: Create Order from Existing Articles
Section titled “Example 1: Create Order from Existing Articles”Scenario: Create an order for existing catalog products.
// 1. Create OrderPOST /orders{ "companyId": "company-uuid", "projectId": "project-uuid", "billedAmount": 0, "orderDate": "2024-01-15T10:00:00Z", "expectedDeliveryDate": "2024-02-15T10:00:00Z"}
// Response: { "id": "order-uuid", ... }
// 2. Add Order ItemsPOST /order-items{ "orderId": "order-uuid", "articleId": "article-1-uuid", "quantity": 1000, "unitPrice": 1.50, "totalPrice": 1500.00, "unit": "pcs"}
POST /order-items{ "orderId": "order-uuid", "articleId": "article-2-uuid", "quantity": 500, "unitPrice": 2.00, "totalPrice": 1000.00, "unit": "pcs"}
// 3. Update Order with Total Billed AmountPATCH /orders/order-uuid{ "billedAmount": 2500.00}Example 2: ERP Synchronization
Section titled “Example 2: ERP Synchronization”Scenario: Sync orders between ERP and Packitoo.
// 1. Create Order with ERP ReferencePOST /orders{ "companyId": "company-uuid", "projectId": "project-uuid", "externalId": "ERP-ORDER-12345", "billedAmount": 3500.00, "orderDate": "2024-01-15T10:00:00Z"}
// 2. Query Orders by ERP IDGET /orders?externalId=ERP-ORDER-12345
// 3. Update Delivery Tracking from ERPPATCH /orders/order-uuid{ "trackingId": "TRACK-987654", "actualDeliveryDate": "2024-02-14T14:30:00Z"}Example 3: Hierarchical Order Items
Section titled “Example 3: Hierarchical Order Items”Scenario: Create an order with grouped items (e.g., product kits).
// 1. Create OrderPOST /orders{ "companyId": "company-uuid", "projectId": "project-uuid", "billedAmount": 5000.00}
// 2. Create Parent Item (Product Kit)POST /order-items{ "orderId": "order-uuid", "articleId": "kit-article-uuid", "quantity": 100, "unitPrice": 50.00, "totalPrice": 5000.00, "unit": "kits"}// Response: { "id": "parent-item-uuid", ... }
// 3. Create Child Items (Kit Components)POST /order-items{ "orderId": "order-uuid", "parentId": "parent-item-uuid", "articleId": "component-a-uuid", "quantity": 100, "position": 1}
POST /order-items{ "orderId": "order-uuid", "parentId": "parent-item-uuid", "articleId": "component-b-uuid", "quantity": 200, "position": 2}Integration Best Practices
Section titled “Integration Best Practices”1. Status Management
Section titled “1. Status Management”- Configure custom statuses for your order workflow
- Common workflow: Pending → Processing → Shipped → Delivered
- Handle edge cases: Cancelled, On Hold, Backordered
2. ERP Synchronization
Section titled “2. ERP Synchronization”- Use
externalIdto maintain bidirectional sync with ERP systems - Store ERP order ID in
externalIdfield - Query by
externalIdto avoid duplicate orders - Sync delivery tracking and status updates
3. Delivery Tracking
Section titled “3. Delivery Tracking”- Set
orderDatewhen order is placed - Set
expectedDeliveryDatebased on production and shipping estimates - Update
trackingIdwhen shipment is created - Set
actualDeliveryDatewhen delivery is confirmed
4. Pricing and Currency
Section titled “4. Pricing and Currency”- Set
billedAmountto match total of all order items - Use
currencyIdto specify billing currency - Ensure
OrderItem.totalPrice = quantity * unitPrice
5. Address Management
Section titled “5. Address Management”- Link
shippingAddressIdfor delivery tracking - Ensure address is valid and complete before order creation
- Consider storing address snapshot to preserve historical data
Related Resources
Section titled “Related Resources”- Brief Integration Guide - Creating product configurations
- Quote Integration Guide - Converting quotes to orders
- Article Entity - Product catalog management
- Company Entity - Customer management
- Project Entity - Project organization