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.
Updates a contract. Use this endpoint for status transitions, commercial field changes, and extension fields.
Path Parameters
| Header | Required | Notes |
|---|
Idempotency-Key | Yes | Unique key for safely retrying this write. Use a stable value from your source system, such as erp-contract-10024-status-active. |
Request Body
Lifecycle status. Values: draft, active, fulfilled, closed.
Source-system contract reference.
Product name when not using a product catalog ID.
Contract quantity as a positive numeric string.
Fixed price as a positive numeric string.
Shipment period start date in YYYY-MM-DD format.
Shipment period end date in YYYY-MM-DD format.
Structured product attribute values keyed by product attribute UUID.
Company-specific extension fields.
Confirms an update when CommodityAI returns an impact warning that requires confirmation.
Request Example
curl -X PATCH "https://commodityai.app/api/v1/contracts/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer cai_live_your_api_key_here" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: erp-contract-10024-status-active" \
-d '{
"status": "active",
"shipment_end": "2026-07-05",
"extension_fields": {
"source_system": "ERP"
}
}'
Response
{
"contract": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"contract_number": "P0001",
"status": "active",
"shipment_end": "2026-07-05"
}
}
Errors and Warnings
Some updates can affect allocations, document requirements, pricing, or other downstream workflow state. If an update needs explicit confirmation, CommodityAI returns a warning response with requires_confirmation: true. Retry the same update with confirmed: true after reviewing the impact.
| Status | Code | Meaning |
|---|
400 | validation_error | Required fields, IDs, date formats, or product attribute values are invalid. |
404 | not_found | The contract or a referenced record was not found for the company. |
409 | conflict | The requested change conflicts with the contract lifecycle or existing downstream records. |
422 | business_rule_failed | The update is structurally valid but fails a CommodityAI contract rule. |