# changeOrderComposition

Source: <https://telegafirst.com/docs/api-op-changeordercomposition>
Locale: ru
releaseGitSha: 0bb11ef116e17ec64c802d5476eaff442e53d252
sourceContentDigest: df72b98d0ac0bad6ac0fe569962c41e07a934d6d6ea59484031a76a21c007bfd
Version: 3

# 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.required | true |
| 0.schema | [0.schema](https://telegafirst.com/docs/schema-c9e1d2bff948b0f4bf6cc89c3a48773adb93013c2d81306438b73d410a441dab) |
| 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.required | true |
| 1.schema | [1.schema](https://telegafirst.com/docs/schema-f664917e1c121e95f4e7a42bf30bef6cd2b4cc434d98f937ed12cbe6602c9e81) |
| 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.required | true |
| 2.schema | [2.schema](https://telegafirst.com/docs/schema-8bfe590d9f642086eed8b48ac3c6e48d59b681e51b411d8308737268ee15c3b1) |

## Тело запроса

| Поле | Значение |
| - | - |
| content.application/json.examples.addLine.summary | "Add a product line" |
| content.application/json.examples.addLine.value.catalog\_seq\_num | 23 |
| content.application/json.examples.addLine.value.kind | "add\_line" |
| content.application/json.examples.addLine.value.quantity | 1 |
| 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\_no | 2 |
| 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\_no | 2 |
| 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\_no | 1 |
| content.application/json.examples.setQuantity.value.quantity | 3 |
| 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\_no | 1 |
| content.application/json.examples.setQuantityAtReviewedTotal.value.quantity | 3 |
| content.application/json.schema | [OrderCompositionApplyRequest](https://telegafirst.com/docs/schema-f4805c809d7841f9e6ee8dee089f8ee87b09fa7b72b4a4fc479b31f383658204) |
| required | true |

## Ответы

| Поле | Значение |
| - | - |
| 200.content.application/json.example.amount | "4500.00" |
| 200.content.application/json.example.currency | "RUB" |
| 200.content.application/json.example.order\_seq\_num | 45 |
| 200.content.application/json.example.order\_version | "W/\\"c8d8e23b45a34ae6\\"" |
| 200.content.application/json.example.replayed | false |
| 200.content.application/json.schema | [OrderCompositionApplyResponse](https://telegafirst.com/docs/schema-56f87b2b7138bfaa6cd5e61e7b9d32c2e940040e0c61add7f063051fa1da2987) |
| 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.required | true |
| 200.headers.ETag.schema | [200.headers.ETag.schema](https://telegafirst.com/docs/schema-a954616bd4d96f5e4df469689bdaa25afb7e6c2df94f42ec0a579fda61a89ca3) |

## Ошибки

| Поле | Значение |
| - | - |
| 400.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 401.description | "Missing or invalid authentication" |
| 403.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 403.description | "Missing orders:write scope (INSUFFICIENT\_SCOPE) or a credential not admitted to this tenant (FORBIDDEN)" |
| 404.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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.schema | [ProblemDetails](https://telegafirst.com/docs/schema-c4113f3de00d728702a8663612e2074cbe3e8b3bb70d2b0dee6f3503fe89bd41) |
| 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" |
