Create Orders/Trackings
The Order API provides a comprehensive, idempotent endpoint for managing order and tracking data in the parcelLab system.
This API allows you to create new orders, update existing orders, add shipment trackings, cancel trackings, and manage partial line item cancellations.
Endpoint Details
Method:
PUTPath:
/v4/track/orders/Full URL:
https://product-api.parcellab.com/v4/track/orders/Authentication: Header
Authorization: Parcellab-API-Token <token>
This endpoint is idempotent, meaning you can safely call it multiple times with the same data without creating duplicate orders. If an order exists, it will be updated; if not, it will be created.
Authentication
Use the Authorization header with this format:
Authorization: Parcellab-API-Token <token>
API tokens can be created at https://app.parcellab.com/service/account/apitoken/. For PUT /v4/track/orders/, the token must include at least the write scope. Make sure to use the API token (non-encoded version, not the encoded token).
Error Handling
The API returns standard HTTP status codes:
200 OK- Order successfully updated201 Created- New order created400 Bad Request- Invalid request data401 Unauthorized- Missing or invalid authentication403 Forbidden- Insufficient permissions404 Not Found- Order not found (for GET requests)
Validation Errors
{
"errors": [
{
"detail": "Cannot cancel 3 of item ITEM-001. Only 2 available.",
"attr": "mutations.0.line_items.0.quantity_to_cancel",
"code": "invalid"
}
],
"type": "validation_error"
}Mutation Results
Each mutation includes a result indicating success or failure:
{
"mutations": [
{
"type": "change_line_item_quantity",
"result": {
"success": true,
"message": "Successfully cancelled items: ITEM-001"
}
}
]
}Best Practices
Use Idempotent Updates: The
PUTendpoint is idempotent. Use it for both creation and updates to avoid duplicates.Partial Updates: Only send the fields you want to update. The API merges changes with existing data.
Order Identification: Use either
order_number+accountorexternal_idto identify orders. When creating new orders,external_idis generated by parcelLab and returned in the response.Tracking Identification: Trackings require either
tracking_number+courierorexternal_reference.Validate Line Item Quantities: Before cancelling, ensure the requested quantity doesn't exceed available quantity.
Use Mutations for Actions: Use mutations for adding trackings or cancelling items rather than direct field updates.
Tags: You can set tags on a tracking to identify custom attributes in filters and exports. For example:
tags: ["loyalty_customer", "customer_loyalty:gold", "international_order", "dropship"].
Data Models
Order Schema
For upserts, send only the fields you want to set or update.
Recommended fields to send
account
integer
Always
Required
order_number
string
Create + most updates
Primary external reference in most integrations.
destination_country_iso3
string
Create
Required on create.
recipient_email
string
Create
Required on create.
recipient_name
string
Recommended
Useful for notifications and lookup UX.
client_key
string
Recommended
Important for multi-brand/multi-shop accounts.
shipping_address
AddressSchema
Recommended
Strongly recommended if available.
billing_address
AddressSchema
Optional
Useful if billing and shipping differ.
language_iso2
string
Recommended
Enables localized communication.
timezone
string
Optional
Helps communication timing.
delivery_method
string
Optional
Must be configured in system.
articles_order
LineItemOrder[]
Recommended
Needed for line-item-level mutations and visibility.
external_reference
string
Optional
Retailer internal order reference.
customer_number
string
Optional
Retailer customer identifier.
invoice_number
string
Optional
Invoice reference.
payment_method
string
Optional
Payment method.
order_currency
string
Optional
ISO 4217
order_total_amount
decimal
Optional
Order total.
order_tax_amount
decimal
Optional
Tax amount.
order_net_amount
decimal
Optional
Net amount.
order_discount_amount
decimal
Optional
Discount amount.
order_date
datetime
Optional
Order creation timestamp.
channel
string
Optional
Sales channel.
announced_delivery_date_min
date
Optional
Earliest expected delivery.
announced_delivery_date_max
date
Optional
Latest expected delivery.
tags
string[]
Optional
For filtering/export.
additional_attributes
AdditionalAttribute[]
Optional
Custom attributes.
mutations
Mutation[]
Optional
Use for tracking and line-item changes.
Generated/returned by parcelLab
external_id(UUID): generated by parcelLab on create.mutations[].operation_id(UUID): generated if not provided.mutations[].result: populated in responses with per-mutation processing status.
Line Item Order Schema
Represents individual products in articles_order.
Recommended fields to send
line_item_id
string
Required identifier for mutations.
quantity
integer
Ordered/open quantity.
sku
string
Recommended
product_id
string
Recommended
variant_id
string
Recommended when variants exist.
article_name
string
Recommended for portal display.
article_category
string
Optional
article_store_url
string
Optional
article_image_url
string
Optional
unit_price
decimal
Optional
tags
string[]
Optional
additional_attributes
AdditionalAttribute[]
Optional
Tracking Schema
Represent an individual shipment, package or parcel used to fulfill (parts of) an order.
Recommended fields to send
tracking_number + courier
string + string
Primary tracking identifier pair.
external_reference
string
Alternative identifier where applicable.
articles
LineItem[]
Recommended for shipment-level line-item mapping.
destination_country_iso3
string
Recommended
recipient_postal_code
string
Recommended when full address is not sent.
shipping_address
AddressSchema
Recommended if tracking-level address differs.
courier_service_level
string
Optional
warehouse
string
Optional
origin_country_iso3
string
Optional
origin_postal_code
string
Optional
announced_delivery_date
date
Optional ETA communication.
announced_send_date
date
Optional
delivery_method
string
Optional
shipping_cost_total
decimal
Optional
shipping_weight_total
float
Optional
shipping_weight_unit
string
Optional
requires_signature
boolean
Optional
is_return
boolean
Optional
flags
string[]
Optional
tags
string[]
Optional
additional_fields
object
Optional custom payload.
Generated/managed by parcelLab
cancelled_datecan be set by parcelLab when acancel_trackingmutation is processed.
Additional Data
parcelLab in general allows you to send additional attributes with custom data. For full data-element definitions, refer to the following page.
Data ModelMutations
Mutations allow you to perform actions on orders.
AddOrUpdateTrackingMutation
Adds or updates a tracking of an order. Update an existing tracking by running this mutation and using the same values for keys courier and tracking_number, as the combined value of those fields are idempotent.
ChangeLineItemQuantityMutation
Cancel individual quantity of an order line item. Quantities already assigned to a tracking are considered fulfilled and cannot be cancelled anymore.
ReplaceLineItemMutation
Replaces a line item with another line item. To cancel a line item, replace it with a quantity: 0 line item.
Typical Use Cases for OMS and WMS Integration
You can use the Order API to update parcelLab about all updates on the order from placement to cancellation or fulfillment.
Integration Flow
Order Placement: Create the order with all known information
Cancellations: Handle partial or full cancellations as needed
Fulfillment: Add trackings as items ship
Delivery: System automatically updates based on carrier events (outside of this API)
Sample Mutations
Cancel Line Items (Partial Cancellation)
This allows cancelling specific quantities of line items at the order level:
Request:
Notes on Line Item Cancellation:
Cancellations are tracked at the order level in
articles_orderThe system validates quantity constraints (including shipped quantity guards)
When line items are cancelled, updates are sent to all trackings in the order
Line item mutation metadata is stored on the item (for example
status,original_quantity,change_reason,updated_at)
OMS Mixed Status Example (2 Cancelled, 3 Shipped, 1 Remaining)
Scenario:
order_number:OMS-100045Line
LINE-1was ordered with quantity6OMS then cancels
2FedEx ships
31remains open/backordered for later shipment
Step 1: Create the order (minimal but valid create payload):
Step 2: OMS partial cancellation (6→4) using change_line_item_quantity:
Step 3: First FedEx shipment (3 units) using add_tracking:
Step 4: Remaining quantity (1) is implicit.
No additional mutation is required to represent "not yet shipped/backordered". At this point:
Ordered/open quantity for
LINE-1is4Shipped quantity recorded across trackings is
3Remaining not-yet-shipped quantity is
1
Step 5a (later): If the remaining 1 ships, send another add_tracking:
Step 5b (alternative): If the remaining 1 is cancelled instead of shipped:
Last updated
Was this helpful?