# Error codes

Error codes and troubleshooting guidance for the Spend API.

This page lists the possible errors associated with the HTTP 400 status code while managing card expenses, reimbursements, vendors, purchase orders, and bills via the Spend API endpoints.

For 400 errors, the response contains a `code` specifying the error encountered, a `message` about the error, and a `source` providing additional context.

## General errors with example response

A general error provides an error response with `code`, `message`, and `source`. The response contains:

- `code`: Unique identifier of the specific validation error encountered.
- `message`: A message about the specific error encountered.
- `source`: The specific field or object within the request that failed.

**Example:**

```json
{
  "code": "invalid_argument",
  "message": "sync_status must be one of NOT_SYNCED, SYNCED, SYNC_FAILED, READY_TO_SYNC.",
  "source": "sync_status"
}
```

## Card expense errors

Error codes for [List card expenses](https://www.airwallex.com/docs/api/spend/expenses/list.md), [Get card expense](https://www.airwallex.com/docs/api/spend/expenses/retrieve.md), and [Sync card expense](https://www.airwallex.com/docs/api/spend/expenses/sync.md).

| **Code**             | **Description**                                                  | **Next steps**                                                    |
| -------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------- |
| `invalid_argument`   | A provided argument has an incorrect type or failed validation.  | See the `message` and `source` in the response for details.       |
| `resource_not_found` | The specified expense ID does not exist.                         | Verify the expense ID and try again.                              |
| `invalid_request`    | The expense cannot be transitioned to the requested sync status. | Check the current sync status and verify the transition is valid. |

## Reimbursement errors

Error codes for [List reimbursement reports](https://www.airwallex.com/docs/api/spend/reimbursements/reimbursement_reports.md), [Get reimbursement report](https://www.airwallex.com/docs/api/spend/reimbursements/retrieve_reimbursement_reports.md), [Sync reimbursement report](https://www.airwallex.com/docs/api/spend/reimbursements/sync_reimbursement_reports.md), and [Mark reimbursement as paid](https://www.airwallex.com/docs/api/spend/reimbursements/mark_as_paid_reimbursement_reports.md).

| **Code**             | **Description**                                                   | **Next steps**                                               |
| -------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------ |
| `invalid_argument`   | A provided argument has an incorrect type or failed validation.   | See the `message` and `source` in the response for details.  |
| `resource_not_found` | The specified reimbursement ID does not exist.                    | Verify the reimbursement ID and try again.                   |
| `invalid_request`    | The reimbursement cannot be transitioned to the requested status. | Check the current status and verify the transition is valid. |

## Vendor errors

Error codes for [Create vendor](https://www.airwallex.com/docs/api/spend/vendors/create.md), [Update vendor](https://www.airwallex.com/docs/api/spend/vendors/sync.md), [List vendors](https://www.airwallex.com/docs/api/spend/vendors/list.md) and [Get vendor](https://www.airwallex.com/docs/api/spend/vendors/retrieve.md).

| **Code**             | **Description**                                                 | **Next steps**                                              |
| -------------------- | --------------------------------------------------------------- | ----------------------------------------------------------- |
| `invalid_argument`   | A provided argument has an incorrect type or failed validation. | See the `message` and `source` in the response for details. |
| `resource_not_found` | The specified vendor ID does not exist.                         | Verify the vendor ID and try again.                         |

## Purchase order errors

Error codes for [Create purchase order](https://www.airwallex.com/docs/api/spend/purchase_orders/create.md), [Update purchase order](https://www.airwallex.com/docs/api/spend/purchase_orders/sync.md), [List purchase orders](https://www.airwallex.com/docs/api/spend/purchase_orders/list.md) and [Get purchase order](https://www.airwallex.com/docs/api/spend/purchase_orders/retrieve.md).

| **Code**             | **Description**                                                 | **Next steps**                                              |
| -------------------- | --------------------------------------------------------------- | ----------------------------------------------------------- |
| `invalid_argument`   | A provided argument has an incorrect type or failed validation. | See the `message` and `source` in the response for details. |
| `resource_not_found` | The specified purchase order ID does not exist.                 | Verify the purchase order ID and try again.                 |

## Bill errors

Error codes for [List bills](https://www.airwallex.com/docs/api/spend/bills/list.md), [Get bill](https://www.airwallex.com/docs/api/spend/bills/retrieve.md), and [Update bill](https://www.airwallex.com/docs/api/spend/bills/sync.md).

| **Code**             | **Description**                                                 | **Next steps**                                              |
| -------------------- | --------------------------------------------------------------- | ----------------------------------------------------------- |
| `invalid_argument`   | A provided argument has an incorrect type or failed validation. | See the `message` and `source` in the response for details. |
| `resource_not_found` | The specified bill ID does not exist.                           | Verify the bill ID and try again.                           |