# Errors

Most common API error responses are described below. Error response must be identified by **HTTP status** and **reason** attribute in your application.

Please note that specific API methods (for example [Create Payment Session](https://docs.lemanpay.net/payment-api/documentation/broken-reference)) have their own errors (e.g. 422 Unprocessable Entity - when order is not valid).

| HTTP Status                 | Reason              | Description                      |
| --------------------------- | ------------------- | -------------------------------- |
| 401 (Unauthorized)          | BadCredentials      | API credentials are not valid    |
| 404 (Not Found)             | PageNotFound        | Page, action or record not found |
| 404 (Not Found)             | RecordNotFound      | Record not found                 |
| 500 (Internal Server Error) | InternalServerError | Something wrong in our side      |
| 429 (Too Many Requests)     | RateLimitException  | API request limit is exceeded    |

### &#x20;<a href="#rest-api-error-codes" id="rest-api-error-codes"></a>

**Error Response Format**

> Example response format

```
{
    "status": "error",
    "code": "010207",
    "data": null,
    "error": "Invalid invoice state for refund"
}
```

| Name                                                 | Type     |
| ---------------------------------------------------- | -------- |
| `status`Will always be “error” for an error response | `string` |
| `code`6 digit error code                             | `string` |
| `data`Will be null for an error response             | `string` |
| `error`The error message                             | `string` |

**HTTP Method - First two digits**

| Name                            | Type     |
| ------------------------------- | -------- |
| `00xxxx`Generic, unmapped error | `string` |
| `01xxxx`POST error              | `string` |
| `02xxxx`GET error               | `string` |
| `03xxxx`PUT error               | `string` |
| `04xxxx`DELETE error            | `string` |

**Resource and Error - Last four digits**

**Unmapped Errors: xx00xx**

These errors are not mapped to a specific resource

| Name                         | Type     |
| ---------------------------- | -------- |
| `xx0000`Generic server error | `string` |
| `xx0001`Resource not found   | `string` |
| `xx0002`Invalid parameters   | `string` |
| `xx0003`Missing parameters   | `string` |

**Invoice Errors: xx01xx**

These errors are mapped to the invoice resource

| Name                                                                   | Type     |
| ---------------------------------------------------------------------- | -------- |
| `xx0100`Generic invoice error                                          | `string` |
| `xx0101`Invoice not found                                              | `string` |
| `xx0102`Invalid parameters                                             | `string` |
| `xx0103`Missing parameters                                             | `string` |
| `xx0108`Invoice is missing email or SMS                                | `string` |
| `xx0109`SMS not verified                                               | `string` |
| `xx0110`Invoice price is below minimum threshold                       | `string` |
| `xx0111`Invoice price is above maximum threshold                       | `string` |
| `xx0112`Invalid SMS number                                             | `string` |
| `xx0113`Error verifying SMS                                            | `string` |
| `xx0114`Unable to update contact information on high value transaction | `string` |
| `xx0115`Email already set on invoice                                   | `string` |
| `xx0116`Unable to perform action outside of demo environment           | `string` |
| `xx0117`Invalid invoice state                                          | `string` |
| `xx0118`Misconfigured account                                          | `string` |

**Refund Errors: xx02xx**

These errors are mapped to the refund resource

| Name                                         | Type     |
| -------------------------------------------- | -------- |
| `xx0200`Generic refund error                 | `string` |
| `xx0201`Refund not found                     | `string` |
| `xx0202`Invalid parameters                   | `string` |
| `xx0203`Missing parameters                   | `string` |
| `xx0204`Active refund request already exists | `string` |
| `xx0207`Invalid invoice state for refund     | `string` |
| `xx0208`Fees are greater than refund amount  | `string` |

<br>
