# Errors

The Banking API uses the  RFC 7807 Problem Details
specification to indicate the failure of an API request.

## Failed Requests (4xx)

| Status Code | Description |
|  --- | --- |
| `400 Bad Request` | The request was unacceptable, usually due to missing a required parameter. See [bad-request](#bad-request). |
| `401 Unauthorized` | The access token could not be authenticated or a consent is no longer authorized for use. |
| `403 Fobidden` | The access token did not have permissions to perform the request. |
| `404 Not Found` | The requested resource was not found. |
| `405 Method Not Allowed` | The request method is known by the server but is not supported by the target resource. Example: `PATCH`. |
| `406 Not Acceptable` | The server cannot use the client-request media type to return the response payload. (The request is most likely missing an `Accept: application/json` header.) |
| `409 Conflict` | The request conflicts with the current state of the server. (Most likely due to a resource that already exists.) |
| `415 Unsupported Media Type` | The media format of the requested data is not supported by the server. (The request is most likely missing a `Content-Type: application/json` header.) |
| `429 Too Many Requests` | Too many requests in a given amount of time. |


## Server Error Responses (5xx)

| Status Code | Description |
|  --- | --- |
| `500 Internal Server Error` | An unhandeled system or application error occurred. |
| `501 Not Implemented` | The request method is not supported by the server and cannot be handled. (Most likely due to a feature that has not been implemented yet.) |
| `503 Service Unavailable` | The server is not ready to handle the request. (The server might be overloaded or down for maintenance.) |
| `504 Gateway Timeout` | This error response is given when the server is acting as a gateway and cannot get a response in time. (Most likely due to an unavailable bank.) |


## Error Types

The different types of problem types returned by the Banking API.

### access-unauthorized

The bearer token is invalid or has expired.

### access-forbidden

Access to the resource was denied, the bearer token may have insufficient scopes.

### access-exhausted

Access to resource was refused because of too many requests in a period of time.

### bad-request

Unable to process the request due to missing or invalid data.

For validation errors, the Banking API returns a Problem Details response and the HTTP `400 Bad Request` response.
The response body will contain an `errors` field that contains a list all the validation errors that occurred.
Each item in the `errors` list indicates the name of the parameter that failed validation, and lists the reasons why the validation failed for that parameter.

```json
{
    "type": "https://developer.zdata.io/apis/banking/development/errors#bad-request",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-948c3730606c7ffa7079b4312c308c78-de7f8c2ce5b5c609-01",
    "errors": {
        "dateFrom": "The dateFrom field is required.",
        "bookingStatus": "The bookingStatus field is required."
    }
}
```

### consent-invalid

The consent is not valid, verify the status and refresh or create a new one if needed.

### not-found

Unable to find the requested resource.

```json
{
  "type": "https://developer.zdata.io/apis/banking/development/errors#not-found",
  "title": "Consent not found",
  "status": 404,
  "traceId": "00-b59a0e52f70db760dde2395863c56103-95cf6e8eb21a0aa4-01"
}
```

### timeout

The request timed out waiting for a response.

### unavailable

The requested service is unavailable.

### unknown

The cause of the problem is unknown.