{
  "openapi": "3.1.0",
  "info": {
    "title": "Pharmagistic Partner API",
    "version": "2026-09-06",
    "description": "Inventory truth, holds and OMS orders for connected storefronts and partners. Date-versioned: every response carries `X-Pharmagistic-Version: 2026-09-06`; pin it on requests. Beta until three partners are live (breaking changes with 30-day notice); GA = 12-month version support."
  },
  "servers": [
    {
      "url": "https://api.pharmagistic.com",
      "description": "production"
    }
  ],
  "tags": [
    {
      "name": "ATP"
    },
    {
      "name": "Orders"
    },
    {
      "name": "Reserve"
    },
    {
      "name": "Inbound"
    }
  ],
  "components": {
    "securitySchemes": {
      "partnerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer <key>:<secret>` — minted in /admin/api-keys."
      }
    },
    "schemas": {},
    "parameters": {}
  },
  "paths": {
    "/api/v1/check": {
      "post": {
        "operationId": "atpCheck",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Available-to-promise for one or more SKUs (no hold)",
        "description": "Scope `atp.check`. Counts exactly the pools a reserve with the same item would draw from; in-date units only; kits in whole kits.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string",
                          "minLength": 1
                        },
                        "qty": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 10000
                        },
                        "brand_code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "sku",
                        "qty"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-item availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": "string"
                              },
                              "brand_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested_qty": {
                                "type": "integer"
                              },
                              "available_qty": {
                                "type": "integer",
                                "description": "In kits for a multi-formula SKU"
                              },
                              "atp_qty": {
                                "type": "integer"
                              },
                              "promised_qty": {
                                "type": "integer"
                              },
                              "backorder_qty": {
                                "type": "integer"
                              },
                              "tracks_inventory": {
                                "type": "boolean"
                              },
                              "known": {
                                "type": "boolean"
                              },
                              "components": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "formula_id": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "per_kit": {
                                      "type": "integer"
                                    },
                                    "available_units": {
                                      "type": "integer"
                                    },
                                    "atp_units": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "formula_id",
                                    "per_kit",
                                    "available_units",
                                    "atp_units"
                                  ]
                                }
                              },
                              "presale": {
                                "type": [
                                  "object",
                                  "null"
                                ],
                                "properties": {
                                  "available": {
                                    "type": "integer",
                                    "description": "Pre-sale units still open beyond real stock. Never included in atp_qty."
                                  },
                                  "claimed": {
                                    "type": "integer",
                                    "description": "Units already claimed by waiting orders; they have first right to arriving stock."
                                  },
                                  "ship_by": {
                                    "type": "string",
                                    "description": "YYYY-MM-DD"
                                  }
                                },
                                "required": [
                                  "available",
                                  "claimed",
                                  "ship_by"
                                ],
                                "description": "Only while pre-sale is open for this single-product SKU"
                              }
                            },
                            "required": [
                              "sku",
                              "brand_code",
                              "requested_qty",
                              "available_qty",
                              "atp_qty",
                              "promised_qty",
                              "backorder_qty",
                              "tracks_inventory",
                              "known"
                            ]
                          }
                        }
                      },
                      "required": [
                        "items"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reserve": {
      "post": {
        "operationId": "atpReserve",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Hold inventory (brand pool first, then shared per access)",
        "description": "Scope `atp.reserve`. Idempotent by `external_ref` (one active hold per key + reference). Kits are held whole or not at all. 422 `invalid_item` covers an unknown or untracked SKU, an unknown brand code, and an archived/draft formula; 409 `retry` means another hold took the same units at the same moment; 409 `hold_ceiling` means this key already holds the most shared-pool stock it may at once (release or confirm some holds first). A brand key's hold lasts at most 120 minutes whatever `ttl_minutes` asks; only the platform key may hold longer.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string",
                          "minLength": 1
                        },
                        "qty": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 10000
                        },
                        "brand_code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "sku",
                        "qty"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 100
                  },
                  "ttl_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 525600
                  },
                  "external_ref": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The hold",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "reservation_token": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "expires_at": {
                          "type": "string"
                        },
                        "idempotent": {
                          "type": "boolean"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": "string"
                              },
                              "brand_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "reserved_qty": {
                                "type": "integer",
                                "description": "In kits: a kit is held whole or not at all"
                              },
                              "from_brand_pool": {
                                "type": "integer"
                              },
                              "from_shared_pool": {
                                "type": "integer"
                              },
                              "fg_ids": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "format": "uuid"
                                }
                              },
                              "components": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "formula_id": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "per_kit": {
                                      "type": "integer"
                                    },
                                    "requested_units": {
                                      "type": [
                                        "integer",
                                        "null"
                                      ],
                                      "description": "null on an idempotent replay"
                                    },
                                    "reserved_units": {
                                      "type": "integer"
                                    },
                                    "from_brand_pool": {
                                      "type": "integer"
                                    },
                                    "from_shared_pool": {
                                      "type": "integer"
                                    },
                                    "fg_ids": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "format": "uuid"
                                      }
                                    }
                                  },
                                  "required": [
                                    "formula_id",
                                    "per_kit",
                                    "requested_units",
                                    "reserved_units",
                                    "from_brand_pool",
                                    "from_shared_pool",
                                    "fg_ids"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "sku",
                              "brand_code",
                              "reserved_qty",
                              "from_brand_pool",
                              "from_shared_pool",
                              "fg_ids",
                              "components"
                            ]
                          }
                        }
                      },
                      "required": [
                        "reservation_token",
                        "expires_at",
                        "idempotent",
                        "items"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {retry, no_inventory, hold_ceiling}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "error.code ∈ {invalid_item}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/presale": {
      "post": {
        "operationId": "atpPresale",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Claim, check and settle pre-sale units (console)",
        "description": "Scope `atp.reserve`, PLATFORM keys only (a brand key is 403). Pre-sale lets a sold-out size be sold now and shipped when the batch is received; it never holds a unit and never changes `atp`. `commit` claims units beyond real stock (idempotent by `external_ref`; 409 `presale_off` when the size is not open, `presale_cap` over the cap, `not_presale` for a kit or multi-part SKU, `presale_conflict` for a repeat with a different quantity). `status` answers waiting | ready | released per order: ready means real stock now covers it, oldest claim first, and the console then reserves for real. `pay` marks the console order paid: only paid claims take part in the release walk (unpaid ones hold cap, take no stock, and lapse after 72 hours). `status`/`settle`/`pay` only see claims made by the same key lineage. `settle` records that the claim became a real reservation (`released`) or was abandoned (`cancelled`, giving the cap back).",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "commit"
                        ]
                      },
                      "external_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "sku": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            "qty": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 100000
                            }
                          },
                          "required": [
                            "sku",
                            "qty"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 100
                      }
                    },
                    "required": [
                      "action",
                      "external_ref",
                      "items"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "status"
                        ]
                      },
                      "external_refs": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "minItems": 1,
                        "maxItems": 200
                      }
                    },
                    "required": [
                      "action",
                      "external_refs"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "pay"
                        ]
                      },
                      "external_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": [
                      "action",
                      "external_ref"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "settle"
                        ]
                      },
                      "external_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "outcome": {
                        "type": "string",
                        "enum": [
                          "released",
                          "cancelled"
                        ]
                      }
                    },
                    "required": [
                      "action",
                      "external_ref",
                      "outcome"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "status / settle",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "external_ref": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "formula_id": {
                                "type": "string"
                              },
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string"
                              },
                              "idempotent": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "formula_id",
                              "sku",
                              "status",
                              "idempotent"
                            ]
                          }
                        },
                        "orders": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "external_ref": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "waiting",
                                  "ready",
                                  "released"
                                ]
                              },
                              "ship_by": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "paid": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "external_ref",
                              "status",
                              "ship_by",
                              "paid"
                            ]
                          }
                        },
                        "outcome": {
                          "type": "string"
                        },
                        "settled": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "commit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "external_ref": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "formula_id": {
                                "type": "string"
                              },
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string"
                              },
                              "idempotent": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "formula_id",
                              "sku",
                              "status",
                              "idempotent"
                            ]
                          }
                        },
                        "orders": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "external_ref": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "waiting",
                                  "ready",
                                  "released"
                                ]
                              },
                              "ship_by": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "paid": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "external_ref",
                              "status",
                              "ship_by",
                              "paid"
                            ]
                          }
                        },
                        "outcome": {
                          "type": "string"
                        },
                        "settled": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request, presale_invalid}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {presale_cap, presale_off, presale_conflict, not_presale}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/release": {
      "post": {
        "operationId": "atpRelease",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Release a hold",
        "description": "Scope `atp.release`. Another key's token is a 404, never a 403.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reservation_token": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "reservation_token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Released (idempotent)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "ok"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "error.code ∈ {gone}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/consume": {
      "post": {
        "operationId": "atpConsume",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Consume a hold WITHOUT creating an OMS order",
        "description": "Scope `atp.consume` (not granted by default). For a caller that ships the order itself; the units leave the pool under the caller's reference. A hold that became an OMS order is refused.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reservation_token": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "external_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "reservation_token",
                  "external_ref"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Consumed (idempotent by external_ref)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "consumed_units": {
                          "type": "integer"
                        },
                        "external_ref": {
                          "type": "string"
                        },
                        "idempotent": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "consumed_units",
                        "external_ref",
                        "idempotent"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "error.code ∈ {wrong_state}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/consume/lots": {
      "get": {
        "operationId": "atpConsumeLots",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "The lots an order consumed under a reference shipped from",
        "description": "Scope `atp.consume`. `external_ref` is the order id the units were consumed under (the console order id). Answers the package(s) that order shipped in and, per item, its lots: `label_bound` (scanned at the label station) or, when the package has no binding, `pick_planned` (the lot the pick slip named, not scanned). `expires_on` / `expiry_kind` are the lot's one recorded date (EXP or BUD), null when undated or mixed: expiry is optional. A brand key sees its own brand only. Read-only; a failed read is 503, never a partial answer.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "external_ref",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Lots (empty `packages` when the OMS has no package for the reference yet)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "external_ref": {
                          "type": "string"
                        },
                        "packages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "remote_shipment_id": {
                                "type": "string"
                              },
                              "order_number": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string"
                              },
                              "items": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "position": {
                                      "type": "integer"
                                    },
                                    "sku": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "name": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "lot_tracked_vials": {
                                      "type": "integer"
                                    },
                                    "lots": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "lot": {
                                            "type": "string"
                                          },
                                          "quantity": {
                                            "type": "integer"
                                          },
                                          "expires_on": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "expiry_kind": {
                                            "type": [
                                              "string",
                                              "null"
                                            ],
                                            "enum": [
                                              "EXP",
                                              "BUD",
                                              null
                                            ]
                                          },
                                          "lot_source": {
                                            "type": "string",
                                            "enum": [
                                              "label_bound",
                                              "pick_planned"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "lot",
                                          "quantity",
                                          "expires_on",
                                          "expiry_kind",
                                          "lot_source"
                                        ]
                                      }
                                    },
                                    "lots_complete": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": [
                                    "position",
                                    "sku",
                                    "name",
                                    "lot_tracked_vials",
                                    "lots",
                                    "lots_complete"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "remote_shipment_id",
                              "order_number",
                              "status",
                              "items"
                            ]
                          }
                        },
                        "as_of": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "external_ref",
                        "packages",
                        "as_of"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/consume/reverse": {
      "post": {
        "operationId": "atpReverseConsume",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Give back the units a consume took, when the sale is reversed",
        "description": "Scope `atp.consume` — the inverse of the authority that took them. Keyed by the `external_ref` the consume was made under, because a consume creates no order here to cancel. For a caller that ships the order itself and has refunded or cancelled it. A reservation that was PLACED as an OMS order is refused with 409: cancel that order instead. Only units still allocated under that reference move — anything shipped, quarantined or destroyed has moved on. THE CALLER OWNS THE \"has it shipped?\" QUESTION: on this configuration the caller buys the label and the OMS never hears about it, so this endpoint cannot check it.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "external_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "external_ref"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returned (idempotent)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "returned_units": {
                          "type": "integer"
                        },
                        "idempotent": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "returned_units",
                        "idempotent"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {not_reversible, not_consumed}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/consume/correct": {
      "post": {
        "operationId": "atpCorrectConsume",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Correct which product a consume took, even after it shipped",
        "description": "Scope `atp.correct` (granted to no key by default; it can move shipped stock). Keyed by the `external_ref` the consume was made under. A correction is a swap: shipped units may only be removed if at least as many units are added. `remove` returns that many consumed units of a sku (shipped or allocated) to the pool, keeping their lot; `add` consumes that many available units of another sku, picked the way /reserve picks (first-expiry-first-out, the key's brand pool then the shared pool). `sku` is the OMS sku; `line_sku` names the line on a mirrored order when it reads differently. `qty` is in kits. Unsellable returned units (expired, archived, unreleased lot) are quarantined, and the reply counts them. Adds draw from the pool the removed units came from (shared or a brand); removed units spanning pools are refused as `mixed_pools`. An add item may carry `lot` (pick only that batch_number; single-component products only, else `invalid_item`) and `unit_price` (dollars) to set the mirror line's price and total; omitted leaves it as is (NULL on a new line). Refused with nothing moved if the consumed units or the stock are not there. Idempotent on `idempotency_key`: a replay returns the first result; the same key with a different body is a 409.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "external_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "remove": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "qty": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 100000
                        },
                        "line_sku": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        }
                      },
                      "required": [
                        "sku",
                        "qty"
                      ]
                    },
                    "maxItems": 50,
                    "default": []
                  },
                  "add": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "qty": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 100000
                        },
                        "line_sku": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "unit_price": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000
                        },
                        "lot": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        }
                      },
                      "required": [
                        "sku",
                        "qty"
                      ]
                    },
                    "maxItems": 50,
                    "default": []
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "external_ref",
                  "idempotency_key"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Corrected (idempotent by idempotency_key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "returned": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": "string"
                              },
                              "qty": {
                                "type": "integer"
                              },
                              "lots": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "lot": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "qty": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "lot",
                                    "qty"
                                  ]
                                }
                              },
                              "units_to_available": {
                                "type": "integer"
                              },
                              "units_quarantined": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "qty",
                              "lots"
                            ]
                          }
                        },
                        "added": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": "string"
                              },
                              "qty": {
                                "type": "integer"
                              },
                              "lots": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "lot": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "qty": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "lot",
                                    "qty"
                                  ]
                                }
                              },
                              "lot_assumed": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "sku",
                              "qty",
                              "lots"
                            ]
                          }
                        },
                        "idempotent": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "returned",
                        "added",
                        "idempotent"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {not_consumed, not_enough_consumed, insufficient_stock, idempotency_conflict, shipped_requires_swap, line_mismatch, mixed_pools}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "error.code ∈ {invalid_item, blocked_product}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inventory": {
      "get": {
        "operationId": "atpInventory",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "ATP for one SKU by brand plus totals",
        "description": "Scope `atp.inventory`. `tracks_inventory: false` for a known non-physical SKU (discount, fee); 404 for an unknown one.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "sku",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "brand_code",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Positions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string"
                        },
                        "tracks_inventory": {
                          "type": "boolean"
                        },
                        "components": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "formula_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "per_kit": {
                                "type": "integer"
                              },
                              "on_hand_units": {
                                "type": "integer"
                              },
                              "reserved_units": {
                                "type": "integer"
                              },
                              "atp_units": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "formula_id",
                              "per_kit",
                              "on_hand_units",
                              "reserved_units",
                              "atp_units"
                            ]
                          }
                        },
                        "by_brand": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "brand_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "on_hand": {
                                "type": "integer"
                              },
                              "reserved": {
                                "type": "integer"
                              },
                              "atp": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "brand_code",
                              "on_hand",
                              "reserved",
                              "atp"
                            ]
                          }
                        },
                        "totals": {
                          "type": "object",
                          "properties": {
                            "on_hand": {
                              "type": "integer"
                            },
                            "reserved": {
                              "type": "integer"
                            },
                            "atp": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "on_hand",
                            "reserved",
                            "atp"
                          ]
                        }
                      },
                      "required": [
                        "sku",
                        "tracks_inventory",
                        "by_brand",
                        "totals"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/products": {
      "get": {
        "operationId": "catalogProducts",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Every sellable SKU, with availability for this key",
        "description": "Scope `atp.inventory`. The catalog LISTING: every other endpoint answers about a SKU you already name, so nothing could tell you a product had been ADDED. Untracked SKUs (`tracks_inventory: false`) and physical SKUs with no bill of materials (`sellable: false`) are returned flagged, never omitted — a product list must be able to show that a SKU exists and cannot be reserved. `atp` is in kits, across the pools this key can see.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "products": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "tracks_inventory": {
                                "type": "boolean"
                              },
                              "sellable": {
                                "type": "boolean"
                              },
                              "ever_produced": {
                                "type": "boolean"
                              },
                              "atp": {
                                "type": "integer"
                              },
                              "presale_available": {
                                "type": "integer",
                                "description": "Pre-sale units open beyond real stock (separate from atp). Present only while pre-sale is open for this SKU."
                              },
                              "presale_claimed": {
                                "type": "integer"
                              },
                              "presale_ship_by": {
                                "type": "string",
                                "description": "YYYY-MM-DD"
                              }
                            },
                            "required": [
                              "sku",
                              "name",
                              "tracks_inventory",
                              "sellable",
                              "ever_produced",
                              "atp"
                            ]
                          }
                        },
                        "count": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "products",
                        "count"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders": {
      "post": {
        "operationId": "placeOrder",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Place the pickable OMS order, from a hold or directly from items (one transaction)",
        "description": "Scope `orders.write`. Two body shapes: `reservation_token` (two-phase, from a prior reserve) or `items` (reserve and place in one transaction). `Idempotency-Key` is required: one key = one order; a replay returns the original with `idempotent: true` and 200. The same key with a different hold is 422 idempotency_mismatch, and so is the same key with a different `external_order_ref`. `shipping_address` is free-form but must serialise under 4 KB. `external_order_ref` is your own order number: stored, returned on every read and in the order webhooks, unique per brand among orders that are not cancelled (a repeat is 409 duplicate_external_ref; a replay of the same Idempotency-Key is not a repeat). SHORT ORDERS (`items` shape): the order keeps the quantity you asked for. By default the WHOLE order waits: status `on_hold`, `waiting_for_stock: true`, each line shows `quantity` (asked), `units` (held so far) and `backordered` (kits not covered yet). It releases by itself when stock arrives, oldest order first, and the existing `order.held` webhook fires when it starts waiting and `order.released` when it is complete (subscribe an endpoint to both). A brand set to refuse short orders gets 409 insufficient_stock with `short_lines`, and nothing is reserved. A brand set to ship what is in stock now and send the rest later gets the covered kits as this order (status `ready_to_ship`, lines are what ships now) and the rest as a separate follow-up order (`follow_up_order_id`, same `external_order_ref`, `order.held` webhook with `parent_order_id`) that releases by itself when stock arrives; GET the order to see its follow-up orders with their status and tracking. A short order that names no brand (platform key without `brand_code`) is 422 brand_required: it cannot wait. `reservation_empty` no longer occurs on the `items` shape: an order with no stock at all waits, or is refused.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": true,
            "name": "Idempotency-Key",
            "in": "header"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "reservation_token": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "external_order_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "customer": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "consumer"
                                ]
                              },
                              "email": {
                                "type": "string",
                                "maxLength": 254,
                                "format": "email"
                              },
                              "full_name": {
                                "type": "string",
                                "maxLength": 200
                              },
                              "phone": {
                                "type": "string",
                                "maxLength": 40
                              }
                            },
                            "required": [
                              "type",
                              "email"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "account"
                                ]
                              },
                              "account_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "consumer_id": {
                                "type": "string",
                                "format": "uuid"
                              }
                            },
                            "required": [
                              "type",
                              "account_id"
                            ]
                          }
                        ]
                      },
                      "shipping_address": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "notes": {
                        "type": "string",
                        "maxLength": 2000
                      },
                      "brand_code": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "label": {
                        "type": "object",
                        "properties": {
                          "format": {
                            "type": "string",
                            "enum": [
                              "pdf"
                            ]
                          },
                          "content_base64": {
                            "type": "string",
                            "minLength": 8,
                            "maxLength": 2796211
                          },
                          "tracking_number": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9-]{6,40}$"
                          },
                          "carrier": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,39}$"
                          },
                          "service": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,59}$"
                          }
                        },
                        "required": [
                          "format",
                          "content_base64",
                          "tracking_number",
                          "carrier"
                        ]
                      }
                    },
                    "required": [
                      "reservation_token",
                      "customer"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "sku": {
                              "type": "string",
                              "minLength": 1
                            },
                            "qty": {
                              "type": "integer",
                              "exclusiveMinimum": 0,
                              "maximum": 10000
                            },
                            "brand_code": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "sku",
                            "qty"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 100
                      },
                      "external_order_ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "customer": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "consumer"
                                ]
                              },
                              "email": {
                                "type": "string",
                                "maxLength": 254,
                                "format": "email"
                              },
                              "full_name": {
                                "type": "string",
                                "maxLength": 200
                              },
                              "phone": {
                                "type": "string",
                                "maxLength": 40
                              }
                            },
                            "required": [
                              "type",
                              "email"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "account"
                                ]
                              },
                              "account_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "consumer_id": {
                                "type": "string",
                                "format": "uuid"
                              }
                            },
                            "required": [
                              "type",
                              "account_id"
                            ]
                          }
                        ]
                      },
                      "shipping_address": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "notes": {
                        "type": "string",
                        "maxLength": 2000
                      },
                      "brand_code": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "ttl_minutes": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 120
                      },
                      "label": {
                        "type": "object",
                        "properties": {
                          "format": {
                            "type": "string",
                            "enum": [
                              "pdf"
                            ]
                          },
                          "content_base64": {
                            "type": "string",
                            "minLength": 8,
                            "maxLength": 2796211
                          },
                          "tracking_number": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9-]{6,40}$"
                          },
                          "carrier": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,39}$"
                          },
                          "service": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,59}$"
                          }
                        },
                        "required": [
                          "format",
                          "content_base64",
                          "tracking_number",
                          "carrier"
                        ]
                      }
                    },
                    "required": [
                      "items",
                      "customer"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of an earlier placement",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "order_total": {
                          "type": "number"
                        },
                        "idempotent": {
                          "type": "boolean"
                        },
                        "waiting_for_stock": {
                          "type": "boolean",
                          "description": "True while the order is held because stock does not cover it yet. It releases by itself, oldest order first, when stock arrives"
                        },
                        "external_order_ref": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "The merchant's own order number, as sent"
                        },
                        "follow_up_order_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Present when the brand ships what is in stock now and sends the rest later: this order is complete (lines are what ships now) and the uncovered rest waits as this separate order, with the same external_order_ref"
                        },
                        "lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "quantity": {
                                "type": "integer",
                                "description": "Kits asked for"
                              },
                              "units": {
                                "type": "integer",
                                "description": "Units held for this line so far"
                              },
                              "backordered": {
                                "type": "integer",
                                "description": "Kits asked for that stock does not cover yet. 0 once the line is complete"
                              },
                              "unit_price": {
                                "type": "number"
                              },
                              "line_total": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "sku",
                              "quantity",
                              "units",
                              "backordered",
                              "unit_price",
                              "line_total"
                            ]
                          }
                        },
                        "label": {
                          "type": "object",
                          "properties": {
                            "attached": {
                              "type": "boolean"
                            },
                            "tracking_number": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string",
                              "description": "Why the label was not attached. The order itself was placed; send the label again with PUT /orders/{ref}/label"
                            }
                          },
                          "required": [
                            "attached"
                          ],
                          "description": "Present only when the request carried a `label`"
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "order_total",
                        "idempotent",
                        "waiting_for_stock",
                        "external_order_ref",
                        "lines"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Placed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "order_total": {
                          "type": "number"
                        },
                        "idempotent": {
                          "type": "boolean"
                        },
                        "waiting_for_stock": {
                          "type": "boolean",
                          "description": "True while the order is held because stock does not cover it yet. It releases by itself, oldest order first, when stock arrives"
                        },
                        "external_order_ref": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "The merchant's own order number, as sent"
                        },
                        "follow_up_order_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Present when the brand ships what is in stock now and sends the rest later: this order is complete (lines are what ships now) and the uncovered rest waits as this separate order, with the same external_order_ref"
                        },
                        "lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "quantity": {
                                "type": "integer",
                                "description": "Kits asked for"
                              },
                              "units": {
                                "type": "integer",
                                "description": "Units held for this line so far"
                              },
                              "backordered": {
                                "type": "integer",
                                "description": "Kits asked for that stock does not cover yet. 0 once the line is complete"
                              },
                              "unit_price": {
                                "type": "number"
                              },
                              "line_total": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "sku",
                              "quantity",
                              "units",
                              "backordered",
                              "unit_price",
                              "line_total"
                            ]
                          }
                        },
                        "label": {
                          "type": "object",
                          "properties": {
                            "attached": {
                              "type": "boolean"
                            },
                            "tracking_number": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string",
                              "description": "Why the label was not attached. The order itself was placed; send the label again with PUT /orders/{ref}/label"
                            }
                          },
                          "required": [
                            "attached"
                          ],
                          "description": "Present only when the request carried a `label`"
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "order_total",
                        "idempotent",
                        "waiting_for_stock",
                        "external_order_ref",
                        "lines"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request, invalid_label, idempotency_required}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, reservation_forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {reservation_not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {reservation_used, unresolved_stack, kit_incomplete, hold_race, duplicate_external_ref, insufficient_stock}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "error.code ∈ {reservation_gone, reservation_expired, reservation_empty}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "error.code ∈ {blocked_product, invalid_customer, idempotency_mismatch, unknown_brand_code, brand_required}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{ref}": {
      "get": {
        "operationId": "getOrder",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "An order this key placed, by order id, Idempotency-Key or external_order_ref",
        "description": "Scope `orders.read`. A platform key spanning brands may add `?brand_code=` when looking up by `external_order_ref`; a number that still matches more than one order is 409 ambiguous_external_ref. `waiting_for_stock` is true while a short order is held; lines carry `backordered`. `follow_up_orders` lists the orders split off this one (partial shipments) with their own status, tracking and lines; `parent_order_id` is set on such a follow-up. Another key's order is a 404.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": true,
            "name": "ref",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 40,
              "description": "Only for a platform key looking up by external_order_ref: narrows to one brand"
            },
            "required": false,
            "description": "Only for a platform key looking up by external_order_ref: narrows to one brand",
            "name": "brand_code",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "The order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "order_total": {
                          "type": "number"
                        },
                        "order_date": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "idempotency_key": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "external_order_ref": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "The merchant's own order number, as sent on placement"
                        },
                        "waiting_for_stock": {
                          "type": "boolean",
                          "description": "True while the order is held because stock does not cover it yet"
                        },
                        "parent_order_id": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid",
                          "description": "Set on a follow-up order: the order it was split from"
                        },
                        "follow_up_orders": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "order_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "status": {
                                "type": "string"
                              },
                              "order_total": {
                                "type": "number"
                              },
                              "waiting_for_stock": {
                                "type": "boolean"
                              },
                              "tracking": {
                                "type": [
                                  "object",
                                  "null"
                                ],
                                "properties": {
                                  "number": {
                                    "type": "string"
                                  },
                                  "carrier": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "shipped_at": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "number",
                                  "carrier",
                                  "shipped_at"
                                ]
                              },
                              "lines": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "sku": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "quantity": {
                                      "type": "integer"
                                    },
                                    "backordered": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "sku",
                                    "quantity",
                                    "backordered"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "order_id",
                              "status",
                              "order_total",
                              "waiting_for_stock",
                              "tracking",
                              "lines"
                            ]
                          },
                          "description": "Orders split off this one when the brand ships what is in stock now and sends the rest later; each has its own status and tracking. Empty when the order was not split"
                        },
                        "tracking": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "number": {
                              "type": "string"
                            },
                            "carrier": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "shipped_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "number",
                            "carrier",
                            "shipped_at"
                          ]
                        },
                        "lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "quantity": {
                                "type": "integer",
                                "description": "Kits asked for"
                              },
                              "units": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer",
                                "description": "Kits not covered by stock yet"
                              },
                              "unit_price": {
                                "type": "number"
                              },
                              "line_total": {
                                "type": "number"
                              },
                              "fulfilled": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "sku",
                              "name",
                              "quantity",
                              "units",
                              "backordered",
                              "unit_price",
                              "line_total",
                              "fulfilled"
                            ]
                          }
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "order_total",
                        "order_date",
                        "idempotency_key",
                        "external_order_ref",
                        "waiting_for_stock",
                        "parent_order_id",
                        "follow_up_orders",
                        "tracking",
                        "lines"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {ambiguous_external_ref}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{ref}/cancel": {
      "post": {
        "operationId": "cancelOrder",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Cancel an order this key placed, before it is picked",
        "description": "Scope `orders.write`. Pre-pick only: the allocated units go back to the sellable pool and the order becomes `cancelled`. Once the order is picked, packed or shipped the call is 409 order_not_cancellable and the goods come back through a return authorization instead. Cancelling an already-cancelled order is 200 with `idempotent: true` and releases nothing. Another key's order is a 404.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": true,
            "name": "ref",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "cancelled"
                          ]
                        },
                        "released_units": {
                          "type": "integer"
                        },
                        "idempotent": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "released_units",
                        "idempotent"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, order_forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found, order_not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {order_not_cancellable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{ref}/label": {
      "put": {
        "operationId": "setOrderLabel",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Attach or replace the shipping label you bought yourself, on an order that has not shipped",
        "description": "Scope `orders.write`. For merchants whose stock sits in the warehouse and who buy their own postage: the warehouse prints this PDF and packs, and the order ships with this tracking number. Base64 PDF only (2 MB decoded at most, must start with %PDF-); the OMS never fetches a label from a URL. `POST /orders` accepts the same object as `label`. 409 on a shipped, delivered or cancelled order (order_not_open), on a follow-up order from a partial shipment (label_not_allowed: the warehouse buys that label), and once the warehouse has acted on the order (label_locked: a shipment exists, or staff already printed the label). A tracking number already used by another shipment or order is 409 tracking_in_use. Replacing before then is allowed. Another key's order is a 404.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": true,
            "name": "ref",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "format": {
                    "type": "string",
                    "enum": [
                      "pdf"
                    ]
                  },
                  "content_base64": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 2796211
                  },
                  "tracking_number": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9-]{6,40}$"
                  },
                  "carrier": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,39}$"
                  },
                  "service": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]{0,59}$"
                  }
                },
                "required": [
                  "format",
                  "content_base64",
                  "tracking_number",
                  "carrier"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Label stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "tracking_number": {
                          "type": "string"
                        },
                        "replaced": {
                          "type": "boolean",
                          "description": "True when this replaced a label sent earlier"
                        }
                      },
                      "required": [
                        "order_id",
                        "tracking_number",
                        "replaced"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request, invalid_label}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {label_not_allowed, label_locked, tracking_in_use, order_not_open, order_has_no_brand}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error, storage_failed}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shipments/combine": {
      "post": {
        "operationId": "combineShipments",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Ship several of this key's orders in one box (combined shipments)",
        "description": "Scope `orders.write`. Folds the secondary orders into the primary's box: marks each secondary combined and cancels its redundant ShipStation queue order, so only the primary's one label ships the package. Buys no label. `Idempotency-Key` (the console shipment_groups id) is REQUIRED; a replay whose secondaries are already folded into this primary is 200 with `idempotent: true`. Another key's order is a 404; a cross-brand order is 400/403. A ShipStation failure on any secondary is 502 shipstation_error — safe to retry. Top-level `combined: true` means the request was processed; `secondaries[].combined` is true only when that secondary's ShipStation order is confirmed out of the queue (`cancelled` / `already_cancelled`). `sim_skipped` (shipping simulation: ShipStation was not contacted, the order is still live there) and `not_found` (no mirrored ShipStation order for that order number) are reported `combined: false` and the secondary is not folded, because it can still ship on its own.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "group_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "primary_order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "secondary_order_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "group_ref",
                  "primary_order_id",
                  "secondary_order_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Combined (or an idempotent replay)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "combined": {
                          "type": "boolean",
                          "enum": [
                            true
                          ],
                          "description": "The request was processed. Whether each secondary is in the box is `secondaries[].combined`"
                        },
                        "group_ref": {
                          "type": "string"
                        },
                        "primary_order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "secondaries": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "order_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "combined": {
                                "type": "boolean",
                                "description": "True only when this secondary's ShipStation order is confirmed out of the queue (cancelled / already_cancelled) and it was folded into the box. False for sim_skipped, not_found, already_labeled and error: the secondary can still ship on its own"
                              },
                              "shipstation": {
                                "type": "string",
                                "enum": [
                                  "cancelled",
                                  "sim_skipped",
                                  "already_cancelled",
                                  "already_labeled",
                                  "not_found",
                                  "error"
                                ],
                                "description": "sim_skipped: shipping simulation is on for the brand, ShipStation was not contacted and the order is still live there. not_found: no mirrored ShipStation order carries this order number (not synced yet, or in an account the OMS does not mirror); nothing was cancelled"
                              }
                            },
                            "required": [
                              "order_id",
                              "combined",
                              "shipstation"
                            ]
                          }
                        },
                        "idempotent": {
                          "type": "boolean",
                          "description": "True only for a replay that found every secondary already folded into this primary and cancelled nothing new"
                        }
                      },
                      "required": [
                        "combined",
                        "group_ref",
                        "primary_order_id",
                        "secondaries",
                        "idempotent"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "502": {
            "description": "error.code ∈ {shipstation_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inbound": {
      "post": {
        "operationId": "createInboundNotice",
        "tags": [
          "Inbound"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Announce your own finished stock on its way to the warehouse",
        "description": "Scope `inbound.write`, BRAND keys only (the notice belongs to the key's brand; sandbox keys are refused). `Idempotency-Key` is required: one key = one notice; a replay returns the original with `idempotent: true` and 200, the same key with a different body is 422 idempotency_mismatch. `reference` is your own shipment number, unique among your notices that are not cancelled (409 duplicate_reference). Each line names one of OUR catalog SKUs (see `GET /api/v1/products`), your lot exactly as printed (any format up to 64 characters, at least 3 letters or digits once punctuation is ignored; two merchants may use the same lot number, and one lot may cover several of your products), an optional future `expiry_date`, and the vial count. A SKU we do not have is 422 unknown_sku (an exact-case match on an active product wins; a SKU that still matches more than one product is 422 ambiguous_sku); a SKU that is not a plain single-vial product (a multi-product kit, a multi-vial kit, or one with no product mapped yet) is 422 stack_not_receivable. Nothing in the catalog is ever created by this call. The warehouse receives the stock line by line: good vials land in YOUR pool as available (waiting orders release), damaged vials are held aside, and shortages or overages are recorded, never refused. Read progress with `GET /api/v1/inbound/{id}`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": true,
            "name": "Idempotency-Key",
            "in": "header"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "description": "Your own reference for this shipment (PO or ASN number), unique among your open notices"
                  },
                  "expected_date": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "When you expect it to arrive, YYYY-MM-DD"
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "sku": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "description": "Our catalog SKU, as listed by GET /api/v1/products"
                        },
                        "lot_number": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "description": "The lot printed on your vials, exactly as you want it recorded. Any format up to 64 characters; at least 3 letters or digits"
                        },
                        "expiry_date": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                          "description": "YYYY-MM-DD, must be in the future. Omit for an undated lot"
                        },
                        "expected_qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 100000,
                          "description": "How many finished vials of this SKU and lot you are sending"
                        }
                      },
                      "required": [
                        "sku",
                        "lot_number",
                        "expected_qty"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "reference",
                  "lines"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of an earlier create",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "idempotent": {
                          "type": "boolean"
                        },
                        "notice": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "reference": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "open",
                                "receiving",
                                "received",
                                "cancelled"
                              ]
                            },
                            "expected_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "notes": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string"
                            },
                            "received_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "expected_qty": {
                                  "type": "integer",
                                  "description": "VIALS: sum of expected_qty x units_per_kit"
                                },
                                "received_qty": {
                                  "type": "integer",
                                  "description": "VIALS put on the shelf as yours"
                                },
                                "damaged_qty": {
                                  "type": "integer",
                                  "description": "VIALS held aside as damaged (whole damaged kits plus broken vials)"
                                }
                              },
                              "required": [
                                "expected_qty",
                                "received_qty",
                                "damaged_qty"
                              ]
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "line_no": {
                                    "type": "integer"
                                  },
                                  "sku": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "lot_number": {
                                    "type": "string",
                                    "description": "As you gave it"
                                  },
                                  "expiry_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "expected_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit: vials, or kits when units_per_kit is greater than 1"
                                  },
                                  "received_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit (vials, or kits when units_per_kit > 1): good stock put on the shelf as yours"
                                  },
                                  "damaged_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit: arrived damaged; held aside, never sold"
                                  },
                                  "units_per_kit": {
                                    "type": "integer",
                                    "description": "Vials in one unit of this line: 1 for a plain vial line, more for a kit line"
                                  },
                                  "damaged_vials": {
                                    "type": "integer",
                                    "description": "Kit lines: individual broken vials inside kits that still count as received; held aside. 0 otherwise"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "open",
                                      "received"
                                    ]
                                  },
                                  "discrepancy_note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ],
                                    "description": "Short / over / damaged, written when the warehouse receives"
                                  }
                                },
                                "required": [
                                  "line_no",
                                  "sku",
                                  "lot_number",
                                  "expiry_date",
                                  "expected_qty",
                                  "received_qty",
                                  "damaged_qty",
                                  "units_per_kit",
                                  "damaged_vials",
                                  "status",
                                  "discrepancy_note"
                                ]
                              }
                            }
                          },
                          "required": [
                            "id",
                            "reference",
                            "status",
                            "expected_date",
                            "notes",
                            "created_at",
                            "received_at",
                            "totals",
                            "lines"
                          ]
                        }
                      },
                      "required": [
                        "idempotent",
                        "notice"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "idempotent": {
                          "type": "boolean"
                        },
                        "notice": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "reference": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "open",
                                "receiving",
                                "received",
                                "cancelled"
                              ]
                            },
                            "expected_date": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "notes": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string"
                            },
                            "received_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "expected_qty": {
                                  "type": "integer",
                                  "description": "VIALS: sum of expected_qty x units_per_kit"
                                },
                                "received_qty": {
                                  "type": "integer",
                                  "description": "VIALS put on the shelf as yours"
                                },
                                "damaged_qty": {
                                  "type": "integer",
                                  "description": "VIALS held aside as damaged (whole damaged kits plus broken vials)"
                                }
                              },
                              "required": [
                                "expected_qty",
                                "received_qty",
                                "damaged_qty"
                              ]
                            },
                            "lines": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "line_no": {
                                    "type": "integer"
                                  },
                                  "sku": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "lot_number": {
                                    "type": "string",
                                    "description": "As you gave it"
                                  },
                                  "expiry_date": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "expected_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit: vials, or kits when units_per_kit is greater than 1"
                                  },
                                  "received_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit (vials, or kits when units_per_kit > 1): good stock put on the shelf as yours"
                                  },
                                  "damaged_qty": {
                                    "type": "integer",
                                    "description": "In the line's unit: arrived damaged; held aside, never sold"
                                  },
                                  "units_per_kit": {
                                    "type": "integer",
                                    "description": "Vials in one unit of this line: 1 for a plain vial line, more for a kit line"
                                  },
                                  "damaged_vials": {
                                    "type": "integer",
                                    "description": "Kit lines: individual broken vials inside kits that still count as received; held aside. 0 otherwise"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "open",
                                      "received"
                                    ]
                                  },
                                  "discrepancy_note": {
                                    "type": [
                                      "string",
                                      "null"
                                    ],
                                    "description": "Short / over / damaged, written when the warehouse receives"
                                  }
                                },
                                "required": [
                                  "line_no",
                                  "sku",
                                  "lot_number",
                                  "expiry_date",
                                  "expected_qty",
                                  "received_qty",
                                  "damaged_qty",
                                  "units_per_kit",
                                  "damaged_vials",
                                  "status",
                                  "discrepancy_note"
                                ]
                              }
                            }
                          },
                          "required": [
                            "id",
                            "reference",
                            "status",
                            "expected_date",
                            "notes",
                            "created_at",
                            "received_at",
                            "totals",
                            "lines"
                          ]
                        }
                      },
                      "required": [
                        "idempotent",
                        "notice"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request, idempotency_required}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {duplicate_reference}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "error.code ∈ {idempotency_mismatch, unknown_sku, ambiguous_sku, stack_not_receivable, blocked_product, invalid_lot, invalid_expiry, brand_required}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listInboundNotices",
        "tags": [
          "Inbound"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "This brand's inbound notices, newest first",
        "description": "Scope `inbound.read`, brand keys only. Up to 50 notices with per-notice totals (no lines; read one for those). `?status=open|receiving|received|cancelled` narrows.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "receiving",
                "received",
                "cancelled"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Notices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "reference": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "open",
                              "receiving",
                              "received",
                              "cancelled"
                            ]
                          },
                          "expected_date": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "notes": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "received_at": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "totals": {
                            "type": "object",
                            "properties": {
                              "expected_qty": {
                                "type": "integer",
                                "description": "VIALS: sum of expected_qty x units_per_kit"
                              },
                              "received_qty": {
                                "type": "integer",
                                "description": "VIALS put on the shelf as yours"
                              },
                              "damaged_qty": {
                                "type": "integer",
                                "description": "VIALS held aside as damaged (whole damaged kits plus broken vials)"
                              }
                            },
                            "required": [
                              "expected_qty",
                              "received_qty",
                              "damaged_qty"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "reference",
                          "status",
                          "expected_date",
                          "notes",
                          "created_at",
                          "received_at",
                          "totals"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inbound/{id}": {
      "get": {
        "operationId": "getInboundNotice",
        "tags": [
          "Inbound"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "One inbound notice with received and damaged counts per line",
        "description": "Scope `inbound.read`, brand keys only. `received_qty` is good vials put on your shelf, `damaged_qty` vials that arrived damaged; `discrepancy_note` says short / over / damaged once the warehouse has counted. Another brand's notice is a 404.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "The notice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "open",
                            "receiving",
                            "received",
                            "cancelled"
                          ]
                        },
                        "expected_date": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "notes": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "received_at": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "totals": {
                          "type": "object",
                          "properties": {
                            "expected_qty": {
                              "type": "integer",
                              "description": "VIALS: sum of expected_qty x units_per_kit"
                            },
                            "received_qty": {
                              "type": "integer",
                              "description": "VIALS put on the shelf as yours"
                            },
                            "damaged_qty": {
                              "type": "integer",
                              "description": "VIALS held aside as damaged (whole damaged kits plus broken vials)"
                            }
                          },
                          "required": [
                            "expected_qty",
                            "received_qty",
                            "damaged_qty"
                          ]
                        },
                        "lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "line_no": {
                                "type": "integer"
                              },
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "lot_number": {
                                "type": "string",
                                "description": "As you gave it"
                              },
                              "expiry_date": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "expected_qty": {
                                "type": "integer",
                                "description": "In the line's unit: vials, or kits when units_per_kit is greater than 1"
                              },
                              "received_qty": {
                                "type": "integer",
                                "description": "In the line's unit (vials, or kits when units_per_kit > 1): good stock put on the shelf as yours"
                              },
                              "damaged_qty": {
                                "type": "integer",
                                "description": "In the line's unit: arrived damaged; held aside, never sold"
                              },
                              "units_per_kit": {
                                "type": "integer",
                                "description": "Vials in one unit of this line: 1 for a plain vial line, more for a kit line"
                              },
                              "damaged_vials": {
                                "type": "integer",
                                "description": "Kit lines: individual broken vials inside kits that still count as received; held aside. 0 otherwise"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "open",
                                  "received"
                                ]
                              },
                              "discrepancy_note": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "Short / over / damaged, written when the warehouse receives"
                              }
                            },
                            "required": [
                              "line_no",
                              "sku",
                              "lot_number",
                              "expiry_date",
                              "expected_qty",
                              "received_qty",
                              "damaged_qty",
                              "units_per_kit",
                              "damaged_vials",
                              "status",
                              "discrepancy_note"
                            ]
                          }
                        }
                      },
                      "required": [
                        "id",
                        "reference",
                        "status",
                        "expected_date",
                        "notes",
                        "created_at",
                        "received_at",
                        "totals",
                        "lines"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/introspect": {
      "post": {
        "operationId": "introspectKey",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Is this token a live OMS key, and what may it do?",
        "description": "Scope `keys.introspect`, PLATFORM keys only (a brand key is 403). The body carries the token a partner presented elsewhere; the answer is `active: false` (200) for an unknown, revoked, expired-brand or mis-bound key, and the key's brand, scopes and sandbox flag when active. Never echoes hashes or rate limits. The console caches the answer for five minutes (decision 14A / 3A).",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 256
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verdict (active true or false)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "key": {
                          "type": "object",
                          "properties": {
                            "key_prefix": {
                              "type": "string"
                            },
                            "partner_name": {
                              "type": "string"
                            },
                            "brand_code": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "is_sandbox": {
                              "type": "boolean"
                            },
                            "shared_pool_access": {
                              "type": "string",
                              "enum": [
                                "reserve",
                                "read",
                                "none"
                              ]
                            }
                          },
                          "required": [
                            "key_prefix",
                            "partner_name",
                            "brand_code",
                            "scopes",
                            "is_sandbox",
                            "shared_pool_access"
                          ]
                        }
                      },
                      "required": [
                        "active"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coa": {
      "get": {
        "operationId": "listCoa",
        "tags": [
          "COA"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Certificates of Analysis — the current certificate for every product, with PDF links",
        "description": "Scope `atp.inventory` (a key that may read what we hold may read the public certificate for it). Proxied from the storefront platform so inventory and COAs share one host and one key; shapes are the platform's partner feed, unchanged. Match certificates to products by `product.slug`; the operator sends the slug ↔ SKU map with your key. `?product=` narrows (repeatable). `?updated_since=` is an incremental sync that INCLUDES archival and retirement events; a `retired` record is a tombstone with an empty `certificate_url` — take the certificate down. `?format=csv` returns text/csv with the next cursor in an `x-next-cursor` header. 503 `upstream_unavailable` means the certificate platform did not answer; keep showing the last certificate you fetched.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "current",
                "archived",
                "retired",
                "all"
              ],
              "default": "current",
              "description": "Retired lots are withdrawn tombstones with an empty certificate_url; they appear only under retired|all."
            },
            "required": false,
            "description": "Retired lots are withdrawn tombstones with an empty certificate_url; they appear only under retired|all.",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Incremental sync, INCLUDING archival and retirement events."
            },
            "required": false,
            "description": "Incremental sync, INCLUDING archival and retirement events.",
            "name": "updated_since",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "description": "Product slug(s); repeatable. Narrows, never widens."
            },
            "required": false,
            "description": "Product slug(s); repeatable. Narrows, never widens.",
            "name": "product",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ],
              "default": "json"
            },
            "required": false,
            "name": "format",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 2048,
              "description": "Opaque; from the previous page."
            },
            "required": false,
            "description": "Opaque; from the previous page.",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "One page of certificates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "slug": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "research_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "slug",
                              "name",
                              "research_code"
                            ]
                          },
                          "batch_number": {
                            "type": "string"
                          },
                          "vial_size": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tested_on": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lab_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "purity_pct": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "current",
                              "archived",
                              "retired"
                            ]
                          },
                          "certificate_url": {
                            "type": "string"
                          },
                          "independent_result_url": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "verify_url": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "product",
                          "batch_number",
                          "vial_size",
                          "tested_on",
                          "lab_name",
                          "purity_pct",
                          "status",
                          "certificate_url",
                          "independent_result_url",
                          "verify_url",
                          "updated_at"
                        ]
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable, upstream_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coa/lot/{lot}": {
      "get": {
        "operationId": "lookupCoaByLot",
        "tags": [
          "COA"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "The certificate(s) for one lot number",
        "description": "Scope `atp.inventory`. An unknown lot is an empty `data` array, never a 404. The same lookup is public without a key at https://usamadepeptides.us/coa/lookup?lot=<LOT>.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true,
            "name": "lot",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Zero or more certificates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "slug": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "research_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "slug",
                              "name",
                              "research_code"
                            ]
                          },
                          "batch_number": {
                            "type": "string"
                          },
                          "vial_size": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tested_on": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lab_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "purity_pct": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "current",
                              "archived",
                              "retired"
                            ]
                          },
                          "certificate_url": {
                            "type": "string"
                          },
                          "independent_result_url": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "verify_url": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "product",
                          "batch_number",
                          "vial_size",
                          "tested_on",
                          "lab_name",
                          "purity_pct",
                          "status",
                          "certificate_url",
                          "independent_result_url",
                          "verify_url",
                          "updated_at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable, upstream_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coa/releases": {
      "get": {
        "operationId": "listCoaReleases",
        "tags": [
          "COA"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Lot COAs ready to publish, for the storefront platform",
        "description": "Scope `atp.inventory`, the PLATFORM key only (a brand or sandbox key is 403): lots appear here before they are public. Lists outbound COAs that are approved, not rejected, not superseded, on a released batch that is a real lot (lot number set, not count stock, not archived); `lot` is the lot printed on the vial. The console pulls this, maps `skus` through its SKU map and adds the PDF to its COA library; its lookup and partner feed then serve it. Ordered by `eligible_at` (the later of approval and release, both stamped by the database) with a keyset `cursor`. Transactions do not commit in timestamp order, so re-read with `since` a day behind the last row and dedupe on `id`. `file.url` is a signed link valid for 15 minutes; `file` is null when the stored file is missing (hold it for a person). `?id=` (repeatable, up to 100) re-checks specific COAs in one page; an id missing from the answer has left the feed (superseded by a corrected report, or its batch no longer released): take it down or hold it for a person.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Eligible at or after this instant. Re-read with an overlap (a day) and dedupe on `id`: transactions do not commit in timestamp order."
            },
            "required": false,
            "description": "Eligible at or after this instant. Re-read with an overlap (a day) and dedupe on `id`: transactions do not commit in timestamp order.",
            "name": "since",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 512,
              "description": "Opaque; from the previous page."
            },
            "required": false,
            "description": "Opaque; from the previous page.",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              },
              "maxItems": 100,
              "description": "Re-check these COA ids only (repeatable, up to 100). An id missing from the answer has left the feed: superseded by a corrected report, or its batch is no longer released. Not combinable with since or cursor."
            },
            "required": false,
            "description": "Re-check these COA ids only (repeatable, up to 100). An id missing from the answer has left the feed: superseded by a corrected report, or its batch is no longer released. Not combinable with since or cursor.",
            "name": "id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "One page of approved COAs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "releases": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "lot": {
                                "type": "string"
                              },
                              "approved_at": {
                                "type": "string"
                              },
                              "eligible_at": {
                                "type": "string"
                              },
                              "formula": {
                                "type": "object",
                                "properties": {
                                  "code": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "name": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "code",
                                  "name"
                                ]
                              },
                              "skus": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "lab_name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "tested_on": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "purity_pct": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "file": {
                                "type": [
                                  "object",
                                  "null"
                                ],
                                "properties": {
                                  "url": {
                                    "type": "string"
                                  },
                                  "file_name": {
                                    "type": "string"
                                  },
                                  "content_type": {
                                    "type": "string"
                                  },
                                  "size_bytes": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "url",
                                  "file_name",
                                  "content_type",
                                  "size_bytes"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "lot",
                              "approved_at",
                              "eligible_at",
                              "formula",
                              "skus",
                              "lab_name",
                              "tested_on",
                              "purity_pct",
                              "file"
                            ]
                          }
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "releases",
                        "next_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shipments": {
      "get": {
        "operationId": "listShipments",
        "tags": [
          "Shipments"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "This key's brand's ShipStation queue, by modification time",
        "description": "Scope `shipments.read`, BRAND keys only (a platform key is 403: it names no brand). Pages the brand's mirrored shipments ordered by `greatest(remote_modified_at, updated_at)`; `since` filters on that same time (a label voided or an order cancelled weeks after shipping is returned when it changes, not when it shipped). `shipped_at` is the floor's shipped stamp, else the mirror's modified time for a label-purchased row. `stage`, `held`, `hold_reason`, `exception_reason` and the floor's `shipped_at` come from real OMS floor work only: work done while shipping simulation covers the brand (shadow mode) never reached a carrier, so it is not reported — those fields read null/false and `shipped_at` comes only from a label ShipStation holds. `items[].components[]` expands each item to vials, in priority order: the OMS stack BOM, then the brand's SKU alias (by name when the SKU is blank), then the brand's default vial size, else nothing; `items[].resolution` (`bom|alias|default|ignored|unknown`) says which, and `components[].labelled` is false for unlabelled units (e.g. BAC water). `ignored` items (free promos) have no components and must not be counted. The OMS prices nothing. `next_cursor` is opaque; stop when null. Read by the console's 3PL client portal and its nightly fee job.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "since",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "One page, newest change last",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "shipments": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "remote_shipment_id": {
                                "type": "string"
                              },
                              "shipment_number": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "external_order_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "processing",
                                  "label_purchased",
                                  "cancelled",
                                  "on_hold"
                                ]
                              },
                              "stage": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "enum": [
                                  "queued",
                                  "picking",
                                  "picked",
                                  "packing",
                                  "packed",
                                  "labeled",
                                  "shipped",
                                  "exception",
                                  null
                                ],
                                "description": "The OMS floor's stage. Null when the floor has not touched it, and for work done under shipping simulation (never reported)"
                              },
                              "held": {
                                "type": "boolean",
                                "description": "A real floor hold. Simulated floor work is never reported"
                              },
                              "hold_reason": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "enum": [
                                  "inventory_short",
                                  "payment_issue",
                                  "compliance_review",
                                  "customer_request",
                                  "qa_review",
                                  "other",
                                  null
                                ],
                                "description": "Why the floor is holding it (null when not held). The console's reserve gate is not a floor hold; the console knows those itself."
                              },
                              "exception_reason": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "Free text from the floor when stage is exception; null otherwise"
                              },
                              "shipped_at": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "The real floor hand-off time, else the mirror's modified time once ShipStation holds a label. A simulated hand-off is never reported"
                              },
                              "remote_created_at": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "remote_modified_at": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "tracking_number": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "carrier_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "service_code": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "label_cost_cents": {
                                "type": [
                                  "integer",
                                  "null"
                                ],
                                "description": "The brand's own postage; informational"
                              },
                              "item_count": {
                                "type": "integer",
                                "description": "Informational; price from components"
                              },
                              "amount_paid_cents": {
                                "type": [
                                  "integer",
                                  "null"
                                ],
                                "description": "What the brand's customer paid for the order incl. shipping (ShipStation amount_paid); null when unknown"
                              },
                              "items": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "sku": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "name": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "quantity": {
                                      "type": "integer"
                                    },
                                    "unit_price_cents": {
                                      "type": [
                                        "integer",
                                        "null"
                                      ],
                                      "description": "What the brand's customer paid per unit (ShipStation unit_price); null when ShipStation had none"
                                    },
                                    "resolution": {
                                      "type": "string",
                                      "enum": [
                                        "bom",
                                        "alias",
                                        "default",
                                        "ignored",
                                        "unknown",
                                        "paired"
                                      ],
                                      "description": "How components were derived: OMS stack BOM; brand SKU/name alias; brand default vial size; alias marked ignore; nothing matched; paired = a \"<item> — N Free\" line given the vials of the paid line it repeats in the same shipment"
                                    },
                                    "components": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "formula_code": {
                                            "type": [
                                              "string",
                                              "null"
                                            ],
                                            "description": "OMS formula; null for an alias or brand-default component"
                                          },
                                          "vial_size": {
                                            "type": [
                                              "string",
                                              "null"
                                            ],
                                            "description": "formulas.vial_size as written (\"10mL clear glass\"); null for alias/default components"
                                          },
                                          "vial_ml": {
                                            "type": [
                                              "number",
                                              "null"
                                            ],
                                            "description": "Millilitres: parsed from vial_size (BOM), else the alias / brand default; null when unknown or unlabelled"
                                          },
                                          "labelled": {
                                            "type": "boolean",
                                            "description": "True when each vial gets a label (BOM, vial alias, brand default); false for an unlabelled unit such as BAC water"
                                          },
                                          "quantity": {
                                            "type": "integer",
                                            "description": "Vials of this formula in the shipment: per-kit × item quantity"
                                          },
                                          "catalog_skus": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            },
                                            "description": "Active single-formula OMS stack SKUs for formula_code (sorted; empty when none or no formula). Lets the console value a vial at the client's catalog price; never a fee input"
                                          }
                                        },
                                        "required": [
                                          "formula_code",
                                          "vial_size",
                                          "vial_ml",
                                          "labelled",
                                          "quantity",
                                          "catalog_skus"
                                        ]
                                      },
                                      "description": "Empty when resolution is ignored or unknown"
                                    },
                                    "lots": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "lot": {
                                            "type": "string"
                                          },
                                          "quantity": {
                                            "type": "integer"
                                          },
                                          "expires_on": {
                                            "type": [
                                              "string",
                                              "null"
                                            ]
                                          },
                                          "expiry_kind": {
                                            "type": [
                                              "string",
                                              "null"
                                            ],
                                            "enum": [
                                              "EXP",
                                              "BUD",
                                              null
                                            ]
                                          },
                                          "lot_source": {
                                            "type": "string",
                                            "enum": [
                                              "label_bound",
                                              "pick_planned"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "lot",
                                          "quantity",
                                          "expires_on",
                                          "expiry_kind",
                                          "lot_source"
                                        ]
                                      },
                                      "description": "The lots this item shipped from: label_bound when the label station bound them, else pick_planned (the pick slip's plan). Each carries its one recorded date (EXP or BUD) or none. Empty when no lot is recorded; absent when the lots could not be read. Informational; never a fee input"
                                    }
                                  },
                                  "required": [
                                    "sku",
                                    "name",
                                    "quantity",
                                    "unit_price_cents",
                                    "resolution",
                                    "components"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "remote_shipment_id",
                              "shipment_number",
                              "external_order_id",
                              "status",
                              "stage",
                              "held",
                              "hold_reason",
                              "exception_reason",
                              "shipped_at",
                              "remote_created_at",
                              "remote_modified_at",
                              "tracking_number",
                              "carrier_code",
                              "service_code",
                              "label_cost_cents",
                              "item_count",
                              "amount_paid_cents",
                              "items"
                            ]
                          }
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "brand_code": {
                          "type": "string"
                        },
                        "as_of": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "shipments",
                        "next_cursor",
                        "brand_code",
                        "as_of"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inventory/summary": {
      "get": {
        "operationId": "inventorySummary",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "What the OMS can ship for this key's brand, one row per formula",
        "description": "Scope `atp.inventory`, BRAND keys only (a platform key is 403). The brand's OWN units (`own.on_hand/reserved/atp`) are counted; the shared pool is a bucket (`shared`: `in_stock` | `low` (≤ 25 units) | `out` | `no_access` when the brand's `shared_pool_access` is none) — never a count, because the shared pool is the manufacturer's stock. `sold_recently` marks formulas the brand shipped through a stack BOM in the last 90 days. Rows the brand could neither ship nor has sold are omitted. Read by the console's 3PL client portal Inventory tab (increment 4, D13).",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "The summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "brand_code": {
                          "type": "string"
                        },
                        "as_of": {
                          "type": "string"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "formula_code": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "vial_size": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "own": {
                                "type": "object",
                                "properties": {
                                  "on_hand": {
                                    "type": "integer"
                                  },
                                  "reserved": {
                                    "type": "integer"
                                  },
                                  "atp": {
                                    "type": "integer"
                                  }
                                },
                                "required": [
                                  "on_hand",
                                  "reserved",
                                  "atp"
                                ]
                              },
                              "shared": {
                                "type": "string",
                                "enum": [
                                  "in_stock",
                                  "low",
                                  "out",
                                  "no_access"
                                ]
                              },
                              "sold_recently": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "formula_code",
                              "name",
                              "vial_size",
                              "own",
                              "shared",
                              "sold_recently"
                            ]
                          }
                        }
                      },
                      "required": [
                        "brand_code",
                        "as_of",
                        "rows"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipts": {
      "get": {
        "operationId": "listReceipts",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Units received into this key's brand's own stock, by batch and day",
        "description": "Scope `atp.inventory`, BRAND keys only. One row per (day, batch, formula) of finished goods labelled or received into the brand's OWN pool in the last 180 days, with the units received and how many of them remain on the shelf. Shared-pool stock never appears here. Read by the console's 3PL client portal Receiving section (increment 4, D15).",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "The receipts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "brand_code": {
                          "type": "string"
                        },
                        "as_of": {
                          "type": "string"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "received_on": {
                                "type": "string",
                                "description": "YYYY-MM-DD: the day the units were labelled to the brand, else created"
                              },
                              "batch_number": {
                                "type": "string"
                              },
                              "formula_code": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "vial_size": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "product_type": {
                                "type": "string"
                              },
                              "units": {
                                "type": "integer"
                              },
                              "remaining": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "received_on",
                              "batch_number",
                              "formula_code",
                              "name",
                              "vial_size",
                              "product_type",
                              "units",
                              "remaining"
                            ]
                          }
                        }
                      },
                      "required": [
                        "brand_code",
                        "as_of",
                        "rows"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brand/status": {
      "get": {
        "operationId": "brandStatus",
        "tags": [
          "Shipments"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "This key's brand's shipping connection (no credentials)",
        "description": "Scope `shipments.read`, BRAND keys only. Which carrier queue the brand is connected through (`shipstation_v2|shipstation_v1|easyship|shippo`, or null), whether the last queue sync worked and when, a credential-free error when it did not, and mirror counts. Never returns a key. Read by the console's 3PL client record.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "brand_code": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "shipping": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "shipstation_v2",
                                "shipstation_v1",
                                "easyship",
                                "shippo",
                                null
                              ]
                            },
                            "connected": {
                              "type": "boolean"
                            },
                            "last_sync_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_sync_ok": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "last_error": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Credential-free reason the last sync failed"
                            }
                          },
                          "required": [
                            "provider",
                            "connected",
                            "last_sync_at",
                            "last_sync_ok",
                            "last_error"
                          ]
                        },
                        "mirror": {
                          "type": "object",
                          "properties": {
                            "shipments": {
                              "type": "integer"
                            },
                            "open": {
                              "type": "integer"
                            },
                            "latest_change_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "shipments",
                            "open",
                            "latest_change_at"
                          ]
                        },
                        "as_of": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "brand_code",
                        "name",
                        "is_active",
                        "shipping",
                        "mirror",
                        "as_of"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/mint": {
      "post": {
        "operationId": "mintPortalKey",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Mint a brand-scoped read-only portal key (console \"Connect OMS\")",
        "description": "Scope `keys.mint`, PLATFORM keys only (a brand key is 403). Mints one key bound to the named brand carrying only `shipments.read` and/or `atp.inventory` — no write or keys.* scope can be minted here. Returns the `pk_…:ssk_…` token ONCE (`Cache-Control: no-store`); the OMS stores only SHA-256 hashes. `replace` (default true) revokes the brand's earlier console portal keys. The console stores the token encrypted and never shows it to a person.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "brand": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "description": "Brand slug or code"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "shipments.read",
                        "atp.inventory"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 2,
                    "description": "Subset of shipments.read, atp.inventory; nothing else may be minted here"
                  },
                  "replace": {
                    "type": "boolean",
                    "default": true,
                    "description": "After the new key is stored, revoke this brand's earlier read-only console portal keys"
                  }
                },
                "required": [
                  "brand",
                  "scopes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Minted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "token": {
                          "type": "string",
                          "description": "pk_…:ssk_… — returned ONCE; the OMS stores only hashes"
                        },
                        "key_prefix": {
                          "type": "string"
                        },
                        "brand_code": {
                          "type": "string"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "replaced": {
                          "type": "integer",
                          "description": "Earlier console portal keys for this brand revoked"
                        }
                      },
                      "required": [
                        "token",
                        "key_prefix",
                        "brand_code",
                        "scopes",
                        "replaced"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {conflict}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/status": {
      "get": {
        "operationId": "keyIssuanceStatus",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "A client organisation's store-key issuance status (console \"Connect your store\")",
        "description": "Scope `keys.mint`, PLATFORM keys only (a brand key is 403). Query `console_org_id` (UUID). Always returns the sandbox and the production row (sandbox keys bind to the SANDBOX brand, so this is keyed by console organisation, not brand): issuance state, reveal-link expiry, the issued key's last use, the replaced key's expiry while a rotation grace runs, and whether it was marked undelivered. Never returns a token, hash or key.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "console_org_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "responses": {
          "200": {
            "description": "Status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "console_org_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "environments": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "is_sandbox": {
                                "type": "boolean"
                              },
                              "state": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "enum": [
                                  "requested",
                                  "approved",
                                  "revealed",
                                  "undelivered",
                                  "expired",
                                  null
                                ],
                                "description": "null = never requested; an approved link past its expiry reads expired"
                              },
                              "console_ticket_number": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "token_expires_at": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "key_last_used_at": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "The issued key's last successful call"
                              },
                              "previous_key_expires_at": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "The replaced key's expiry while a rotation grace window is running"
                              },
                              "undelivered": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "is_sandbox",
                              "state",
                              "console_ticket_number",
                              "token_expires_at",
                              "key_last_used_at",
                              "previous_key_expires_at",
                              "undelivered"
                            ]
                          },
                          "description": "Always two rows: sandbox then production"
                        }
                      },
                      "required": [
                        "console_org_id",
                        "environments"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reserve-cache": {
      "post": {
        "operationId": "pushReserve",
        "tags": [
          "Reserve"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "summary": "Push the console's prepaid-reserve mirror for one brand",
        "description": "Scope `reserve.write`, PLATFORM keys only (a brand key is 403). ADR 0017: the OMS stores what the console pushes and never computes a balance or a fee. Replaces the brand's cache row (`balance_cents`, `gate_enabled`, `as_of`) and ALL of its per-shipment fee rows with the payload, atomically. `brand` is a slug or code. When `gate_enabled` and the balance is <= 0 or below a shipment's fee, that queued shipment is not claimable by the pick floor (it stays queued). `blocked` counts the brand's queued rows the gate now blocks.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "brand": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "description": "Brand slug or code"
                  },
                  "balance_cents": {
                    "type": "integer",
                    "description": "The console's reserve balance for the brand, in cents"
                  },
                  "gate_enabled": {
                    "type": "boolean"
                  },
                  "as_of": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the console computed this balance"
                  },
                  "shipments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "remote_shipment_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "fee_cents": {
                          "type": "integer",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "remote_shipment_id",
                        "fee_cents"
                      ]
                    },
                    "maxItems": 2000
                  }
                },
                "required": [
                  "brand",
                  "balance_cents",
                  "gate_enabled",
                  "as_of",
                  "shipments"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mirror replaced",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "brand_code": {
                          "type": "string"
                        },
                        "balance_cents": {
                          "type": "integer"
                        },
                        "gate_enabled": {
                          "type": "boolean"
                        },
                        "as_of": {
                          "type": "string"
                        },
                        "fee_rows": {
                          "type": "integer",
                          "description": "Per-shipment fee rows now stored for the brand"
                        },
                        "blocked": {
                          "type": "integer",
                          "description": "Queued worklog rows the gate now blocks from claiming"
                        }
                      },
                      "required": [
                        "brand_code",
                        "balance_cents",
                        "gate_enabled",
                        "as_of",
                        "fee_rows",
                        "blocked"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/confirm": {
      "post": {
        "operationId": "atpConfirm",
        "tags": [
          "ATP"
        ],
        "security": [
          {
            "partnerKey": []
          }
        ],
        "deprecated": true,
        "summary": "Legacy: place an OMS order from a hold (use POST /api/v1/orders)",
        "description": "Scope `atp.confirm`. The same transaction as `/api/v1/orders` with `confirm:<reservation_token>` as the idempotency key. Error codes keep their original names (not_found, gone, forbidden). `shipping_address` must serialise under 4 KB.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
              "example": "2026-09-06"
            },
            "required": false,
            "description": "Pin the API date. Omit for the current one (2026-09-06); a date newer than the deployment is a 400 unsupported_version.",
            "name": "X-Pharmagistic-Version",
            "in": "header"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reservation_token": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "order": {
                    "type": "object",
                    "properties": {
                      "external_ref": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "customer": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "consumer"
                                ]
                              },
                              "email": {
                                "type": "string",
                                "maxLength": 254,
                                "format": "email"
                              },
                              "full_name": {
                                "type": "string",
                                "maxLength": 200
                              },
                              "phone": {
                                "type": "string",
                                "maxLength": 40
                              }
                            },
                            "required": [
                              "type",
                              "email"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "account"
                                ]
                              },
                              "account_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "consumer_id": {
                                "type": "string",
                                "format": "uuid"
                              }
                            },
                            "required": [
                              "type",
                              "account_id"
                            ]
                          }
                        ]
                      },
                      "shipping_address": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "notes": {
                        "type": "string",
                        "maxLength": 2000
                      }
                    },
                    "required": [
                      "customer"
                    ]
                  }
                },
                "required": [
                  "reservation_token",
                  "order"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "order_total": {
                          "type": "number"
                        },
                        "idempotent": {
                          "type": "boolean"
                        },
                        "items_allocated": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "qty": {
                                "type": "integer"
                              },
                              "units": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "qty",
                              "units"
                            ]
                          }
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "order_total",
                        "idempotent",
                        "items_allocated"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Placed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string"
                        },
                        "order_total": {
                          "type": "number"
                        },
                        "idempotent": {
                          "type": "boolean"
                        },
                        "items_allocated": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "qty": {
                                "type": "integer"
                              },
                              "units": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "qty",
                              "units"
                            ]
                          }
                        }
                      },
                      "required": [
                        "order_id",
                        "status",
                        "order_total",
                        "idempotent",
                        "items_allocated"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "error.code ∈ {invalid_input, unsupported_version, bad_request}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "error.code ∈ {unauthorized}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "error.code ∈ {forbidden, brand_mismatch}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "error.code ∈ {not_found}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "error.code ∈ {reservation_used, kit_incomplete, unresolved_stack, hold_race}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "error.code ∈ {gone}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "error.code ∈ {blocked_product, invalid_customer}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "error.code ∈ {rate_limited}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "error.code ∈ {internal_error}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "error.code ∈ {service_unavailable}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "short_lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sku": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "requested": {
                                "type": "integer"
                              },
                              "available": {
                                "type": "integer"
                              },
                              "backordered": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "sku",
                              "requested",
                              "available",
                              "backordered"
                            ]
                          },
                          "description": "Only on 409 insufficient_stock: the lines stock could not cover"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {},
  "x-aliases": {
    "/api/v1/atp/{check|reserve|release|consume|inventory|confirm}": "/api/v1/{same} — rewrite kept for one release after 2026-09-06"
  },
  "x-version-header": "X-Pharmagistic-Version"
}
