Skip to main content
POST
/
api
/
v1
/
contracts
/
{id}
/
legs
curl -X POST "https://commodityai.app/api/v1/contracts/123e4567-e89b-12d3-a456-426614174000/legs" \
  -H "Authorization: Bearer cai_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-contract-10024-leg-c" \
  -d '{
    "label": "C",
    "quantity": "10000",
    "overrides": {
      "shipment_start": "2026-07-01",
      "shipment_end": "2026-07-15",
      "destination_port_id": "623e4567-e89b-12d3-a456-426614174005"
    }
  }'
{
  "leg": {
    "id": "723e4567-e89b-12d3-a456-426614174006",
    "contract_id": "123e4567-e89b-12d3-a456-426614174000",
    "label": "C",
    "quantity": "10000"
  }
}

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.

Adds a leg to a contract. Use legs when a contract needs split quantity, different shipment windows, different delivery terms, or leg-level overrides.

Path Parameters

id
string
required
Contract UUID.

Headers

HeaderRequiredNotes
Idempotency-KeyYesUnique key for safely retrying this write. Use a stable value from your source system, such as erp-contract-10024-leg-c.

Request Body

quantity
string
required
Leg quantity as a positive numeric string.
label
string
Optional single-letter leg label, such as A or B.
overrides
object
Optional leg-level overrides for product, quality, pricing, delivery, payment, broker, or trader fields.

Request Example

curl -X POST "https://commodityai.app/api/v1/contracts/123e4567-e89b-12d3-a456-426614174000/legs" \
  -H "Authorization: Bearer cai_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-contract-10024-leg-c" \
  -d '{
    "label": "C",
    "quantity": "10000",
    "overrides": {
      "shipment_start": "2026-07-01",
      "shipment_end": "2026-07-15",
      "destination_port_id": "623e4567-e89b-12d3-a456-426614174005"
    }
  }'

Response

{
  "leg": {
    "id": "723e4567-e89b-12d3-a456-426614174006",
    "contract_id": "123e4567-e89b-12d3-a456-426614174000",
    "label": "C",
    "quantity": "10000"
  }
}

Errors

StatusCodeMeaning
400validation_errorQuantity, label, or override fields are invalid.
404not_foundThe contract or a referenced override record was not found for the company.
409conflictThe leg label already exists or the contract lifecycle does not allow adding a leg.