К содержанию
TelegaFirst

Для AI-агентов: markdown этой страницы — /docs/api-op-changeordercomposition.mdиндекс документации — /llms.txt

changeOrderComposition

Обновлено

POST /api/v1/orders/{seqNum}/composition

changeOrderComposition

Авторизация и права

Scopes: ALL. Auth alternatives: OR; scopes внутри альтернативы: ALL.

ПолеЗначение
security.0.hubApiKey[]
security.1.hubBearer[]
securitySchemes.hubApiKey.in"header"
securitySchemes.hubApiKey.name"X-Api-Key"
securitySchemes.hubApiKey.type"apiKey"
securitySchemes.hubBearer.scheme"bearer"
securitySchemes.hubBearer.type"http"
x-required-scopes["orders:write"]

Параметры запроса

ПолеЗначение
0.description"Tenant Order sequence (seq_num) serialized as canonical decimal digits."
0.in"path"
0.name"seqNum"
0.requiredtrue
0.schema0.schema
1.description"Required durable money receipt key; replay is retained for 30 days and returns the stored result with replayed=true."
1.in"header"
1.name"Idempotency-Key"
1.requiredtrue
1.schema1.schema
2.description"The order version the change is based on: the weak ETag of GET /api/v1/orders/{id}. Any other value is a stale version (412)."
2.in"header"
2.name"If-Match"
2.requiredtrue
2.schema2.schema

Тело запроса

ПолеЗначение
content.application/json.examples.addLine.summary"Add a product line"
content.application/json.examples.addLine.value.catalog_seq_num23
content.application/json.examples.addLine.value.kind"add_line"
content.application/json.examples.addLine.value.quantity1
content.application/json.examples.removeLine.summary"Remove line 2"
content.application/json.examples.removeLine.value.kind"remove_line"
content.application/json.examples.removeLine.value.line_no2
content.application/json.examples.setLinePrice.summary"Agree a unit price for line 2"
content.application/json.examples.setLinePrice.value.final_unit_amount"1500.00"
content.application/json.examples.setLinePrice.value.kind"set_line_price"
content.application/json.examples.setLinePrice.value.line_no2
content.application/json.examples.setLinePrice.value.reason"Loyal customer"
content.application/json.examples.setQuantity.summary"Set the quantity of line 1"
content.application/json.examples.setQuantity.value.kind"set_quantity"
content.application/json.examples.setQuantity.value.line_no1
content.application/json.examples.setQuantity.value.quantity3
content.application/json.examples.setQuantityAtReviewedTotal.summary"Set the quantity only at the reviewed order total"
content.application/json.examples.setQuantityAtReviewedTotal.value.expected_amount"4500.00"
content.application/json.examples.setQuantityAtReviewedTotal.value.kind"set_quantity"
content.application/json.examples.setQuantityAtReviewedTotal.value.line_no1
content.application/json.examples.setQuantityAtReviewedTotal.value.quantity3
content.application/json.schemaOrderCompositionApplyRequest
requiredtrue

Ответы

ПолеЗначение
200.content.application/json.example.amount"4500.00"
200.content.application/json.example.currency"RUB"
200.content.application/json.example.order_seq_num45
200.content.application/json.example.order_version"W/\"c8d8e23b45a34ae6\""
200.content.application/json.example.replayedfalse
200.content.application/json.schemaOrderCompositionApplyResponse
200.description"The change is applied, or the same Idempotency-Key replays its stored result (replayed=true)"
200.headers.ETag.description"The order version (Hub weak ETag); send it as If-Match to change the composition."
200.headers.ETag.requiredtrue
200.headers.ETag.schema200.headers.ETag.schema

Ошибки

ПолеЗначение
400.content.application/problem+json.schemaProblemDetails
400.description"Invalid strict body, path or an Idempotency-Key over 128 characters (VALIDATION_ERROR), or a missing Idempotency-Key (IDEMPOTENCY_KEY_REQUIRED)"
401.content.application/problem+json.schemaProblemDetails
401.description"Missing or invalid authentication"
403.content.application/problem+json.schemaProblemDetails
403.description"Missing orders:write scope (INSUFFICIENT_SCOPE) or a credential not admitted to this tenant (FORBIDDEN)"
404.content.application/problem+json.schemaProblemDetails
404.description"No order with this seq_num, or no active line with this line_no, in this tenant (NOT_FOUND)"
409.content.application/problem+json.schemaProblemDetails
409.description"The order is closed (ORDER_CLOSED) or already paid (ORDER_ALREADY_PAID); the recomposed total differs from expected_amount (PRICE_CHANGED); another change to this order is being applied (CONFLICT); or the receipt for this key is still pending (IDEMPOTENCY_KEY_IN_FLIGHT)"
412.content.application/problem+json.schemaProblemDetails
412.description"The order changed since the If-Match ETag was read (PRECONDITION_FAILED); current_etag and the ETag header carry the current version"
422.content.application/problem+json.schemaProblemDetails
422.description"The last active line cannot be removed or the product, price or resulting total is not accepted (INVALID_INPUT), the quantity is outside 1..999 (INVALID_QUANTITY), the product allows one per order (QUANTITY_LIMIT), or the key was reused with a different body (IDEMPOTENCY_KEY_MISMATCH)"
428.content.application/problem+json.schemaProblemDetails
428.description"If-Match with the order version is required (PRECONDITION_REQUIRED)"

Дополнительные условия

ПолеЗначение
description"Apply one change to the composition of an open, unpaid order: remove_line, set_quantity, set_line_price or add_line (a variant change is a remove plus an add). Prices are recalculated by the platform under its pricing rules; an unpaid payment link is reissued for the new amount and the old one no longer pays the order. MCP agents prepare the same change with prepare_order_composition_change first."
operationId"changeOrderComposition"
tags["orders"]
x-idempotency"durable-receipt"