# Code and Formats
source: https://developer.mastercard.com/mastercard-processing-debit/documentation/code-and-formats/index.md

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

| **Status Code** |      **Response**      |                                                                           **Description**                                                                            |
|-----------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 204             | NO CONTENT             | The server successfully executed the method but returned no response body.                                                                                           |
| 400             | BAD REQUEST            | Server cannot or will not process the request due its invalid structure or data.                                                                                     |
| 401             | UNAUTHORIZED           | The user does not have access to the service.                                                                                                                        |
| 403             | FORBIDDEN              | The user is not authorized to perform the operation.                                                                                                                 |
| 404             | NOT FOUND              | The requested resource does not exist.                                                                                                                               |
| 405             | METHOD NOT ALLOWED     | The requested URL exists, but the requested HTTP method is not applicable.                                                                                           |
| 415             | UNSUPPORTED MEDIA TYPE | The server does not support the request payload's media type. For the Mastercard Processing API, the `Content-Type` header must be `application/json;charset=utf-8`. |

## Error Structure {#error-structure}

To provide a consistent experience across all Mastercard APIs, the Mastercard Processing API follows the standard structure for each scenario that can occur.

Mastercard returns errors in the following structure:

```json
{
   "Errors":{
      "Error":[
         {
            "Source":"<Source of the issue>",
            "ReasonCode":"<Unique code>",
            "Description":"<Description of the error>",
            "Recoverable": true/false,
         }
      ]
   }
}
```

|  **Field**  |                                                                                                                                                                       **Description**                                                                                                                                                                       |
|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Source      | The application that generated the given error. Every error message that is generated and returned by the Gateway will have this field equal to `Gateway`. If the field value is `MASTERCARD PROCESSING`, it means that an error was generated by the Mastercard Processing application.                                                                    |
| ReasonCode  | Identifies the error case encountered when any Mastercard Processing API is called. For example, `REQUEST_VALIDATION` is used when the request is invalid due to some missing or invalid parameters.                                                                                                                                                        |
| Description | Description of the `ReasonCode` field with additional details.                                                                                                                                                                                                                                                                                              |
| Recoverable | Indicates whether this error will always be returned for this request, or retrying can change the outcome. For example, if the request contains an invalid request parameter, retrying will never result in success. However, if the error is related to some unexpected timeout with the service, retrying the call could result in a successful response. |

## Gateway Error Codes {#gateway-error-codes}

In addition to service error codes, error codes can also be returned by Mastercard's gateway. A gateway is used to verify your request's signature and route it to the correct location.

You can find a list of the errors returned by our Gateway and resolutions on the [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/) page.

## Mastercard Processing Error Codes {#mastercard-processing-error-codes}

For a complete list of Mastercard Processing application-specific error codes, refer to the following table:

| **HTTP Response Status Code** |          **Reason Code**           |                                                        **Description**                                                        |                                                                                                                                                                                                                                                                            **How to Resolve**                                                                                                                                                                                                                                                                             |
|-------------------------------|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 404                           | ACCOUNT_CONTRACT_DOES _NOT_EXIST   | Account contract with id \<account_contract_id\> not found.                                                                   | Verify and correct the `account_contract_id` value in the request and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 400                           | CERTIFICATE_NOT_FOUND              | Cannot find response encryption key for fingerprint \<public fingerprint\> and client id \<Mastercard Developers Client ID\>. | Check the Mastercard Encryption Key associated with the provided Client ID in your Mastercard Developers project to ensure it is valid and has not expired. If expired, generate new key and reconfigure your integration accordingly.                                                                                                                                                                                                                                                                                                                                    |
| 400                           | DUPLICATED_X_MC _CORRELATION_ID    | The given `X-Mc-Correlation-Id` header was used in previous request.                                                          | Specify the correct unique value in the `X-Mc-Correlation-Id` or `Correlation-Id` header, and try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400                           | INVALID_DATE_FORMAT                | Date time has invalid format. Correct format is `YYYY-MM-DDThh:mm:ssZ`.                                                       | Specify the correct date format in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                  |
| 500                           | INVALID_INSTITUTION _CONFIGURATION | Incorrect Officer ID in the API configuration.                                                                                | Contact the Mastercard Processing representative to resolve an Officer ID mismatch between the API and the CMS.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 400                           | NO_PUBLIC_KEY_FINGERPRINT          | Cannot find `publicKeyFingerprint` value inside JWE structure.                                                                | Ensure the public key fingerprint value is correctly included in the JWE structure. Refer to the [documentation](https://developer.mastercard.com/platform/documentation/authentication/securing-sensitive-data-using-payload-encryption/#jwe-encryption) for detailed guidance on JSON Web Encryption used by Mastercard.                                                                                                                                                                                                                                                |
| 400                           | NOT_ACCOUNT_CONTRACT               | Contract with id \<contract_id\> is not an account.                                                                           | Verify and correct the `contract_id` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 403                           | OPERATION_DENIED                   | Operation \<operationId\> is disabled in your API configuration.                                                              | Contact the Mastercard Processing representative if you want to use the operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 403                           | OPERATION_DENIED                   | Invalid or unsupported operation. Verify HTTP method, endpoint, and resource ID format.                                       | Make sure you are calling the correct endpoint as defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                               |
| 400                           | REQUEST_BODY_PROCESSING _ERROR     | The given field \<field name\> has invalid value.                                                                             | Specify the correct field value defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                                 |
| 400                           | REQUEST_BODY_PROCESSING _ERROR     | There is a problem with parsing request body.                                                                                 | The three most common causes are: 1. Sending an unencrypted payload while the API expects a JWE payload (as specified [here](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption/#breaking-the-encrypted-payload-down)). 2. Sending a valid JWE payload, but the decrypted JSON does not match the API model defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md). 3. Sending an invalid JSON body. |
| 400                           | REQUEST_VALIDATION                 | Invalid field \<field name\> value in object \<object name\>. Validation error: \<validation description\>.                   | Specify the correct field value defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                                 |
| 400                           | SCALE_IS_NOT_SUPPORTED             | Actual scale of precision: \<scale\> is not supported for \<field name\> field in request body.                               | Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                         |
| 415                           | UNSUPPORTED_CHARSET_ERROR          | Charset \<charset\> is not supported. Only UTF-8 charset is supported.                                                        | Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-debit/documentation/api-reference/index.md), and try again. For the Mastercard Processing API, the `Content-Type` header must be `application/json;charset=utf-8`.                                                                                                                                                                                                                                                                  |

### Sample Errors {#sample-errors}

The following is a sample error response when updating STIP balance for an account contract by sending a `PUT` request to the `/accounts/101223/stip-balance` endpoint:

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "NOT_ACCOUNT_CONTRACT",
        "Description": "Contract with id 101223 is not an account.",
        "Recoverable": false
      }
    ]
  }
}
```

