---
id: reauthorize
title: "Reauthorize order"
sidebar_label: Reauthorize order
hide_title: true
description: "Management API - Orders - Reauthorize order"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Ingress from "../../../src/components/ingress/ingress.react";
import Idempotency from "../idempotency.mdx";

<Ingress title="Reauthorize order">
  Order items that have not yet been captured can be changed with the reauthorize
  endpoint. Already captured items won't be affected by the reauthorize call.
</Ingress>

:::note Raising the amount has extra conditions
Only credit payment methods allow an increase, and only on orders with status `NotActivated` or
`PartActivated`. Prepaid options do not support raising the amount after the original purchase.
See [Order lifecycle](/docs/manage/concepts/order-lifecycle) for what each status allows.
:::

## Examples

### Reauthorize order with items

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'res', }
]}>

<TabItem value="req">

```http
POST /manage/orders/{{orderId}}/reauthorize HTTP/1.1
Host: api.uat.walleydev.com // Test environment. Production uses a different hostname.
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "amount": 285.0,
  "actionReference": "test-captureref-123",
  "items": [
    {
      "id": "10001",
      "description": "Shoes",
      "unitPrice": 95,
      "quantity": 1,
      "vat": 25
    },
    {
      "id": "10002",
      "description": "T-Shirt",
      "unitPrice": 95,
      "quantity": 2,
      "vat": 25
    }
  ]
}
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 202 Accepted
Location: /manage/orders/1b1f5ef6-92n1-4b46-b1dc-ae2e00c4c315

/* No body */
```

</TabItem>

</Tabs>

### Reauthorize order with amount

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'res', }
]}>

<TabItem value="req">

```http
POST /manage/orders/{{orderId}}/reauthorize HTTP/1.1
Host: api.uat.walleydev.com // Test environment. Production uses a different hostname.
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "amount": 280.0,
  "actionReference": "test-captureref-123"
}
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 202 Accepted
Location: /manage/orders/1b1f5ef6-92n1-4b46-b1dc-ae2e00c4c315

/* No body */
```

</TabItem>

</Tabs>

### Reauthorize order with increased amount

Orders in the state `NotActivated` can be increased using the reauthorize endpoint.
When an order is reauthorized with an increased amount, an additional credit check is required.

The endpoint will return a 201 status code with a location header to check the status of the reauthorize call.
This process may potentially involve authorization from the customer.

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'creditcheck', }
]}>

<TabItem value="req">

```http
POST /manage/orders/{{orderId}}/reauthorize HTTP/1.1
Host: api.uat.walleydev.com // Test environment. Production uses a different hostname.
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "amount": 380.0,
  "actionReference": "test-captureref-123",
  "items": [
    {
      "id": "10001",
      "description": "Shoes",
      "unitPrice": 95,
      "quantity": 2,
      "vat": 25
    },
    {
      "id": "10002",
      "description": "T-Shirt",
      "unitPrice": 95,
      "quantity": 2,
      "vat": 25
    }
  ]
}
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 202 Accepted
Location: /manage/orders/1b1f5ef6-92n1-4b46-b1dc-ae2e00c4c315

/* No body */
```

</TabItem>

<TabItem value="creditcheck">

```http
HTTP/1.1 201 Created
Location: /manage/orders/b6be7ec0-311b-490d-8856-af8d00c783b5/reauthorize/1b1f5ef6-92n1-4b46-b1dc-ae2e00c4c315


/* No body */
```

</TabItem>

</Tabs>

<br />

These HTTP status codes are valid for the POST `reauthorize` request.

| Http status code | Description                                                                                                    |
| ---------------- | -------------------------------------------------------------------------------------------------------------- |
| 201              | Reauthorization started and needs a credit check. Poll the `Location` header. See [Get reauthorized status](#get-reauthorized-status) |
| 202              | Reauthorization accepted                                                                                       |
| 401              | Token missing, expired, or invalid                                                                             |
| 403              | No permission for this store, or the order has not finished syncing                                            |
| 404              | Order not found, or the order has not finished syncing                                                         |
| 409              | A request with the same idempotency key is already in progress                                                 |
| 422              | Validation or state error. See [error codes](/docs/manage/orders/reauthorize#error-codes)                      |

See [Errors](/docs/manage/errors) for what to do about each of these.

<br />

### Get reauthorized status

Use this endpoint to poll for the status of a reauthorized call that responded with a 201 status code.
Retrieve `reauthorizeId` from the location header in the 201 response.

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'res', }
]}>

<TabItem value="req">

```http
GET /manage/orders/{{orderId}}/reauthorize/{{reauthorizeId}} HTTP/1.1
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
      "id": "ca81364e-895f-4250-bdb2-a9dafa13c4bc",
      "orderId": "b2be7nc0-351b-890d-8856-af8d00a783b5",
      "status": "Completed",
      "createdAt": "2023-01-17T12:09:27.029057+00:00"
  },
  "links": {},
  "metaData": {}
}
```

</TabItem>

</Tabs>

| Http status code | Description                    |
| ---------------- | ------------------------------ |
| 200              | Reauthorize found              |
| 404              | Order or reauthorize not found |

<br />

## Data Model

### Request

#### Request headers

| Header            | Required | Explanation                                                                                                             |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Authorization** | Yes      | See [Authentication](/docs/manage/getting-started/authentication) for how to generate the Bearer token value |

#### Request body

| Property            | Required | Explanation                                                                                                 | Type   | Notes                                                                                 |
| ------------------- | -------- | ----------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------- |
| **amount**          | Yes      | The new amount to authorize. If you send order items, it must match their total.                            | number | Maximum 2 decimals                                                                    |
| **description**     | No       | A description for the reauthorization. Used as the description when you send no order items.                | string | Visible on invoices if applicable. Maximum 50 characters                              |
| **actionReference** | No       | A reference to this specific reauthorization.                                                                   | string | This will appear as a data property on the settlement report. Maximum 255 characters. |
| **items**           | No       | The article items and quantity to authorize.                                                                | array  | [Reauthorize Item](/docs/manage/orders/models/reauthorize-item)                       |

If you are doing a reauthorize with items, you will have to provide [items in the request](/docs/manage/orders/models/reauthorize-item).

<br />

### Response

`202 Accepted` indicates a successful reauthorization when the amount is the same or lower than the original order.<br />
`201 Created` indicates that an additional status check is needed when the reauthorization amount is higher than the original order.

:::note The reauthorization is not live yet
`202` means Walley accepted the request, not that it has been applied. Reading the order back right
away usually returns the old version. See
[Asynchronous operations](/docs/manage/concepts/asynchronous-operations) for how to read the result
and retry safely.
:::

#### Response body

| Property      | Explanation                                                                                                                                               | Type   |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| **id**        | The id of the reauthorization                                                                                                                             | string |
| **orderId**   | The orderId affected by the reauthorization                                                                                                               | string |
| **status**    | `Completed` for a successfully completed reauthorize. `Failed` for example when a credit check was denied or additional household income data was needed. | string |
| **createdAt** | The timestamp of the reauthorization                                                                                                                      | date   |

<br />

### Error codes

#### Change order

| Code                                                                  | Message                                                        |
| --------------------------------------------------------------------- | -------------------------------------------------------------- |
| REAUTHORIZE_ORDER_ALREADY_CAPTURED                                    | You cannot reauthorize an already fully captured order         |
| REAUTHORIZE_MATCHING_ARTICLES_WITH_DIFFERENT_VAT                      | Request inclueds identical articles with mismatched VAT        |
| REAUTHORIZE_ARTICLE_EXISTS_BUT_OTHER_INFORMATION                      | Request inclueds identical articles with mismatched unit price |
| REAUTHORIZE_ORDER_INCREASE_ABOVE_CURRENT_TOTAL_AMOUNT_IS_NOT_ALLOWED  | Total amount must be less than or equal to original amount     |
| REAUTHORIZE_AMOUNT_MUST_BE_GREATER_THAN_ZERO                          | Total amount must be positive                                  |
| REAUTHORIZE_AMOUNT_MUST_MATCH_SUM_OF_ARTICLES                         | Total amount must match article amount                         |
| REAUTHORIZE_AMOUNT_HAS_TOO_MANY_DECIMALS                              | Total amount have too many decimals                            |
| REAUTHORIZE_DESCRIPTION_TOO_LONG                                      | Description have a max limit of 50 characters                  |
| REAUTHORIZE_ID_TOO_LONG                                               | Item Id have a max limit of 50 characters                      |
| REAUTHORIZE_UNIT_PRICE_HAS_TOO_MANY_DECIMALS                          | Item Unit Price has too many decimals                          |
| REAUTHORIZE_QUANTITY_MUST_BE_GREATER_THAN_ZERO                        | Item Quantity must be greater than zero                        |
| REAUTHORIZE_VAT_MUST_BE_GREATER_THAN_ZERO                             | Item Vat must be greater than zero                             |
| REAUTHORIZE_INVALID_INVOICE_STATUS                                    | You cannot reauthorize an order in state closed or expired     |
| REAUTHORIZE_INCREASED_AMOUNT_NOT_AVAILABLE_FOR_PREPAID_PAYMENT_METHOD | It is not possible to increase order amount on prepaid orders  |

<Idempotency />
