Skip to main content

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.

Contracts are the center of CommodityAI’s standard object model. They represent purchase and sale agreements, with legs for allocatable segments and allocations for buy-to-sell coverage. Use these APIs when an external system creates or maintains contract records and needs CommodityAI IDs and references for reconciliation.

Resource Model

ResourceRole
ContractParent purchase or sale agreement. Stores counterparty, product, quantity, delivery, payment, status, and external reference metadata.
LegAllocatable segment of a contract. Simple contracts use one default leg; tranched contracts use multiple lettered legs with leg-level overrides.
AllocationQuantity assigned to a purchase leg, sale leg, or both sides. Complete allocations connect purchase volume to sale volume.
Product attributesCommodity-specific product fields such as grade, origin, form, packaging, and company-defined attributes.
Quality specificationStructured requirement set for contracted product quality, tolerances, sampling, inspection, or certificate requirements.

Flow

  1. Create purchase and sale contracts.
  2. Add legs when a contract needs tranches, shipment windows, ports, destinations, or quantity splits.
  3. Set product attributes and quality specifications at the contract level.
  4. Override product, quality, pricing, delivery, or payment fields on legs when needed.
  5. Create allocations for purchase-side, sale-side, or complete purchase-to-sale coverage.
  6. Store returned IDs and references in the upstream system.

Create Model

Contract creation is not just a parent record insert. CommodityAI also creates the operating structure around the contract:
AreaBehavior
LegsCreates one default 0 leg for simple contracts, or lettered legs for tranched contracts.
Product attributesAccepts structured product attribute values through quality_attributes or the attribute-values endpoint.
Quality specificationsCreates contract-scoped quality specs when provided, or seeds from product and grade templates.
Pricing termsStores formula pricing terms and components, optionally scoped to a leg.
Extension fieldsValidates and stores configured contract extension fields.
ControlsValidates tenant references, tolerance ranges, pricing term references, and counterparty limits.

References

ExampleMeaning
P0001Purchase contract
S0001Sale contract
P0001.001Simple purchase-side allocation reference
P0001.A01Tranched purchase-side allocation reference

Endpoints

List Contracts

Retrieve company contracts.

Create Contract

Create a purchase or sale contract.

Product Attributes & Quality

Understand structured product values and quality specs.

Pricing Terms

Understand formula pricing terms accepted during contract creation.

Get Contract

Retrieve a single contract by ID.

Update Contract

Update commercial terms, status, or extension fields.

List Contract Legs

Retrieve allocatable legs for a contract.

Add Contract Leg

Add a tranche or allocatable segment.

List Allocations

Retrieve complete and partial allocation records.

Create Allocation

Create one-sided or purchase-to-sale allocations.

Set Attribute Values

Set structured product attribute values.