> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wizcommerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error codes

> This section outlines the error response format used in our API. When an error occurs, the API will return a structured JSON response to provide detailed information about the problem.

## ErrorResponse Structure

The `ErrorResponse` is a JSON object that contains the following fields:

* **`code`**: A string representing the error code. This field helps to identify the type of error.
* **`message`**: A string that provides a human-readable description of the error.
* **`details`** *(optional)*: An optional array that provides additional context or information about the error, often with specific details related to the failed request.

## Error Response

### Invalid Request (400)

A request is invalid, often due to missing or incorrect parameters.

```json theme={null}
{
  "code": "INVALID_REQUEST",
  "message": "The request data is invalid.",
  "details": [
    {
      "field": "email",
      "error": "Invalid email format"
    }
  ]
}
```

### Not Found (404)

The requested resource could not be found.

```json theme={null}
{
  "code": "NOT_FOUND",
  "message": "The requested user was not found.",
  "details": null
}
```

### Conflict (409)

There was a conflict when attempting to create or update a resource.

```json theme={null}
{
  "code": "CONFLICT",
  "message": "Email address already in use.",
  "details": [
    {
      "field": "email",
      "error": "This email address is already associated with an existing user."
    }
  ]
}
```

### Internal Server Error (500)

An unexpected error occurred on the server while processing the request.

```json theme={null}
{
  "code": "INTERNAL_ERROR",
  "message": "An internal server error occurred.",
  "details": null
}
```

## Common Error Codes

Below is a list of common error codes you may encounter in the API responses:

| **Code**              | **Message**                                                                                           | **Description**                                                    |
| --------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `INVALID_REQUEST`     | The request data is invalid.                                                                          | The request was malformed or had invalid parameters.               |
| `NOT_FOUND`           | The resource was not found.                                                                           | The requested resource could not be found.                         |
| `CONFLICT`            | Conflict with existing data.                                                                          | A conflict occurred with existing data (e.g., duplicate resource). |
| `UNAUTHORIZED`        | You are not authorized to access this resource.                                                       | The client lacks proper authentication.                            |
| `FORBIDDEN`           | You do not have permission.                                                                           | The client does not have permission to perform the operation.      |
| `INTERNAL_ERROR`      | An internal error occurred.                                                                           | A server-side error occurred during request processing.            |
| `BAD_GATEWAY`         | The server is acting as a gateway or proxy and received an invalid response from the upstream server. | The server could not communicate with upstream services.           |
| `GATEWAY_TIMEOUT`     | The server did not receive a timely response from the upstream server.                                | A timeout occurred when contacting upstream services.              |
| `SERVICE_UNAVAILABLE` | The service is temporarily unavailable.                                                               | The service is currently unavailable, possibly due to maintenance. |
