box-heartCreate 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: PUT

  • Path: /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.

chevron-rightkey Authenticationhashtag

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).

chevron-rightbug Error Handlinghashtag

The API returns standard HTTP status codes:

  • 200 OK - Order successfully updated

  • 201 Created - New order created

  • 400 Bad Request - Invalid request data

  • 401 Unauthorized - Missing or invalid authentication

  • 403 Forbidden - Insufficient permissions

  • 404 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

  1. Use Idempotent Updates: The PUT endpoint is idempotent. Use it for both creation and updates to avoid duplicates.

  2. Partial Updates: Only send the fields you want to update. The API merges changes with existing data.

  3. Order Identification: Use either order_number + account or external_id to identify orders. When creating new orders, external_id is generated by parcelLab and returned in the response.

  4. Tracking Identification: Trackings require either tracking_number + courier or external_reference.

  5. Validate Line Item Quantities: Before cancelling, ensure the requested quantity doesn't exceed available quantity.

  6. Use Mutations for Actions: Use mutations for adding trackings or cancelling items rather than direct field updates.

  7. 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.

chevron-rightGenerated/returned by parcelLabhashtag
  • 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.

chevron-rightGenerated/managed by parcelLabhashtag
  • shipped_quantity

  • original_quantity

  • status

  • change_reason

  • updated_at

Tracking Schema

Represent an individual shipment, package or parcel used to fulfill (parts of) an order.

chevron-rightGenerated/managed by parcelLabhashtag
  • cancelled_date can be set by parcelLab when a cancel_tracking mutation is processed.

chevron-rightExample tracking payload as JSONhashtag

Additional Data

parcelLab in general allows you to send additional attributes with custom data. For full data-element definitions, refer to the following page.

disc-driveData Modelchevron-right

Mutations

Mutations allow you to perform actions on orders.

chevron-rightAddOrUpdateTrackingMutationhashtag

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.

chevron-rightCancelTrackingMutationhashtag

Cancel a tracking by identifying it by its courier and tracking_number.

chevron-rightChangeLineItemQuantityMutationhashtag

Cancel individual quantity of an order line item. Quantities already assigned to a tracking are considered fulfilled and cannot be cancelled anymore.

chevron-rightAddLineItemMutationhashtag

Adds a line item to an order.

chevron-rightReplaceLineItemMutationhashtag

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

  1. Order Placement: Create the order with all known information

  2. Cancellations: Handle partial or full cancellations as needed

  3. Fulfillment: Add trackings as items ship

  4. Delivery: System automatically updates based on carrier events (outside of this API)

Sample Mutations

chevron-rightfile-circle-plus Create a New Orderhashtag

Request:

Response:

chevron-rightfile-pen Update an Existing Orderhashtag

Only send the fields you want to update:

Request:

chevron-rightbox-circle-check Add Tracking to an Orderhashtag

Request:

chevron-rightfile-circle-xmark Cancel a Trackinghashtag

Request:

chevron-rightcart-circle-xmark Cancel Line Items (Partial Cancellation)hashtag

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_order

  • The 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)

chevron-rightconveyor-belt-boxes Complex Multi-Operation Updatehashtag

You can combine multiple operations in a single request:

Request:

chevron-rightboxes-packing OMS Mixed Status Example (2 Cancelled, 3 Shipped, 1 Remaining)hashtag

Scenario:

  • order_number: OMS-100045

  • Line LINE-1 was ordered with quantity 6

  • OMS then cancels 2

  • FedEx ships 3

  • 1 remains open/backordered for later shipment

Step 1: Create the order (minimal but valid create payload):

Step 2: OMS partial cancellation (64) 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-1 is 4

  • Shipped quantity recorded across trackings is 3

  • Remaining 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:

chevron-rightcart-circle-exclamation Other Minimal Mutation Payloads (Same order_number Pattern)hashtag

Add a line item:

Replace a line item (substitution):

Cancel an existing tracking (e.g., label voided):

Last updated

Was this helpful?