# Update the order amount and order lines

> `PATCH https://api.kustom.co/ordermanagement/v1/orders/{order_id}/authorization`

Set new order amount and order lines. Read more on [Updating orders](https://docs.kustom.co/contents/api/order-management/orders/updateauthorization)

## Parameters

- `order_id` (string, path, required) — Order id
- `Klarna-Idempotency-Key` (string, header) — This header will guarantee the idempotency of the operation. The key should be unique and is recommended to be a UUID version 4. Retries of requests are safe to be applied in case of errors such as network errors, socket errors and timeouts. Input values of the operation are disregarded when evaluating the idempotency of the operation, only the key matters.

## Request body

`application/json`

- `description` (string) — Description of the change.
- `order_amount` (integer, required) — The new total order amount. Minor units.
- `order_lines[]` (array<object>, required) — New set of order lines for the order.
  - `image_url` (string) — URL to an image that can be embedded in communications between Klarna and the customer.
  - `merchant_data` (string) — Data about the order line.
  - `name` (string, required) — Descriptive item name.
  - `product_identifiers` (object) — product_identifiers
    - `brand` (string) — The product's brand name as generally recognized by consumers. If no brand is available for a product, do not supply any value. Maximum 70 characters. Example: Intel
    - `category_path` (string) — The product's category path as used in the merchant's webshop. Include the full and most detailed category and separate the segments with ' > '. Maximum 750 characters. Example: Electronics Store > Computers & Tablets > Desktops
    - `color` (string) — Color to be shown to the end customer (max 64 characters). Example: Denim blue
    - `global_trade_item_number` (string) — The product's Global Trade Item Number (GTIN). Common types of GTIN are EAN, ISBN or UPC. Exclude dashes and spaces, where possible. Maximum 50 characters. Example: 735858293167
    - `manufacturer_part_number` (string) — The product's Manufacturer Part Number (MPN), which - together with the brand - uniquely identifies a product. Only submit MPNs assigned by a manufacturer and use the most specific MPN possible. Maximum 70 characters. Example: BOXNUC5CPYH
    - `size` (string) — Size to be shown to the end customer (max 64 characters). Example: 4
  - `product_url` (string) — URL to the product that can be used in communications between Klarna and the customer.
  - `quantity` (integer, required) — Item quantity.
  - `quantity_unit` (string) — Unit used to describe the quantity.
  - `reference` (string) — Article number, SKU, or similar identifier on the product variant level.
  - `tax_rate` (integer) — The tax rate in percent with two implicit decimals.
  - `total_amount` (integer, required) — Total amount including tax and discounts (`quantity * unit_price - total_discount_amount`).
  - `total_discount_amount` (integer) — The discount amount in minor units. Includes tax. Example: 1200 = $12. Max value: 200000000
  - `total_tax_amount` (integer) — The total tax amount in minor units.
  - `type` (string) — Order line type. Enum: `physical`, `discount`, `shipping_fee`, `sales_tax`, `store_credit`, `gift_card`, `digital`, `surcharge`, `return_fee`, `package`.
  - `unit_price` (integer, required) — Unit price including tax without applying discounts in minor units.

### Example request

```json
{
  "description": "Added charger",
  "order_amount": 0,
  "order_lines": [
    {
      "image_url": "https://yourstore.example/product/headphones.png",
      "merchant_data": "Some metadata",
      "name": "<string>",
      "product_identifiers": {
        "brand": "Intel",
        "category_path": "Electronics Store > Computers & Tablets > Desktops",
        "color": "Denim blue",
        "global_trade_item_number": 735858293167,
        "manufacturer_part_number": "BOXNUC5CPYH",
        "size": 4
      },
      "product_url": "https://yourstore.example/product/headphones",
      "quantity": 1,
      "quantity_unit": "pcs.",
      "reference": 75001,
      "tax_rate": 0,
      "total_amount": 0,
      "total_discount_amount": 0,
      "total_tax_amount": 0,
      "type": "physical",
      "unit_price": 0
    }
  ]
}
```

## Responses

### 204

Authorization was updated.

`application/json`

```json
"<string>"
```

### 403

Update authorization not allowed. Decision is based on order state and outcome of risk assessment.

`application/json`

- `correlation_id` (string) — Correlation id. For searching logs.
- `error_code` (string) — Error code
- `error_messages[]` (array<string>) — Error messages

```json
{
  "correlation_id": "66782175-ae05-44fc-9eb3-eeceadbad271",
  "error_code": "NOT_ALLOWED",
  "error_messages": [
    "<string>"
  ]
}
```

### 404

Not Found

`*/*`

- `correlation_id` (string)
- `error_code` (string) Enum: `INTERNAL_ERROR`, `NOT_FOUND`, `TOO_MANY_REQUESTS`, `REFUND_NOT_ALLOWED`, `CAPTURE_NOT_ALLOWED`, `CANCEL_NOT_ALLOWED`, `UPDATE_NOT_ALLOWED`, `NO_SUCH_ORDER`, `BAD_REQUEST`, `PAYLOAD_TOO_LARGE`, `NO_SUCH_CAPTURE`, `RESOURCE_NOT_FOUND`, `INVALID_REQUEST_PARAMETERS`, `NOT_ALLOWED`, `UNSUPPORTED_MEDIA_TYPE`, `FORBIDDEN`.
- `error_messages[]` (array<string>)

```json
{
  "correlation_id": "<string>",
  "error_code": "INTERNAL_ERROR",
  "error_messages": [
    "<string>"
  ]
}
```

### 409

Conflict

`*/*`

```json
"<string>"
```

### Errors

| Code | Status | What it means | Retry |
| --- | --- | --- | --- |
| `UPDATE_NOT_ALLOWED` | 403 | The order's state or risk assessment does not allow changing its amount or address. Needs `AUTHORIZED`. | Never retry |
