Create a purchase-side, sale-side, or purchase-to-sale allocation
Creates an allocation for a quantity. An allocation can be complete, with both a purchase leg and sale leg, or partial, with only one side provided. When both sides are provided, the allocation links purchased volume to sold volume. When only one side is provided, CommodityAI records the one-sided allocation and returns a reference for the provided side.Documentation Index
Fetch the complete documentation index at: https://docs.commodityai.io/llms.txt
Use this file to discover all available pages before exploring further.
purchase_leg_id or sale_leg_id is required.quantity must be a positive numeric string.draft or active.quantity_unit_id is inherited from the purchase leg when present, otherwise from the sale leg.P0001.001 or P0001.A01.| Header | Required | Notes |
|---|---|---|
Idempotency-Key | Yes | Unique key for safely retrying this write. Use a stable value from your source system, such as erp-allocation-7781-create. |
purchase_leg_id or sale_leg_id is required.purchase_leg_id or sale_leg_id is required.error_code values when a business rule blocks the request. Warnings, when present, are returned separately from the created allocation.
| Code | Meaning |
|---|---|
WRONG_CONTRACT_TYPE | The purchase leg belongs to a sale contract, or the sale leg belongs to a purchase contract. |
CONTRACT_CLOSED | A referenced contract is closed. |
CONTRACT_FULFILLED | A referenced contract is fulfilled. |
SELF_DEALING | Both legs belong to the same contract. |
COMPANY_MISMATCH | A referenced leg does not belong to your company. |
UNIT_INCOMPATIBLE | Purchase and sale legs have incompatible quantity units. |
SCHEDULE_NOT_COVERED | Scheduled legs are not covered by a matching schedule. |
CAPACITY_EXCEEDED | Quantity exceeds remaining capacity on one of the provided legs. |