{
  "openapi": "3.0.3",
  "info": {
    "title": "PULPO WMS API - 3PL Integration (Single merchant)",
    "version": "4.4.0",
    "description": "# PULPO WMS API Documentation\nComplete API documentation for integrating with PULPO WMS as a 3PL fulfiller.\n\n## Overview\n\nThis API enables third-party logistics (3PL) providers to integrate with PULPO WMS for managing:\n- **Incoming processes**: Purchase orders, goods receipt, stock replenishment\n- **Outgoing processes**: Sales orders, picking, packing, shipping\n- **Inventory management**: Products, stock levels, kitting\n- **Master data**: Merchants, channels, third parties, warehouses\n\n## Key Concepts\n\n### Multi-tenant Architecture\n- **Tenant**: Your PULPO WMS account\n- **Merchant**: Your customers (in 3PL scenarios)\n- **Channel**: Sales channels for each merchant (e.g., Shopify, Amazon)\n- **Warehouse**: Physical warehouse locations\n\n### Authentication\n- OAuth 2.0 password grant flow\n- Tokens expire after 60 minutes\n- Store and reuse tokens to avoid rate limits\n\n### Rate Limits\n- Default: 60-300 calls per minute (tenant-based)\n- Handle 429 responses with exponential backoff\n- Use bulk endpoints when possible\n\n### Pagination\n- Offset-based pagination\n- Use `limit` (1-2000, default 10) and `offset` (default 0)\n- Use `capped_limit=0` for better performance (no total count)\n- Use `sort_by=id:asc` to avoid duplicate results\n\n### Webhooks\n- Subscribe to events for real-time updates\n- Webhook payloads include full event data\n- Configure retry logic for failed deliveries\n\n## Getting Started\n\n1. Authenticate using `/auth` endpoint\n2. Get your tenant and warehouse info from `/iam/users/me` and `/warehouses`\n3. Create master data: Products, Third Parties\n4. Subscribe to webhooks for order events\n5. Create Purchase Orders (incoming) or Sales Orders (outgoing)\n\n## Common Workflows\n\n### Incoming Process (Purchase Order)\n```\n1. POST /inventory/bulk/products (create products)\n2. POST /iam/bulk/third_parties (create suppliers)\n3. POST /reception/bulk/purchase_orders (create PO)\n4. Warehouse receives goods (via Android app)\n5. Webhook: purchase_order_finished (GR - Goods Receipt)\n6. Webhook: replenishment_order_finished (stock available)\n```\n\n### Outgoing Process (Sales Order)\n```\n1. POST /iam/bulk/third_parties (create customers)\n2. POST /sales/bulk/orders (create sales order)\n3. Warehouse picks items (via Android app)\n4. Webhook: packing_order_finished (PIC - Picking Complete)\n5. Warehouse packs items (via Android app)\n6. Webhook: sales_order_finished (PGI - Post Goods Issue)\n```\n\n## Support\n- Integration Guide: Version 4.4.0 (July 2024)\n- API Documentation: https://eu.pulpo.co/api/v1/swagger/index.html\n"
  },
  "servers": [
    {
      "url": "https://eu.pulpo.co/api/v1",
      "description": "Production EU"
    },
    {
      "url": "https://am.pulpo.co/api/v1",
      "description": "Production Americas"
    },
    {
      "url": "https://eu-show.pulpo.co/api/v1",
      "description": "Staging/Demo Environment"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "OAuth 2.0 authentication endpoints"
    },
    {
      "name": "User & Tenant",
      "description": "User and tenant information, and the tenant's **tags**.\n\n### Tags = product_categories\n\nWhat the PULPO apps (mobile and browser) call **tags** is called\n**`product_categories`** in the API. They are the same thing — only the name\ndiffers. Despite the name, they are not limited to products: a tag can be assigned\nto **products**, **users** and **warehouse locations**.\n\nCreate a tag once per tenant, then assign it by its **ID**:\n\n| Record | How to assign tags |\n|--------|--------------------|\n| Product | `product_categories: [ids]` in `POST` / `PUT /inventory/bulk/products` |\n| User | `product_categories: [ids]` in `POST /iam/users`, later `POST /iam/users/{id}/categories` |\n| Location | `product_categories: [ids]` in `POST /warehouses/locations` or `PUT /warehouses/locations/{id}` |\n\nIn every case the list **replaces** the record's tags and `[]` removes them all.\nSend tag IDs only — codes, objects, or a field called `tags` don't work.\n\nProducts and locations can be searched by tag with `product_categories=<id>`.\n\n**Locations — watch out:**\n- `PUT /warehouses/locations/{id}` **without** `product_categories` removes all of\n  the location's tags. Always resend them.\n- `POST /warehouses/locations/categories/assign`\n  (`{\"locations\": [ids], \"product_categories\": [ids]}`) **adds** tags instead of\n  replacing them, creates duplicates when repeated, and its result doesn't show\n  in `GET /warehouses/locations/{id}` (only in the location search). Prefer\n  `PUT /warehouses/locations/{id}`.\n"
    },
    {
      "name": "Warehouses",
      "description": "Warehouse management"
    },
    {
      "name": "Products",
      "description": "Product master data"
    },
    {
      "name": "Third Parties",
      "description": "Suppliers and customers"
    },
    {
      "name": "Purchase Orders",
      "description": "Incoming goods and purchase orders"
    },
    {
      "name": "Sales Orders",
      "description": "## Outgoing Orders and Fulfillment\n\nSales orders represent outgoing goods from the warehouse. They go through a defined\nstate machine from creation to completion.\n\n### Sales Order vs Fulfillment Order\n\nA **sales order** is the customer-facing order. A **fulfillment order** is the\nexecution unit inside the warehouse — typically there is one fulfillment order per\nsales order, but a sales order may be split into multiple fulfillment orders\n(e.g., partial fulfillment, multi-warehouse).\n\nPicking tasks operate on **fulfillment_order IDs**, not sales order IDs.\n\nThe `paused` state lives on the **fulfillment order** (`fulfillment_orders[0].state`).\nThe parent sales order remains in `state: queue` while a fulfillment order is paused.\nClients should derive the effective UI state as\n`fulfillment_orders[0].state || sales_order.state`.\n\n### Order State Flow\n\n```\nqueue ──→ picking ──→ packing ──→ shipping ──→ ended\n  │                                              ✗ (cannot cancel)\n  ├──→ paused (on FO) ──→ queue (resume)\n  │\n  ├──→ cancelled (from queue)\n  │\npicking ──→ cancelled (if packing locations available)\n  │\npacking ──→ cancelled\n```\n\n### State Descriptions\n\n| State | Description |\n|-------|-------------|\n| `queue` | Order created, waiting to be picked |\n| `picking` | Items are being picked in the warehouse |\n| `packing` | Items are being packed into boxes |\n| `shipping` | Packed and ready for shipment |\n| `ended` | Order fully fulfilled (Post Goods Issue / PGI) |\n| `paused` | Temporarily held — applied to the **fulfillment order**, not the sales order |\n| `cancelled` | Order cancelled — cannot cancel from `ended` |\n\n### Priority Levels\n\n| Value | Level |\n|-------|-------|\n| 1 | Low |\n| 2 | Normal |\n| 3 | High |\n| 4 | Top |\n\n### Common Filter Operators\n\nSales order list endpoints accept these operator-prefixed filter values:\n\n| Operator | Example | Meaning |\n|----------|---------|---------|\n| `between:` | `delivery_date=between:2024-03-01 00:00:00,2024-03-31 23:59:59` | Date range (inclusive) |\n| `gte:` / `lte:` | `inserted_at=gte:2024-03-01 00:00:00` | Greater/less than or equal |\n| `gt:` / `lt:` | `order_items_count=gt:5` | Strictly greater/less |\n| `to_list:` | `merchant_id=to_list:69,70,71` | Match any of the listed values |\n| `includes:` | `product_id=includes:123,456` | Order contains any of these products |\n| `contains:` | `order_num=contains:SO-2024` | Substring match |\n\nThe `to_list:` operator works on `merchant_id`, `priority`, `criterium`, and most\nID-style filters, not just `priority`.\n"
    },
    {
      "name": "Picking",
      "description": "## Picking Tasks\n\nA picking task corresponds to one warehouse picker walking the floor with a\ndevice. There are three picking strategies, all selectable when the task is\ncreated:\n\n| Strategy | Endpoint | Semantics |\n|----------|----------|-----------|\n| `single` | `POST /picking/bulk/orders` | One picking task **per** fulfillment_order |\n| `batch` | `POST /picking/orders` (`cart: false`) | One picking task grouping multiple fulfillment_orders |\n| `cart` | `POST /picking/orders` (`cart: true`) | Batch pick where each FO is placed in a separate cart slot |\n\nPicking task creation always operates on **fulfillment_order IDs**, not sales\norder IDs (see Sales Orders tag). Flatten `sales_order.fulfillment_orders[].id`\nbefore posting.\n\n### Picking Order States\n\n| State | Description |\n|-------|-------------|\n| `queue` | Created, awaiting a picker |\n| `taken` | Claimed by a picker |\n| `ended` | All items picked |\n| `mixed` | Partially picked — some lines remain |\n| `cancelled` | Cancelled, items returned to stock |\n\n### Insufficient Stock Errors\n\nBoth creation endpoints return a structured 400 (`/picking/bulk/orders`) or\n422 (`/picking/orders`) when a fulfillment_order has insufficient stock for one\nor more lines. See `PickingCreateError` schema. The `items[].insufficient_stock`\nstring identifies the failing product. The bulk endpoint additionally returns a\ntop-level `created[]` array with the picklists that were created.\n\nThe turbo label endpoints (`/picking/orders/turbo`, `/picking/bulk/orders/turbo`)\nare asynchronous: errors appear in the fulfillment order's `process_information`.\n"
    },
    {
      "name": "Packing",
      "description": "## Packing Tasks\n\nA packing task is created by the system after picking completes. One packer\nclaims a task and works through its packing boxes until the order is ready to\nship.\n\n### Packing Order State Machine\n\n```\nqueue ─accept─→ taken ─lock─→ locked\n                 │ ↑           │\n                 │ └─unlock────┘ (owner: → taken; non-owner: → queue)\n                 │\n                 └─finish─→ ended ─close─→ closed\n```\n\n| State | Description |\n|-------|-------------|\n| `queue` | Awaiting a packer |\n| `taken` | Owned by a packer (see `owner.id`) |\n| `locked` | Paused — kept by owner but not actively worked |\n| `ended` | All boxes closed and `/finish` was called |\n| `closed` | Final state — `/close` released the owner lock and assigned a shipping location |\n| `cancelled` | Cancelled (terminal) |\n\n### Ownership and \"one task at a time\"\n\nThe authoritative ownership signal is `owner.id` on the packing order. A user\nmay only own one active (`taken` or `locked`) packing order at a time — call\n`GET /iam/users/{id}/tasks` to discover the current owned task before opening\na new one. Paused (`locked`) tasks are NOT included in that endpoint's\nresponse — they are queryable via `GET /packing/orders?state=locked`.\n\nIf a non-owner calls `POST /unlock` on a `locked` task, the task transitions\nback to `queue` (not `taken`) — they must then call `POST /accept` to claim it.\n\n### Polling After Box Close\n\nAfter triggering label generation, clients should poll `GET /packing/orders/{id}`\nevery ~5 seconds until each closed box has an `attachments[]` entry (the label PDF\nURL) or `shipment_tracking.error_message` is set. The PULPO app gives up after\n~2 minutes; client integrations should use the same budget (24 attempts).\n\nThe label readiness signal is the presence of `attachments[0].url` on the packing\nbox — **not** solely `shipment_tracking.status`.\n"
    },
    {
      "name": "Label Provider Integration",
      "description": "## External Label Provider Integration\n\nFor integrations where an external system generates shipping labels (e.g., a carrier API or label service),\nPULPO WMS provides a dedicated workflow using webhooks and API endpoints.\n\n### Trigger Conditions\n\nLabel generation is triggered when **both** of these conditions are met:\n\n- **Option A:** `packing_order_finished` **AND** `turbo_label_packing_created`\n- **Option B:** `packing_box_closed` **AND** `turbo_label_packing_created`\n\nThe `turbo_label_packing_created` webhook indicates that PULPO WMS expects an external label provider\nto generate the label. Without this event, the packing events are informational only.\n\n### Integration Workflow\n\n```\n1. Subscribe to webhooks: packing_box_closed + turbo_label_packing_created\n2. Receive packing_box_closed (or packing_order_finished) webhook\n   → Extract: packing_order_id, box_id, shipment_tracking.id\n   → Extract: order_num, merchant_id, merchant_channel_id (for routing)\n3. PUT /packing/orders/{id}/boxes/{box_id}/shipment_tracking/{tracking_id}\n   → Set status: pulpowms_label_generation_started\n4. Generate label in your system using order/box data\n5. POST /packing/orders/{id}/boxes/{box_id}/attach\n   → Upload label PDF file\n6. PUT /packing/orders/{id}/boxes/{box_id}/shipment_tracking/{tracking_id}\n   → Set status: pulpowms_label_generated\n   → Include: tracking_code, tracking_url, carrier_code\n7. Webhook: shipment_tracking_updated fires (confirms label attached)\n```\n\n### Timing\n\nThe PULPO app waits **up to 2 minutes** for a label after box closure.\nIf no label is generated within this time, the packer must wait or skip.\n\n### Shipment Tracking Status Flow\n\n| From | To | Meaning |\n|------|----|---------|\n| `null` | `pulpowms_label_generation_started` | Label generation in progress |\n| `pulpowms_label_generation_started` | `pulpowms_label_generated` | Success — tracking info available |\n| `pulpowms_label_generation_started` | `pulpowms_label_generation_failed` | Failure — see error_message |\n| `null` | `pulpowms_label_not_required` | Skip label for this box |\n\n### Key Webhook Fields\n\nWhen processing `packing_box_closed` or `packing_order_finished` webhooks:\n\n| Field | Description |\n|-------|-------------|\n| `data.sales_order_id` | Unique sales order ID in PULPO |\n| `data.sales_order.order_num` | External order number (customer side) |\n| `merchant_id` / `merchant_channel_id` | For routing to the correct carrier/service |\n| `packing_boxes[].shipment_tracking.id` | Tracking ID needed for PUT calls |\n| `packing_boxes[].packing_box_items` | Items in the box (product, quantity, SKU) |\n"
    },
    {
      "name": "Batch Management",
      "description": "## Batch & Expiration Date Management\n\nProducts with `batch_control: true` and `management_type: lot` or `serial` support batch tracking\nwith expiration dates. This is essential for perishable goods, pharmaceuticals, or any product\nrequiring lot traceability.\n\n### Prerequisites\n\nTo use batch management, the product must be created with:\n- `management_type`: `lot` (for lot-based tracking) or `serial` (for serial number tracking)\n- `batch_control`: `true` (enables expiration date tracking)\n\n### Batch Lifecycle\n\n```\n1. Create product with batch_control=true, management_type=lot\n2. POST /inventory/products/{product_id}/batches → Create batch with expiration_date\n3. Reference batch in purchase orders (items[].batches array)\n4. GET /inventory/products/{product_id}/batches → List batches for a product\n5. GET /inventory/stocks/expiring → Monitor expiring stock across warehouse\n6. PUT /inventory/products/batches/{batch_id} → Update batch expiration date\n```\n\n### Batch Fields\n\n| Field | Description | Format |\n|-------|-------------|--------|\n| `number` | Alphanumerical batch/lot number | String |\n| `type` | Batch type: `lot`, `serial`, or `none` | String |\n| `expiration_date` | Expiration date of the batch | `YYYY-MM-DD` |\n| `client_id` | Client identifier associated to batch | String |\n| `third_party_id` | Supplier ID for the batch | Integer |\n\n### Using Batches in Orders\n\nWhen creating purchase orders or sales orders for batch-controlled products,\ninclude the `batches` array in the order items:\n\n```json\n{\n  \"items\": [\n    {\n      \"product_id\": 7646303,\n      \"requested_quantity\": 100,\n      \"batches\": [\"LOT-2025-001\"]\n    }\n  ]\n}\n```\n"
    },
    {
      "name": "Serial Number Management",
      "description": "## Serial Number Tracking\n\nProducts with `management_type: serial` enable individual unit tracking using unique serial numbers.\nThis is essential for electronics, high-value goods, warranty tracking, or any product requiring\nindividual item traceability.\n\n### Prerequisites\n\nTo use serial number tracking, the product must be created with:\n- `management_type`: `serial`\n- `batch_control`: `true` (enables expiration date tracking if needed)\n\n### Key Differences: Serial vs Lot\n\n| Feature | Lot (`lot`) | Serial (`serial`) |\n|---------|------------|-------------------|\n| Quantity per batch | Multiple units share a lot number | Each unit has a unique serial number |\n| Use case | Perishable goods, bulk items | Electronics, high-value items |\n| Receiving | Multiple items under one lot | One item per serial number |\n| Traceability | Lot-level | Individual unit-level |\n\n### Serial Number Lifecycle\n\n```\n1. Create product with management_type=serial\n2. POST /inventory/products/{product_id}/batches\n   → Create a batch entry with type=serial and a unique serial number\n3. Reference serial number in purchase orders (items[].batches array)\n4. Each serial number is received as a single unit in the warehouse\n5. GET /inventory/products/{product_id}/batches?type=serial\n   → List all serial numbers for a product\n6. Serial numbers are tracked through picking, packing, and shipping\n```\n\n### Creating a Serial Number\n\nUse the same batch endpoint but with `type: serial`:\n\n```json\nPOST /inventory/products/{product_id}/batches\n{\n  \"number\": \"SN-2025-ABC123\",\n  \"type\": \"serial\",\n  \"expiration_date\": \"2027-12-31\",\n  \"client_id\": \"CLIENT-001\"\n}\n```\n\n### Using Serial Numbers in Orders\n\nWhen creating purchase orders or sales orders for serial-tracked products,\ninclude each serial number in the `batches` array:\n\n```json\n{\n  \"items\": [\n    {\n      \"product_id\": 7646303,\n      \"requested_quantity\": 3,\n      \"batches\": [\"SN-001\", \"SN-002\", \"SN-003\"]\n    }\n  ]\n}\n```\n\n> **Note:** The `requested_quantity` must match the number of serial numbers provided.\n\n### Serial Numbers in Returns\n\nWhen processing returns for serial-tracked products, include the exact serial numbers\nbeing returned in the `batches` array. You can retrieve the original serial numbers\nfrom the sales order via `GET /sales/orders/{id}`.\n\n### Monitoring Serial-Tracked Stock\n\n- `GET /inventory/products/{product_id}/batches?type=serial` — List all serial numbers for a product\n- `GET /inventory/stocks/expiring` — Monitor expiring serial-tracked items (if expiration dates are set)\n- `GET /inventory/stocks` — Check stock levels filtered by product\n"
    },
    {
      "name": "Returns",
      "description": "## Returns Workflow\n\nPULPO WMS supports customer returns by creating purchase orders of type `return`.\nThe return flow links back to the original sales order, allowing full traceability.\n\n### Return Process\n\n```\n1. GET /sales/orders/{sales_order_id}\n   → Retrieve original order: products, quantities, batches, third_party_id\n2. POST /reception/bulk/purchase_orders (type=return)\n   → Create return PO referencing the sales_order_id\n   → Use tracking code as order_num for traceability\n3. Warehouse receives returned goods (Android app or via POST /reception/incoming_goods)\n   → Per-item state set to `accepted` or `rejected`\n   → Accepted items route to a reception/storage location_type\n   → Rejected items route to a return location_type for inspection\n4. Webhook: purchase_order_finished (goods received)\n5. Webhook: replenishment_order_finished (stock restocked)\n```\n\n### Inspection Outcomes\n\nInspection outcomes are recorded **per incoming_good item**, not on the return PO\nitself. Each item carries:\n\n| Field | Purpose |\n|-------|---------|\n| `state` | `accepted` or `rejected` |\n| `accepted_quantity` / `rejected_quantity` | Split when a partial quantity is accepted |\n| `destination_location_id` | Routes to a reception/storage or return location |\n| `batch_number` / `lot_number` / `serial_number` | Batch/serial traceability |\n| `attachments[]` | Inspection photos (PDF/image) attached to the item |\n| `notes` | Free-text inspection note |\n\nUse `GET /reception/incoming_goods?document_type=return` (with date filters) to\nretrieve the inspection history for returns, including per-item outcomes.\n\n### Listing Returns for a Sales Order\n\n`GET /sales/orders/{id}/returns` summarizes return PO records linked to a sales order.\nFor detailed per-item inspection data including photos, query the related\n`incoming_goods` records instead.\n\n### Key Fields for Returns\n\n| Field | Description | Required |\n|-------|-------------|----------|\n| `type` | Must be `return` | ✅ |\n| `sales_order_id` | ID of the original sales order in PULPO | ✅ |\n| `third_party_id` | Customer ID (type=C) — the customer becomes the \"supplier\" of the returned goods | ✅ |\n| `warehouse_id` | Warehouse that will receive the return | ✅ |\n| `delivery_date` | Expected receipt date (format: `YYYY-MM-DDTHH:MM:SS`) | ✅ |\n| `order_num` | External reference — use the shipment tracking code for traceability | ✅ |\n| `items[].product_id` or `items[].sku` | Product being returned | ✅ |\n| `items[].requested_quantity` | Quantity to be returned | ✅ |\n| `items[].batches` | Array of batch/lot numbers (required for `lot` or `serial` products) | Conditional |\n\n### Batch Handling in Returns\n\n- For products with `management_type: none` — the `batches` array should be empty `[]`\n- For products with `management_type: lot` or `serial` — include the batch/lot numbers in the `batches` array as strings\n- Batch information can be retrieved from the original sales order via `GET /sales/orders/{id}`\n\n### Important Notes\n\n- The `third_party_id` for returns is the **customer** (type=C), not the supplier.\n  This ID is currently **not present** in the packing webhooks — you must retrieve it\n  from the sales order or store it from the original order creation.\n- `merchant_id` and `merchant_channel_id` are not mandatory for non-3PL tenants,\n  but recommended for proper routing.\n"
    },
    {
      "name": "Stock",
      "description": "Inventory and stock management — all endpoints for checking product availability and stock levels.\n\n## Checking Product Availability\n\nPULPO WMS provides several ways to query stock depending on your use case:\n\n| Endpoint | Purpose | Best For |\n|----------|---------|----------|\n| `GET /inventory/stocks/summary` | Aggregated stock totals (total, available, unavailable, rejected) | Quick availability checks, dashboard displays |\n| `POST /inventory/stocks/products/locations` | Stock breakdown by warehouse location | Warehouse operations, location-level inventory |\n| `GET /inventory/stocks/expiring` | Stock sorted by expiration date | Perishable goods monitoring, expiry compliance |\n| `GET /inventory/stocks/availability/products/{id}/batches` | Per-batch/serial available quantities | Batch-specific fulfillment, serial number tracking |\n\n### Available vs Total Stock\n\nThe **summary** endpoint distinguishes between:\n- **Total**: Stock physically in storage, user, cross-docking, and packing locations\n- **Available**: Total minus open orders — this is what you can actually fulfill\n- **Unavailable**: Stock reserved by open orders + in reception + in return\n- **Rejected**: Stock in return locations pending inspection\n\n### Filtering\n\nAll stock endpoints support filtering by `product_id` and `warehouse_id`. The summary endpoint also supports `merchant_id` for multi-tenant queries.\n"
    },
    {
      "name": "Kitting",
      "description": "Kit assembly and kitting tasks"
    },
    {
      "name": "Webhooks",
      "description": "Event subscriptions and webhooks"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/auth": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Authenticate or refresh an access token",
        "description": "OAuth 2.0 endpoint supporting two grant types:\n\n- `password` — exchange username + password for an access token.\n- `refresh_token` — exchange a previously issued `refresh_token` for a fresh\n  access token without re-prompting for credentials.\n\n**Important:**\n- Tokens expire after 60 minutes\n- Store the token and reuse it until expiry\n- Do NOT request a new token for every API call\n- Create a dedicated API user with access to all warehouses\n- If the auth response includes a `refresh_token`, use the `refresh_token` grant\n  to silently renew the access token instead of re-submitting credentials.\n",
        "operationId": "authenticate",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/AuthRequest"
                  },
                  {
                    "$ref": "#/components/schemas/AuthRefreshRequest"
                  }
                ]
              },
              "examples": {
                "password": {
                  "summary": "Password grant",
                  "value": {
                    "grant_type": "password",
                    "username": "api_user@company.com",
                    "password": "your_secure_password",
                    "scope": "default"
                  }
                },
                "refresh": {
                  "summary": "Refresh token grant",
                  "value": {
                    "grant_type": "refresh_token",
                    "refresh_token": "rt_8f2a..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                },
                "example": {
                  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
                  "expires_in": 3600,
                  "scope": "default",
                  "token_type": "bearer",
                  "refresh_token": "rt_8f2a..."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitExceeded"
          }
        }
      }
    },
    "/auth/revoke": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Revoke an access or refresh token",
        "description": "Best-effort logout — revokes the supplied token so it can no longer be used.\n\nSend the current `Authorization: Bearer <token>` header AND the token to revoke\nin the body. Servers may accept revoking a `refresh_token` here as well.\n\nReturning 200 indicates the token is no longer valid; clients should also clear\ntheir local copy regardless of the response.\n",
        "operationId": "revokeToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "Access or refresh token to revoke"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token revoked"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/iam/users/me": {
      "get": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Get current user information",
        "description": "Returns detailed information about the authenticated user, including:\n- Tenant ID and details\n- Accessible warehouses (allowlist — users only see data for these warehouses)\n- Accessible merchants (allowlist)\n- User profiles and permissions\n\nUse this endpoint to obtain your `tenant_id` and `warehouse_id` values.\n\nThe returned `warehouses[]` and `merchants[]` define the user's effective\nauthorization scope. There is no explicit role/permission field — visibility\nis implied by these allowlists, and clients should filter server responses\nagainst the same sets.\n",
        "operationId": "getCurrentUser",
        "responses": {
          "200": {
            "description": "User information retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/iam/users/{id}/merchants": {
      "get": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "List merchants accessible to a user",
        "description": "Returns the merchants the given user has access to. Equivalent to\n`me.merchants[]`, but addressable by ID.\n\nIf this endpoint is not available for your tenant, fall back to\n`GET /merchants/` and intersect with the user's `merchants` allowlist.\n",
        "operationId": "getUserMerchants",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 1295
          }
        ],
        "responses": {
          "200": {
            "description": "Merchants for the user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "merchants": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Merchant"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/iam/merchants/{id}/channels": {
      "get": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "List sales channels for a merchant",
        "description": "Returns the merchant_channels configured for a given merchant. Use the\nreturned `id` as `merchant_channel_id` on order/product creation.\n",
        "operationId": "getMerchantChannels",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Merchant ID",
            "example": 69
          }
        ],
        "responses": {
          "200": {
            "description": "Channels retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "merchant_channels": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MerchantChannel"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/iam/users/{id}/tasks": {
      "get": {
        "tags": [
          "User & Tenant",
          "Picking",
          "Packing"
        ],
        "summary": "List active tasks owned by a user",
        "description": "Returns the set of in-flight warehouse tasks currently assigned to a user.\n\nUseful for the \"one task at a time per user\" rule applied in picking/packing —\nbefore opening a new flow, check whether the user already owns an active task.\n\n**Note:** Paused (`locked`) packing orders are **not** included here. Query\n`GET /packing/orders?state=locked` to find them.\n",
        "operationId": "getUserTasks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "User ID",
            "example": 1295
          }
        ],
        "responses": {
          "200": {
            "description": "Active tasks for the user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserTasks"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/products/categories": {
      "get": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Search tags (product_categories)",
        "description": "Lists the tenant's tags. Tags are called `product_categories` in the API.\n\n**Filters:** `id`, `code` and `name` are exact, case-sensitive matches (`code=Cold`\ndoes not find `cold`). `id` and `code` also accept `to_list:` for several values.\n\n`total_results` is `null` when `offset` is greater than 0.\n",
        "operationId": "searchTags",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Tag ID, or `to_list:id1,id2`",
            "example": "to_list:16901,16902"
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact code, or `to_list:code1,code2`",
            "example": "cold"
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact name"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          }
        ],
        "responses": {
          "200": {
            "description": "Tags retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "nullable": true
                    },
                    "product_categories": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tag"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 2,
                  "product_categories": [
                    {
                      "id": 16901,
                      "code": "heavy",
                      "name": "heavy",
                      "tenant_id": 1445
                    },
                    {
                      "id": 16902,
                      "code": "cold",
                      "name": "cold",
                      "tenant_id": 1445
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Create a tag (product_category)",
        "description": "Creates a tag for the tenant. Send a plain object (not wrapped).\n\n- `code`, `name` and `tenant_id` are required. `tenant_id` must be your own tenant\n  (see `GET /iam/users/me`).\n- `code` must be unique within the tenant. It is case-sensitive, so `cold` and\n  `Cold` count as different codes.\n- `name` does not need to be unique.\n\nUse the returned `id` to assign the tag to products, users or locations.\n",
        "operationId": "createTag",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code",
                  "name",
                  "tenant_id"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "example": "fragile"
                  },
                  "name": {
                    "type": "string",
                    "example": "Fragile"
                  },
                  "tenant_id": {
                    "type": "integer",
                    "example": 1445
                  }
                }
              },
              "example": {
                "code": "fragile",
                "name": "Fragile",
                "tenant_id": 1445
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Tag created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                },
                "example": {
                  "id": 20311,
                  "code": "fragile",
                  "name": "Fragile",
                  "tenant_id": 1445
                }
              }
            }
          },
          "400": {
            "description": "Missing field, duplicate code, or a tenant the user doesn't belong to.",
            "content": {
              "application/json": {
                "examples": {
                  "missingName": {
                    "summary": "Missing name",
                    "value": {
                      "errors": {
                        "name": "can't be blank"
                      }
                    }
                  },
                  "missingTenant": {
                    "summary": "Missing tenant_id",
                    "value": {
                      "errors": {
                        "tenant": "User not allowed in tenant nil",
                        "tenant_id": "can't be blank"
                      }
                    }
                  },
                  "duplicateCode": {
                    "summary": "Code already used",
                    "value": {
                      "errors": {
                        "code": "has already been taken"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/products/categories/{id}": {
      "get": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Get a tag by ID",
        "operationId": "getTag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 16902
          }
        ],
        "responses": {
          "200": {
            "description": "Tag retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown ID",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Update a tag",
        "description": "Changes a tag's `code` and/or `name`. Only the fields you send change. The same\nrules as on create apply: `code` must stay unique, neither may be empty.\n\nProducts, users and locations keep the tag — they reference it by ID, so a new\ncode or name shows up everywhere.\n",
        "operationId": "updateTag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 20311
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "name": "Fragile — handle with care"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tag updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown ID, duplicate code, or empty value.",
            "content": {
              "application/json": {
                "examples": {
                  "duplicateCode": {
                    "summary": "Code already used",
                    "value": {
                      "errors": {
                        "code": "has already been taken"
                      }
                    }
                  },
                  "emptyName": {
                    "summary": "Empty name",
                    "value": {
                      "errors": {
                        "name": "can't be blank"
                      }
                    }
                  },
                  "invalidId": {
                    "summary": "Unknown ID",
                    "value": {
                      "errors": {
                        "id": "The given id is invalid"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Delete a tag",
        "description": "Deletes a tag and returns it.\n\n**Careful:** a tag that is in use can be deleted too. There is no warning — the\ntag is silently removed from the products that had it (tested for products;\nusers and locations presumably behave the same).\n",
        "operationId": "deleteTag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 20311
          }
        ],
        "responses": {
          "200": {
            "description": "Tag deleted. The body is the deleted tag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown ID",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/iam/users/{id}/categories": {
      "post": {
        "tags": [
          "User & Tenant"
        ],
        "summary": "Set a user's tags",
        "description": "Sets the user's **tags** (`product_categories`). The body is a plain JSON array of\ntag IDs.\n\nThe list **replaces** the user's tags; `[]` removes all of them. If any ID is\nunknown, the whole call fails and nothing changes. Tag codes are rejected.\n\nThis is the only way to change a user's tags after creation:\n`PUT /iam/users/{id}` silently ignores `product_categories`. When creating a user\nwith `POST /iam/users`, tags can be sent directly as `product_categories: [ids]`.\n\nReturns the full user, including the new `product_categories`.\n",
        "operationId": "setUserTags",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "User ID",
            "example": 4778
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "example": [
                16901,
                16902
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tags set. The body is the full user.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "username": {
                      "type": "string"
                    },
                    "product_categories": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tag"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body is not a JSON array.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "_json": "Parameter should be mandatory, list"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown tag ID or tag code sent, or unknown user. Nothing changed.",
            "content": {
              "application/json": {
                "examples": {
                  "unknownTag": {
                    "summary": "Unknown tag ID",
                    "value": {
                      "errors": {
                        "message": "invalid_product_category_id"
                      }
                    }
                  },
                  "code": {
                    "summary": "Code instead of ID",
                    "value": {
                      "errors": {
                        "message": "Expected id where receiving \"cold\""
                      }
                    }
                  },
                  "unknownUser": {
                    "summary": "Unknown user",
                    "value": {
                      "errors": {
                        "id": "The given id is invalid"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/warehouses/": {
      "get": {
        "tags": [
          "Warehouses"
        ],
        "summary": "List all warehouses",
        "description": "Returns detailed information about all warehouses accessible to the current user.\n\nUse this to get warehouse IDs required for order creation.\n",
        "operationId": "listWarehouses",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Warehouses retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "example": 1
                    },
                    "warehouses": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Warehouse"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/warehouses/locations": {
      "get": {
        "tags": [
          "Warehouses"
        ],
        "summary": "Get warehouse locations",
        "description": "Returns physical locations within a warehouse.\n\n**Use cases:**\n- Find kitting locations for kitting tasks\n- Map warehouse layout\n- Track stock by specific bin/shelf\n",
        "operationId": "getWarehouseLocations",
        "parameters": [
          {
            "name": "location_type_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter by location type (e.g., kitting, storage, return)"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Locations retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "locations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Location"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory/products": {
      "get": {
        "tags": [
          "Products"
        ],
        "summary": "Search products",
        "description": "Search and filter products with pagination.\n\n**Useful filters:**\n- `id`, `sku`, `article_number`, `barcode` — exact match, or `sku`/`name`\n  accept a `contains:term` prefix for a substring search\n- `name`, `description` — exact match, or `contains:term` on `name`\n- `management_type` — `none`, `lot`, `serial`\n- `third_party_id` — default supplier\n- `merchant_id` (also `to_list:`), `active`, `has_stock`\n- `product_categories` — tag ID, or `to_list:id1,id2` for products with any of\n  them. Tag codes return an error.\n- `holds_stock_on_warehouse_id` / `holds_blocked_stock_on_warehouse_id` —\n  single ID or `to_list:id1,id2`\n- `related_orders_state`, `related_orders_delivery_date` — exact match only,\n  `YYYY-MM-DD HH:MM:SS`. A bare date or a `gte:`/`between:`/etc. prefix\n  returns a 500 error.\n- `view_attributes=id,sku,name` (return only specific fields)\n\n`__or_search` and `show_deleted` are accepted but don't do anything on this\nendpoint — deleted products never appear in search results regardless.\n",
        "operationId": "searchProducts",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "sku",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match or `contains:term` substring search",
            "example": "COFFEE-001"
          },
          {
            "name": "article_number",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match."
          },
          {
            "name": "barcode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match against any of the product's `barcodes`."
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match or `contains:term`"
          },
          {
            "name": "description",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match."
          },
          {
            "name": "management_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "none",
                "lot",
                "serial"
              ]
            }
          },
          {
            "name": "third_party_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Default supplier ID."
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:1,2,3` for multiple.",
            "example": "69"
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "example": true
          },
          {
            "name": "has_stock",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Whether the product has at least one stock record."
          },
          {
            "name": "holds_stock_on_warehouse_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Restricts `has_stock` to the given warehouse(s). Single ID or\n`to_list:id1,id2`.\n"
          },
          {
            "name": "holds_blocked_stock_on_warehouse_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Product holds stock on a blocked position (unavailable state) in the\ngiven warehouse(s). Single ID or `to_list:id1,id2`.\n"
          },
          {
            "name": "related_orders_state",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "State of orders that reference this product."
          },
          {
            "name": "related_orders_delivery_date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Delivery date of orders that reference this product. Exact match only,\n`YYYY-MM-DD HH:MM:SS` — a bare date or a `gte:`/`between:`/etc. prefix\nreturns a 500 error.\n"
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return"
          }
        ],
        "responses": {
          "200": {
            "description": "Products found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/bulk/products": {
      "post": {
        "tags": [
          "Products"
        ],
        "summary": "Create products in bulk",
        "description": "Creates multiple products at once. Products are the master data for all items in your warehouse.\n\nTo update existing products instead, use `PUT /inventory/bulk/products`.\n\n**Important fields:**\n- `sku`: Unique identifier per product (your external reference)\n- `name`: Unique product name\n- `merchant_id`: Owner of the product\n- `barcodes`: Required for scanning in warehouse (Android app)\n- `management_type`: none, lot, or serial (for batch tracking)\n\n**Recommended batch size:** up to 50 items per request.\n",
        "operationId": "bulkCreateProducts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ProductInput"
                }
              },
              "example": [
                {
                  "active": true,
                  "name": "Premium Coffee Beans 1kg",
                  "sku": "COFFEE-001",
                  "management_type": "lot",
                  "batch_control": true,
                  "cost_price": 15.99,
                  "minimum_purchase_unit": 1,
                  "minimum_sales_unit": 1,
                  "units_per_purchase_package": 1,
                  "units_per_sales_package": 1,
                  "purchase_measure_units": "BOX",
                  "sales_measure_units": "BOX",
                  "weight": 1.2,
                  "length": 20,
                  "width": 15,
                  "height": 10,
                  "tenant_id": 87,
                  "merchant_id": 69,
                  "merchant_channel_id": null,
                  "barcodes": [
                    "5060123456789",
                    "COFFEE-001"
                  ],
                  "attributes": {
                    "image_url": "https://example.com/coffee.jpg",
                    "color": "brown"
                  }
                }
              ]
            }
          }
        },
        "responses": {
          "201": {
            "description": "Products processed. Check `created` for the products that succeeded and\n`errors` for the ones that didn't — a partial failure still returns 201\nif at least the request itself was well-formed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateProductsResponse"
                },
                "example": {
                  "created": [
                    {
                      "id": 1957711,
                      "sku": "COFFEE-001"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "All items failed validation — none were created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateProductsResponse"
                },
                "example": {
                  "created": [],
                  "errors": {
                    "COFFEE-001": {
                      "units_per_sales_package": "can't be blank",
                      "sales_measure_units": "can't be blank"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitExceeded"
          }
        }
      },
      "put": {
        "tags": [
          "Products"
        ],
        "summary": "Update products in bulk",
        "description": "Updates existing products. Works as bulk — if any product update fails, the\nremaining products continue processing.\n\n**Identify the product to update:**\n- `sku`: Product SKU (looked up together with your tenant)\n- `id`: PULPO product ID also works, if you already store it\n\n**Updatable fields:**\nSend only the fields you want to change, plus the identifier — this is a\npartial update, **except for `barcodes`**: it must always be included and\nnon-empty (resend the existing barcodes if you're not changing them, or the\nrequest fails). Any other field accepted by product creation can be updated\n— `name`, `active`, `cost_price`, `attributes`, etc.\n\n**`attributes` is replaced, not merged:** whatever you send becomes the\nproduct's complete `attributes` object, and any key you leave out is deleted\n(including `image_url`, which drives the dashboard thumbnail). To change one\nattribute, send all existing keys along with it.\n\nTo deactivate a product instead of updating it, send `active: false`.\n\n**Recommended batch size:** up to 50 items per request.\n",
        "operationId": "bulkUpdateProducts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ProductInput"
                }
              },
              "examples": {
                "partialUpdate": {
                  "summary": "Change a single field",
                  "value": [
                    {
                      "sku": "COFFEE-001",
                      "cost_price": 16.49,
                      "barcodes": [
                        "5060123456789",
                        "COFFEE-001"
                      ]
                    }
                  ]
                },
                "updateAttributes": {
                  "summary": "Update custom attributes",
                  "description": "`attributes` is replaced as a whole — this payload resends the\nexisting `image_url` so the dashboard thumbnail is kept, alongside\nthe new keys. Values can be strings, numbers, booleans, nested\nobjects, or arrays.\n",
                  "value": [
                    {
                      "sku": "COFFEE-001",
                      "barcodes": [
                        "5060123456789",
                        "COFFEE-001"
                      ],
                      "attributes": {
                        "image_url": "https://example.com/coffee.jpg",
                        "roast": "medium",
                        "origin_region": "Huila",
                        "organic": true,
                        "shelf_life_days": 365,
                        "certifications": {
                          "fair_trade": true,
                          "rainforest_alliance": false
                        },
                        "tags": [
                          "single-origin",
                          "bestseller"
                        ]
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Products processed. Check `updated` for the products that succeeded and\n`errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateProductsResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 1957711,
                      "sku": "COFFEE-001"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "All items failed validation — none were updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateProductsResponse"
                },
                "example": {
                  "updated": [],
                  "errors": {
                    "COFFEE-001": {
                      "barcodes": "Product barcodes is a mandatory field and may not be empty"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Products"
        ],
        "summary": "Delete products in bulk",
        "description": "Permanently removes products. Deleted products no longer appear in\n`GET /inventory/products` or other product searches.\n\nWorks as bulk — if any product fails to delete, the remaining products are\nstill processed.\n\n**Recommended batch size:** up to 50 items per request.\n",
        "operationId": "bulkDeleteProducts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ProductReference"
                    },
                    "title": "By sku or id objects"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "title": "By SKU strings"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "title": "By ID numbers"
                  }
                ]
              },
              "examples": {
                "bySku": {
                  "summary": "Delete by SKUs",
                  "value": [
                    {
                      "sku": "COFFEE-001"
                    },
                    {
                      "sku": "COFFEE-002"
                    }
                  ]
                },
                "byId": {
                  "summary": "Delete by IDs",
                  "value": [
                    {
                      "id": 1957711
                    },
                    {
                      "id": 1957712
                    }
                  ]
                },
                "byStringList": {
                  "summary": "Delete by SKU strings",
                  "value": [
                    "COFFEE-001",
                    "COFFEE-002"
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Products processed. Check `deleted` for the products that succeeded and\n`errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteProductsResponse"
                },
                "example": {
                  "deleted": [
                    {
                      "id": 1957711,
                      "sku": "COFFEE-001"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "All items failed — none were deleted (e.g. unknown sku/id).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteProductsResponse"
                },
                "example": {
                  "deleted": [],
                  "errors": {
                    "COFFEE-001": {
                      "sku": "invalid product sku equals to \"COFFEE-001\""
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/iam/bulk/third_parties": {
      "post": {
        "tags": [
          "Third Parties"
        ],
        "summary": "Create third parties in bulk",
        "description": "Creates suppliers (type=S) or customers (type=C) in bulk.\n\nTo update existing third parties instead, use `PUT /iam/bulk/third_parties`.\n\n**Suppliers (type=S):**\n- Used in purchase orders\n- `merchant_channel_id` can be NULL\n\n**Customers (type=C):**\n- Used in sales orders\n- `merchant_channel_id` is optional for single-merchant (non-3PL) tenants — defaults to your account's channel\n\n**Important:**\n- Store the returned `id` for use in orders\n- `identifier_number` + `third_type` must be unique — creating a duplicate is\n  rejected, it does not update the existing record\n\n**Recommended batch size:** up to 50 items per request.\n",
        "operationId": "bulkCreateThirdParties",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ThirdPartyInput"
                }
              },
              "examples": {
                "supplier": {
                  "summary": "Supplier example",
                  "value": [
                    {
                      "active": true,
                      "name": "Acme Coffee Suppliers Ltd",
                      "identifier_type": "VAT",
                      "identifier_number": "GB123456789",
                      "third_type": "S",
                      "email": "orders@acmecoffee.com",
                      "tenant_id": 87,
                      "merchant_id": 69,
                      "merchant_channel_id": null
                    }
                  ]
                },
                "customer": {
                  "summary": "Customer example",
                  "value": [
                    {
                      "active": true,
                      "name": "John's Coffee Shop",
                      "identifier_type": "ID",
                      "identifier_number": "CUST-12345",
                      "third_type": "C",
                      "email": "john@coffeeshop.com",
                      "tenant_id": 87,
                      "merchant_id": 69,
                      "merchant_channel_id": 76,
                      "attributes": {
                        "addresses": [
                          {
                            "name": "John Smith",
                            "company_name": "John's Coffee Shop",
                            "phone_number": "+44 20 1234 5678",
                            "address": {
                              "street": "123 High Street",
                              "city": "London",
                              "zip": "SW1A 1AA",
                              "country": "GB",
                              "country_code": "826",
                              "email": "john@coffeeshop.com"
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Third parties processed. Check `created` for the ones that succeeded\nand `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateThirdPartiesResponse"
                },
                "example": {
                  "created": [
                    {
                      "id": 3218515,
                      "identifier_number": "GB123456789"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "All items failed validation — none were created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateThirdPartiesResponse"
                },
                "example": {
                  "created": [],
                  "errors": {
                    "GB123456789": {
                      "third_party": "third party identification number already taken."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "put": {
        "tags": [
          "Third Parties"
        ],
        "summary": "Update third parties in bulk",
        "description": "Updates existing suppliers or customers. Works as bulk — if any item fails,\nthe remaining ones continue processing. This is a partial update — send only\nthe fields you want to change, plus an identifier.\n\n**Identify the third party to update:**\n- `identifier_number` (with `third_type`)\n- `id`: PULPO third party ID also works\n\n**Recommended batch size:** up to 50 items per request.\n",
        "operationId": "bulkUpdateThirdParties",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ThirdPartyInput"
                }
              },
              "example": [
                {
                  "identifier_number": "GB123456789",
                  "third_type": "S",
                  "name": "Acme Coffee Suppliers (renamed)"
                }
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Third parties processed. Check `updated` for the ones that succeeded\nand `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateThirdPartiesResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 3218515,
                      "identifier_number": "GB123456789"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "All items failed — none were updated (e.g. unknown identifier_number/id).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateThirdPartiesResponse"
                },
                "example": {
                  "updated": [],
                  "errors": {
                    "GB123456789": {
                      "id": "can't find third party with identifier_number \"GB123456789\""
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/iam/third_parties/{id}": {
      "delete": {
        "tags": [
          "Third Parties"
        ],
        "summary": "Delete a third party",
        "description": "Deletes a single supplier or customer by its PULPO ID. This is a soft\ndelete — the record is deactivated (`active: false`, `deleted_at`,\n`deleted_by` set) and no longer appears in third party searches.\n\nThird parties referenced by existing orders (purchase orders or sales\norders) cannot be deleted — deactivate them instead with\n`PUT /iam/bulk/third_parties` (`active: false`).\n",
        "operationId": "deleteThirdParty",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Third party deleted (soft-deleted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdParty"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Invalid ID, or the third party has order history and cannot be deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "invalidId": {
                    "summary": "Unknown ID",
                    "value": {
                      "errors": {
                        "id": "The given id is invalid"
                      }
                    }
                  },
                  "hasOrders": {
                    "summary": "Referenced by existing orders",
                    "value": {
                      "errors": {
                        "sales_orders": "contained_in_association"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory/stocks": {
      "get": {
        "tags": [
          "Stock"
        ],
        "summary": "List stock records",
        "description": "Lists raw stock records, optionally scoped to a product, location, batch, or\nwarehouse. Each row represents a stock quantity at a specific\n(product, location, batch) tuple.\n\n**When to use this vs the other stock endpoints:**\n\n| Use case | Endpoint |\n|----------|----------|\n| Aggregate per-product totals | `GET /inventory/stocks/summary` |\n| Per-location quantities | `POST /inventory/stocks/products/locations` |\n| Soon-to-expire stock | This endpoint or `GET /inventory/stocks/batches` (the batch-grouped variant returns more complete batch metadata) |\n| Count units at one location | This endpoint with `location_id` + `limit=1` |\n\nEach row includes nested `batch: { id, number, expiration_date, type }` for\nbatch-managed products — use this rather than `/inventory/stocks/expiring`\nwhen you need full batch metadata.\n",
        "operationId": "listStocks",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "batch_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:1,2,3` for multiple."
          }
        ],
        "responses": {
          "200": {
            "description": "Stock records retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "stocks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StockRecord"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/stocks/summary": {
      "get": {
        "tags": [
          "Stock"
        ],
        "summary": "Get stock summary",
        "description": "Returns stock summary for products with detailed breakdown.\n\n**Stock Types:**\n- `total`: Stock in storage, user, cross-docking, packing locations\n- `available`: Total minus open orders\n- `unavailable`: Open orders + reception + return\n- `rejected`: Stock in return locations\n\n**Filters:**\n- Filter by `product_id`, `warehouse_id`, `merchant_id`\n- Repeat `product_id` to query multiple products in one call:\n  `?product_id=1957711&product_id=1957712`\n- `merchant_id` accepts `to_list:1,2,3` for multi-merchant queries\n- Combine filters for precise queries\n",
        "operationId": "getStockSummary",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "oneOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                }
              ]
            },
            "description": "Product ID; repeat the parameter to query multiple products.",
            "explode": true,
            "example": 1957711
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 140
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:1,2,3` for multiple.",
            "example": "69"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Stock summary retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StockSummary"
                  }
                },
                "example": [
                  {
                    "product_id": 1957711,
                    "sku": "COFFEE-001",
                    "name": "Premium Coffee Beans 1kg",
                    "merchant_id": 69,
                    "total": 150,
                    "available": 120,
                    "unavailable": 30,
                    "rejected": 5,
                    "last_movement": "replenishment_order_finished"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/inventory/stocks/batches": {
      "get": {
        "tags": [
          "Stock",
          "Batch Management"
        ],
        "summary": "List stock grouped by batch",
        "description": "Returns stock aggregated by batch (one row per batch), with each row carrying\nthe total quantity across all locations holding that batch plus the per-location\nbreakdown.\n\nThis is the recommended endpoint for expiring-stock reporting when you need\nfull batch metadata — `GET /inventory/stocks/expiring` returns a truncated\nsubset of fields.\n\n**Filters:**\n- `batch_expiration_date` — supports `between:`, `gte:`, `lte:` (e.g.,\n  `lte:2025-12-31` for soon-to-expire batches)\n- `total_quantity` — supports `gte:`, `gt:` (e.g., `gt:0` to exclude empty\n  batches)\n- `product_management_type` — `lot` or `serial`\n- `merchant_id=to_list:...` for multi-merchant queries\n",
        "operationId": "listStockBatches",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:` for multiple."
          },
          {
            "name": "batch_expiration_date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Expiration filter. Supports `between:`, `gte:`, `lte:`.",
            "example": "lte:2025-12-31"
          },
          {
            "name": "total_quantity",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Quantity filter. Supports `gte:`, `gt:`.",
            "example": "gt:0"
          },
          {
            "name": "product_management_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "lot",
                "serial"
              ]
            }
          },
          {
            "name": "zone_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "location_type_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Batch-grouped stock retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "stocks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BatchStock"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/stocks/expiring": {
      "get": {
        "tags": [
          "Stock",
          "Batch Management"
        ],
        "summary": "Get expiring stock",
        "description": "Lists stock items sorted by expiration date (ascending), allowing you to identify\nproducts that are expiring soon.\n\n**Use cases:**\n- Monitor perishable goods approaching expiry\n- Plan promotions or markdowns for soon-to-expire stock\n- Generate expiry reports for compliance\n\n**Filters:**\n- `product_id`: Filter by specific product\n- `batch_id`: Filter by specific batch\n- `zone_id`, `location_id`: Filter by warehouse zone/location\n- `stock_state_id`: Filter by stock state\n",
        "operationId": "getExpiringStock",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Product ID to filter",
            "example": 1957711
          },
          {
            "name": "batch_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Batch ID to filter"
          },
          {
            "name": "location_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Location ID to filter"
          },
          {
            "name": "zone_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Zone ID to filter"
          },
          {
            "name": "location_type_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Location Type ID to filter"
          },
          {
            "name": "stock_state_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Stock State ID to filter"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Expiring stock retrieved (sorted by expiration date ascending)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "stocks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ExpiringStock"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 3,
                  "stocks": [
                    {
                      "product_id": 1957711,
                      "product_sku": "COFFEE-001",
                      "product_name": "Premium Coffee Beans 1kg",
                      "batch_id": 45231,
                      "batch_number": "LOT-2025-001",
                      "expiration_date": "2025-12-31",
                      "quantity": 50,
                      "location_id": 229364,
                      "location_code": "M-1-1-2-1-1"
                    },
                    {
                      "product_id": 1957711,
                      "product_sku": "COFFEE-001",
                      "product_name": "Premium Coffee Beans 1kg",
                      "batch_id": 45232,
                      "batch_number": "LOT-2025-002",
                      "expiration_date": "2026-06-30",
                      "quantity": 100,
                      "location_id": 229385,
                      "location_code": "M-1-2-1-1-3"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/stocks/availability/products/{id}/batches": {
      "get": {
        "tags": [
          "Stock",
          "Batch Management"
        ],
        "summary": "Get batch availability for a product",
        "description": "Returns the available and reception quantities per batch for a given product.\nUseful for checking which batches have stock available for fulfillment.\n",
        "operationId": "getBatchAvailability",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Product ID",
            "example": 1957711
          }
        ],
        "responses": {
          "200": {
            "description": "Batch availability retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "availability_batches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AvailabilityBatch"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 2,
                  "availability_batches": [
                    {
                      "id": 1,
                      "batch_id": 45231,
                      "product_id": 1957711,
                      "available_quantity": 50,
                      "reception_quantity": 0,
                      "location_type_id": 1
                    },
                    {
                      "id": 2,
                      "batch_id": 45232,
                      "product_id": 1957711,
                      "available_quantity": 100,
                      "reception_quantity": 25,
                      "location_type_id": 1
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/stocks/products/locations": {
      "post": {
        "tags": [
          "Stock"
        ],
        "summary": "Get stock by product and location",
        "description": "Returns detailed stock information per product and per physical location.\n\n**New Feature:**\n- `include_packed_goods_segmentation=true`: Shows if stock is packed or loose\n- `packed_or_loose` values: `packed`, `loose`, `both`\n\n**Use cases:**\n- Detailed location-level stock reports\n- Loading unit tracking\n- Warehouse layout optimization\n",
        "operationId": "getStockByLocation",
        "parameters": [
          {
            "name": "include_packed_goods_segmentation",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include packed/loose stock breakdown"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "warehouse_id": {
                    "type": "integer"
                  },
                  "product_id": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stock locations retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "stocks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StockLocation"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 2,
                  "stocks": [
                    {
                      "product_id": 1957711,
                      "product_sku": "COFFEE-001",
                      "product_name": "Premium Coffee Beans 1kg",
                      "merchant_id": 69,
                      "location_id": 229364,
                      "location_code": "M-1-1-2-1-1",
                      "quantity": 87,
                      "packed_or_loose": "loose"
                    },
                    {
                      "product_id": 1957711,
                      "product_sku": "COFFEE-001",
                      "product_name": "Premium Coffee Beans 1kg",
                      "merchant_id": 69,
                      "location_id": 229385,
                      "location_code": "M-1-2-1-1-3",
                      "quantity": 200,
                      "packed_or_loose": "packed"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/inventory/stocks/correct": {
      "post": {
        "tags": [
          "Stock"
        ],
        "summary": "Correct stock at a location",
        "description": "Adds or removes stock for a product at a specific location. The path isn't\nunder `/bulk/`, but the request still accepts multiple `items` in one call.\n\n**Direction:** `quantity` is signed — positive adds stock, negative removes\nit. Removing more than what's available at that location returns a 422\n(`not_enough_stock_to_remove_for_given_location_product_batch`).\n\n**Batch-controlled products (`lot`/`serial`):** include `item_batches`, one\nentry per batch/lot/serial affected. For `serial`-managed products, each\nbatch's `quantity` must be `1` — a serial is a single unique unit. For `lot`\nit can be any amount. The batch-level quantities are what actually get\napplied — keep the item's own `quantity` equal to their sum to avoid\nconfusion, even though it isn't strictly validated against it.\n\n**Recommended batch size:** up to 50 corrections (`items` entries) per\nrequest.\n",
        "operationId": "correctStock",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "warehouse_id",
                  "items"
                ],
                "properties": {
                  "warehouse_id": {
                    "type": "integer",
                    "description": "Warehouse the correction applies to.",
                    "example": 140
                  },
                  "reason_codes": {
                    "type": "array",
                    "description": "Optional reason code(s) for the correction, referenced by `id`\n— not by code string.\n",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "example": 198
                        }
                      }
                    }
                  },
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/StockCorrectionItemInput"
                    }
                  }
                }
              },
              "examples": {
                "noneManagedProduct": {
                  "summary": "Correct a plain (non-lot/serial) product",
                  "value": {
                    "warehouse_id": 140,
                    "items": [
                      {
                        "location_id": 229364,
                        "product_id": 1957711,
                        "quantity": 5
                      }
                    ]
                  }
                },
                "lotOrSerialProduct": {
                  "summary": "Correct a lot/serial product via item_batches",
                  "value": {
                    "warehouse_id": 140,
                    "items": [
                      {
                        "location_id": 229364,
                        "product_id": 1957712,
                        "quantity": 5,
                        "item_batches": [
                          {
                            "batch_id": 45231,
                            "quantity": 5
                          }
                        ]
                      }
                    ]
                  }
                },
                "removeStock": {
                  "summary": "Remove stock (negative quantity)",
                  "value": {
                    "warehouse_id": 140,
                    "items": [
                      {
                        "location_id": 229364,
                        "product_id": 1957711,
                        "quantity": -5
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stock corrected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StockCorrection"
                },
                "example": {
                  "id": 55438,
                  "sequence_number": "SC-0000021",
                  "warehouse_id": 140,
                  "owner_id": 4625,
                  "comment": null,
                  "reason_codes": [],
                  "inserted_at": "2024-03-25T09:00:00",
                  "items": [
                    {
                      "id": 219242,
                      "product_id": 1957711,
                      "location_id": 229364,
                      "quantity": -5,
                      "loading_unit_location_id": null,
                      "batches": []
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Validation error — a required field is missing, or (for negative\nquantities) there isn't enough stock to remove.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "notEnoughStock": {
                    "summary": "Not enough stock to remove",
                    "value": {
                      "errors": {
                        "errors": [
                          {
                            "error": "not_enough_stock_to_remove_for_given_location_product_batch",
                            "location_id": 229364,
                            "product_id": 1957711
                          }
                        ]
                      }
                    }
                  },
                  "missingField": {
                    "summary": "Missing required item field",
                    "value": {
                      "errors": {
                        "items": [
                          {
                            "errors": {
                              "product_id": "can't be blank"
                            },
                            "quantity": 5,
                            "location_id": 229364
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory/products/batches": {
      "get": {
        "tags": [
          "Batch Management"
        ],
        "summary": "Search all batches",
        "description": "Searches batches across all products with optional filters.\n\n**Filters:**\n- `product_id`: Filter by specific product\n- `number`: Filter by batch/lot number\n- `type`: Filter by batch type\n- `expiration_date`: Filter by expiration date\n- `existing_stock`: Only show batches with existing stock\n- `show_unavailable_stock`: Include batches with unavailable stock\n",
        "operationId": "searchBatches",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter by product ID",
            "example": 1957711
          },
          {
            "name": "number",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Alphanumerical batch/lot number"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "lot",
                "serial",
                "none"
              ]
            },
            "description": "Type of batch"
          },
          {
            "name": "expiration_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Expiration date filter (format: YYYY-MM-DD)"
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Client identifier associated to batch"
          },
          {
            "name": "existing_stock",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Only show batches with existing stock"
          },
          {
            "name": "show_unavailable_stock",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Include batches with unavailable stock"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Batches retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "batches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Batch"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/products/{id}/batches": {
      "get": {
        "tags": [
          "Batch Management"
        ],
        "summary": "List batches for a product",
        "description": "Returns all batches associated with a specific product.\nOnly applicable for products with `batch_control: true` and `management_type: lot` or `serial`.\n\n**Filters:**\n- `number`: Filter by batch/lot number\n- `type`: Filter by batch type (`lot`, `serial`, `none`)\n- `expiration_date`: Filter by expiration date (format: `YYYY-MM-DD`)\n- `client_id`: Filter by client identifier\n",
        "operationId": "listProductBatches",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Product ID",
            "example": 1957711
          },
          {
            "name": "number",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Alphanumerical batch/lot number",
            "example": "LOT-2025-001"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "lot",
                "serial",
                "none"
              ]
            },
            "description": "Type of batch",
            "example": "lot"
          },
          {
            "name": "expiration_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Expiration date filter (format: YYYY-MM-DD)",
            "example": "2025-12-31"
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Client identifier associated to batch"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Batches retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "batches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Batch"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 2,
                  "batches": [
                    {
                      "id": 45231,
                      "number": "LOT-2025-001",
                      "type": "lot",
                      "expiration_date": "2025-12-31",
                      "product_id": 1957711,
                      "third_party_id": 3218515,
                      "client_id": null,
                      "inserted_at": "2025-01-15T10:30:00",
                      "updated_at": "2025-01-15T10:30:00"
                    },
                    {
                      "id": 45232,
                      "number": "LOT-2025-002",
                      "type": "lot",
                      "expiration_date": "2026-06-30",
                      "product_id": 1957711,
                      "third_party_id": 3218515,
                      "client_id": null,
                      "inserted_at": "2025-03-01T14:00:00",
                      "updated_at": "2025-03-01T14:00:00"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Batch Management"
        ],
        "summary": "Create a batch for a product",
        "description": "Creates a new batch/lot for a product that has `batch_control: true`.\n\n**Required setup:**\n- Product must have `management_type` set to `lot` or `serial`\n- Product must have `batch_control` set to `true`\n\n**Use cases:**\n- Pre-create batches before receiving goods\n- Register lot numbers with expiration dates for perishable products\n- Track serial numbers for individual items\n",
        "operationId": "createBatch",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Product ID",
            "example": 1957711
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "number": {
                    "type": "string",
                    "description": "Alphanumerical batch/lot number",
                    "example": "LOT-2025-003"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "lot",
                      "serial",
                      "none"
                    ],
                    "description": "Type of batch: `lot`, `serial`, or `none`",
                    "example": "lot"
                  },
                  "expiration_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Expiration date (format: YYYY-MM-DD)",
                    "example": "2026-01-15"
                  },
                  "client_id": {
                    "type": "string",
                    "description": "Client identifier associated to batch"
                  },
                  "third_party_id": {
                    "type": "string",
                    "description": "Supplier ID for the batch",
                    "example": "3218515"
                  }
                },
                "required": [
                  "number",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Batch created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                },
                "example": {
                  "id": 45233,
                  "number": "LOT-2025-003",
                  "type": "lot",
                  "expiration_date": "2026-01-15",
                  "product_id": 1957711,
                  "third_party_id": 3218515,
                  "client_id": null,
                  "inserted_at": "2025-03-21T09:00:00",
                  "updated_at": "2025-03-21T09:00:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inventory/products/batches/{id}": {
      "get": {
        "tags": [
          "Batch Management"
        ],
        "summary": "Get batch by ID",
        "description": "Returns detailed information about a specific batch by its ID.\n",
        "operationId": "getBatch",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Batch ID",
            "example": 45231
          }
        ],
        "responses": {
          "200": {
            "description": "Batch retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "put": {
        "tags": [
          "Batch Management"
        ],
        "summary": "Update a batch",
        "description": "Updates fields of a batch, such as the expiration date, lot number, or supplier.\n\n**Common use cases:**\n- Correct an expiration date\n- Update the supplier (third_party_id) associated with a batch\n- Change the client identifier\n",
        "operationId": "updateBatch",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Batch ID",
            "example": 45231
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "number": {
                    "type": "string",
                    "description": "Alphanumerical batch/lot number"
                  },
                  "expiration_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Expiration date (format: YYYY-MM-DD)",
                    "example": "2026-06-30"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "lot",
                      "serial",
                      "none"
                    ],
                    "description": "Type of batch"
                  },
                  "client_id": {
                    "type": "string",
                    "description": "Client identifier associated to batch"
                  },
                  "third_party_id": {
                    "type": "string",
                    "description": "Supplier ID for the batch"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Batch updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/picking/orders": {
      "get": {
        "tags": [
          "Picking"
        ],
        "summary": "List picking orders",
        "description": "Retrieves picking orders with filtering and pagination.\n\n**Possible states** (fixed, managed by PULPO):\n- `queue`: Waiting to be picked\n- `taken`: Being picked\n- `locked`: Remainder of a picking that was finished early with items missing\n  (usually out of stock). The system creates it locked so it isn't picked again\n  and again while stock is still missing — it must be unlocked manually before\n  a picker can take it.\n- `mixed`: Partially picked\n- `ended`: Picking completed\n- `cancelled`: Cancelled\n\n**Useful filters:**\n- `warehouse_id=140`\n- `state=ended`\n- `merchant_id=69`\n- `sales_order_id=13283307` — picking history for a specific sales order\n- `updated_at=between:2024-03-01 00:00:00,2024-03-31 23:59:59`\n\n`sort_by` is not supported here — any value returns `500 Internal Server Error`.\n",
        "operationId": "listPickingOrders",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queue",
                "taken",
                "locked",
                "mixed",
                "ended",
                "cancelled"
              ]
            }
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "sales_order_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Picking orders related to a specific sales order"
          }
        ],
        "responses": {
          "200": {
            "description": "Picking orders retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "picking_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PickingOrder"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Picking"
        ],
        "summary": "Create a batch or cart picklist",
        "description": "Creates **one** picklist that groups all given fulfillment orders. Use it for\n**batch** picking (`cart: false`) and **cart** picking (`cart: true`). For one\npicklist per order (standard picking), use `POST /picking/bulk/orders`.\n\n| Request | Resulting picklist `type` |\n|---------|---------------------------|\n| several FOs, `cart: false` | `consolidated` |\n| several FOs, `cart: true` | `cart_picking` |\n| one FO, `cart: false` | `normal` |\n\n**`orders_count`** splits the given fulfillment orders evenly over that many\npicklists. Example: 4 FOs with `orders_count: 2` give 2 picklists with 2 FOs each.\nThese picklists get `type: normal`.\n\n**`pickers`:** the first user ID becomes the picklist `owner`. Further IDs are\nignored. The picklist stays in `queue` until the picker starts it.\n\n**All or nothing:** if any fulfillment order can't be picked (for example missing\nstock or already on a picklist), no picklist is created and the call returns `422`.\n\n**`delete_missing_stock_sales_items: true`** reduces lines without enough stock to\nthe available quantity, so the picklist can still be created. The sales order\nkeeps its original quantities.\n\n`cart: true` does not change `is_cart` on the sales orders.\n\n**Turbo label:** with `turbo_label: true` the picklist is created as a turbo label\npicklist and the labels are generated **within this request** (synchronous, about\n5 seconds per order on staging). For larger volumes use the asynchronous\n`POST /picking/orders/turbo` instead.\n",
        "operationId": "createPickingOrder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fulfillment_orders"
                ],
                "properties": {
                  "fulfillment_orders": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "integer"
                    },
                    "description": "Fulfillment order IDs (`fulfillment_orders[].id` on the sales order)",
                    "example": [
                      14619144,
                      14619143
                    ]
                  },
                  "cart": {
                    "type": "boolean",
                    "default": false,
                    "description": "`true` = cart picking, `false` = batch picking"
                  },
                  "orders_count": {
                    "type": "integer",
                    "description": "Split the fulfillment orders over this many picklists."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Note shown on the picklist"
                  },
                  "pickers": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "User ID to assign the picklist to. Only the first ID is used."
                  },
                  "delete_missing_stock_sales_items": {
                    "type": "boolean",
                    "default": false,
                    "description": "When `true`, lines without enough stock are reduced to the available\nquantity instead of failing the request.\n"
                  },
                  "turbo_label": {
                    "type": "boolean",
                    "default": false,
                    "description": "Generate labels synchronously (see description)."
                  }
                }
              },
              "examples": {
                "batch": {
                  "summary": "Batch picking",
                  "value": {
                    "fulfillment_orders": [
                      14619144,
                      14619143
                    ],
                    "cart": false,
                    "notes": "Handle with care",
                    "delete_missing_stock_sales_items": false,
                    "pickers": []
                  }
                },
                "cart": {
                  "summary": "Cart picking, assigned to a picker",
                  "value": {
                    "fulfillment_orders": [
                      14619140,
                      14619141
                    ],
                    "cart": true,
                    "notes": "",
                    "delete_missing_stock_sales_items": false,
                    "pickers": [
                      4778
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Picklist(s) created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "picking_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PickingOrder"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 1,
                  "picking_orders": [
                    {
                      "id": 79796,
                      "sequence_number": "PI-0000087",
                      "state": "queue",
                      "type": "consolidated",
                      "notes": "Handle with care",
                      "warehouse_id": 2236,
                      "owner": {},
                      "items": [
                        {
                          "fulfillment_order_id": 14619144,
                          "sales_order_id": 28237271,
                          "requested_quantity": 1,
                          "picked_quantity": 0
                        },
                        {
                          "fulfillment_order_id": 14619143,
                          "sales_order_id": 28237272,
                          "requested_quantity": 1,
                          "picked_quantity": 0
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "`fulfillment_orders` missing or empty.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "fulfillment_orders": "Parameter should be mandatory, list, not_empty"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Nothing was created. Unknown IDs, a fulfillment order that already has a\npicklist, or missing stock.\n",
            "content": {
              "application/json": {
                "examples": {
                  "unknownId": {
                    "summary": "Unknown fulfillment order",
                    "value": {
                      "errors": {
                        "message": "Invalid fulfillment orders: 99999999"
                      }
                    }
                  },
                  "alreadyPicked": {
                    "summary": "Already on a picklist",
                    "value": {
                      "errors": [
                        {
                          "fulfillment_order_id": "Picking orders are already created for the given fulfillment order"
                        }
                      ]
                    }
                  },
                  "missingStock": {
                    "summary": "Missing stock",
                    "value": {
                      "errors": [
                        {
                          "items": [
                            {
                              "id": "14619144",
                              "order_num": "SO-2026-4711",
                              "fulfillment_sequence_number": "FO-0000147",
                              "insufficient_stock": "not enough stock available for item with product \"NP0003\""
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/picking/orders/turbo": {
      "post": {
        "tags": [
          "Picking"
        ],
        "summary": "Create a turbo label batch picklist (asynchronous)",
        "description": "Turbo label version of `POST /picking/orders`: **one** picklist for all given\nfulfillment orders (`type: consolidated_turbo_label`, or `turbo_label` for a\nsingle FO). Before picking starts, PULPO creates a draft packing order per sales\norder and fetches the shipping labels.\n\n**Asynchronous.** The call returns `204 No Content` immediately. The work runs in\nthe background and can take from seconds to minutes, because labels come from\nexternal carrier systems. Track the result per fulfillment order with\n`GET /sales/orders/fulfillments` and its `process_information`:\n\n| `process_information.status` | Meaning |\n|------------------------------|---------|\n| `queue` | Waiting to be processed |\n| `started` | Picklist created, labels being fetched. `value` = picklist number |\n| `turbo_label_created` | Done. `value` = picklist number (e.g. `PI-0000095`) |\n| `error_creating_picking` | Failed. See `errors`. The fulfillment order stays in `queue` and can be submitted again |\n\n**Labels:** one packing box and label **per unit** in a draft packing order of\ntype `turbo_label`, one packing order per sales order.\n\n**Not supported here:** `cart: true` and `turbo_label_per_order: true` both end in\n`error_creating_picking`.\n\nUnknown fulfillment order IDs are rejected synchronously with `422`. All other\nerrors (missing stock, already on a picklist) only show up in\n`process_information`.\n\n**Matching the status to your request:** the `x-request-id` header of the `204`\nresponse equals `process_information.attributes.request_id` of the run it\nstarted. Ignore statuses with a different `request_id` — they are left over from\nan earlier run.\n",
        "operationId": "createTurboPickingOrder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fulfillment_orders"
                ],
                "properties": {
                  "fulfillment_orders": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "integer"
                    },
                    "example": [
                      14619146,
                      14619142
                    ]
                  },
                  "cart": {
                    "type": "boolean",
                    "default": false,
                    "description": "Must be `false`. Cart picking is not supported in turbo mode."
                  },
                  "notes": {
                    "type": "string"
                  },
                  "pickers": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "User ID to assign the picklist to. Only the first ID is used."
                  },
                  "delete_missing_stock_sales_items": {
                    "type": "boolean",
                    "default": false
                  },
                  "turbo_label": {
                    "type": "boolean",
                    "description": "Ignored — this call always works in turbo mode."
                  }
                }
              },
              "example": {
                "fulfillment_orders": [
                  14619146,
                  14619142
                ],
                "cart": false,
                "notes": "",
                "delete_missing_stock_sales_items": false,
                "pickers": [
                  4778
                ],
                "turbo_label": true
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Accepted. Processing runs in the background — poll `process_information`."
          },
          "400": {
            "description": "`fulfillment_orders` missing or empty.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "fulfillment_orders": "Parameter should be mandatory, list, not_empty"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown fulfillment order ID. Nothing was started.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "message": "Invalid fulfillment orders: 99999999"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/picking/bulk/orders/turbo": {
      "post": {
        "tags": [
          "Picking"
        ],
        "summary": "Create turbo label standard picklists (asynchronous)",
        "description": "Turbo label version of `POST /picking/bulk/orders`: **one** picklist per\nfulfillment order (`type: turbo_label`). Before picking starts, PULPO creates a\ndraft packing order per sales order and fetches the shipping labels.\n\n**Asynchronous.** The call returns `204 No Content` immediately. The work runs in\nthe background and can take from seconds to minutes, because labels come from\nexternal carrier systems. Track the result per fulfillment order with\n`GET /sales/orders/fulfillments` and its `process_information`:\n\n| `process_information.status` | Meaning |\n|------------------------------|---------|\n| `queue` | Waiting to be processed |\n| `started` | Picklist created, labels being fetched. `value` = picklist number |\n| `turbo_label_created` | Done. `value` = picklist number (e.g. `PI-0000092`) |\n| `error_creating_picking` | Failed. See `errors`. The fulfillment order stays in `queue` and can be submitted again |\n\nEach fulfillment order is processed on its own — one can fail while the others\nsucceed.\n\n**Labels:**\n- Default: one packing box and label **per unit**.\n- `turbo_label_per_order: true` with a `shipment_box_template_id`: **one** box and\n  label for the whole order. Without a template ID this fails with\n  `shipment_box_template_id_required_for_order_per_box_strategy`.\n\n**Errors only show up in `process_information`** — the call itself always\nreturns `204` once the body is valid. Unknown fulfillment order IDs are silently\nignored.\n\n**Matching the status to your request:** the `x-request-id` header of the `204`\nresponse equals `process_information.attributes.request_id` of the run it\nstarted. Ignore statuses with a different `request_id` — they are left over from\nan earlier run.\n",
        "operationId": "bulkCreateTurboPickingOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fulfillment_orders"
                ],
                "properties": {
                  "fulfillment_orders": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "integer"
                    },
                    "example": [
                      14619148
                    ]
                  },
                  "orders_count": {
                    "type": "integer",
                    "description": "Accepted but has no effect on this call."
                  },
                  "pickers": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "notes": {
                    "type": "string"
                  },
                  "delete_missing_stock_sales_items": {
                    "type": "boolean",
                    "default": false
                  },
                  "turbo_label": {
                    "type": "boolean",
                    "description": "Ignored — this call always works in turbo mode."
                  },
                  "turbo_label_per_order": {
                    "type": "boolean",
                    "default": false,
                    "description": "One box and label per order instead of per unit. Requires `shipment_box_template_id`."
                  },
                  "shipment_box_template_id": {
                    "type": "integer",
                    "nullable": true,
                    "description": "Box template for `turbo_label_per_order` (from `GET /packing/boxes`)."
                  }
                }
              },
              "examples": {
                "perUnit": {
                  "summary": "One label per unit",
                  "value": {
                    "fulfillment_orders": [
                      14619148
                    ],
                    "orders_count": 1,
                    "pickers": [],
                    "turbo_label": true,
                    "notes": "",
                    "delete_missing_stock_sales_items": false,
                    "turbo_label_per_order": false,
                    "shipment_box_template_id": null
                  }
                },
                "perOrder": {
                  "summary": "One label per order",
                  "value": {
                    "fulfillment_orders": [
                      14619148
                    ],
                    "turbo_label": true,
                    "turbo_label_per_order": true,
                    "shipment_box_template_id": 4299
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Accepted. Processing runs in the background — poll `process_information`."
          },
          "400": {
            "description": "`fulfillment_orders` missing or empty.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "fulfillment_orders": "Parameter should be mandatory, list, not_empty"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/picking/bulk/orders": {
      "post": {
        "tags": [
          "Picking"
        ],
        "summary": "Create standard picklists (one per order)",
        "description": "Creates **one picklist per fulfillment order** (`type: normal`). Use this for\nstandard picking. For one picklist covering several orders, use\n`POST /picking/orders`.\n\n`orders_count` has no effect here — there is always one picklist per order.\n\n**`pickers`:** the picklists are assigned to the given users in turn (first\npicklist → first picker, second → second picker, …). Each becomes the picklist\n`owner`; the picklist stays in `queue`.\n\n**Partial success:** each fulfillment order is handled on its own. Those that\nwork are listed in `created`, the others in `errors`. If at least one fails, the\nstatus is `400` — always read both lists. An unknown fulfillment order ID fails\nthe whole call with `422` and creates nothing.\n\n**`delete_missing_stock_sales_items: true`** reduces lines without enough stock to\nthe available quantity, so the picklist can still be created. The sales order\nkeeps its original quantities.\n\n**Turbo label:** with `turbo_label: true` the picklists are created as turbo label\npicklists and the labels are generated **within this request** (synchronous,\nabout 5 seconds per order on staging). For larger volumes use the asynchronous\n`POST /picking/bulk/orders/turbo` instead.\n",
        "operationId": "bulkCreatePickingOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fulfillment_orders"
                ],
                "properties": {
                  "fulfillment_orders": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "integer"
                    },
                    "example": [
                      14619150
                    ]
                  },
                  "orders_count": {
                    "type": "integer",
                    "description": "Accepted but has no effect on this call."
                  },
                  "pickers": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "User IDs, assigned to the picklists in turn."
                  },
                  "turbo_label": {
                    "type": "boolean",
                    "default": false,
                    "description": "Generate labels synchronously (see description)."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Note shown on every created picklist"
                  },
                  "delete_missing_stock_sales_items": {
                    "type": "boolean",
                    "default": false
                  }
                }
              },
              "example": {
                "fulfillment_orders": [
                  14619150
                ],
                "orders_count": 1,
                "pickers": [],
                "turbo_label": false,
                "notes": "",
                "delete_missing_stock_sales_items": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "All picklists created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PickingCreateError"
                },
                "example": {
                  "created": [
                    {
                      "id": 79787,
                      "sequence_number": "PI-0000078",
                      "notes": "",
                      "order_num": "SO-2026-4711",
                      "fulfillment_sequence_number": "FO-0000127"
                    }
                  ],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "At least one fulfillment order failed. Entries in `created` were still\ncreated. Also returned when `fulfillment_orders` is missing or empty.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PickingCreateError"
                },
                "examples": {
                  "partial": {
                    "summary": "One failed, one created",
                    "value": {
                      "created": [
                        {
                          "id": 79794,
                          "sequence_number": "PI-0000085",
                          "notes": null,
                          "order_num": "SO-2026-4712",
                          "fulfillment_sequence_number": "FO-0000135"
                        }
                      ],
                      "errors": [
                        {
                          "id": 15411495,
                          "order_num": "SO-2026-4711",
                          "fulfillment_sequence_number": "FO-0000126",
                          "items": [
                            {
                              "picking_already_created": "Picking orders are already created for the given fulfillment order: SO-2026-4711"
                            }
                          ]
                        }
                      ]
                    }
                  },
                  "missingStock": {
                    "summary": "Missing stock",
                    "value": {
                      "created": [],
                      "errors": [
                        {
                          "id": 15411612,
                          "order_num": "SO-2026-4713",
                          "fulfillment_sequence_number": "FO-0000145",
                          "items": [
                            {
                              "id": "15411612",
                              "order_num": "SO-2026-4713",
                              "fulfillment_sequence_number": "FO-0000145",
                              "insufficient_stock": "not enough stock available for item with product \"NP0003\""
                            }
                          ]
                        }
                      ]
                    }
                  },
                  "invalidPicker": {
                    "summary": "Unknown picker",
                    "value": {
                      "created": [],
                      "errors": [
                        {
                          "id": 15411602,
                          "order_num": "SO-2026-4714",
                          "fulfillment_sequence_number": "FO-0000136",
                          "owner_id": "Invalid picker id"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "An unknown fulfillment order ID was sent. Nothing was created.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "message": "An undefined error has been captured!"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Picking"
        ],
        "summary": "Delete picklists in bulk",
        "description": "Deletes several picklists in one call. The body is a plain JSON array of\npicklist IDs (`picking_orders[].id`), not wrapped in an object.\n\n**What happens to the orders:** the fulfillment orders and sales orders go back\nto `queue` and can be put on a new picklist. Nothing is cancelled. For turbo label\npicklists, the draft packing order and its labels are deleted too.\n\n`process_information` on the fulfillment order is **not** reset — it still shows\nthe deleted picklist's number until a new turbo run starts.\n\n**Partial success:** each ID is handled on its own. If at least one fails, the\nstatus is `422` — read both `deleted` and `errors`.\n\nTested on picklists in `queue` only.\n",
        "operationId": "bulkDeletePickingOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "integer"
                }
              },
              "example": [
                79786,
                79787
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "All picklists deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeletePickingResult"
                },
                "example": {
                  "deleted": [
                    {
                      "id": 79786,
                      "sequence_number": "PI-0000077",
                      "owner": {},
                      "creator": {}
                    },
                    {
                      "id": 79787,
                      "sequence_number": "PI-0000078",
                      "owner": {},
                      "creator": {}
                    }
                  ],
                  "errors": []
                }
              }
            }
          },
          "400": {
            "description": "Body is not a non-empty array of IDs.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "_json": "Parameter should be mandatory, <list,integer>, not_empty"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "At least one ID failed (unknown or already deleted). Entries in `deleted` were\nstill deleted.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeletePickingResult"
                },
                "example": {
                  "deleted": [
                    {
                      "id": 79787,
                      "sequence_number": "PI-0000078",
                      "owner": {},
                      "creator": {}
                    }
                  ],
                  "errors": [
                    {
                      "message": "invalid_picking_order",
                      "picking_order_id": 99999999
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/picking/orders/{id}": {
      "delete": {
        "tags": [
          "Picking"
        ],
        "summary": "Delete a picklist",
        "description": "Deletes one picklist. Same effect as `DELETE /picking/bulk/orders` with a single\nID: the orders go back to `queue`, and turbo label packing orders are removed.\nReturns the deleted picklist.\n",
        "operationId": "deletePickingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Picklist ID",
            "example": 79789
          }
        ],
        "responses": {
          "200": {
            "description": "Picklist deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "picking_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PickingOrder"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown or already deleted ID.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/packing/orders": {
      "get": {
        "tags": [
          "Packing"
        ],
        "summary": "List packing orders",
        "description": "Retrieves packing orders with filtering and pagination.\n\n**Possible states** (fixed, managed by PULPO): `draft`, `queue`, `taken`,\n`locked` (paused), `ended`, `closed`, `cancelled`.\n\nPass `state=locked` to retrieve paused packing orders — `locked` tasks are NOT\nincluded in `GET /iam/users/{id}/tasks`, only in this list.\n\n**Useful filters:**\n- `warehouse_id`\n- `state`\n- `sales_order_id` — packing orders related to a specific sales order\n- `view_attributes` — comma-separated field list (controls which nested\n  attributes are returned; useful to keep payloads small for queue views)\n\n**Performance:** pass `capped_limit=0` to skip the total-results count for\n~20% lower latency.\n",
        "operationId": "listPackingOrders",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "queue",
                "taken",
                "locked",
                "ended",
                "closed",
                "cancelled"
              ]
            }
          },
          {
            "name": "sales_order_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return. Example:\n`id,sequence_number,state,inserted_at,fulfillment_order_id,sales_order_id,origin_location,items,sales_order,fulfillment_order`.\n"
          }
        ],
        "responses": {
          "200": {
            "description": "Packing orders retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "packing_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PackingOrder"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/packing/orders/{id}": {
      "get": {
        "tags": [
          "Packing"
        ],
        "summary": "Get a packing order by ID",
        "description": "Returns the full packing order, including `owner`, `origin_location`,\n`packing_boxes[]` with attached labels (`attachments[]`), and the items to\npack.\n\nClients implementing the packing flow should call this endpoint to poll for\nlabel readiness after a box is closed (~5s interval, ~24 attempts).\n\n**Possible states** (fixed, managed by PULPO): `draft`, `queue`, `taken`,\n`locked` (paused), `ended`, `closed`, `cancelled`.\n",
        "operationId": "getPackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 1272633
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return"
          }
        ],
        "responses": {
          "200": {
            "description": "Packing order retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PackingOrder"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/packing/orders/{id}/accept": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Claim (accept) a packing order",
        "description": "Transitions `queue → taken` and sets `owner` to the calling user.\n\nA user may only own one active packing order at a time. Use\n`GET /iam/users/{id}/tasks` first to ensure no other task is owned.\n\nIf the order is in `locked` state and the caller is the original owner, use\n`/unlock` instead. If the caller is not the original owner of a `locked`\norder, call `/unlock` (returns the order to `queue`) and then `/accept`.\n",
        "operationId": "acceptPackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Packing order claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PackingOrder"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/packing/orders/{id}/lock": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Pause (lock) a packing order",
        "description": "Pauses an in-flight packing order. Transitions `taken → locked` while keeping\nthe current owner. The task disappears from `GET /iam/users/{id}/tasks` but\nremains visible via `GET /packing/orders?state=locked`.\n\nResume with `/unlock` (owner) or by `/unlock` + `/accept` (different user).\n",
        "operationId": "lockPackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Packing order locked"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/packing/orders/{id}/unlock": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Resume (unlock) a packing order",
        "description": "Unlocks a paused packing order. Behavior depends on the caller:\n\n| Caller | Transition |\n|--------|------------|\n| Original owner | `locked → taken` (resumes work) |\n| Any other user | `locked → queue` (owner is cleared; the task can then be `/accept`-ed by anyone) |\n",
        "operationId": "unlockPackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Packing order unlocked"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/packing/orders/{id}/boxes": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Close one or more packing boxes (replace boxes array)",
        "description": "Commits the set of closed packing boxes for the packing order.\n\n**Important — replace semantics:** the request body is a complete list of\nboxes that should exist for this order. The server **replaces** (not appends)\nthe existing boxes. Callers MUST resend every previously-closed box in this\nlist or those records will be wiped.\n\nEach box must include `box_number` (1-indexed across the full list) and\n`packing_order_id` (matching the path parameter).\n",
        "operationId": "closePackingBoxes",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PackingBoxInput"
                }
              },
              "example": [
                {
                  "packing_order_id": 1272633,
                  "box_number": 1,
                  "weight": 1.5,
                  "length": 30,
                  "width": 20,
                  "height": 15,
                  "packing_box_items": [
                    {
                      "product_id": 7646303,
                      "quantity": 2
                    }
                  ]
                },
                {
                  "packing_order_id": 1272633,
                  "box_number": 2,
                  "weight": 0.8,
                  "length": 25,
                  "width": 18,
                  "height": 10,
                  "packing_box_items": [
                    {
                      "product_id": 7646305,
                      "quantity": 1
                    }
                  ]
                }
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Boxes committed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "description": "PackingBox ID (in the same order as the request)"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Invalid state transition (e.g., order state went back to `queue` after a non-owner unlock)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/packing/orders/{packing_order_id}/boxes/{box_id}/attach": {
      "post": {
        "tags": [
          "Packing",
          "Label Provider Integration"
        ],
        "summary": "Attach label file to packing box",
        "description": "Uploads a shipping label PDF file to a packing box.\n\n**File Requirements:**\n- Format: PDF\n- Type: `label`\n- Max size: Check with PULPO support\n\n**Workflow:**\n1. Update shipment tracking to \"started\"\n2. Generate label PDF in your system\n3. POST label file to this endpoint\n4. Update shipment tracking to \"generated\" with tracking codes\n",
        "operationId": "attachLabelToBox",
        "parameters": [
          {
            "name": "packing_order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "box_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "attachment": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF file of shipping label"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "label"
                    ],
                    "default": "label"
                  }
                },
                "required": [
                  "attachment",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Label attached successfully"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/packing/orders/{id}/finish": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Finish a packing order",
        "description": "Transitions `taken → ended`. All items must be packed and each closed box\nmust have a label attachment (or `pulpowms_label_not_required` status).\n\nAfter `/finish`, call `/close` with a `shipping_location_id` to release the\nowner lock and move the order to `closed`.\n",
        "operationId": "finishPackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Packing order finished"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/packing/orders/{id}/close": {
      "post": {
        "tags": [
          "Packing"
        ],
        "summary": "Close a packing order",
        "description": "Final step of the packing flow. Transitions `ended → closed`, sets\n`end_date`, and releases the owner's \"one active task\" slot so they can\nclaim a new packing order.\n\nRequires a `shipping_location_id` — the warehouse location where the\npacked boxes are physically dropped off for the carrier. Look it up via\n`GET /warehouses/locations?location_type_id={shipping_area}` (the shipping\narea location type for the warehouse).\n",
        "operationId": "closePackingOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "shipping_location_id"
                ],
                "properties": {
                  "shipping_location_id": {
                    "type": "integer",
                    "description": "Warehouse location where the boxes are dropped off"
                  }
                }
              },
              "example": {
                "shipping_location_id": 109911
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Packing order closed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/packing/orders/{packing_order_id}/boxes/{box_id}/shipment_tracking/{tracking_id}": {
      "put": {
        "tags": [
          "Packing",
          "Label Provider Integration"
        ],
        "summary": "Update shipment tracking information",
        "description": "Updates shipment tracking for a specific packing box.\n\n**Label Generation Workflow:**\n1. Subscribe to `packing_box_closed` webhook\n2. Receive webhook when box is closed\n3. PUT with status `pulpowms_label_generation_started`\n4. Generate label in your system\n5. POST label file to attach endpoint\n6. PUT with status `pulpowms_label_generated` + tracking info\n\n**Status Values:**\n- `null`: Initial state\n- `pulpowms_label_generation_started`: Label generation in progress\n- `pulpowms_label_generated`: Label successfully created\n- `pulpowms_label_generation_failed`: Label creation failed\n- `pulpowms_label_not_required`: Skip label (no waiting)\n\n**Retrying a failed label:** PUT this endpoint with body `{ \"retry\": true }`\nto re-trigger label generation for the same tracking record. Combine with\n`PATCH /fulfillment_orders/{id}/ship_to` first if the failure was an\naddress issue.\n\n**Polling:** after triggering label generation, poll\n`GET /packing/orders/{id}` every ~5 seconds for up to ~2 minutes (24 attempts).\nTreat the presence of `packing_boxes[].attachments[0].url` as the readiness\nsignal — not `shipment_tracking.status` alone. PULPO's own app gives up at\nthe 2-minute mark.\n",
        "operationId": "updateShipmentTracking",
        "parameters": [
          {
            "name": "packing_order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 35149
          },
          {
            "name": "box_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 24157
          },
          {
            "name": "tracking_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 14704
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShipmentTrackingUpdate"
              },
              "examples": {
                "started": {
                  "summary": "Label generation started",
                  "value": {
                    "status": "pulpowms_label_generation_started",
                    "error_message": ""
                  }
                },
                "success": {
                  "summary": "Label generated successfully",
                  "value": {
                    "status": "pulpowms_label_generated",
                    "tracking_code": "1Z999AA10123456784",
                    "tracking_url": "https://www.ups.com/track?tracknum=1Z999AA10123456784",
                    "carrier_code": "UPS",
                    "error_message": ""
                  }
                },
                "failed": {
                  "summary": "Label generation failed",
                  "value": {
                    "status": "pulpowms_label_generation_failed",
                    "error_message": "Carrier API timeout - please retry"
                  }
                },
                "notRequired": {
                  "summary": "Label not required for this box",
                  "value": {
                    "status": "pulpowms_label_not_required",
                    "error_message": "All labels attached to first box"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Shipment tracking updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShipmentTracking"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/sales/orders": {
      "get": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Search sales orders",
        "description": "Searches and filters sales orders with pagination. Supports a wide range of filters\nfor querying orders by state, date, customer, product, and more.\n\n**Possible states** (fixed, managed by PULPO): `queue`, `picking`, `packing`,\n`shipping`, `ended`, `cancelled`. A paused order is not a sales order state — it\nshows as `paused` on `fulfillment_orders[].state` while the sales order stays in\n`queue`.\n\n**Date filters** support range queries:\n- `between:2024-01-01 00:00:00,2024-03-31 23:59:59`\n- `gte:2024-01-01 00:00:00` (greater than or equal)\n- `lte:2024-03-31 23:59:59` (less than or equal)\n\n**Numeric filters** (order_items_count, volume, weight):\n- `gte:value`, `gt:value`, `lte:value`, `lt:value`\n\n**Product filters:**\n- `product_id=123` — orders containing this product\n- `product_id=includes:123,456` — orders containing any of these products\n- `not_product_id=123` — orders NOT containing this product\n\n**Priority filters:**\n- `priority=2` — single priority\n- `priority=to_list:1,2,3` — multiple priorities\n\n**Performance tip:** Use `view_attributes=id,order_num,state` to return only specific fields.\n",
        "operationId": "searchSalesOrders",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queue",
                "picking",
                "packing",
                "shipping",
                "ended",
                "cancelled"
              ]
            },
            "description": "Filter by order state",
            "example": "queue"
          },
          {
            "name": "order_num",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by external order number",
            "example": "SO-2024-12345"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter by warehouse ID",
            "example": 140
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by merchant ID. Use `to_list:1,2,3` for multiple.",
            "example": "69"
          },
          {
            "name": "third_party_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter by customer/third party ID"
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by customer client ID"
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Orders containing this product. Use `includes:id1,id2` for multiple.",
            "example": "1957711"
          },
          {
            "name": "not_product_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Orders NOT containing this product"
          },
          {
            "name": "priority",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by priority. Use `to_list:1,2` for multiple.",
            "example": "2"
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by sales channel"
          },
          {
            "name": "inserted_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Creation date filter (format: YYYY-MM-DD hh:mm:ss). Supports `between:`, `gte:`, `lte:`",
            "example": "between:2024-03-01 00:00:00,2024-03-31 23:59:59"
          },
          {
            "name": "updated_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Last update filter (format: YYYY-MM-DD hh:mm:ss). Supports `between:`, `gte:`, `lte:`"
          },
          {
            "name": "delivery_date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Delivery date filter. Supports `between:`, `gte:`, `lte:`"
          },
          {
            "name": "order_items_count",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by number of line items. Supports `gte:`, `gt:`, `lte:`, `lt:`"
          },
          {
            "name": "estimated_total_weight",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by total weight. Supports `gte:`, `gt:`, `lte:`, `lt:`"
          },
          {
            "name": "estimated_total_volume",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by total volume. Supports `gte:`, `gt:`, `lte:`, `lt:`"
          },
          {
            "name": "order_products_qty",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by total product quantity. Supports `gte:`, `gt:`, `lte:`, `lt:`"
          },
          {
            "name": "criterium",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by criterium. Use `to_list:` for multiple."
          },
          {
            "name": "return_label",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by return label code"
          },
          {
            "name": "product_category_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Orders with products matching category ID"
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return (e.g. `id,order_num,state`). No associations supported.",
            "example": "id,order_num,state,inserted_at"
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by sales order ID"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          }
        ],
        "responses": {
          "200": {
            "description": "Sales orders retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "sales_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SalesOrder"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 42,
                  "sales_orders": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "type": "sales_order",
                      "state": "queue",
                      "warehouse_id": 140,
                      "merchant_id": 69,
                      "merchant_channel_id": 76,
                      "priority": 2,
                      "delivery_date": "2024-03-26T14:00:00",
                      "inserted_at": "2024-03-25T10:00:00",
                      "updated_at": "2024-03-25T10:00:00"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/orders/{id}": {
      "get": {
        "tags": [
          "Sales Orders",
          "Returns"
        ],
        "summary": "Get sales order by ID",
        "description": "Retrieves detailed information about a specific sales order by its PULPO ID.\n\n**Use cases:**\n- Get order details for creating a return purchase order\n- Check current order state and fulfillment status\n- Retrieve product list, quantities, and batch information\n- Get the `third_party_id` (customer) needed for return orders\n\n**Response includes:**\n- Order metadata (state, dates, merchant info)\n- Items with product IDs, SKUs, and quantities\n- Ship-to address and customer details\n- Shipment instructions and tracking info\n- Batch/lot information for batch-controlled products\n\n**Possible states** (fixed, managed by PULPO): `queue`, `picking`, `packing`,\n`shipping`, `ended`, `cancelled`. A paused order shows as `paused` on\n`fulfillment_orders[].state`, not on the sales order.\n",
        "operationId": "getSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 13283307
          }
        ],
        "responses": {
          "200": {
            "description": "Sales order retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                },
                "example": {
                  "id": 13283307,
                  "order_num": "SO-2024-12345",
                  "type": "sales_order",
                  "state": "ended",
                  "warehouse_id": 140,
                  "merchant_id": 69,
                  "merchant_channel_id": 76,
                  "third_party_id": 3218516,
                  "priority": 2,
                  "delivery_date": "2024-03-26T14:00:00",
                  "shipping_method_id": 952,
                  "notes": null,
                  "inserted_at": "2024-03-25T10:00:00",
                  "updated_at": "2024-03-27T16:30:00",
                  "items": [
                    {
                      "product_id": 7646303,
                      "product_sku": "COFFEE-001",
                      "quantity": 5,
                      "batches": [
                        "LOT-2025-001"
                      ]
                    },
                    {
                      "product_id": 7646305,
                      "product_sku": "MUG-002",
                      "quantity": 2,
                      "batches": []
                    }
                  ],
                  "ship_to": {
                    "name": "John Smith",
                    "company_name": "John's Coffee Shop",
                    "phone_number": "+44 20 1234 5678",
                    "address": {
                      "street": "123 High Street",
                      "city": "London",
                      "zip": "SW1A 1AA",
                      "country": "GB",
                      "country_code": "826",
                      "email": "john@coffeeshop.com"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Update a single sales order",
        "description": "Updates an individual sales order by ID. Use this when editing one order\nwith a partial payload — for batch updates, use `PUT /sales/bulk/orders`.\n\n### Editable fields\n\n- `notes`\n- `priority` (1=low, 2=normal, 3=high, 4=top)\n- `delivery_date`\n- `items` — replaces the full line-item list; each item may include `id`\n  (to match an existing line), `product_id`, and `quantity`\n- `ship_to` — when only the address changes for an in-flight order, prefer\n  `PATCH /fulfillment_orders/{id}/ship_to` (the address actually used by\n  shipping)\n\n### Edit window\n\nUpdates are rejected when the order is in `picking`, `in_picking`, `packing`,\n`in_packing`, `packed`, `ended`, or `cancelled` states. Clients should\ngate the edit UI on these states.\n",
        "operationId": "updateSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 13283307
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4
                  },
                  "delivery_date": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "description": "Existing line ID (omit to add a new line)"
                        },
                        "product_id": {
                          "type": "integer"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 1
                        }
                      }
                    }
                  },
                  "ship_to": {
                    "$ref": "#/components/schemas/ShipTo"
                  }
                }
              },
              "example": {
                "notes": "Rush — confirmed by customer",
                "priority": 4,
                "delivery_date": "2024-03-26T10:00:00"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sales order updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/sales/bulk/orders": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Create sales orders in bulk",
        "description": "Creates multiple sales orders for outgoing fulfillment.\n\n**Order Types:**\n- `sales_order`: Standard outgoing order (default)\n- `warehouse_movement`: Transfer to another warehouse\n- `return`: Return to supplier\n- `POS_external`: Direct stock reduction (no picking/packing)\n\n**Workflow:**\n1. Create sales order via API\n2. Warehouse picks items (Android app)\n3. Webhook `packing_order_finished` fires (Picking Complete)\n4. Warehouse packs items (Android app)\n5. Webhook `sales_order_finished` fires (Post Goods Issue)\n\n**Customer:** `third_party_id` is required — create the customer first via\n`POST /iam/bulk/third_parties` (type=C), then pass its `id` here.\n\n**Priorities:** required. 1=low, 2=normal, 3=high, 4=top — send `1` if you\ndon't have a use case for it.\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkCreateSalesOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SalesOrderInput"
                }
              },
              "examples": {
                "withExistingCustomer": {
                  "summary": "Order with existing customer",
                  "value": [
                    {
                      "type": "sales_order",
                      "order_num": "SO-2024-12345",
                      "delivery_date": "2024-03-26T14:00:00",
                      "warehouse_id": 140,
                      "merchant_id": 69,
                      "merchant_channel_id": 76,
                      "third_party_id": 3218516,
                      "priority": 2,
                      "shipping_method_id": 952,
                      "items": [
                        {
                          "product_sku": "COFFEE-001",
                          "quantity": 5
                        }
                      ],
                      "ship_to": {
                        "name": "John Smith",
                        "company_name": "John's Coffee Shop",
                        "phone_number": "+44 20 1234 5678",
                        "address": {
                          "street": "123 High Street",
                          "city": "London",
                          "zip": "SW1A 1AA",
                          "country": "GB",
                          "country_code": "826",
                          "email": "john@coffeeshop.com"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sales orders processed. Check `created` for the orders that succeeded\nand `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateSalesOrdersResponse"
                },
                "example": {
                  "created": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "All items failed validation — none were created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateSalesOrdersResponse"
                },
                "example": {
                  "created": [],
                  "errors": {
                    "SO-2024-12345": {
                      "third_party_id": "can't be blank",
                      "priority": "can't be blank"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "put": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Update sales orders in bulk",
        "description": "Updates multiple existing sales orders. Works as bulk — if any update fails,\nthe remaining orders continue processing. This is a partial update — send\nonly the fields you want to change, plus an identifier.\n\n**Updatable fields:**\n- `order_num`: External order number\n- `delivery_date`: Delivery date\n- `priority`: Order priority (1=low, 2=normal, 3=high, 4=top)\n- `ship_to`: Shipping address\n- `notes`: Order notes\n- `items`: Order line items (replaces existing items)\n- `shipping_method_id`: Shipping method\n- `attributes`: Custom attributes\n\n**Important:**\n- Orders must be identified by `order_num` or `id`\n- Orders in state `ended` or `cancelled` cannot be updated\n- Updating items replaces the full item list\n- Updating `attributes` replaces the whole object — keys you leave out are\n  deleted, so resend every key you want to keep\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkUpdateSalesOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SalesOrderInput"
                }
              },
              "examples": {
                "rushOrder": {
                  "summary": "Change priority, notes, and delivery date",
                  "value": [
                    {
                      "order_num": "SO-2024-12345",
                      "priority": 4,
                      "notes": "Rush order - expedite",
                      "delivery_date": "2024-03-25T09:00:00"
                    }
                  ]
                },
                "updateAttributes": {
                  "summary": "Update custom attributes",
                  "description": "`attributes` is replaced as a whole — include every key you want\nto keep, not just the ones you're changing.\n",
                  "value": [
                    {
                      "order_num": "SO-2024-12345",
                      "attributes": {
                        "channel_order_ref": "AMZ-302-4471829",
                        "gift_wrap": true,
                        "gift_message": "Happy birthday, Anna!",
                        "customer_tier": "gold",
                        "packing_instructions": {
                          "branded_tape": true,
                          "insert_flyer": "SPRING26"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sales orders processed. Check `updated` for the orders that succeeded\nand `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "All items failed (e.g. unknown order, or state doesn't allow updates).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [],
                  "errors": {
                    "SO-2024-12345": {
                      "id": "can't find sales order with order_num \"SO-2024-12345\""
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales/bulk/orders/quick": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Create POS orders (instant stock reduction)",
        "description": "Creates sales orders of type `POS_external` that immediately reduce stock without\ngoing through picking/packing processes.\n\n**Use cases:**\n- Point of sale transactions\n- Direct sales from warehouse\n- Stock adjustments via sales\n\n**Behavior:**\n- Order status immediately changes to \"finished\"\n- Stock is reduced instantly\n- No picking or packing tasks created\n- Webhook `sales_order_finished` fires immediately\n\nDespite the instant-fulfillment behavior, `delivery_date` is still required\nby the schema — send the current time if you don't have a real one.\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkCreateQuickOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SalesOrderInput"
                }
              },
              "example": [
                {
                  "type": "POS_external",
                  "order_num": "POS-2024-001",
                  "delivery_date": "2024-03-26T14:00:00",
                  "warehouse_id": 140,
                  "merchant_id": 69,
                  "merchant_channel_id": 76,
                  "third_party_id": 3218516,
                  "priority": 1,
                  "items": [
                    {
                      "product_sku": "COFFEE-001",
                      "quantity": 2
                    }
                  ]
                }
              ]
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quick orders processed and fulfilled. Check `created` for the orders\nthat succeeded and `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateSalesOrdersResponse"
                },
                "example": {
                  "created": [
                    {
                      "id": 13283400,
                      "order_num": "POS-2024-001",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "All items failed (validation error or insufficient stock).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateSalesOrdersResponse"
                },
                "example": {
                  "created": [],
                  "errors": {
                    "POS-2024-001": {
                      "message": "insufficient_stock_quantity",
                      "product_ids": [
                        1957711
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales/orders/fulfillments": {
      "get": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Search fulfillment orders",
        "description": "Lists fulfillment orders. Use it to read the `fulfillment_orders[].id` values\nfor picking, and to poll `process_information` after an asynchronous turbo\nlabel picking request.\n\n**Polling turbo label picking:**\n`GET /sales/orders/fulfillments?view_attributes=id,order_num,sequence_number,process_information&id=to_list:14619148,14619149`\n— repeat until every `process_information.status` is `turbo_label_created` or\n`error_creating_picking`.\n\nOnly trust a status whose `attributes.request_id` equals the `x-request-id`\nresponse header of your turbo call. `process_information` keeps the result of the\nprevious run — including after its picklist was deleted — until a new run starts.\n\n`total_results` is `null` when `offset` is greater than 0.\n",
        "operationId": "searchFulfillmentOrders",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "One ID, or several with `to_list:` (e.g. `to_list:14619148,14619149`)",
            "example": "to_list:14619148,14619149"
          },
          {
            "name": "sales_order_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 28237369
          },
          {
            "name": "order_num",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "SO-2026-4711"
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "queue"
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return",
            "example": "id,order_num,sequence_number,process_information"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Fulfillment orders retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "nullable": true
                    },
                    "fulfillment_orders": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "sequence_number": {
                            "type": "string"
                          },
                          "order_num": {
                            "type": "string"
                          },
                          "sales_order_id": {
                            "type": "integer"
                          },
                          "state": {
                            "type": "string"
                          },
                          "process_information": {
                            "$ref": "#/components/schemas/ProcessInformation"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "done": {
                    "summary": "Labels created",
                    "value": {
                      "total_results": 1,
                      "fulfillment_orders": [
                        {
                          "id": 14619148,
                          "order_num": "SO-2026-4711",
                          "sequence_number": "FO-0000149",
                          "process_information": {
                            "id": 378867,
                            "process": "turbo_label",
                            "status": "turbo_label_created",
                            "value": "PI-0000092",
                            "errors": {},
                            "attributes": {
                              "request_id": "GOM4Ux3YD8fPFZQAAbUy"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "failed": {
                    "summary": "Picklist creation failed",
                    "value": {
                      "total_results": 1,
                      "fulfillment_orders": [
                        {
                          "id": 15411612,
                          "order_num": "SO-2026-4713",
                          "sequence_number": "FO-0000145",
                          "process_information": {
                            "id": 378882,
                            "process": "turbo_label",
                            "status": "error_creating_picking",
                            "value": null,
                            "errors": {
                              "items": [
                                {
                                  "id": "15411612",
                                  "order_num": "SO-2026-4713",
                                  "insufficient_stock": "not enough stock available for item with product \"NP0003\""
                                }
                              ]
                            },
                            "attributes": {
                              "request_id": "GOM4imc-fnoXhVkAAcSS"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/fulfillment_orders/{id}/ship_to": {
      "patch": {
        "tags": [
          "Sales Orders",
          "Packing"
        ],
        "summary": "Update the ship-to address on a fulfillment order",
        "description": "Updates the delivery address used during packing/shipping. This is the\nendpoint to call when a label generation failure was caused by a bad\naddress — fix the address here, then retry label generation by calling\n`PUT /packing/orders/{id}/boxes/{box_id}/shipment_tracking/{tracking_id}`\nwith `{ \"retry\": true }`.\n\nAddress changes via this endpoint do not propagate back to the parent\nsales order's `ship_to`; use `PUT /sales/orders/{id}` or\n`PUT /sales/bulk/orders` to persist the change there too.\n",
        "operationId": "updateFulfillmentOrderShipTo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Fulfillment order ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShipTo"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Address updated"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/sales/orders/{id}/cancel": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Cancel a single sales order",
        "description": "Cancels a specific sales order by ID.\n\n**Cancellation rules:**\n- Orders in state `ended` **cannot** be cancelled\n- Orders in state `picking` cannot be cancelled when no packing locations are available\n- The result depends on current state:\n  - `queue` → cancelled immediately\n  - `picking` → picking cancelled, items returned to stock\n  - `packing` → packing cancelled, items returned to stock\n",
        "operationId": "cancelSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 13283307
          }
        ],
        "responses": {
          "200": {
            "description": "Sales order cancelled"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/bulk/orders/cancel": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Cancel sales orders in bulk",
        "description": "Cancels multiple sales orders. Supports multiple payload formats for flexibility.\n\n**Payload formats:**\n- Array of objects with `order_num`: `[{\"order_num\": \"SO-001\"}, ...]`\n- Array of order numbers: `[\"SO-001\", \"SO-002\", ...]`\n- Array of objects with `id`: `[{\"id\": 123}, ...]`\n- Array of IDs: `[123, 456, ...]`\n\n**Cancellation rules:**\n- Orders in state `ended` **cannot** be cancelled\n- Orders in state `picking` cannot be cancelled when there are no available packing locations\n- The cancellation action depends on the current order state:\n  - `queue` → cancelled immediately\n  - `picking` → picking task cancelled, items returned\n  - `packing` → packing task cancelled, items returned\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkCancelSalesOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/SalesOrderReference"
                    },
                    "title": "By order_num or id objects"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "title": "By order_num strings"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "title": "By ID numbers"
                  }
                ]
              },
              "examples": {
                "byOrderNum": {
                  "summary": "Cancel by order numbers",
                  "value": [
                    {
                      "order_num": "SO-2024-12345"
                    },
                    {
                      "order_num": "SO-2024-12346"
                    }
                  ]
                },
                "byId": {
                  "summary": "Cancel by IDs",
                  "value": [
                    {
                      "id": 13283307
                    },
                    {
                      "id": 13283308
                    }
                  ]
                },
                "byStringList": {
                  "summary": "Cancel by order number strings",
                  "value": [
                    "SO-2024-12345",
                    "SO-2024-12346"
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sales orders processed. Check `updated` for the orders that were\ncancelled and `errors` for the ones that weren't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "All items failed (e.g. unknown order, or state doesn't allow cancellation).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [],
                  "errors": {
                    "SO-2024-12345": {
                      "state": "can't cancel sales order with state \"cancelled\""
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales/orders/{id}/pause": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Pause a single sales order",
        "description": "Pauses a sales order. Only orders in state `queue` can be paused.\nPaused orders are not available for picking.\n",
        "operationId": "pauseSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 13283307
          }
        ],
        "responses": {
          "200": {
            "description": "Sales order paused"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/bulk/orders/pause": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Pause sales orders in bulk",
        "description": "Pauses multiple sales orders. Only orders in state `queue` can be paused.\n\n**Payload formats** (same as cancel):\n- `[{\"order_num\": \"SO-001\"}, ...]`\n- `[\"SO-001\", ...]`\n- `[{\"id\": 123}, ...]`\n- `[123, ...]`\n\nPaused orders will not be picked until resumed.\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkPauseSalesOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/SalesOrderReference"
                    }
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                ]
              },
              "examples": {
                "byOrderNum": {
                  "summary": "Pause by order numbers",
                  "value": [
                    {
                      "order_num": "SO-2024-12345"
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sales orders processed. Check `updated` for the orders that were\npaused and `errors` for the ones that weren't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/orders/{id}/resume": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Resume a paused sales order",
        "description": "Resumes a paused sales order. Only orders in state `paused` can be resumed.\nThe order returns to `queue` state and becomes available for picking.\n",
        "operationId": "resumeSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 13283307
          }
        ],
        "responses": {
          "200": {
            "description": "Sales order resumed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/bulk/orders/resume": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Resume sales orders in bulk",
        "description": "Resumes previously paused sales orders. Only orders in state `paused` can be resumed.\nResumed orders return to `queue` state and become available for picking.\n\n**Payload formats** (same as cancel/pause):\n- `[{\"order_num\": \"SO-001\"}, ...]`\n- `[\"SO-001\", ...]`\n- `[{\"id\": 123}, ...]`\n- `[123, ...]`\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkResumeSalesOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/SalesOrderReference"
                    }
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                ]
              },
              "examples": {
                "byOrderNum": {
                  "summary": "Resume by order numbers",
                  "value": [
                    {
                      "order_num": "SO-2024-12345"
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sales orders processed. Check `updated` for the orders that were\nresumed and `errors` for the ones that weren't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateSalesOrdersResponse"
                },
                "example": {
                  "updated": [
                    {
                      "id": 13283307,
                      "order_num": "SO-2024-12345",
                      "return_labels": []
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/sales/orders/{id}/returns": {
      "get": {
        "tags": [
          "Sales Orders",
          "Returns"
        ],
        "summary": "Get returns for a sales order",
        "description": "Returns the return data associated with a specific sales order.\n\n**Use cases:**\n- Check if a sales order has any associated return purchase orders\n- Get details of returned products and quantities\n- Verify return status before creating a new return\n\nThis is useful to avoid creating duplicate returns and to track\nthe return history of an order.\n",
        "operationId": "getSalesOrderReturns",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 13283307
          }
        ],
        "responses": {
          "200": {
            "description": "Return data retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sales_order_id": {
                      "type": "integer",
                      "example": 13283307
                    },
                    "returns": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "purchase_order_id": {
                            "type": "integer",
                            "description": "Return purchase order ID",
                            "example": 892341
                          },
                          "order_num": {
                            "type": "string",
                            "example": "TRACK-123456"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "queue",
                              "receiving",
                              "ended",
                              "cancelled"
                            ],
                            "example": "ended"
                          },
                          "items": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "product_id": {
                                  "type": "integer",
                                  "example": 7646303
                                },
                                "product_sku": {
                                  "type": "string",
                                  "example": "COFFEE-001"
                                },
                                "requested_quantity": {
                                  "type": "integer",
                                  "example": 2
                                },
                                "received_quantity": {
                                  "type": "integer",
                                  "example": 2
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/sales/orders/{id}/attach": {
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Attach a file to a sales order",
        "description": "Uploads one file (for example a delivery note) and attaches it to the sales order.\nSend it as `multipart/form-data`. Each call adds a new attachment — uploading the\nsame file twice creates two attachments.\n\n**`type`** — one of `document`, `label`, `photo` or `undefined`. Left out or empty,\nit is stored as `undefined`. Any other value is rejected.\n\n**`document_type`** — only allowed with `type=document`. It is free text and stored\nexactly as sent (no fixed list, case is kept), for example `delivery_note` or\n`invoice`. Sending it with any other `type` is rejected.\n\n**Files:** PDF and images (PNG tested) are accepted, plain text files are rejected.\n\nAttachments can be added in any order state, including `ended`. They are returned\nin `attachments[]` when you fetch or search the sales order.\n",
        "operationId": "attachFileToSalesOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 28188860
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "attachment"
                ],
                "properties": {
                  "attachment": {
                    "type": "string",
                    "format": "binary",
                    "description": "The file to upload (PDF or image)."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "document",
                      "label",
                      "photo",
                      "undefined"
                    ],
                    "default": "undefined"
                  },
                  "document_type": {
                    "type": "string",
                    "description": "Free text, only with `type=document`. Example `delivery_note`."
                  },
                  "filename": {
                    "type": "string",
                    "description": "Name to store instead of the uploaded file's name."
                  }
                }
              },
              "example": {
                "attachment": "delivery_note_4711.pdf",
                "type": "document",
                "document_type": "delivery_note"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "File attached. The body is the full sales order (same shape as\n`GET /sales/orders/{id}`) including the new entry in `attachments[]`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                },
                "example": {
                  "id": 28188860,
                  "order_num": "SO-2026-4711",
                  "state": "queue",
                  "attachments": [
                    {
                      "id": "02ff6301-d514-43f1-896b-391ba9a94d8a",
                      "name": "delivery_note_4711.pdf",
                      "type": "document",
                      "document_type": "delivery_note",
                      "extension": "pdf",
                      "file_type": "application/pdf",
                      "url": "https://s3.eu-central-1.amazonaws.com/pulpo-wms-eu-show-attachments/uploads/02ff6301-d514-43f1-896b-391ba9a94d8a.pdf"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid `type`, `document_type` without `type=document`, or a missing or unsupported file.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "invalidType": {
                    "summary": "Unknown type",
                    "value": {
                      "errors": {
                        "type": "is invalid"
                      }
                    }
                  },
                  "documentTypeNotAllowed": {
                    "summary": "document_type with type other than document",
                    "value": {
                      "errors": {
                        "document_type": "there_can_only_be_a_document_type_when_type_is_document"
                      }
                    }
                  },
                  "noFile": {
                    "summary": "No file sent",
                    "value": {
                      "errors": {
                        "message": "invalid_or_empty_attachment"
                      }
                    }
                  },
                  "invalidFile": {
                    "summary": "Unsupported file (e.g. .txt)",
                    "value": {
                      "errors": {
                        "message": "invalid_file"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown sales order ID.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales/orders/{id}/attachments/{attachment_id}": {
      "delete": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Delete a sales order attachment",
        "description": "Removes one attachment from the sales order. Returns the full sales order without\nthe removed entry.\n",
        "operationId": "deleteSalesOrderAttachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Sales order ID",
            "example": 28188860
          },
          {
            "name": "attachment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Attachment ID (UUID) from `attachments[].id`",
            "example": "02ff6301-d514-43f1-896b-391ba9a94d8a"
          }
        ],
        "responses": {
          "200": {
            "description": "Attachment removed. The body is the full sales order.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown or already deleted attachment ID.",
            "content": {
              "application/json": {
                "example": {
                  "errors": {
                    "attachment_id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shipping/shipping_methods": {
      "get": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Search shipping methods",
        "description": "Lists the shipping methods the user can access. Use it to find the `id` you send\nas `shipping_method_id` when creating sales orders.\n\n**Filters** (`name`, `carrier`, `merchant_id`, `merchant_channel_id`) are exact\nand case-sensitive matches: `name=FedEx` finds \"FedEx\", `name=fedex` and\n`name=Fed` find nothing. Filters combine with AND. There is no `service` filter.\n\n`total_results` is `null` when `offset` is greater than 0.\n",
        "operationId": "searchShippingMethods",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact shipping method name (case-sensitive)",
            "example": "DHL Standard"
          },
          {
            "name": "carrier",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact carrier (case-sensitive)",
            "example": "DHL"
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Only methods of this merchant",
            "example": 1053
          },
          {
            "name": "merchant_channel_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Only methods of this merchant channel",
            "example": 1068
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          }
        ],
        "responses": {
          "200": {
            "description": "Shipping methods retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "nullable": true,
                      "description": "Total matches. `null` when `offset` is greater than 0."
                    },
                    "shipping_methods": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ShippingMethod"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 2,
                  "shipping_methods": [
                    {
                      "id": 3218,
                      "name": "DHL Standard",
                      "carrier": "DHL",
                      "service": "standard",
                      "fetch_label": true,
                      "merchant_id": 1053,
                      "merchant_channel_id": 1068,
                      "tenant_id": 1445,
                      "updated_at": "2026-10-01T13:21:29"
                    },
                    {
                      "id": 3219,
                      "name": "FedEx",
                      "carrier": null,
                      "service": null,
                      "fetch_label": true,
                      "merchant_id": 1053,
                      "merchant_channel_id": 1068,
                      "tenant_id": 1445,
                      "updated_at": "2026-10-01T13:21:37"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Create a shipping method",
        "description": "Creates one shipping method. Only `name` is required, and it must be unique within\nthe merchant.\n\nIf `merchant_id` and `merchant_channel_id` are left out, the method is created for\nthe user's own merchant and channel.\n",
        "operationId": "createShippingMethod",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShippingMethodInput"
              },
              "example": {
                "name": "UPS Express",
                "carrier": "UPS",
                "service": "express",
                "merchant_id": 1053,
                "merchant_channel_id": 1068
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Shipping method created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShippingMethod"
                },
                "example": {
                  "id": 3258,
                  "name": "UPS Express",
                  "carrier": "UPS",
                  "service": "express",
                  "fetch_label": true,
                  "merchant_id": 1053,
                  "merchant_channel_id": 1068,
                  "tenant_id": 1445,
                  "updated_at": "2026-10-29T08:49:06"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed — missing or duplicate name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "missingName": {
                    "summary": "No name",
                    "value": {
                      "errors": {
                        "name": "can't be blank"
                      }
                    }
                  },
                  "duplicateName": {
                    "summary": "Name already used",
                    "value": {
                      "errors": {
                        "name": "has already been taken"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/shipping/bulk/shipping_methods": {
      "put": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Bulk create or update shipping methods",
        "description": "Creates or updates several shipping methods in one call. The body is a plain JSON\narray (not wrapped in an object).\n\n**Matching:** each entry is matched to an existing method by `name` within the\nmerchant. A match is updated, otherwise a new method is created. `id` in the body is\nignored, so a method cannot be renamed through this endpoint.\n\n**Always send `merchant_id` and `merchant_channel_id`.** Unlike the single create,\na new method created here without them gets no merchant. It then doesn't appear\nin searches, can't be fetched or deleted by the user, and later calls with the same\nname create further duplicates.\n\nPartial success: valid entries are saved even when others fail. If any entry fails\nthe status is `422`, so always read both `created`/`updated` and `errors`.\n",
        "operationId": "bulkUpsertShippingMethods",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "$ref": "#/components/schemas/ShippingMethodInput"
                }
              },
              "example": [
                {
                  "name": "UPS Express",
                  "carrier": "UPS",
                  "service": "saver",
                  "merchant_id": 1053,
                  "merchant_channel_id": 1068
                },
                {
                  "name": "DPD Classic",
                  "carrier": "DPD",
                  "service": "classic",
                  "merchant_id": 1053,
                  "merchant_channel_id": 1068
                }
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "All entries saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ShippingMethod"
                      }
                    },
                    "updated": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ShippingMethod"
                      }
                    },
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "example": {
                  "created": [
                    {
                      "id": 3265,
                      "name": "DPD Classic",
                      "carrier": "DPD",
                      "service": "classic",
                      "fetch_label": true,
                      "merchant_id": 1053,
                      "merchant_channel_id": 1068,
                      "tenant_id": 1445,
                      "updated_at": "2026-10-29T08:49:27"
                    }
                  ],
                  "updated": [
                    {
                      "id": 3258,
                      "name": "UPS Express",
                      "carrier": "UPS",
                      "service": "saver",
                      "fetch_label": true,
                      "merchant_id": 1053,
                      "merchant_channel_id": 1068,
                      "tenant_id": 1445,
                      "updated_at": "2026-10-29T08:49:27"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "Body is not a non-empty JSON array.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "example": {
                  "errors": {
                    "_json": "Parameter should be mandatory, list, not_empty"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "At least one entry failed. Entries listed in `created`/`updated` were still\nsaved.\n",
            "content": {
              "application/json": {
                "example": {
                  "created": [
                    {
                      "id": 3266,
                      "name": "DPD Express",
                      "carrier": null,
                      "service": null,
                      "fetch_label": true,
                      "merchant_id": 1053,
                      "merchant_channel_id": 1068,
                      "tenant_id": 1445,
                      "updated_at": "2026-10-29T08:49:27"
                    }
                  ],
                  "updated": [],
                  "errors": {
                    "invalid_name_in_new_shipping_method": {
                      "name": "can't be blank"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shipping/shipping_methods/{id}": {
      "get": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Get shipping method by ID",
        "description": "Returns one shipping method by its PULPO ID.",
        "operationId": "getShippingMethod",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Shipping method ID",
            "example": 3218
          }
        ],
        "responses": {
          "200": {
            "description": "Shipping method retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShippingMethod"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown ID, or the shipping method belongs to a merchant the user cannot\naccess.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "invalidId": {
                    "summary": "Unknown ID",
                    "value": {
                      "errors": {
                        "id": "The given id is invalid"
                      }
                    }
                  },
                  "noAccess": {
                    "summary": "Other merchant",
                    "value": {
                      "errors": {
                        "message": "user_does_not_have_access_to_shipping_method_merchant"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sales Orders"
        ],
        "summary": "Delete a shipping method",
        "description": "Permanently deletes a shipping method and returns the deleted record.\n\nA shipping method that has ever been assigned to an order cannot be deleted —\nthis also applies when those orders are cancelled. The API then answers `422`\nwith a technical database message mentioning\n`fulfillment_orders_shipping_method_id_fkey`.\n",
        "operationId": "deleteShippingMethod",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Shipping method ID",
            "example": 3258
          }
        ],
        "responses": {
          "200": {
            "description": "Shipping method deleted. The body is the deleted record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShippingMethod"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Unknown ID, no access, or the method is used by orders.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "examples": {
                  "invalidId": {
                    "summary": "Unknown or already deleted ID",
                    "value": {
                      "errors": {
                        "id": "The given id is invalid"
                      }
                    }
                  },
                  "inUse": {
                    "summary": "Used by orders",
                    "value": {
                      "errors": {
                        "message": "constraint error when attempting to delete struct: \"fulfillment_orders_shipping_method_id_fkey\" (foreign_key_constraint) ..."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reception/purchase_orders": {
      "get": {
        "tags": [
          "Purchase Orders",
          "Returns"
        ],
        "summary": "List purchase orders",
        "description": "Lists purchase orders (incoming, returns, warehouse movements) with filters and pagination.\n\n### Useful filters\n\n- `id`, `order_num` — exact match\n- `warehouse_id`, `state`, `merchant_id` (also `to_list:`)\n- `product_sku`, `product_name` — exact match, not a substring search\n- `delivery_date` — exact match only, `YYYY-MM-DD HH:MM:SS`. `between:`/`gte:`/`lte:`\n  prefixes are **not** supported and return a 500 error.\n- `view_attributes` — comma-separated field list to return\n\n`type`, `third_party_id`, `updated_at`, and a plain `inserted_at` filter are\naccepted but don't actually filter anything on this endpoint — the response is\nunaffected either way, so don't rely on them.\n\n### Performance\n\nPass `cap_limit=0` (or `capped_limit=0`) to skip the total-results count for\n~20% lower latency. Stop paginating when the returned page is shorter than\nthe requested `limit`.\n",
        "operationId": "listPurchaseOrders",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "order_num",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "PO-2024-001"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 140
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queue",
                "checking",
                "finished_partially",
                "closed",
                "cancelled"
              ]
            }
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:1,2,3` for multiple."
          },
          {
            "name": "product_sku",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact SKU match.",
            "example": "COFFEE-001"
          },
          {
            "name": "product_name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact product name match (not a substring search)."
          },
          {
            "name": "delivery_date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match only, `YYYY-MM-DD HH:MM:SS`. Range prefixes\n(`between:`/`gte:`/`lte:`) are not supported and return a 500 error.\n",
            "example": "2024-03-25 09:00:00"
          },
          {
            "name": "view_attributes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated list of fields to return"
          }
        ],
        "responses": {
          "200": {
            "description": "Purchase orders retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "description": "Omitted when `cap_limit=0`"
                    },
                    "purchase_orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PurchaseOrder"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/reception/bulk/purchase_orders": {
      "post": {
        "tags": [
          "Purchase Orders",
          "Returns"
        ],
        "summary": "Create purchase orders in bulk",
        "description": "Creates multiple purchase orders for incoming goods.\n\n**Order Types:**\n- `purchase_order`: Standard incoming goods (default)\n- `return`: Customer returns (see Returns section for full workflow)\n- `warehouse_movement`: Stock transfer from another warehouse\n\n**Workflow:**\n1. Create purchase order via API\n2. Warehouse receives goods (Android app)\n3. Webhook `purchase_order_finished` fires (Goods Receipt)\n4. Webhook `replenishment_order_finished` fires (stock available)\n\n**Important:**\n- Products and suppliers must exist before creating PO\n- Use `product_sku` OR `product_id` in items\n- `delivery_date` should be in format YYYY-MM-DDTHH:MM:SS\n\n**For Returns:**\n- Set `type: return`\n- Include `sales_order_id` referencing the original order\n- Use the **customer** (type=C) as `third_party_id` (the customer becomes the \"supplier\" of returned goods)\n- For batch-controlled products, include batch/lot numbers in `items[].batches` array\n- Use the shipment tracking code as `order_num` for traceability\n\n**Recommended batch size:** up to 50 orders per request.\n",
        "operationId": "bulkCreatePurchaseOrders",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PurchaseOrderInput"
                }
              },
              "examples": {
                "standardPurchaseOrder": {
                  "summary": "Standard purchase order",
                  "value": [
                    {
                      "type": "purchase_order",
                      "order_num": "PO-2024-001",
                      "delivery_date": "2024-03-25T09:00:00",
                      "warehouse_id": 140,
                      "merchant_id": 69,
                      "merchant_channel_id": null,
                      "third_party_id": 3218515,
                      "notes": "Urgent delivery - coffee beans",
                      "items": [
                        {
                          "product_sku": "COFFEE-001",
                          "requested_quantity": 100,
                          "batches": [
                            {
                              "batch_number": "LOT-2024-03",
                              "expiration_date": "2025-03-01",
                              "quantity": 100
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                "withLoadingUnits": {
                  "summary": "Purchase order with loading units (packagings)",
                  "value": [
                    {
                      "order_num": "PO-1LEVEL-001",
                      "type": "purchase_order",
                      "delivery_date": "2024-03-13T12:50:00",
                      "third_party_id": 5393,
                      "warehouse_id": 1686,
                      "items": [
                        {
                          "line_item_number": "00010",
                          "product_id": 30816,
                          "product_sku": "product_none_1_sku",
                          "requested_quantity": 20
                        },
                        {
                          "line_item_number": "00020",
                          "product_id": 30817,
                          "product_sku": "product_none_2_sku",
                          "requested_quantity": 40
                        }
                      ],
                      "packagings": [
                        {
                          "line_item_number": "00010",
                          "barcode": "BOX00010",
                          "barcode_agency": "custom",
                          "packaging_type": "box",
                          "packaging_level": 0,
                          "location_level_barcode": null,
                          "quantity_in_package": 20,
                          "dimensions_width": 30,
                          "dimensions_height": 30,
                          "dimensions_length": 30,
                          "dimensions_weight": 30
                        },
                        {
                          "line_item_number": "00020",
                          "barcode": "BOX00020",
                          "barcode_agency": "custom",
                          "packaging_type": "box",
                          "packaging_level": 0,
                          "location_level_barcode": null,
                          "quantity_in_package": 40,
                          "dimensions_width": 30,
                          "dimensions_height": 30,
                          "dimensions_length": 30,
                          "dimensions_weight": 30
                        }
                      ]
                    }
                  ]
                },
                "returnOrder": {
                  "summary": "Customer return order",
                  "value": [
                    {
                      "type": "return",
                      "order_num": "XXXXXXXXXXX",
                      "sales_order_id": 5732510,
                      "delivery_date": "2025-04-01T10:00:00",
                      "third_party_id": 1075095,
                      "warehouse_id": 882,
                      "merchant_id": 76,
                      "merchant_channel_id": 76,
                      "items": [
                        {
                          "product_id": 7646303,
                          "requested_quantity": 2,
                          "notes": null,
                          "batches": []
                        },
                        {
                          "product_id": 7646305,
                          "requested_quantity": 2,
                          "notes": null,
                          "batches": []
                        }
                      ]
                    }
                  ]
                },
                "returnOrderWithBatches": {
                  "summary": "Return order with batch-controlled products",
                  "value": [
                    {
                      "type": "return",
                      "order_num": "TRACK-123456",
                      "sales_order_id": 5732510,
                      "delivery_date": "2025-04-01T10:00:00",
                      "third_party_id": 1075095,
                      "warehouse_id": 882,
                      "merchant_id": 76,
                      "merchant_channel_id": 76,
                      "items": [
                        {
                          "product_id": 7646303,
                          "requested_quantity": 5,
                          "notes": "Damaged in transit",
                          "batches": [
                            "LOT-2025-001"
                          ]
                        }
                      ]
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Purchase orders processed. Check `created` for the ones that succeeded\nand `errors` for the ones that didn't.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreatePurchaseOrdersResponse"
                },
                "example": {
                  "created": [
                    {
                      "id": 360707,
                      "order_num": "PO-2024-001"
                    }
                  ],
                  "errors": {}
                }
              }
            }
          },
          "400": {
            "description": "All items failed validation — none were created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreatePurchaseOrdersResponse"
                },
                "example": {
                  "created": [],
                  "errors": {
                    "PO-2024-001": {
                      "delivery_date": "can't be blank"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/reception/purchase_orders/{id}": {
      "delete": {
        "tags": [
          "Purchase Orders"
        ],
        "summary": "Cancel/delete a purchase order",
        "description": "Cancels a purchase order that hasn't been received yet. This **is** available\nvia the API — despite older guidance suggesting cancellation was warehouse-only,\n`DELETE` on a `queue`-state order removes it and it no longer appears in\n`GET /reception/purchase_orders` searches.\n\nOrders that have already started receiving are not expected to be\ncancellable this way — this hasn't been verified against every state.\n",
        "operationId": "deletePurchaseOrder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Purchase order deleted/cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Invalid ID, or the order's state doesn't allow cancellation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reception/incoming_goods/{id}": {
      "get": {
        "tags": [
          "Purchase Orders",
          "Returns"
        ],
        "summary": "Get an incoming-goods record by ID",
        "description": "Returns the full incoming-goods record, including per-item states, batch\ndetails, destination locations, inspection photos (`attachments[]`), and\nthe operator who recorded the receipt (`owner`).\n",
        "operationId": "getIncomingGood",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Incoming-goods record retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncomingGood"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/reception/incoming_goods": {
      "get": {
        "tags": [
          "Purchase Orders",
          "Returns"
        ],
        "summary": "List incoming-goods (receiving) records",
        "description": "Lists incoming-goods records — individual receiving events against purchase\norders. A purchase order may have multiple incoming_goods (partial receipts).\n\nFor returns, query with `document_type=return` to see inspection history,\nincluding per-item accepted/rejected outcomes and attached photos.\n\n### Filters\n\n- `warehouse_id`, `purchase_order_id`, `merchant_id` (`to_list:` supported),\n  `owner_id`, `sequence_number` — exact match\n- `document_type` — `purchase_order`, `return`, `warehouse_movement`, `none`\n  (`none` = unplanned receiving without a PO)\n- `start_date` / `end_date` — filter by `inserted_at`. **Must be a full\n  date-time** (`YYYY-MM-DDTHH:MM:SS`) — a bare `YYYY-MM-DD` date returns a\n  500 error.\n\n`sales_order_id` and a plain `inserted_at` filter are not supported by this\nendpoint — both are silently ignored or error; use `start_date`/`end_date`\ninstead.\n",
        "operationId": "listIncomingGoods",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/CappedLimit"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "purchase_order_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "document_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "purchase_order",
                "return",
                "warehouse_movement",
                "none"
              ]
            }
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Merchant ID. Use `to_list:1,2,3` for multiple."
          },
          {
            "name": "owner_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "User ID that received/owns the incoming-goods record."
          },
          {
            "name": "sequence_number",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact match, e.g. `IG-0000017`."
          },
          {
            "name": "start_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filters by `inserted_at`, on/after this timestamp. Must be a full\n`YYYY-MM-DDTHH:MM:SS` date-time — a bare `YYYY-MM-DD` date returns a\n500 error.\n",
            "example": "2026-01-01T00:00:00"
          },
          {
            "name": "end_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filters by `inserted_at`, on/before this timestamp. Same format\nrequirement as `start_date`.\n",
            "example": "2026-12-31T00:00:00"
          }
        ],
        "responses": {
          "200": {
            "description": "Incoming-goods records retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer"
                    },
                    "incoming_goods": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/IncomingGood"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Purchase Orders",
          "Returns"
        ],
        "summary": "Record a receiving event",
        "description": "Records goods received — normally against a purchase order (or return PO), but\nalso usable for unplanned receiving with `document_type: none` and no\n`purchase_order_id`. Multiple `incoming_goods` records can be created per PO for\npartial receipts; the `purchase_order_finished` webhook fires once cumulative\nquantities equal the requested quantities.\n\nThere is no endpoint to delete or cancel an incoming-goods record once created.\n\n### Per-item outcomes\n\nEach item carries a `state` — `accepted` or `rejected` — and a\n`destination_location_id` that routes the physical units accordingly (storage\nvs return locations). Rejected items should carry `reason_codes`.\n",
        "operationId": "createIncomingGood",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IncomingGoodInput"
              },
              "examples": {
                "againstPurchaseOrder": {
                  "summary": "Receiving against a purchase order",
                  "value": {
                    "warehouse_id": 140,
                    "third_party_id": 3218515,
                    "purchase_order_id": 360707,
                    "document_type": "purchase_order",
                    "owner_id": 1295,
                    "start_date": "2024-03-25T09:00:00",
                    "end_date": "2024-03-25T09:42:00",
                    "merchant_id": 69,
                    "merchant_channel_id": null,
                    "notes": "Two units rejected — broken seals",
                    "items": [
                      {
                        "product_sku": "COFFEE-001",
                        "quantity": 98,
                        "state": "accepted",
                        "destination_location_id": 229364,
                        "batch_id": 45231
                      },
                      {
                        "product_sku": "COFFEE-001",
                        "quantity": 2,
                        "state": "rejected",
                        "destination_location_id": 229999,
                        "batch_id": 45231,
                        "reason_codes": [
                          {
                            "reason_code": "pulpo_0000001"
                          }
                        ]
                      }
                    ]
                  }
                },
                "unplanned": {
                  "summary": "Unplanned receiving (no purchase order)",
                  "value": {
                    "warehouse_id": 140,
                    "third_party_id": 3218515,
                    "document_type": "none",
                    "owner_id": 1295,
                    "start_date": "2024-03-25T09:00:00",
                    "end_date": "2024-03-25T09:42:00",
                    "merchant_id": 69,
                    "notes": "Walk-in delivery, no PO on file",
                    "items": [
                      {
                        "product_id": 1957711,
                        "quantity": 12,
                        "state": "accepted",
                        "destination_location_id": 229364
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Receiving event recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncomingGood"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/warehouses/location_types": {
      "get": {
        "tags": [
          "Kitting"
        ],
        "summary": "Get kitting location types",
        "description": "Helper endpoint to find kitting location type IDs.\n\nUse the returned ID with `/warehouses/locations` to find actual kitting locations.\n",
        "operationId": "getKittingLocationType",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "contains:kitting"
          }
        ],
        "responses": {
          "200": {
            "description": "Location types found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory/kits": {
      "post": {
        "tags": [
          "Kitting"
        ],
        "summary": "Create kit template",
        "description": "Creates a kit template that defines how to assemble a new product from component products.\n\n**Workflow:**\n1. Create kit product (the final assembled item)\n2. Create kit template (this endpoint) defining components\n3. Create kitting task to assemble kits\n4. Webhook fires when kits are assembled\n\n**Example:**\n- Kit Product: \"Coffee Gift Box\"\n- Components: 2x Coffee Beans, 1x Coffee Mug, 1x Gift Box\n",
        "operationId": "createKit",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KitInput"
              },
              "example": {
                "name": "Coffee Gift Box Kit",
                "product_id": 1957720,
                "items": [
                  {
                    "product_id": 1957711,
                    "quantity": 2
                  },
                  {
                    "product_id": 1957712,
                    "quantity": 1
                  },
                  {
                    "product_id": 1957713,
                    "quantity": 1
                  }
                ],
                "warehouses": [
                  140
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kit created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Kit"
                }
              }
            }
          }
        }
      }
    },
    "/kitting/tasks": {
      "post": {
        "tags": [
          "Kitting"
        ],
        "summary": "Create kitting task",
        "description": "Creates a task to assemble kits from component products.\n\n**Workflow:**\n1. Webhook `replenishment_order_created` (type=kit_move): Components moved to kitting area, stock reduced\n2. Warehouse assembles kits (Android app)\n3. Webhook `replenishment_order_finished` (type=kitting): Kits moved to storage, kit product stock increased\n\n**Requirements:**\n- Kit template must exist\n- Sufficient component stock must be available\n- `destination_location_id` must be a kitting location\n",
        "operationId": "createKittingTask",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KittingTaskInput"
              },
              "example": {
                "warehouse_id": 140,
                "destination_location_id": 109200,
                "items": [
                  {
                    "kit_id": 5,
                    "quantity": 10
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kitting task created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KittingTask"
                }
              }
            }
          }
        }
      }
    },
    "/webhook/": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook subscriptions",
        "description": "Returns your webhook subscriptions. Use it to check what is subscribed, or to find the\n`id` you need to [delete a subscription](#tag/Webhooks/operation/deleteWebhook).\n\n**Only enabled webhooks by default.** Without `enabled=false` in the query, disabled\nsubscriptions are left out, even when you filter by their `id` or `url`. To see\neverything, call once with `enabled=true` and once with `enabled=false`.\n\n**Filters** (all optional, combine as needed):\n- `id`, `url`, `method`, `enabled`, `warehouse_id`, `merchant_id`,\n  `merchant_channel_id` match exactly.\n- `url` also accepts a partial match with `like:`, e.g. `url=like:%25my-domain%25`\n  (`%25` is the URL-encoded `%` wildcard).\n- Each filter takes one value. Lists such as `warehouse_id=1,2` or\n  `warehouse_id=in:1,2` are not supported and return an error.\n- Unknown query parameters are ignored.\n\n**Paging:** `total_results` is only filled on the first page (`offset` 0 or not set).\nOn later pages it is `null`, so read it from the first call.\n",
        "operationId": "listWebhooks",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Webhook ID"
          },
          {
            "name": "url",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact endpoint URL, or `like:%pattern%` for a partial match",
            "example": "like:%your-domain%"
          },
          {
            "name": "method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "POST"
              ]
            }
          },
          {
            "name": "enabled",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "`true` (the default) returns enabled webhooks, `false` returns disabled ones.\nAny other value returns an error.\n"
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 140
          },
          {
            "name": "merchant_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 69
          },
          {
            "name": "merchant_channel_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": 76
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching webhook subscriptions. An empty `webhooks` list (and `total_results: 0`)\nwhen nothing matches.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "nullable": true,
                      "description": "Total matches. `null` when `offset` is greater than 0.",
                      "example": 1
                    },
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 1,
                  "webhooks": [
                    {
                      "id": "75cd3548-52e9-4a14-a950-d09455df060a",
                      "url": "https://your-domain.com/webhooks/pulpo/sales-orders",
                      "method": "POST",
                      "enabled": true,
                      "warehouse_id": 140,
                      "merchant_id": 69,
                      "merchant_channel_id": 76,
                      "allowed_types": [
                        "sales_order_created",
                        "sales_order_finished"
                      ],
                      "client_id": null,
                      "client": null,
                      "updated_at": "2026-10-21T13:11:52"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Subscribe to webhook events",
        "description": "Subscribes your endpoint to receive real-time notifications for warehouse events.\n\n**Available Events:**\n\n**Purchase Orders / Incoming:**\n- `purchase_order_updated` [📎](/guide/incoming#purchase_order_updated \"Sample payload\"): PO modified\n- `purchase_order_deleted`: PO deleted\n- `purchase_order_finished` [📎](/guide/incoming#purchase_order_finished \"Sample payload\"): Goods receipt completed (GR)\n- `purchase_order_finished_early` [📎](/guide/incoming#purchase_order_finished_early \"Sample payload\"): PO closed with partial receipt\n- `incoming_good_created` [📎](/guide/incoming#incoming_good_created \"Sample payload\"): Receiving task created\n- `replenishment_order_created` [📎](/guide/incoming#replenishment_order_created \"Sample payload\"): Stock movement to storage started\n- `replenishment_order_finished` [📎](/guide/incoming#replenishment_order_finished \"Sample payload\"): Stock available in warehouse\n\n**Sales Orders / Outgoing:**\n- `sales_order_created` [📎](/guide/outgoing#sales_order_created \"Sample payload\"): Order accepted\n- `sales_order_updated` [📎](/guide/outgoing#sales_order_updated \"Sample payload\"): Order modified\n- `sales_order_cancelled` [📎](/guide/outgoing#sales_order_cancelled \"Sample payload\"): Order cancelled\n- `sales_order_finished` [📎](/guide/outgoing#sales_order_finished \"Sample payload\"): Order fully shipped (PGI)\n- `fulfillment_order_finished` [📎](/guide/outgoing#fulfillment_order_finished \"Sample payload\"): Single fulfillment completed\n- `picking_order_created` [📎](/guide/outgoing#picking_order_created \"Sample payload\"): Picking task created\n- `picking_order_finished` [📎](/guide/outgoing#picking_order_finished \"Sample payload\"): Picking completed\n- `packing_order_created` [📎](/guide/outgoing#packing_order_created \"Sample payload\"): Packing task created\n- `packing_order_finished` [📎](/guide/outgoing#packing_order_finished \"Sample payload\"): Packing completed (PIC)\n- `packing_order_closed` [📎](/guide/outgoing#packing_order_closed \"Sample payload\"): Packing task closed and left the packing station\n- `packing_box_closed` [📎](/label-provider/webhooks#packing_box_closed \"Sample payload\"): Individual box sealed (for label generation)\n\n**Stock & Inventory:**\n- `stock_correction_finished` [📎](/guide/stock-changes#stock_correction_finished \"Sample payload\"): Manual stock adjustment\n- `counting_task_created`: Inventory count started\n- `counting_task_finished`: Inventory count completed\n- `counting_task_closed` [📎](/guide/stock-changes#counting_task_closed \"Sample payload\"): Count finalized\n\n**Shipping:**\n- `shipment_tracking_updated` [📎](/label-provider/shipment-tracking#shipment_tracking_updated \"Sample payload\"): Tracking info changed\n- `turbo_label_packing_created`: Quick label process\n\n**Filters:**\n- Filter by `warehouse_id`, `merchant_id`, `merchant_channel_id`\n- `allowed_types`: Array of event types to receive\n\n**Best Practices:**\n- Implement idempotency (webhook may retry)\n- Return 200 OK quickly (process async)\n- Verify webhook signature if available\n- Handle out-of-order delivery\n",
        "operationId": "subscribeWebhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSubscription"
              },
              "examples": {
                "salesOrderEvents": {
                  "summary": "Subscribe to sales order events",
                  "value": {
                    "url": "https://your-domain.com/webhooks/pulpo/sales-orders",
                    "method": "POST",
                    "warehouse_id": 140,
                    "merchant_id": 69,
                    "merchant_channel_id": 76,
                    "allowed_types": [
                      "sales_order_created",
                      "packing_order_finished",
                      "sales_order_finished"
                    ]
                  }
                },
                "purchaseOrderEvents": {
                  "summary": "Subscribe to purchase order events",
                  "value": {
                    "url": "https://your-domain.com/webhooks/pulpo/purchase-orders",
                    "method": "POST",
                    "warehouse_id": 140,
                    "merchant_id": 69,
                    "allowed_types": [
                      "purchase_order_updated",
                      "purchase_order_finished",
                      "replenishment_order_finished"
                    ]
                  }
                },
                "labelGeneration": {
                  "summary": "Subscribe for label provider integration",
                  "value": {
                    "url": "https://your-domain.com/webhooks/pulpo/labels",
                    "method": "POST",
                    "warehouse_id": 140,
                    "merchant_id": 69,
                    "merchant_channel_id": 76,
                    "allowed_types": [
                      "packing_box_closed",
                      "packing_order_finished",
                      "turbo_label_packing_created",
                      "shipment_tracking_updated"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook subscription created. The new subscription is returned inside a `webhooks`\nlist. Keep `webhooks[0].id`: you need it to delete the subscription later.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_results": {
                      "type": "integer",
                      "example": 1
                    },
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                },
                "example": {
                  "total_results": 1,
                  "webhooks": [
                    {
                      "id": "75cd3548-52e9-4a14-a950-d09455df060a",
                      "url": "https://your-domain.com/webhooks/pulpo/sales-orders",
                      "method": "POST",
                      "enabled": true,
                      "warehouse_id": 140,
                      "merchant_id": 69,
                      "merchant_channel_id": 76,
                      "allowed_types": [
                        "sales_order_created",
                        "sales_order_finished"
                      ],
                      "client_id": null,
                      "client": null,
                      "updated_at": "2026-10-21T13:11:52"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Validation failed. `errors` names each invalid field, for example a missing\n`url`, `method` or `warehouse_id`, or an unknown event in `allowed_types`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "errors": {
                    "warehouse_id": "can't be blank",
                    "allowed_types": "has an invalid entry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhook/{id}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Get a webhook subscription",
        "description": "Returns one webhook subscription by its `id`. Unlike the list, this also returns\ndisabled webhooks. The webhook is returned directly, not inside a `webhooks` list.\n",
        "operationId": "getWebhook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Webhook ID (UUID)",
            "example": "75cd3548-52e9-4a14-a950-d09455df060a"
          }
        ],
        "responses": {
          "200": {
            "description": "The webhook subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "422": {
            "description": "No webhook with this id exists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook subscription",
        "description": "Removes a webhook subscription, so PULPO no longer sends its events to that URL.\n\nThe `id` is the UUID returned when you subscribed (`webhooks[].id` in the\n[Subscribe to webhook events](#tag/Webhooks/operation/subscribeWebhook) response). If\nyou don't have it any more, look it up with\n[List webhook subscriptions](#tag/Webhooks/operation/listWebhooks). Disabled webhooks\ncan be deleted too.\n\n**Responses:**\n- `204 No Content` with an empty body when the webhook was deleted.\n- `422` with `{\"errors\": {\"id\": \"The given id is invalid\"}}` when no webhook with this\n  id exists, including one you already deleted. Treat this as \"already gone\" if you\n  retry deletes.\n",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Webhook ID (UUID)",
            "example": "0ba223d3-79df-404f-9b3f-17ac5ed0826a"
          }
        ],
        "responses": {
          "204": {
            "description": "Webhook deleted. The response body is empty."
          },
          "422": {
            "description": "No webhook with this id exists (never existed or already deleted)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "errors": {
                    "id": "The given id is invalid"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT token obtained from `/auth` endpoint.\n\nInclude in all requests:\n```\nAuthorization: Bearer <your_token>\n```\n"
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "description": "Number of items to return (1-2000)",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2000,
          "default": 10
        },
        "example": 100
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "description": "Number of items to skip",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        },
        "example": 0
      },
      "SortBy": {
        "name": "sort_by",
        "in": "query",
        "description": "Sort field and direction (field:asc or field:desc)",
        "schema": {
          "type": "string",
          "pattern": "^[a-z_]+:(asc|desc)$"
        },
        "example": "id:asc"
      },
      "CappedLimit": {
        "name": "capped_limit",
        "in": "query",
        "description": "Set to 0 to exclude total_results and improve performance by ~20%.\nPagination continues until returned items < limit.\n",
        "schema": {
          "type": "integer",
          "enum": [
            0,
            20,
            100,
            2000
          ],
          "default": 2000
        },
        "example": 0
      }
    },
    "schemas": {
      "AuthRequest": {
        "type": "object",
        "required": [
          "grant_type",
          "username",
          "password",
          "scope"
        ],
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "password"
            ],
            "description": "OAuth 2.0 grant type"
          },
          "username": {
            "type": "string",
            "format": "email",
            "description": "User email address",
            "example": "api_user@company.com"
          },
          "password": {
            "type": "string",
            "format": "password",
            "description": "User password"
          },
          "scope": {
            "type": "string",
            "enum": [
              "default"
            ],
            "description": "Access scope",
            "default": "default"
          }
        }
      },
      "AuthResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "JWT access token",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
          },
          "expires_in": {
            "type": "integer",
            "description": "Token expiration in seconds",
            "example": 3600
          },
          "scope": {
            "type": "string",
            "example": "default"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "bearer"
            ],
            "example": "bearer"
          },
          "refresh_token": {
            "type": "string",
            "description": "Refresh token. Use with `grant_type=refresh_token` on `/auth` to renew\nthe access token silently. May be omitted on tenants without refresh\ntokens configured.\n"
          }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1295
          },
          "username": {
            "type": "string",
            "example": "api_user@company.com"
          },
          "first_name": {
            "type": "string",
            "example": "John"
          },
          "last_name": {
            "type": "string",
            "example": "Doe"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "api_user@company.com"
          },
          "active": {
            "type": "boolean",
            "example": true
          },
          "tenant_id": {
            "type": "integer",
            "description": "Your PULPO WMS account ID",
            "example": 87
          },
          "language": {
            "type": "string",
            "example": "en"
          },
          "tenant": {
            "type": "object",
            "description": "Tenant details",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time",
                "description": "Use as the lower bound when querying historic stats — there is no\ndata before the tenant's `inserted_at`.\n"
              }
            }
          },
          "warehouses": {
            "type": "array",
            "description": "Effective warehouse allowlist for this user. Filter all server responses\nagainst this set — there is no explicit role/permission field.\n",
            "items": {
              "$ref": "#/components/schemas/WarehouseSimple"
            }
          },
          "merchants": {
            "type": "array",
            "description": "Effective merchant allowlist for this user.",
            "items": {
              "$ref": "#/components/schemas/Merchant"
            }
          }
        }
      },
      "Warehouse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 140
          },
          "name": {
            "type": "string",
            "example": "Main Warehouse London"
          },
          "company_name": {
            "type": "string",
            "example": "PULPO WMS Ltd"
          },
          "tenant_id": {
            "type": "integer",
            "example": 87
          },
          "active": {
            "type": "boolean",
            "example": true
          },
          "priority": {
            "type": "integer",
            "example": 1
          },
          "line1": {
            "type": "string",
            "description": "Address line 1",
            "example": "123 Warehouse Street"
          },
          "line2": {
            "type": "string",
            "description": "Address line 2",
            "example": "Unit 5"
          },
          "city": {
            "type": "string",
            "example": "London"
          },
          "state": {
            "type": "string",
            "example": "England"
          },
          "zip_code": {
            "type": "string",
            "example": "E1 6AN"
          },
          "country_code": {
            "type": "string",
            "example": "826"
          },
          "phone": {
            "type": "string",
            "example": "+44 20 1234 5678"
          },
          "fax": {
            "type": "string",
            "example": "+44 20 1234 5679"
          },
          "site": {
            "type": "string",
            "description": "Site identifier"
          }
        }
      },
      "WarehouseSimple": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "ProductInput": {
        "type": "object",
        "required": [
          "name",
          "sku",
          "active",
          "management_type",
          "batch_control",
          "tenant_id",
          "cost_price",
          "minimum_purchase_unit",
          "minimum_sales_unit",
          "units_per_purchase_package",
          "units_per_sales_package",
          "purchase_measure_units",
          "sales_measure_units",
          "weight",
          "barcodes"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO WMS product ID. Only used to identify the product on\n`PUT /inventory/bulk/products` (alternative to `sku`) — ignored on create.\n",
            "example": 1957711
          },
          "active": {
            "type": "boolean",
            "description": "Product is active. Set to `false` to deactivate without deleting — see\n`DELETE /inventory/bulk/products` to remove a product entirely.\n",
            "example": true
          },
          "name": {
            "type": "string",
            "description": "Unique product name per tenant",
            "example": "Premium Coffee Beans 1kg"
          },
          "sku": {
            "type": "string",
            "description": "Unique SKU per product and tenant (your reference)",
            "example": "COFFEE-001"
          },
          "description": {
            "type": "string",
            "example": "High-quality Arabica coffee beans"
          },
          "management_type": {
            "type": "string",
            "enum": [
              "none",
              "lot",
              "serial"
            ],
            "description": "Inventory tracking method",
            "example": "lot"
          },
          "batch_control": {
            "type": "boolean",
            "description": "Enable batch/expiry date tracking (use with lot/serial)",
            "example": true
          },
          "tenant_id": {
            "type": "integer",
            "description": "Your PULPO WMS account ID",
            "example": 87
          },
          "merchant_id": {
            "type": "integer",
            "description": "Product owner (merchant). Optional for single-merchant (non-3PL) tenants — defaults to your account's merchant/channel.",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "nullable": true,
            "description": "Specific channel (null = all channels)",
            "example": null
          },
          "third_party_id": {
            "type": "integer",
            "description": "Default supplier ID",
            "example": 3218515
          },
          "cost_price": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "description": "Product cost (use 1 if not relevant)",
            "example": 15.99
          },
          "minimum_purchase_unit": {
            "type": "integer",
            "minimum": 1,
            "description": "Minimum purchase quantity",
            "example": 1
          },
          "minimum_sales_unit": {
            "type": "integer",
            "minimum": 1,
            "description": "Minimum sales quantity",
            "example": 1
          },
          "units_per_purchase_package": {
            "type": "integer",
            "minimum": 1,
            "description": "Units per package (usually 1)",
            "example": 1
          },
          "units_per_sales_package": {
            "type": "integer",
            "minimum": 1,
            "description": "Units per sales package (usually 1)",
            "example": 1
          },
          "purchase_measure_units": {
            "type": "string",
            "description": "Unit of measure for purchasing",
            "example": "BOX"
          },
          "sales_measure_units": {
            "type": "string",
            "description": "Unit of measure for sales",
            "example": "BOX"
          },
          "weight": {
            "type": "number",
            "format": "float",
            "description": "Weight in kg",
            "example": 1.2
          },
          "length": {
            "type": "number",
            "format": "float",
            "description": "Length in cm",
            "example": 20
          },
          "width": {
            "type": "number",
            "format": "float",
            "description": "Width in cm",
            "example": 15
          },
          "height": {
            "type": "number",
            "format": "float",
            "description": "Height in cm",
            "example": 10
          },
          "volume": {
            "type": "number",
            "format": "float",
            "description": "Volume in cubic meters"
          },
          "stackable": {
            "type": "boolean",
            "description": "Can be stacked",
            "example": true
          },
          "barcodes": {
            "type": "array",
            "description": "Product barcodes (required for warehouse scanning)",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "example": [
              "5060123456789",
              "COFFEE-001"
            ]
          },
          "product_categories": {
            "type": "array",
            "description": "**Tags** for the product, as a list of tag IDs (from\n`GET /inventory/products/categories`). Tags are called `product_categories` in\nthe API. Codes or objects are rejected, and an unknown ID rejects the product.\n\nOn update the list **replaces** the product's tags: `[]` removes all, leaving\nthe field out (or `null`) keeps them. A field named `tags` is ignored.\n",
            "items": {
              "type": "integer"
            },
            "example": [
              16902,
              16901
            ]
          },
          "hs_code": {
            "type": "string",
            "description": "Harmonized System code for customs",
            "example": "0901.21"
          },
          "origin_country": {
            "type": "string",
            "description": "Country of origin (ISO 2-letter code)",
            "example": "CO"
          },
          "supplier_product_id": {
            "type": "string",
            "description": "Supplier's product code"
          },
          "article_number": {
            "type": "string",
            "description": "Internal article number (optional). Some integrations match incoming\nproduct feeds against this field as a fallback when SKU is absent.\n"
          },
          "units_per_pallet": {
            "type": "integer",
            "description": "Units per shipping pallet (optional)"
          },
          "lead_time": {
            "type": "integer",
            "description": "Supplier lead time in days. **Note:** sent by some clients but server\npersistence may be partial — verify with your tenant before relying on it\nfor ordering decisions.\n"
          },
          "moq": {
            "type": "integer",
            "description": "Minimum order quantity. **Note:** sent by some clients but server\npersistence may be partial — verify before relying on it.\n"
          },
          "attributes": {
            "type": "object",
            "description": "Custom attributes (flexible JSON). Some keys are read by the dashboard:\n`image_url` (or aliases `imageUrl`, `image`, `picture_url`, `pictureUrl`)\nrenders the product thumbnail. On update, the whole object is replaced,\nnot merged — resend every key you want to keep.\n",
            "additionalProperties": true,
            "example": {
              "image_url": "https://example.com/coffee.jpg",
              "color": "brown",
              "organic": true
            }
          }
        }
      },
      "Product": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ProductInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "description": "PULPO WMS product ID (auto-generated)",
                "example": 1957711
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time",
                "example": "2024-03-20T10:30:00Z"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time",
                "example": "2024-03-20T15:45:00Z"
              },
              "merchant_channel_ids": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "example": [
                  76
                ]
              },
              "third_party": {
                "type": "object",
                "description": "Inline default-supplier reference",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              "product_categories": {
                "type": "array",
                "description": "The product's **tags** (called \"tags\" in the PULPO apps, `product_categories`\nin the API). There is no separate `tags` field.\n",
                "items": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            }
          }
        ]
      },
      "Tag": {
        "type": "object",
        "description": "A tag of the tenant. Called \"tag\" in the PULPO apps and `product_categories` in\nthe API — the same thing. Assignable to products, users and locations.\n",
        "properties": {
          "id": {
            "type": "integer",
            "example": 16902
          },
          "code": {
            "type": "string",
            "description": "Unique per tenant, case-sensitive (`cold` and `Cold` are two tags).",
            "example": "cold"
          },
          "name": {
            "type": "string",
            "description": "Display name. Does not need to be unique.",
            "example": "Cold storage"
          },
          "tenant_id": {
            "type": "integer",
            "example": 1445
          }
        }
      },
      "BulkProductResult": {
        "type": "object",
        "description": "Minimal reference to a created/updated product (not the full record).",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO WMS product ID",
            "example": 1957711
          },
          "sku": {
            "type": "string",
            "example": "COFFEE-001"
          }
        }
      },
      "BulkCreateProductsResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkProductResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item validation errors, keyed by the submitted `sku`. The endpoint\nkeeps processing the rest of the batch even when some items fail — a\nnon-empty `errors` doesn't mean `created` is empty.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "BulkUpdateProductsResponse": {
        "type": "object",
        "properties": {
          "updated": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkProductResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item validation errors, keyed by the submitted `sku` (or `id`, if\nthat's what was used to identify the product). Same partial-failure\nbehavior as `created` above.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "ProductReference": {
        "type": "object",
        "description": "Reference to a product by ID or SKU",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO WMS product ID",
            "example": 1957711
          },
          "sku": {
            "type": "string",
            "description": "Product SKU",
            "example": "COFFEE-001"
          }
        }
      },
      "BulkDeleteProductsResponse": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkProductResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item errors, keyed by the submitted `sku` or `id`. Same\npartial-failure behavior as `created`/`updated` above.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "ThirdPartyInput": {
        "type": "object",
        "required": [
          "active",
          "name",
          "identifier_number",
          "identifier_type",
          "third_type",
          "tenant_id"
        ],
        "properties": {
          "active": {
            "type": "boolean",
            "description": "Third party is active",
            "example": true
          },
          "name": {
            "type": "string",
            "description": "Company/person name",
            "example": "Acme Coffee Suppliers Ltd"
          },
          "identifier_number": {
            "type": "string",
            "description": "External reference (unique with third_type)",
            "example": "SUPPLIER-001"
          },
          "identifier_type": {
            "type": "string",
            "description": "Type of identifier (ID, VAT, TAX, etc)",
            "example": "VAT"
          },
          "third_type": {
            "type": "string",
            "enum": [
              "S",
              "C"
            ],
            "description": "S=Supplier, C=Customer",
            "example": "S"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "orders@acmecoffee.com"
          },
          "tenant_id": {
            "type": "integer",
            "example": 87
          },
          "merchant_id": {
            "type": "integer",
            "description": "Associated merchant. Optional for single-merchant (non-3PL) tenants — defaults to your account's merchant/channel.",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "nullable": true,
            "description": "Required for customers (C), optional for suppliers (S)",
            "example": 76
          },
          "erp_id": {
            "type": "string",
            "description": "External ERP ID"
          },
          "erp_code": {
            "type": "string",
            "description": "External ERP code"
          },
          "attributes": {
            "type": "object",
            "description": "Custom attributes including addresses",
            "properties": {
              "addresses": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ThirdPartyAddress"
                }
              }
            }
          }
        }
      },
      "ThirdParty": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ThirdPartyInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "description": "PULPO WMS third party ID",
                "example": 3218515
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              },
              "deleted_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "deleted_by": {
                "type": "integer",
                "nullable": true
              }
            }
          }
        ]
      },
      "BulkThirdPartyResult": {
        "type": "object",
        "description": "Minimal reference to a created/updated third party (not the full record).",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO WMS third party ID",
            "example": 3218515
          },
          "identifier_number": {
            "type": "string",
            "example": "GB123456789"
          }
        }
      },
      "BulkCreateThirdPartiesResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkThirdPartyResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item validation errors, keyed by the submitted `identifier_number`.\nThe endpoint keeps processing the rest of the batch even when some\nitems fail — a non-empty `errors` doesn't mean `created` is empty.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "BulkUpdateThirdPartiesResponse": {
        "type": "object",
        "properties": {
          "updated": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkThirdPartyResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item errors, keyed by the submitted `identifier_number` (or `id`).\nSame partial-failure behavior as `created` above.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "ThirdPartyAddress": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "John Smith"
          },
          "company_name": {
            "type": "string",
            "example": "John's Coffee Shop"
          },
          "phone_number": {
            "type": "string",
            "example": "+44 20 1234 5678"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        }
      },
      "Address": {
        "type": "object",
        "properties": {
          "street": {
            "type": "string",
            "example": "123 High Street"
          },
          "house_nr": {
            "type": "string",
            "example": "Unit 5"
          },
          "city": {
            "type": "string",
            "example": "London"
          },
          "state": {
            "type": "string",
            "example": "England"
          },
          "zip": {
            "type": "string",
            "example": "SW1A 1AA"
          },
          "country": {
            "type": "string",
            "description": "ISO 2-letter country code",
            "example": "GB"
          },
          "country_code": {
            "type": "string",
            "description": "ISO numeric country code",
            "example": "826"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "john@coffeeshop.com"
          },
          "additional_info": {
            "type": "string",
            "example": "Delivery entrance on side street"
          }
        }
      },
      "PurchaseOrderInput": {
        "type": "object",
        "required": [
          "type",
          "delivery_date",
          "warehouse_id",
          "third_party_id",
          "order_num",
          "items"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "purchase_order",
              "warehouse_movement",
              "return"
            ],
            "default": "purchase_order",
            "description": "Order type",
            "example": "purchase_order"
          },
          "order_num": {
            "type": "string",
            "description": "Your external order number",
            "example": "PO-2024-001"
          },
          "delivery_date": {
            "type": "string",
            "format": "date-time",
            "description": "Expected delivery date (YYYY-MM-DDTHH:MM:SS)",
            "example": "2024-03-25T09:00:00"
          },
          "warehouse_id": {
            "type": "integer",
            "description": "Receiving warehouse",
            "example": 140
          },
          "merchant_id": {
            "type": "integer",
            "description": "Merchant receiving goods. Optional for single-merchant (non-3PL) tenants — defaults to your account's merchant/channel.",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "nullable": true,
            "description": "Optional channel",
            "example": null
          },
          "third_party_id": {
            "type": "integer",
            "description": "Supplier ID (type=S) for purchase orders.\nFor **returns**: use the customer ID (type=C) — the customer becomes the \"supplier\" of returned goods.\n",
            "example": 3218515
          },
          "sales_order_id": {
            "type": "integer",
            "nullable": true,
            "description": "Required when `type=return`. The ID of the original sales order being returned.\nRetrieve this from `GET /sales/orders/{id}` or from the original order creation response.\n",
            "example": 5732510
          },
          "notes": {
            "type": "string",
            "description": "Order notes",
            "example": "Handle with care - fragile items"
          },
          "criterium": {
            "type": "string",
            "description": "Custom sorting/routing criteria"
          },
          "attributes": {
            "type": "object",
            "description": "Custom attributes"
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PurchaseOrderItem"
            }
          },
          "packagings": {
            "type": "array",
            "description": "Optional physical loading units (pallets, boxes, bags, bins, mixed\ncontainers) describing how the order physically arrives. See the\n[Loading units](/guide/loading-units) guide page for the full model,\nnesting rules, and worked examples.\n",
            "items": {
              "$ref": "#/components/schemas/Packaging"
            }
          }
        }
      },
      "PurchaseOrderItem": {
        "type": "object",
        "required": [
          "requested_quantity"
        ],
        "properties": {
          "product_id": {
            "type": "integer",
            "description": "PULPO product ID (use this OR product_sku)",
            "example": 1957711
          },
          "product_sku": {
            "type": "string",
            "description": "Product SKU (use this OR product_id)",
            "example": "COFFEE-001"
          },
          "requested_quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Quantity to receive",
            "example": 100
          },
          "line_item_number": {
            "type": "string",
            "description": "Line number in source system"
          },
          "batches": {
            "type": "array",
            "description": "Batch info for lot/serial managed products",
            "items": {
              "type": "object",
              "properties": {
                "batch_number": {
                  "type": "string",
                  "example": "LOT-2024-03"
                },
                "expiration_date": {
                  "type": "string",
                  "format": "date",
                  "example": "2025-03-01"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "example": 100
                }
              }
            }
          }
        }
      },
      "Packaging": {
        "type": "object",
        "description": "One physical loading unit (pallet, box, bag, bin, or mixed container) on a\npurchase order. See [Loading units](/guide/loading-units) for the nesting\nmodel and validation rules.\n",
        "required": [
          "line_item_number",
          "barcode",
          "packaging_type",
          "packaging_level",
          "quantity_in_package"
        ],
        "properties": {
          "line_item_number": {
            "type": "string",
            "description": "Must match a `line_item_number` in `items`. Ties this unit to one order\nline (SKU).\n",
            "example": "00010"
          },
          "barcode": {
            "type": "string",
            "description": "Identifier of the physical unit. Unique per unit — except a\n`mix_container`, which repeats the same barcode once per SKU it holds.\n",
            "example": "BOX00010"
          },
          "barcode_agency": {
            "type": "string",
            "nullable": true,
            "description": "Source of the barcode, e.g. `custom` for your own barcodes.",
            "example": "custom"
          },
          "packaging_type": {
            "type": "string",
            "enum": [
              "bag",
              "bin",
              "box",
              "pallet",
              "mix_container"
            ]
          },
          "packaging_level": {
            "type": "integer",
            "description": "Nesting depth. `0` is the outermost unit, sitting directly at a\nwarehouse location. Levels must be contiguous from `0` for a given\n`line_item_number` — a level-2 unit requires levels 0 and 1 to exist\ntoo, chained via `location_level_barcode`.\n",
            "example": 0
          },
          "location_level_barcode": {
            "type": "string",
            "nullable": true,
            "description": "`barcode` of the parent unit one level up (same SKU). `null` at\nlevel `0`.\n",
            "example": null
          },
          "quantity_in_package": {
            "type": "integer",
            "minimum": 1,
            "description": "Units of this line's SKU contained in the unit. A parent's quantity\nequals the sum of its children.\n",
            "example": 20
          },
          "dimensions_width": {
            "type": "number",
            "format": "float",
            "description": "Width of the unit.",
            "example": 30
          },
          "dimensions_height": {
            "type": "number",
            "format": "float",
            "description": "Height of the unit.",
            "example": 30
          },
          "dimensions_length": {
            "type": "number",
            "format": "float",
            "description": "Length of the unit.",
            "example": 30
          },
          "dimensions_weight": {
            "type": "number",
            "format": "float",
            "description": "Weight of the unit (named with the `dimensions_` prefix).",
            "example": 30
          }
        }
      },
      "PurchaseOrder": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PurchaseOrderInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "description": "PULPO purchase order ID",
                "example": 360707
              },
              "state": {
                "type": "string",
                "enum": [
                  "queue",
                  "checking",
                  "finished_partially",
                  "closed",
                  "cancelled"
                ],
                "description": "Current PO state. `cancelled` is terminal — a `queue`-state order can\nbe cancelled via `DELETE /reception/purchase_orders/{id}`. For embedded\n\"return\" purchase orders inside `GET /sales/orders/{id}/returns`, the\nAPI may also use the simplified enum\n`[queue, receiving, ended, cancelled]`.\n",
                "example": "queue"
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              },
              "source_channel": {
                "type": "boolean",
                "example": false
              },
              "number_finished_early_events": {
                "type": "integer",
                "nullable": true,
                "description": "Number of times order was finished early"
              }
            }
          }
        ]
      },
      "BulkPurchaseOrderResult": {
        "type": "object",
        "description": "Minimal reference to a created purchase order (not the full record).",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO purchase order ID",
            "example": 360707
          },
          "order_num": {
            "type": "string",
            "example": "PO-2024-001"
          }
        }
      },
      "BulkCreatePurchaseOrdersResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkPurchaseOrderResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item validation errors, keyed by the submitted `order_num`. The\nendpoint keeps processing the rest of the batch even when some items\nfail — a non-empty `errors` doesn't mean `created` is empty.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "ShippingMethod": {
        "type": "object",
        "description": "A shipping method (carrier + service) that sales orders can be assigned to via\n`shipping_method_id`.\n",
        "properties": {
          "id": {
            "type": "integer",
            "example": 3218
          },
          "name": {
            "type": "string",
            "description": "Unique per merchant. Used as the match key by the bulk upsert.",
            "example": "DHL Standard"
          },
          "carrier": {
            "type": "string",
            "nullable": true,
            "example": "DHL"
          },
          "service": {
            "type": "string",
            "nullable": true,
            "example": "standard"
          },
          "fetch_label": {
            "type": "boolean",
            "description": "Whether a shipping label is fetched for this method. Defaults to `true`.",
            "example": true
          },
          "merchant_id": {
            "type": "integer",
            "nullable": true,
            "example": 1053
          },
          "merchant_channel_id": {
            "type": "integer",
            "nullable": true,
            "example": 1068
          },
          "tenant_id": {
            "type": "integer",
            "example": 1445
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-01T13:21:29"
          }
        }
      },
      "ShippingMethodInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Must be unique within the merchant.",
            "example": "DHL Standard"
          },
          "carrier": {
            "type": "string",
            "example": "DHL"
          },
          "service": {
            "type": "string",
            "example": "standard"
          },
          "fetch_label": {
            "type": "boolean",
            "default": true,
            "example": true
          },
          "merchant_id": {
            "type": "integer",
            "example": 1053
          },
          "merchant_channel_id": {
            "type": "integer",
            "example": 1068
          }
        }
      },
      "SalesOrderInput": {
        "type": "object",
        "required": [
          "type",
          "order_num",
          "delivery_date",
          "warehouse_id",
          "third_party_id",
          "priority",
          "items",
          "ship_to"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "sales_order",
              "warehouse_movement",
              "return",
              "POS_external"
            ],
            "default": "sales_order",
            "description": "Order type",
            "example": "sales_order"
          },
          "order_num": {
            "type": "string",
            "description": "Your external order number (must be unique)",
            "example": "SO-2024-12345"
          },
          "delivery_date": {
            "type": "string",
            "format": "date-time",
            "description": "Required delivery date (YYYY-MM-DDTHH:MM:SS)",
            "example": "2024-03-26T14:00:00"
          },
          "warehouse_id": {
            "type": "integer",
            "description": "Fulfilling warehouse",
            "example": 140
          },
          "merchant_id": {
            "type": "integer",
            "description": "Merchant fulfilling order. Optional for single-merchant (non-3PL) tenants — defaults to your account's merchant/channel.",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "description": "Sales channel. Optional for single-merchant (non-3PL) tenants — defaults to your account's merchant/channel.",
            "example": 76
          },
          "third_party_id": {
            "type": "integer",
            "description": "Customer ID (type=C third party). Create the customer first via\n`POST /iam/bulk/third_parties`, then pass its `id` here.\n",
            "example": 3218516
          },
          "identifier_number": {
            "type": "string",
            "description": "Customer external ID reference",
            "example": "CUST-12345"
          },
          "identifier_type": {
            "type": "string",
            "description": "ID type (defaults to CUSTOMER_ID if omitted)",
            "example": "ID"
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1,
            "description": "1=low, 2=normal, 3=high, 4=top. If you don't have a use case for order\npriority, send `1`.\n",
            "example": 1
          },
          "shipping_method_id": {
            "type": "integer",
            "description": "PULPO ID of the shipping method. The shipping method must already exist —\ncreate it with `POST /shipping/shipping_methods` and look it up with\n`GET /shipping/shipping_methods`. An unknown ID makes the whole request fail\nwith `500 Internal Server Error`.\n",
            "example": 952
          },
          "destination_warehouse_id": {
            "type": "integer",
            "description": "Required if type=warehouse_movement",
            "example": null
          },
          "notes": {
            "type": "string",
            "description": "Order notes"
          },
          "criterium": {
            "type": "string",
            "description": "Custom routing criteria"
          },
          "is_cart": {
            "type": "boolean",
            "default": false,
            "description": "Shopping cart mode"
          },
          "ship_to": {
            "$ref": "#/components/schemas/ShipTo"
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/SalesOrderItem"
            }
          },
          "attributes": {
            "type": "object",
            "description": "Custom attributes"
          }
        }
      },
      "SalesOrderItem": {
        "type": "object",
        "required": [
          "quantity"
        ],
        "properties": {
          "product_id": {
            "type": "integer",
            "description": "PULPO product ID (use this OR product_sku)",
            "example": 1957711
          },
          "product_sku": {
            "type": "string",
            "description": "Product SKU (use this OR product_id)",
            "example": "COFFEE-001"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Quantity to fulfill",
            "example": 5
          },
          "line_order_id": {
            "type": "string",
            "description": "Line number in source system"
          },
          "required_date": {
            "type": "string",
            "format": "date-time",
            "description": "Item-specific required date"
          },
          "attributes": {
            "type": "object",
            "description": "Custom line item attributes"
          }
        }
      },
      "SalesOrder": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesOrderInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "description": "PULPO sales order ID",
                "example": 13283307
              },
              "state": {
                "type": "string",
                "enum": [
                  "queue",
                  "picking",
                  "packing",
                  "shipping",
                  "ended",
                  "cancelled"
                ],
                "description": "Current sales order state. The `paused` value actually lives on\n`fulfillment_orders[0].state`; clients should derive the effective\nstate as `fulfillment_orders[0].state || sales_order.state`.\n",
                "example": "queue"
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              },
              "source_channel": {
                "type": "boolean",
                "example": true
              },
              "creator_id": {
                "type": "integer",
                "description": "User who created order"
              },
              "creator": {
                "$ref": "#/components/schemas/Owner"
              },
              "updater": {
                "$ref": "#/components/schemas/Owner"
              },
              "updated_by": {
                "type": "integer",
                "description": "User who last updated the order"
              },
              "cancelled_by": {
                "type": "integer",
                "nullable": true
              },
              "canceller": {
                "$ref": "#/components/schemas/Owner"
              },
              "owner": {
                "$ref": "#/components/schemas/Owner"
              },
              "missing_stock_items_cancelled": {
                "type": "boolean",
                "description": "Items cancelled due to missing stock"
              },
              "channel": {
                "type": "object",
                "description": "Sales channel (denormalised)",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              "shipping_method": {
                "description": "Shipping method — may appear as either a string (legacy) or an object\nwith `name`/`carrier_name` (current).\n",
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "carrier_name": {
                        "type": "string"
                      }
                    }
                  }
                ]
              },
              "third_party": {
                "type": "object",
                "description": "Inline customer summary",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              },
              "ship_to": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ShipTo"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string",
                        "format": "email"
                      }
                    }
                  }
                ]
              },
              "process_information": {
                "$ref": "#/components/schemas/ProcessInformation"
              },
              "product_skus": {
                "type": "array",
                "description": "Flattened SKU list (duplicated per unit)",
                "items": {
                  "type": "string"
                }
              },
              "fulfillment_orders": {
                "type": "array",
                "description": "Execution units. Picking task creation operates on these IDs, not on\nthe sales order ID.\n",
                "items": {
                  "$ref": "#/components/schemas/FulfillmentOrder"
                }
              },
              "items": {
                "type": "array",
                "description": "Order line items. Aliased on some tenants as `lines`, `order_items`,\nor `sales_order_lines` — clients should accept any of these keys.\n",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "product_id": {
                      "type": "integer"
                    },
                    "product_sku": {
                      "type": "string"
                    },
                    "quantity": {
                      "type": "integer"
                    },
                    "fulfilled_quantity": {
                      "type": "integer"
                    },
                    "state": {
                      "type": "string"
                    },
                    "batches": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "attributes": {
                "type": "object",
                "description": "Custom attributes",
                "properties": {
                  "manually_created": {
                    "type": "boolean",
                    "description": "`false` indicates the order was created via API."
                  }
                }
              },
              "attachments": {
                "type": "array",
                "description": "Files attached to the sales order with `POST /sales/orders/{id}/attach`.\n",
                "items": {
                  "$ref": "#/components/schemas/SalesOrderAttachment"
                }
              }
            }
          }
        ]
      },
      "SalesOrderAttachment": {
        "type": "object",
        "description": "A file attached to a sales order.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Attachment ID (UUID). Use it to delete the attachment.",
            "example": "02ff6301-d514-43f1-896b-391ba9a94d8a"
          },
          "name": {
            "type": "string",
            "description": "The `filename` sent on upload, otherwise the uploaded file's name.",
            "example": "delivery_note_4711.pdf"
          },
          "type": {
            "type": "string",
            "enum": [
              "document",
              "label",
              "photo",
              "undefined"
            ],
            "example": "document"
          },
          "document_type": {
            "type": "string",
            "nullable": true,
            "description": "Only set when `type` is `document`. Free text, stored as sent.",
            "example": "delivery_note"
          },
          "extension": {
            "type": "string",
            "example": "pdf"
          },
          "file_type": {
            "type": "string",
            "description": "MIME type",
            "example": "application/pdf"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://s3.eu-central-1.amazonaws.com/pulpo-wms-eu-show-attachments/uploads/02ff6301-d514-43f1-896b-391ba9a94d8a.pdf"
          }
        }
      },
      "BulkSalesOrderResult": {
        "type": "object",
        "description": "Minimal reference to a created/updated sales order (not the full record).",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO sales order ID",
            "example": 13283307
          },
          "order_num": {
            "type": "string",
            "example": "SO-2024-12345"
          },
          "return_labels": {
            "type": "array",
            "items": {},
            "description": "Return shipping labels generated for this order, if any.",
            "example": []
          }
        }
      },
      "BulkCreateSalesOrdersResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkSalesOrderResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item validation errors, keyed by the submitted `order_num`. The\nendpoint keeps processing the rest of the batch even when some items\nfail — a non-empty `errors` doesn't mean `created` is empty.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "BulkUpdateSalesOrdersResponse": {
        "type": "object",
        "description": "Shared response shape for `PUT /sales/bulk/orders` and the bulk\ncancel/pause/resume actions — they all report results under `updated`.\n",
        "properties": {
          "updated": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkSalesOrderResult"
            }
          },
          "errors": {
            "type": "object",
            "description": "Per-item errors, keyed by the submitted `order_num` (or `id`). Same\npartial-failure behavior as `created` above.\n",
            "additionalProperties": true,
            "example": {}
          }
        }
      },
      "SalesOrderReference": {
        "type": "object",
        "description": "Reference to a sales order by ID or order number",
        "properties": {
          "id": {
            "type": "integer",
            "description": "PULPO sales order ID",
            "example": 13283307
          },
          "order_num": {
            "type": "string",
            "description": "External order number",
            "example": "SO-2024-12345"
          }
        }
      },
      "ShipTo": {
        "type": "object",
        "required": [
          "name",
          "address"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Recipient name",
            "example": "John Smith"
          },
          "company_name": {
            "type": "string",
            "description": "Company name",
            "example": "John's Coffee Shop"
          },
          "phone_number": {
            "type": "string",
            "description": "Phone number with country code",
            "example": "+44 20 1234 5678"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        }
      },
      "PickingOrder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1272500
          },
          "sequence_number": {
            "type": "string",
            "description": "Human-readable picking order number",
            "example": "PI-0000123"
          },
          "warehouse_id": {
            "type": "integer",
            "example": 140
          },
          "state": {
            "type": "string",
            "enum": [
              "queue",
              "taken",
              "locked",
              "mixed",
              "ended",
              "cancelled"
            ],
            "example": "ended"
          },
          "type": {
            "type": "string",
            "enum": [
              "single",
              "batch",
              "cart"
            ],
            "description": "Picking strategy. `single` = one task per fulfillment_order; `batch` =\none task across multiple FOs; `cart` = batch with one cart slot per FO.\n"
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "example": 76
          },
          "sales_order_id": {
            "type": "integer",
            "nullable": true,
            "description": "When the task is linked to a single sales order (single-pick)"
          },
          "fulfillment_order_id": {
            "type": "integer",
            "nullable": true
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "owner": {
            "$ref": "#/components/schemas/Owner"
          },
          "items": {
            "type": "array",
            "description": "Items to pick",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "PackingOrder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1272633
          },
          "sequence_number": {
            "type": "string",
            "description": "Human-readable packing order number",
            "example": "PA-0000009"
          },
          "warehouse_id": {
            "type": "integer",
            "example": 140
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "queue",
              "taken",
              "locked",
              "ended",
              "closed",
              "cancelled"
            ],
            "description": "`locked` = paused (kept by owner). `closed` = final (`/close` released\nthe owner lock). See the Packing tag for the full state machine.\n",
            "example": "ended"
          },
          "type": {
            "type": "string",
            "enum": [
              "normal",
              "turbo_label"
            ],
            "example": "normal"
          },
          "sales_order_id": {
            "type": "integer",
            "example": 13283307
          },
          "fulfillment_order_id": {
            "type": "integer",
            "nullable": true
          },
          "sales_order": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "order_num": {
                "type": "string"
              },
              "merchant_id": {
                "type": "integer"
              },
              "merchant_channel_id": {
                "type": "integer"
              }
            }
          },
          "fulfillment_order": {
            "$ref": "#/components/schemas/FulfillmentOrder"
          },
          "owner": {
            "$ref": "#/components/schemas/Owner"
          },
          "origin_location_id": {
            "type": "integer"
          },
          "origin_location": {
            "$ref": "#/components/schemas/OriginLocation"
          },
          "destination_location_id": {
            "type": "integer",
            "nullable": true
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "packing_boxes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PackingBox"
            }
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          },
          "items": {
            "type": "array",
            "description": "Items to pack",
            "items": {
              "type": "object",
              "properties": {
                "quantity": {
                  "type": "integer"
                },
                "product_id": {
                  "type": "integer"
                },
                "batches": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer"
                      },
                      "quantity": {
                        "type": "integer"
                      },
                      "batch_id": {
                        "type": "integer"
                      },
                      "cart_box_id": {
                        "type": "integer",
                        "nullable": true
                      },
                      "batch": {
                        "$ref": "#/components/schemas/Batch"
                      },
                      "cart_box": {
                        "type": "object",
                        "description": "Cart-pick context (where this batch is currently held)",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "barcode": {
                            "type": "string"
                          },
                          "fulfillment_order_id": {
                            "type": "integer"
                          },
                          "sales_order_id": {
                            "type": "integer"
                          },
                          "occupied": {
                            "type": "boolean"
                          },
                          "warehouse_id": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "PackingBox": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1484054
          },
          "packing_order_id": {
            "type": "integer",
            "example": 1272633
          },
          "box_number": {
            "type": "integer",
            "description": "Box sequence number (1-indexed)",
            "example": 1
          },
          "name": {
            "type": "string",
            "example": "Box 1"
          },
          "state": {
            "type": "string",
            "enum": [
              "open",
              "packed",
              "shipped"
            ],
            "example": "packed"
          },
          "weight": {
            "type": "number",
            "format": "float",
            "description": "Box weight in kg",
            "example": 1.5
          },
          "length": {
            "type": "number",
            "format": "float",
            "description": "Box length in cm",
            "example": 30
          },
          "width": {
            "type": "number",
            "format": "float",
            "description": "Box width in cm",
            "example": 20
          },
          "height": {
            "type": "number",
            "format": "float",
            "description": "Box height in cm",
            "example": 15
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "shipment_tracking": {
            "$ref": "#/components/schemas/ShipmentTracking"
          },
          "packing_box_items": {
            "type": "array",
            "description": "Items in this box",
            "items": {
              "$ref": "#/components/schemas/PackingBoxItem"
            }
          },
          "attachments": {
            "type": "array",
            "description": "Label PDFs and other files attached to the box. The presence of a label\nattachment (`type=label`) signals the box is ready to ship.\n",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          }
        }
      },
      "ShipmentTracking": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1328060
          },
          "box_id": {
            "type": "integer",
            "example": 1484054
          },
          "status": {
            "type": "string",
            "nullable": true,
            "enum": [
              null,
              "pulpowms_label_generation_started",
              "pulpowms_label_generated",
              "pulpowms_label_generation_failed",
              "pulpowms_label_not_required"
            ],
            "description": "Label generation status",
            "example": "pulpowms_label_generated"
          },
          "tracking_code": {
            "type": "string",
            "nullable": true,
            "description": "Carrier tracking number",
            "example": "1Z999AA10123456784"
          },
          "tracking_url": {
            "type": "string",
            "nullable": true,
            "format": "uri",
            "description": "Carrier tracking URL",
            "example": "https://www.ups.com/track?tracknum=1Z999AA10123456784"
          },
          "carrier_code": {
            "type": "string",
            "nullable": true,
            "description": "Carrier code (e.g., UPS, DHL, FEDEX)",
            "example": "UPS"
          },
          "error_message": {
            "type": "string",
            "nullable": true,
            "description": "Error message if label generation failed"
          },
          "service_point_id": {
            "type": "integer",
            "nullable": true,
            "description": "Pickup point/service point ID"
          },
          "printed": {
            "type": "boolean",
            "description": "Label has been printed",
            "example": false
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "attributes": {
            "type": "object",
            "nullable": true,
            "description": "Custom tracking attributes"
          }
        }
      },
      "ShipmentTrackingUpdate": {
        "type": "object",
        "description": "Either a status update (`status` + optional tracking info) or a retry signal\n(`retry: true`) to re-attempt label generation for the same tracking record.\n",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "pulpowms_label_generation_started",
              "pulpowms_label_generated",
              "pulpowms_label_generation_failed",
              "pulpowms_label_not_required"
            ],
            "description": "Label generation status",
            "example": "pulpowms_label_generated"
          },
          "retry": {
            "type": "boolean",
            "description": "Set `true` to re-trigger label generation for the same tracking record\n(e.g., after fixing the ship-to address via\n`PATCH /fulfillment_orders/{id}/ship_to`).\n"
          },
          "tracking_code": {
            "type": "string",
            "description": "Carrier tracking number (required for success)",
            "example": "1Z999AA10123456784"
          },
          "tracking_url": {
            "type": "string",
            "format": "uri",
            "description": "Carrier tracking URL",
            "example": "https://www.ups.com/track?tracknum=1Z999AA10123456784"
          },
          "carrier_code": {
            "type": "string",
            "description": "Carrier code (required for success)",
            "example": "UPS"
          },
          "error_message": {
            "type": "string",
            "description": "Error message (required for failed status)",
            "example": "Carrier API timeout"
          },
          "service_point_id": {
            "type": "integer",
            "description": "Pickup point ID"
          },
          "attributes": {
            "type": "object",
            "description": "Custom attributes"
          }
        }
      },
      "StockSummary": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "sku": {
            "type": "string",
            "example": "COFFEE-001"
          },
          "name": {
            "type": "string",
            "example": "Premium Coffee Beans 1kg"
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "total": {
            "type": "number",
            "description": "Total stock in storage/user/cross-docking/packing locations",
            "example": 150
          },
          "available": {
            "type": "number",
            "description": "Total minus open orders",
            "example": 120
          },
          "unavailable": {
            "type": "number",
            "description": "Open orders + reception + return",
            "example": 30
          },
          "rejected": {
            "type": "number",
            "description": "Stock in return locations",
            "example": 5
          },
          "last_movement": {
            "type": "string",
            "description": "Last stock movement type",
            "example": "replenishment_order_finished"
          }
        }
      },
      "StockLocation": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "product_sku": {
            "type": "string",
            "example": "COFFEE-001"
          },
          "product_name": {
            "type": "string",
            "example": "Premium Coffee Beans 1kg"
          },
          "article_number": {
            "type": "string",
            "description": "Internal article number for the product"
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "location_id": {
            "type": "integer",
            "example": 229364
          },
          "location_code": {
            "type": "string",
            "description": "Physical location code",
            "example": "M-1-1-2-1-1"
          },
          "quantity": {
            "type": "integer",
            "example": 87
          },
          "packed_or_loose": {
            "type": "string",
            "nullable": true,
            "enum": [
              "packed",
              "loose",
              "both"
            ],
            "description": "Stock packaging status (if requested)",
            "example": "loose"
          },
          "batch_id": {
            "type": "integer",
            "nullable": true
          },
          "batch_number": {
            "type": "string",
            "nullable": true
          },
          "lot_number": {
            "type": "string",
            "nullable": true
          },
          "expiration_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "best_before_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        }
      },
      "Batch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique batch ID",
            "example": 45231
          },
          "number": {
            "type": "string",
            "description": "Alphanumerical batch/lot number",
            "example": "LOT-2025-001"
          },
          "type": {
            "type": "string",
            "enum": [
              "lot",
              "serial",
              "none"
            ],
            "description": "Type of batch: `lot`, `serial`, or `none`",
            "example": "lot"
          },
          "expiration_date": {
            "type": "string",
            "format": "date",
            "description": "Expiration date of the batch (format: YYYY-MM-DD)",
            "example": "2025-12-31"
          },
          "product_id": {
            "type": "integer",
            "description": "Associated product ID",
            "example": 1957711
          },
          "third_party_id": {
            "type": "integer",
            "nullable": true,
            "description": "Supplier ID associated with this batch",
            "example": 3218515
          },
          "client_id": {
            "type": "string",
            "nullable": true,
            "description": "Client identifier associated to batch"
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time",
            "description": "Creation timestamp",
            "example": "2025-01-15T10:30:00"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Last update timestamp",
            "example": "2025-01-15T10:30:00"
          }
        }
      },
      "StockCorrectionItemBatchInput": {
        "type": "object",
        "required": [
          "batch_id",
          "quantity"
        ],
        "properties": {
          "batch_id": {
            "type": "integer",
            "description": "Existing lot/serial batch ID. For a `serial`-managed product, `quantity`\nmust be `1` on every entry (a serial is a single unique unit); for `lot`\nit can be any amount.\n",
            "example": 45231
          },
          "quantity": {
            "type": "integer",
            "description": "Signed amount to add (positive) or remove (negative) from this batch.",
            "example": 5
          }
        }
      },
      "StockCorrectionItemInput": {
        "type": "object",
        "required": [
          "location_id",
          "product_id",
          "quantity"
        ],
        "properties": {
          "location_id": {
            "type": "integer",
            "description": "Location where the correction is applied.",
            "example": 229364
          },
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "quantity": {
            "type": "integer",
            "description": "Signed amount to add (positive) or remove (negative). For batch-controlled\nproducts, keep this equal to the sum of `item_batches[].quantity` — the\nbatch-level values are what actually get applied.\n",
            "example": 5
          },
          "item_batches": {
            "type": "array",
            "description": "Required for lot/serial-managed products; omit for `none`-managed products.",
            "items": {
              "$ref": "#/components/schemas/StockCorrectionItemBatchInput"
            }
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "StockCorrection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "sequence_number": {
            "type": "string",
            "example": "SC-0000021"
          },
          "warehouse_id": {
            "type": "integer"
          },
          "owner_id": {
            "type": "integer"
          },
          "owner": {
            "$ref": "#/components/schemas/Owner"
          },
          "comment": {
            "type": "string",
            "nullable": true
          },
          "reason_codes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "product_id": {
                  "type": "integer"
                },
                "location_id": {
                  "type": "integer"
                },
                "quantity": {
                  "type": "integer"
                },
                "loading_unit_location_id": {
                  "type": "integer",
                  "nullable": true
                },
                "batches": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          }
        }
      },
      "ExpiringStock": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "product_sku": {
            "type": "string",
            "example": "COFFEE-001"
          },
          "product_name": {
            "type": "string",
            "example": "Premium Coffee Beans 1kg"
          },
          "batch_id": {
            "type": "integer",
            "example": 45231
          },
          "batch_number": {
            "type": "string",
            "example": "LOT-2025-001"
          },
          "expiration_date": {
            "type": "string",
            "format": "date",
            "description": "Expiration date (format: YYYY-MM-DD)",
            "example": "2025-12-31"
          },
          "quantity": {
            "type": "integer",
            "example": 50
          },
          "location_id": {
            "type": "integer",
            "example": 229364
          },
          "location_code": {
            "type": "string",
            "example": "M-1-1-2-1-1"
          }
        }
      },
      "AvailabilityBatch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "batch_id": {
            "type": "integer",
            "description": "Batch ID",
            "example": 45231
          },
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "available_quantity": {
            "type": "integer",
            "description": "Available quantity for this batch",
            "example": 50
          },
          "reception_quantity": {
            "type": "integer",
            "description": "Quantity currently in reception",
            "example": 0
          },
          "location_type_id": {
            "type": "integer",
            "example": 1
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "KitInput": {
        "type": "object",
        "required": [
          "name",
          "product_id",
          "items",
          "warehouses"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Unique kit name",
            "example": "Coffee Gift Box Kit"
          },
          "product_id": {
            "type": "integer",
            "description": "Final product ID (the assembled kit)",
            "example": 1957720
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "description": "Component products",
            "items": {
              "type": "object",
              "required": [
                "product_id",
                "quantity"
              ],
              "properties": {
                "product_id": {
                  "type": "integer",
                  "description": "Component product ID",
                  "example": 1957711
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "Quantity needed per kit",
                  "example": 2
                }
              }
            }
          },
          "warehouses": {
            "type": "array",
            "description": "Warehouse IDs where kit can be assembled",
            "items": {
              "type": "integer"
            },
            "example": [
              140
            ]
          }
        }
      },
      "Kit": {
        "allOf": [
          {
            "$ref": "#/components/schemas/KitInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "example": 5
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "KittingTaskInput": {
        "type": "object",
        "required": [
          "warehouse_id",
          "destination_location_id",
          "items"
        ],
        "properties": {
          "warehouse_id": {
            "type": "integer",
            "description": "Warehouse for kitting",
            "example": 140
          },
          "destination_location_id": {
            "type": "integer",
            "description": "Kitting location ID",
            "example": 109200
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "kit_id",
                "quantity"
              ],
              "properties": {
                "kit_id": {
                  "type": "integer",
                  "description": "Kit template ID",
                  "example": 5
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "Number of kits to assemble",
                  "example": 10
                }
              }
            }
          }
        }
      },
      "KittingTask": {
        "allOf": [
          {
            "$ref": "#/components/schemas/KittingTaskInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "state": {
                "type": "string",
                "enum": [
                  "queue",
                  "in_progress",
                  "completed"
                ]
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "Location": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 109200
          },
          "code": {
            "type": "string",
            "description": "Location barcode/identifier",
            "example": "KITTING-01"
          },
          "name": {
            "type": "string",
            "example": "Kitting Area 1"
          },
          "warehouse_id": {
            "type": "integer",
            "example": 140
          },
          "location_type_id": {
            "type": "integer",
            "example": 15
          },
          "active": {
            "type": "boolean",
            "example": true
          }
        }
      },
      "WebhookSubscription": {
        "type": "object",
        "required": [
          "url",
          "method",
          "warehouse_id",
          "allowed_types"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Your webhook endpoint URL (must be HTTPS)",
            "example": "https://your-domain.com/webhooks/pulpo"
          },
          "method": {
            "type": "string",
            "enum": [
              "POST"
            ],
            "description": "HTTP method. Required, there is no default."
          },
          "warehouse_id": {
            "type": "integer",
            "description": "Warehouse whose events you receive. Required.",
            "example": 140
          },
          "merchant_id": {
            "type": "integer",
            "description": "Filter by merchant",
            "example": 69
          },
          "merchant_channel_id": {
            "type": "integer",
            "description": "Filter by channel",
            "example": 76
          },
          "allowed_types": {
            "type": "array",
            "description": "Event types to receive",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "purchase_order_updated",
                "purchase_order_deleted",
                "purchase_order_finished",
                "purchase_order_finished_early",
                "incoming_good_created",
                "replenishment_order_created",
                "replenishment_order_cancelled",
                "replenishment_order_finished",
                "sales_order_created",
                "sales_order_updated",
                "sales_order_cancelled",
                "sales_order_finished",
                "fulfillment_order_finished",
                "picking_order_created",
                "picking_order_finished",
                "picking_order_cancelled",
                "picking_order_deleted",
                "packing_order_created",
                "packing_order_finished",
                "packing_order_closed",
                "packing_order_cancelled",
                "packing_box_closed",
                "turbo_label_packing_created",
                "shipment_tracking_updated",
                "stock_correction_finished",
                "counting_task_created",
                "counting_task_finished",
                "counting_task_cancelled",
                "counting_task_closed"
              ]
            },
            "example": [
              "sales_order_created",
              "packing_order_finished",
              "sales_order_finished"
            ]
          }
        }
      },
      "Webhook": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WebhookSubscription"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "example": "e8d6c6fe-3408-4e08-9139-769e304966ca"
              },
              "enabled": {
                "type": "boolean",
                "example": true
              },
              "client_id": {
                "nullable": true
              },
              "client": {
                "nullable": true
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "WebhookPayload": {
        "type": "object",
        "description": "Generic webhook payload structure. All webhooks follow this pattern.\n\nThe `data` field contains the event-specific payload (order, shipment, etc.)\n",
        "properties": {
          "webhook_id": {
            "type": "string",
            "nullable": true,
            "description": "Webhook subscription ID"
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique event ID (use for deduplication)",
            "example": "e8d6c6fe-3408-4e08-9139-769e304966ca"
          },
          "type": {
            "type": "string",
            "description": "Event type",
            "example": "sales_order_finished"
          },
          "status": {
            "type": "string",
            "enum": [
              "triggered",
              "failed"
            ],
            "description": "Delivery status",
            "example": "triggered"
          },
          "retry": {
            "type": "boolean",
            "description": "Is this a retry attempt",
            "example": false
          },
          "warehouse_id": {
            "type": "integer",
            "example": 140
          },
          "warehouse_name": {
            "type": "string",
            "example": "Main Warehouse London"
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "merchant_name": {
            "type": "string",
            "example": "default"
          },
          "merchant_channel_id": {
            "type": "integer",
            "example": 76
          },
          "merchant_channel_name": {
            "type": "string",
            "example": "default"
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time",
            "description": "Event timestamp"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "params": {
            "type": "object",
            "description": "Additional parameters"
          },
          "data": {
            "type": "object",
            "description": "Event-specific payload (order, shipment, stock, etc.)"
          }
        }
      },
      "PackingBoxItem": {
        "type": "object",
        "description": "An item contained in a packing box",
        "properties": {
          "line_order_id": {
            "type": "string",
            "nullable": true,
            "description": "External line order reference",
            "example": "123"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Quantity of this product in the box",
            "example": 1
          },
          "product_id": {
            "type": "integer",
            "description": "Unique product ID in PULPO WMS",
            "example": 1957711
          },
          "product": {
            "type": "object",
            "properties": {
              "tenant_id": {
                "type": "integer",
                "example": 5390
              },
              "sku": {
                "type": "string",
                "description": "Product SKU (unique per tenant and merchant)",
                "example": "test_product"
              }
            }
          }
        }
      },
      "PackingBoxClosedWebhookPayload": {
        "type": "object",
        "description": "Webhook payload for `packing_box_closed` events.\n\nThis webhook fires when an individual box is sealed during packing.\nFor label provider integrations, use this event (combined with `turbo_label_packing_created`)\nto trigger label generation per box.\n\n**Key fields for label providers:**\n- `data.sales_order_id` / `data.sales_order.order_num` — identify the customer order\n- `data.packing_boxes[].shipment_tracking.id` — the tracking ID needed for PUT calls\n- `data.packing_boxes[].packing_box_items` — items in this box for label content\n- `merchant_id` / `merchant_channel_id` — for routing to the correct carrier/service\n",
        "properties": {
          "warehouse_name": {
            "type": "string",
            "example": "test_warehouse_1"
          },
          "name": {
            "type": "string",
            "description": "Box name",
            "example": "Box 2"
          },
          "warehouse_id": {
            "type": "integer",
            "example": 5913
          },
          "type": {
            "type": "string",
            "enum": [
              "packing_box_closed"
            ],
            "example": "packing_box_closed"
          },
          "id": {
            "type": "integer",
            "example": 24157
          },
          "box_number": {
            "type": "integer",
            "example": 2
          },
          "height": {
            "type": "number",
            "format": "float",
            "example": 1
          },
          "length": {
            "type": "number",
            "format": "float",
            "example": 1
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "warehouse_id": {
                "type": "integer",
                "example": 5913
              },
              "sequence_number": {
                "type": "string",
                "description": "Packing order sequence number",
                "example": "PA-0000012"
              },
              "sales_order_id": {
                "type": "integer",
                "description": "Unique sales order ID in PULPO WMS",
                "example": 645752
              },
              "sales_order": {
                "type": "object",
                "properties": {
                  "merchant_channel_id": {
                    "type": "integer",
                    "example": 79
                  },
                  "merchant_id": {
                    "type": "integer",
                    "example": 79
                  },
                  "order_num": {
                    "type": "string",
                    "description": "External order number (customer side)",
                    "example": "order1"
                  }
                }
              },
              "packing_boxes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "width": {
                      "type": "number",
                      "format": "float",
                      "example": 1
                    },
                    "weight": {
                      "type": "number",
                      "format": "float",
                      "example": 19
                    },
                    "state": {
                      "type": "string",
                      "example": "packed"
                    },
                    "inserted_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "shipment_tracking": {
                      "type": "object",
                      "description": "Contains the tracking ID needed for label API calls",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "description": "Use this ID in PUT /shipment_tracking/{tracking_id}",
                          "example": 14704
                        }
                      }
                    },
                    "packing_order_id": {
                      "type": "integer",
                      "example": 35149
                    },
                    "packing_box_items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PackingBoxItem"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "PackingOrderFinishedWebhookPayload": {
        "type": "object",
        "description": "Webhook payload for `packing_order_finished` events.\n\nThis webhook fires when the entire packing order is completed.\nIt contains all boxes for the order, each with their own shipment tracking ID.\n\n**Note:** At this point, `shipment_tracking` only contains the `id` field —\ntracking codes and URLs are not yet populated until label generation completes.\n",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "packing_order_finished"
                  ],
                  "example": "packing_order_finished"
                },
                "warehouse_name": {
                  "type": "string",
                  "example": "test_warehouse_1"
                },
                "warehouse_id": {
                  "type": "integer",
                  "example": 5913
                },
                "sales_order_id": {
                  "type": "integer",
                  "example": 13283307
                },
                "order_num": {
                  "type": "string",
                  "description": "External order number (customer side)",
                  "example": "321"
                },
                "merchant_id": {
                  "type": "integer",
                  "example": 79
                },
                "merchant_channel_id": {
                  "type": "integer",
                  "example": 79
                },
                "packing_order_id": {
                  "type": "integer",
                  "example": 1272633
                },
                "packing_boxes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "example": 3708592
                      },
                      "width": {
                        "type": "number",
                        "format": "float"
                      },
                      "length": {
                        "type": "number",
                        "format": "float"
                      },
                      "height": {
                        "type": "number",
                        "format": "float"
                      },
                      "weight": {
                        "type": "number",
                        "format": "float",
                        "example": 37
                      },
                      "shipment_tracking": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "Tracking ID for label API calls",
                            "example": 1328060
                          }
                        }
                      },
                      "packing_order_id": {
                        "type": "integer",
                        "example": 1272633
                      },
                      "packing_box_items": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/PackingBoxItem"
                        }
                      },
                      "name": {
                        "type": "string",
                        "example": "Box 1"
                      },
                      "box_number": {
                        "type": "integer",
                        "example": 1
                      }
                    }
                  }
                },
                "inserted_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "warehouse_id": {
                      "type": "integer"
                    },
                    "sequence_number": {
                      "type": "string",
                      "example": "PA-0000009"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ShipmentTrackingUpdatedWebhookPayload": {
        "type": "object",
        "description": "Webhook payload for `shipment_tracking_updated` events.\n\nThis webhook fires after a shipment tracking record is updated — typically after\nlabel generation completes. Use this to trigger customer notifications (SMS, email, push).\n\n**Status values:**\n- `pulpowms_label_generation_started` — label generation in progress\n- `pulpowms_label_generated` — label successfully created, tracking info available\n- `pulpowms_label_generation_failed` — label creation failed (see error_message)\n",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "shipment_tracking_updated"
            ]
          },
          "warehouse_id": {
            "type": "integer",
            "example": 140
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "merchant_name": {
            "type": "string",
            "example": "default"
          },
          "merchant_channel_id": {
            "type": "integer",
            "example": 76
          },
          "merchant_channel_name": {
            "type": "string",
            "example": "default"
          },
          "status": {
            "type": "string",
            "enum": [
              "triggered",
              "failed"
            ],
            "example": "triggered"
          },
          "retry": {
            "type": "boolean",
            "example": false
          },
          "printed": {
            "type": "boolean",
            "description": "Whether the label has been printed",
            "example": false
          },
          "packing_box_id": {
            "type": "integer",
            "example": 1484054
          },
          "packing_box": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "example": 1484054
              },
              "width": {
                "type": "number",
                "format": "float"
              },
              "weight": {
                "type": "number",
                "format": "float"
              },
              "length": {
                "type": "number",
                "format": "float"
              },
              "height": {
                "type": "number",
                "format": "float"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "sales_order": {
            "type": "object",
            "properties": {
              "warehouse_id": {
                "type": "integer"
              },
              "state": {
                "type": "string",
                "example": "packing"
              },
              "id": {
                "type": "integer",
                "example": 1328060
              },
              "ship_to": {
                "type": "object",
                "description": "Delivery address information",
                "properties": {
                  "phone_number": {
                    "type": "string",
                    "example": "628/802-5673"
                  },
                  "name": {
                    "type": "string",
                    "example": "Batz and Sons"
                  },
                  "company_name": {
                    "type": "string",
                    "example": "Mosciski Group"
                  }
                }
              }
            }
          },
          "address": {
            "type": "object",
            "description": "Warehouse address",
            "properties": {
              "zip": {
                "type": "string",
                "nullable": true
              },
              "street": {
                "type": "string",
                "example": "1 McKenzie Pike"
              },
              "state": {
                "type": "string",
                "nullable": true
              },
              "warehouse_name": {
                "type": "string",
                "example": "fulfiller_warehouse_1"
              },
              "house_nr": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "AuthRefreshRequest": {
        "type": "object",
        "required": [
          "grant_type",
          "refresh_token"
        ],
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "refresh_token"
            ]
          },
          "refresh_token": {
            "type": "string",
            "description": "Refresh token previously issued by `/auth`"
          }
        }
      },
      "Merchant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 69
          },
          "name": {
            "type": "string",
            "example": "ACME Coffee"
          },
          "company_name": {
            "type": "string",
            "example": "ACME Coffee Ltd"
          },
          "commercial_name": {
            "type": "string",
            "description": "Alternate display name (some tenants)"
          },
          "tenant_name": {
            "type": "string",
            "description": "Tenant display name (some tenants)"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "MerchantChannel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 76
          },
          "name": {
            "type": "string",
            "example": "Shopify EU"
          },
          "merchant_id": {
            "type": "integer",
            "example": 69
          },
          "active": {
            "type": "boolean",
            "example": true
          }
        }
      },
      "Owner": {
        "type": "object",
        "description": "Minimal user reference used for task ownership and audit fields.",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1295
          },
          "username": {
            "type": "string",
            "example": "alex@pulpo.example"
          },
          "first_name": {
            "type": "string",
            "example": "Alex"
          },
          "last_name": {
            "type": "string",
            "example": "Doe"
          },
          "email": {
            "type": "string",
            "format": "email"
          }
        }
      },
      "UserTasks": {
        "type": "object",
        "description": "Active warehouse tasks owned by a user. Paused (`locked`) packing orders are\nnot included — query `GET /packing/orders?state=locked` to discover them.\n",
        "properties": {
          "user_id": {
            "type": "integer",
            "example": 1295
          },
          "packing_orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PackingOrder"
            }
          },
          "picking_orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PickingOrder"
            }
          },
          "counting_tasks": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "replenishment_orders": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "loading_unit_tasks": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Attachment": {
        "type": "object",
        "description": "File attached to a packing box, incoming-goods item, or other record.\n\nFor label PDFs on packing boxes, the URL is found under one of `url`,\n`file_url`, or `link` (server-version dependent). Clients should check all\nthree.\n",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string",
            "description": "Display name"
          },
          "filename": {
            "type": "string"
          },
          "file_name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "label",
              "inspection_photo",
              "document"
            ],
            "description": "Purpose of the attachment"
          },
          "content_type": {
            "type": "string",
            "description": "MIME type",
            "example": "application/pdf"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "file_url": {
            "type": "string",
            "format": "uri"
          },
          "link": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "OriginLocation": {
        "type": "object",
        "description": "The pack station / location the packing task is performed at.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "Canonical location code (always populated by PULPO)",
            "example": "PACK-01"
          },
          "name": {
            "type": "string"
          },
          "warehouse_id": {
            "type": "integer"
          }
        }
      },
      "FulfillmentOrder": {
        "type": "object",
        "description": "Execution unit inside the warehouse. One sales order typically has one\nfulfillment order, but may be split into several (multi-warehouse, partial\nfulfillment). Picking tasks operate on fulfillment_order IDs.\n",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1001
          },
          "sequence_number": {
            "type": "string",
            "example": "FO-0000123"
          },
          "state": {
            "type": "string",
            "enum": [
              "queue",
              "picking",
              "packing",
              "paused",
              "ended",
              "cancelled"
            ],
            "description": "The `paused` state lives here, not on the parent sales order.\n"
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "packing_location_id": {
            "type": "integer",
            "nullable": true
          },
          "sales_items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ProcessInformation": {
        "type": "object",
        "nullable": true,
        "description": "Status of a background process on a **fulfillment order**, for example turbo\nlabel picklist creation. Read it with `GET /sales/orders/fulfillments`. It is\n`null` until a background process has run, and on sales orders it stays `null`.\n",
        "properties": {
          "id": {
            "type": "integer",
            "example": 378867
          },
          "process": {
            "type": "string",
            "example": "turbo_label"
          },
          "status": {
            "type": "string",
            "description": "For `turbo_label`: `queue` → `started` → `turbo_label_created`, or\n`error_creating_picking`.\n",
            "example": "turbo_label_created"
          },
          "value": {
            "type": "string",
            "nullable": true,
            "description": "Result reference — for `turbo_label`, the picklist number.",
            "example": "PI-0000092"
          },
          "errors": {
            "type": "object",
            "additionalProperties": true,
            "description": "Why the process failed. Empty on success.",
            "example": {}
          },
          "attributes": {
            "type": "object",
            "additionalProperties": true,
            "example": {
              "request_id": "GOM4Ux3YD8fPFZQAAbUy"
            }
          }
        }
      },
      "StockRecord": {
        "type": "object",
        "description": "Raw stock row returned by `GET /inventory/stocks`.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "product_id": {
            "type": "integer",
            "example": 1957711
          },
          "product_sku": {
            "type": "string",
            "example": "COFFEE-001"
          },
          "product_name": {
            "type": "string"
          },
          "warehouse_id": {
            "type": "integer"
          },
          "location_id": {
            "type": "integer"
          },
          "location_code": {
            "type": "string"
          },
          "location_type_id": {
            "type": "integer"
          },
          "quantity": {
            "type": "integer",
            "example": 50
          },
          "merchant_id": {
            "type": "integer"
          },
          "batch_id": {
            "type": "integer",
            "nullable": true
          },
          "batch": {
            "type": "object",
            "nullable": true,
            "description": "Batch metadata when the product is batch-controlled",
            "properties": {
              "id": {
                "type": "integer"
              },
              "number": {
                "type": "string",
                "example": "LOT-2025-001"
              },
              "expiration_date": {
                "type": "string",
                "format": "date"
              },
              "type": {
                "type": "string",
                "enum": [
                  "lot",
                  "serial",
                  "none"
                ]
              }
            }
          }
        }
      },
      "BatchStock": {
        "type": "object",
        "description": "Batch-grouped stock row returned by `GET /inventory/stocks/batches`. Each\nrow is one batch with its total quantity across all locations plus a\nper-location breakdown.\n",
        "properties": {
          "batch_id": {
            "type": "integer"
          },
          "batch_number": {
            "type": "string",
            "example": "LOT-2025-001"
          },
          "product_id": {
            "type": "integer"
          },
          "product_name": {
            "type": "string"
          },
          "product_sku": {
            "type": "string"
          },
          "expiration_date": {
            "type": "string",
            "format": "date"
          },
          "total_quantity": {
            "type": "integer"
          },
          "stock_locations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "location_id": {
                  "type": "integer"
                },
                "location_code": {
                  "type": "string"
                },
                "location_type_id": {
                  "type": "integer"
                },
                "quantity": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "IncomingGoodInput": {
        "type": "object",
        "required": [
          "warehouse_id",
          "document_type",
          "start_date",
          "end_date",
          "items"
        ],
        "properties": {
          "warehouse_id": {
            "type": "integer"
          },
          "third_party_id": {
            "type": "integer",
            "description": "Supplier (PO) or customer (return)"
          },
          "purchase_order_id": {
            "type": "integer",
            "description": "Required when receiving against a PO/return"
          },
          "document_type": {
            "type": "string",
            "enum": [
              "purchase_order",
              "return",
              "warehouse_movement",
              "none"
            ],
            "description": "`none` = unplanned receiving without a PO"
          },
          "merchant_id": {
            "type": "integer"
          },
          "merchant_channel_id": {
            "type": "integer",
            "nullable": true
          },
          "owner_id": {
            "type": "integer",
            "description": "User performing the receipt. Required for the `owner` field to be\npopulated on the returned record.\n"
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "description": "When receiving began (YYYY-MM-DDTHH:MM:SS)"
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "description": "When receiving completed"
          },
          "notes": {
            "type": "string"
          },
          "reason_codes": {
            "type": "array",
            "description": "Order-level reason codes. Rejected items more commonly carry their own.",
            "items": {
              "type": "object",
              "properties": {
                "reason_code": {
                  "type": "string",
                  "example": "pulpo_0000001"
                }
              }
            }
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/IncomingGoodItemInput"
            }
          }
        }
      },
      "IncomingGoodItemInput": {
        "type": "object",
        "required": [
          "quantity",
          "state",
          "destination_location_id"
        ],
        "properties": {
          "product_id": {
            "type": "integer",
            "description": "Use this OR `product_sku`"
          },
          "product_sku": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "accepted",
              "rejected"
            ],
            "description": "Inspection outcome for this line"
          },
          "destination_location_id": {
            "type": "integer",
            "description": "Storage/reception location for accepted units, return/rejection location\nfor rejected units.\n"
          },
          "batch_id": {
            "type": "integer",
            "description": "Required for batch-controlled products"
          },
          "reason_codes": {
            "type": "array",
            "description": "Reason(s) for a rejected item.",
            "items": {
              "type": "object",
              "properties": {
                "reason_code": {
                  "type": "string",
                  "example": "pulpo_0000001"
                }
              }
            }
          },
          "temp_id": {
            "type": "string",
            "description": "Optional client-generated identifier (e.g. a UUID) to correlate this item\nacross your own request/response handling. Not persisted or echoed back.\n"
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "IncomingGoodItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IncomingGoodItemInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "accepted_quantity": {
                "type": "integer",
                "description": "Populated when a partial quantity was accepted"
              },
              "rejected_quantity": {
                "type": "integer"
              },
              "batch_number": {
                "type": "string"
              },
              "lot_number": {
                "type": "string"
              },
              "serial_number": {
                "type": "string"
              },
              "expiration_date": {
                "type": "string",
                "format": "date"
              },
              "product": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "sku": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "cost_price": {
                    "type": "number"
                  }
                }
              },
              "batch": {
                "$ref": "#/components/schemas/Batch"
              },
              "attachments": {
                "type": "array",
                "description": "Inspection photos / documents",
                "items": {
                  "$ref": "#/components/schemas/Attachment"
                }
              },
              "reason_codes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Inspection reason codes. Currently stored client-side on dashboards;\nserver-side persistence is partial.\n"
              }
            }
          }
        ]
      },
      "IncomingGood": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IncomingGoodInput"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "sequence_number": {
                "type": "string",
                "example": "IG-0000017"
              },
              "criterium": {
                "type": "string"
              },
              "inserted_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              },
              "owner": {
                "$ref": "#/components/schemas/Owner"
              },
              "third_party": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  },
                  "identifier_number": {
                    "type": "string"
                  }
                }
              },
              "purchase_order": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "order_num": {
                    "type": "string"
                  }
                }
              },
              "sales_order": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "order_num": {
                    "type": "string"
                  }
                }
              },
              "sales_order_id": {
                "type": "integer",
                "nullable": true
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/IncomingGoodItem"
                }
              }
            }
          }
        ]
      },
      "PackingBoxInput": {
        "type": "object",
        "description": "Box payload for `POST /packing/orders/{id}/boxes`. The full set of boxes\nmust be sent — server **replaces** the existing boxes array.\n",
        "required": [
          "packing_order_id",
          "box_number"
        ],
        "properties": {
          "packing_order_id": {
            "type": "integer",
            "description": "Must match the path parameter"
          },
          "box_number": {
            "type": "integer",
            "description": "1-indexed across the full list"
          },
          "weight": {
            "type": "number",
            "format": "float"
          },
          "length": {
            "type": "number",
            "format": "float"
          },
          "width": {
            "type": "number",
            "format": "float"
          },
          "height": {
            "type": "number",
            "format": "float"
          },
          "packing_box_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PackingBoxItem"
            }
          }
        }
      },
      "PickingCreateError": {
        "type": "object",
        "description": "Result of `POST /picking/bulk/orders` (`201` / `400`): `created[]` lists the\npicklists that were created, `errors[]` the fulfillment orders that failed\n(partial success). `POST /picking/orders` returns the same `errors[]` entries with\n`422`, but only the `items` part.\n",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "description": "Fulfillment order ID that failed"
                },
                "order_num": {
                  "type": "string"
                },
                "fulfillment_sequence_number": {
                  "type": "string",
                  "example": "FO-0000145"
                },
                "owner_id": {
                  "type": "string",
                  "description": "Set when a picker ID is invalid",
                  "example": "Invalid picker id"
                },
                "items": {
                  "type": "array",
                  "description": "One entry per problem. Entries can be empty objects for lines that are\nfine.\n",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Fulfillment order ID"
                      },
                      "order_num": {
                        "type": "string"
                      },
                      "fulfillment_sequence_number": {
                        "type": "string"
                      },
                      "insufficient_stock": {
                        "type": "string",
                        "description": "Names the product without enough stock",
                        "example": "not enough stock available for item with product \"NP0003\""
                      },
                      "picking_already_created": {
                        "type": "string",
                        "description": "The fulfillment order is already on a picklist"
                      }
                    }
                  }
                }
              }
            }
          },
          "created": {
            "type": "array",
            "description": "Picklists created (`/picking/bulk/orders` only)",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "description": "Picklist ID"
                },
                "sequence_number": {
                  "type": "string",
                  "example": "PI-0000078"
                },
                "notes": {
                  "type": "string",
                  "nullable": true
                },
                "order_num": {
                  "type": "string"
                },
                "fulfillment_sequence_number": {
                  "type": "string",
                  "example": "FO-0000127"
                }
              }
            }
          }
        }
      },
      "BulkDeletePickingResult": {
        "type": "object",
        "description": "Result of `DELETE /picking/bulk/orders`.",
        "properties": {
          "deleted": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "description": "Picklist ID"
                },
                "sequence_number": {
                  "type": "string",
                  "example": "PI-0000077"
                },
                "owner": {
                  "type": "object"
                },
                "creator": {
                  "type": "object"
                }
              }
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "invalid_picking_order"
                },
                "picking_order_id": {
                  "type": "integer",
                  "example": 99999999
                }
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message",
            "example": "Invalid request parameters"
          },
          "errors": {
            "type": "object",
            "description": "Field-specific errors",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "code": {
            "type": "string",
            "description": "Error code",
            "example": "VALIDATION_ERROR"
          }
        }
      },
      "RateLimitError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "enum": [
              "rate_limit_reached"
            ],
            "example": "rate_limit_reached"
          },
          "retry_after_seconds": {
            "type": "number",
            "format": "float",
            "description": "Seconds to wait before retrying",
            "example": 1
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request - invalid parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "message": "Validation failed",
              "errors": {
                "sku": [
                  "has already been taken"
                ]
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized - invalid or missing token",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "message": "Invalid or expired token"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "message": "Resource not found"
            }
          }
        }
      },
      "RateLimitExceeded": {
        "description": "Rate limit exceeded - too many requests",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait before retry"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/RateLimitError"
            },
            "example": {
              "message": "rate_limit_reached",
              "retry_after_seconds": 1
            }
          }
        }
      }
    }
  }
}
