# Code and Formats
source: https://developer.mastercard.com/merchant-self-services/documentation/code-and-formats/index.md

## Error Codes {#error-codes}

### Error Structure {#error-structure}

The Merchant Self Services API returns errors in the following structure.

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "<source>",
        "ReasonCode": "<unique code>",
        "Description": "<short description of the error>",
        "Recoverable": true/false,
        "Details": "<Optional detailed description of the issue>"
      }
    ]
  }
}
```

## HTTP Response Status Codes {#http-response-status-codes}

| Status code |       Response       |                                                                                                                                                                                                 Description                                                                                                                                                                                                 |
|-------------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 200         | OK                   | The request has succeeded and the response includes a payload.                                                                                                                                                                                                                                                                                                                                              |
| 400         | BAD REQUEST          | Applicable for any request errors, whether outside or inside the array/list. As soon as a request error is encountered within an individual element of the request array/list, this HTTP response status is returned with no response payload. See [400 Bad Request](https://developer.mastercard.com/merchant-self-services/documentation/code-and-formats/index.md#400-bad-request) for more information. |
| 401         | UNAUTHORIZED         | Missing or invalid authentication token. Also returned if the client ID in the request doesn't correspond to any member in the system.                                                                                                                                                                                                                                                                      |
| 403         | FORBIDDEN            | The user isn't authorized to perform the operation or the resource is unavailable for some reason, such as time constraints or if the resource being operated doesn't belong to the member.                                                                                                                                                                                                                 |
| 404         | NOT FOUND            | The requested resource could not be found.                                                                                                                                                                                                                                                                                                                                                                  |
| 405         | METHOD NOT ALLOWED   | The method --- such as POST, PUT, GET or DELETE --- specified in the Request-Line isn't allowed for the resource identified by the Request-URI.                                                                                                                                                                                                                                                             |
| 415         | UNSUPPORTED          | The server does not support the request payload's media type.                                                                                                                                                                                                                                                                                                                                               |
| 422         | UNPROCESSABLE ENTITY | The server understands the content type of the request entity, and the syntax of the request entity is correct. But the server wasn't able to process the contained instructions due to other reasons, such as validation errors.                                                                                                                                                                           |
| 429         | TOO MANY REQUESTS    | Too many requests hit the API too quickly.                                                                                                                                                                                                                                                                                                                                                                  |

## API Specific Error Codes {#api-specific-error-codes}

### 400 Bad Request {#400-bad-request}

A 400 Bad Request Error indicates that we can't process your request, most likely due to an issue on your side. In these instances, we'll return an error code and message explaining the error.

This table shows the code and message you will receive and steps you can take to resolve the error.

|       Reason Code       |                                                                 Description                                                                  |                     How to resolve                     |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
| `InvalidData`           | A field or set of fields fails a validation. The `InvalidData` response is returned for each invalid field with HTTP Status code 400.        | Provide a valid field or set of fields for each error. |
| `InvalidParameterSet`   | Request body is malformed or missing.                                                                                                        | Provide a valid request body.                          |
| `FormatInvalid`         | A field isn't correctly formatted. An example of an incorrectly formatted field would be if a String value is sent in an Integer type field. | Provide a correctly formatted field.                   |
| `MissingRequiredHeader` | Required request header is missing or null                                                                                                   | Request header must be provided and must not be null.  |
| `ParameterInvalid`      | A path or query parameter isn't valid. An example of an invalid parameter would be if a String value is passed in an Integer type parameter. | Provide a valid path or query parameter.               |
| `QueryStringMissing`    | A required query string parameter is missing from the request.                                                                               | Provide the required query string parameter.           |

## Gateway Errors {#gateway-errors}

For more information about 4xx/5xx response codes and possible resolutions, see [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/).
