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

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

| **Status Code** |      **Response**      |                                                                           **Description**                                                                            |
|-----------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 200             | OK                     | Everything worked as expected.                                                                                                                                       |
| 201             | CREATED                | A `POST` method successfully created a resource.                                                                                                                     |
| 204             | NO CONTENT             | The server successfully executed the method but returned no response body.                                                                                           |
| 400             | BAD REQUEST            | The server cannot or will not process the request due to 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.                                                                                           |
| 409             | CONFLICT               | The request conflicts with another request (perhaps due to using the same `Idempotency-Key`).                                                                        |
| 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`. |
| 422             | UNPROCESSABLE CONTENT  | The API cannot complete the requested action, or the request action is semantically incorrect or fails business validation.                                          |

## Error Structure {#error-structure}

To ensure 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,
            "Details": "<Details of the error>"
         }
      ]
   }
}
```

|  **Field**  |                                                                                                                                                                 **Description**                                                                                                                                                                  |
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Source      | The application that generated the given error. Every error message 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 | Provides 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 succeed. However, if the error is related to some unexpected timeout with the service, retrying the call could result in a successful response. |
| Details     | Provides detailed error information wherever appropriate to help in resolving errors.                                                                                                                                                                                                                                                            |

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

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

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

## Mastercard Processing Credit API Error Codes {#mastercard-processing-credit-api-error-codes}

Note: The following error codes are specific to the Mastercard Processing Credit API. For errors with the `Source` field value as the `Gateway`, refer to [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-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                                                                                                                                                                                                                                                                               |
|---------------------------|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 400                       | AMOUNT_EXCEEDS_BALANCE                        | Deal amount specified exceeds the current balance.                                                                                                           | Adjust the value to be within the allowed limits and retry the request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 404                       | BALANCE_CODE_DOES_NOT _EXIST                  | Balance code with id \<balance_code\> not found or is 0.                                                                                                     | Verify and correct the `balance_code` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 400                       | CANNOT_CREATE_INSTALLMENT _SIMULATION         | For given parameters, the installment simulation cannot be created.                                                                                          | Ensure that all parameters are valid according to the product documentation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 400                       | CARD_IS_EXPIRED                               | Card contract with id \<contract_id\> is expired.                                                                                                            | Verify and correct the 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 a new key and reconfigure your integration accordingly.                                                                                                                                                                                                                                                                                                                                   |
| 404                       | CONTRACT_DOES_NOT_EXIST                       | Contract with id \<contract_id\> not found.                                                                                                                  | Verify and correct the `contract_id` value in the request and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 400                       | CREDIT_LIMIT_IS_MISSING                       | Credit limit is missing.                                                                                                                                     | Specify the correct value in the `contract_id` path parameter. Specified `contract_id` does not have credit limit in the CMS set so you are not able to set a new credit limit.                                                                                                                                                                                                                                                                                                                                                                                            |
| 400                       | CREDIT_LIMIT_CONFLICT                         | Only one credit limit can be set at a time.                                                                                                                  | Specify the correct value in the `limitEffectiveDate` and `limitExpirationDate` in the request body. It is not permitted to set more than one temporary limit at the same time for a specified contract.                                                                                                                                                                                                                                                                                                                                                                   |
| 400                       | DUPLICATED_CORRELATION _ID                    | The given \<X-Mc-Correlation-Id\> header was used in the previous request.                                                                                   | Specify the correct unique value in the `X-Mc-Correlation-Id` or `Correlation-Id` header, and try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 409                       | IDEMPOTENCY_KEY_ALREADY _IN_PROGRESS          | The original request with the same Idempotency Key is still being processed.                                                                                 | Ensure the original request associated with the `Idempotency-Key` is fully processed before resending another request with the same key.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 422                       | IDEMPOTENCY_KEY_ALREADY _USED                 | Idempotency Key MUST not be reused across different payloads.                                                                                                | Make sure not to reuse the `Idempotency-Key` with other request body within 24 hours from the initial request.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 400                       | INSTITUTION_CONFIGURATION _NOT_FOUND_ERROR    | User configuration was not found for id \<external user id\>.                                                                                                | Your API configuration is incorrect. Contact the Mastercard Processing representative.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 400                       | INSTALLMENT_AMOUNT_OUT _OF_BOUNDS             | "Deal amount specified exceeds current balance." or "Invalid doc amount , minimum amount is \<amount\>." or "Invalid doc amount , maximum amount is \<XX\>." | Verify the credit card with installments product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                            |
| 404                       | INSTALLMENT_CHAIN_DOES _NOT_EXIST             | Installment chain with id \<installment_chain_id\> not found.                                                                                                | Verify and correct the `installment_chain_id` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 400                       | INSTALLMENT_LIMIT_CONFLICT                    | Only one installment limit can be set at a time.                                                                                                             | Verify and correct the `limit_type_code`, `limitEffectiveDate`, and `limitExpirationDate` values in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 400                       | INSTALLMENT_NOT_ACTIVE                        | Instalment is not available for contract.                                                                                                                    | Specify the correct value in the `contract_id` path parameter and verify if the contract has active classifier ALLOW_RET_INST and/or ALLOW_CASH_INST.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 400                       | INSTALLMENT_PLAN_ALREADY _CLOSED              | The installment plan with id \<installment_chain_id\> is already closed.                                                                                     | Avoid duplicate requests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | INSTALLMENT_TOTAL_ACTIVE _PLAN_LIMIT_EXCEEDED | Installment total active plan limit exceeded.                                                                                                                | Verify the credit card with installments product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                            |
| 400                       | INVALID_FREE_PERIOD                           | Invalid free period.                                                                                                                                         | Verify the credit card with installments product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                            |
| 400                       | INVALID_DATE_FORMAT                           | Date has an invalid format. Correct format is `YYYY-MM-DD`.                                                                                                  | Specify the correct date format in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | INVALID_DATE_FORMAT                           | Date time has an 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-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | INVALID_HOLIDAY_DURATION                      | Holiday duration is too long.                                                                                                                                | Verify and correct the `holidayDuration` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| 400                       | INVALID_INSTALLMENT _SCHEME_CODE              | Installment scheme code \<installmentSchemeCode\> is invalid.                                                                                                | Verify and correct the `installmentSchemeCode` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 400                       | INVALID_INSTALLMENT _SERVICE_CODE             | Installment service code `INVALID` is invalid.                                                                                                               | Verify and correct the `installmentServiceCode` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | INVALID_PORTION_AMOUNT                        | "Invalid portion amount: tenor is too big." or Invalid portion amount \<portionAmount\>, minimum portion amount is \<XX\>.                                   | Verify the product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 400                       | INVALID_SCHEME_CODE                           | Incompatible installment scheme code.                                                                                                                        | Verify and correct the `installmentSchemeCode` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 400                       | INVALID_TARIFF_DATE                           | The given `startDate` or `endDate` has invalid value. The `endDate` must be greater or equal the `startDate` and `tariff` cannot be applied from past date.  | Verify and correct the value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 400                       | INVALID_TENOR                                 | "Invalid tenor , minimum tenor is \<XX\>." or "Invalid tenor , minimum tenor is \<XX\>."                                                                     | Verify the product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 404                       | LIMIT_TYPE_CODE _DOES_NOT_EXIST               | Limit type code \<limit_type_code\> does not exist for contract with id \<contract_id\>.                                                                     | Verify the product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 400                       | MAX_NUMBER_OF_RECORDS _EXCEEDED               | Response exceeded recordset limit.                                                                                                                           | Narrow the query so the result set stays under the default limit of 1000 records.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 400                       | NO_ACTIVE_INSTALLMENT _PLAN                   | There is no active installment with installment chain id \<installment_chain_id\>.                                                                           | Verify and correct the value in the request and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 400                       | NO_PUBLIC_KEY_FINGERPRINT                     | Cannot find `publicKeyFingerprint` value inside JWE structure.                                                                                               | Ensure that 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                       | 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-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                                 |
| 400                       | REQUEST_BODY_PROCESSING _ERROR                | There is a problem with parsing the 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-credit/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\>.                                                  | Example of Description: "Invalid field `cardContractCustomData[0].tagValue` value in object `cardContractCreation`. Validation error: Field `tagValue` contains illegal characters." Specify the correct field value defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                            |
| 400                       | REQUEST_VALIDATION                            | Invalid object %s. Validation error: \<validation description\>.                                                                                             | Example of Description: "Invalid object `addressModification`. Validation error: One of fields: email, addressLine1, addressLine2, addressLine3, addressLine4 must be set." Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                             |
| 400                       | REQUEST_VALIDATION                            | Validation error: \<validation description\>.                                                                                                                | Example of Description: "Validation error: The header `Customer-Public-Rsa-Key` is invalid." Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                            |
| 400                       | REQUEST_VALIDATION                            | Missing required HTTP header \<header name\>.                                                                                                                | Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                         |
| 400                       | REQUEST_VALIDATION                            | Missing required request parameter \<parameter name\>.                                                                                                       | Specify the correct data in the request defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-credit/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                                         |
| 400                       | TARIFF_CODE_DOES_NOT _EXIST                   | The given tariff code \<tariffCode\> does not exist.                                                                                                         | Verify and correct the `tariffCode` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 404                       | TRANSACTION_DOES_NOT _EXIST                   | Transaction with id \<transaction_id\> not found.                                                                                                            | Verify and correct the `transaction_id` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 400                       | TRANSACTION_INSTALLMENT _PLAN_ALREADY_ACTIVE  | Another installment plan is active for transaction with id \<transaction_id\>.                                                                               | Avoid duplicate requests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | TRANSACTION_NOT_ALLOWED                       | "Transaction type is not allowed, see Instalment Scheme Groups." or "Transaction belongs to a closed billing cycle."                                         | Verify the product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 400                       | UNPAID_PRINCIPAL_AMOUNT _EXCEEDED             | Unpaid principal amount limit exceeded.                                                                                                                      | Verify the product configuration that you requested during the onboarding process in the Product Parameterization Workbook (PPW).                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| 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-credit/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}

Sample error response when sending a `PUT` request to the `/contracts/123/credit-limit` endpoint to set a new credit limit for not existing contract in the CMS:

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "MASTERCARD PROCESSING",
        "ReasonCode": "CARD_CONTRACT_DOES_NOT_EXIST",
        "Description": "Card contract with id 123 not found.",
        "Recoverable": false
      }
    ]
  }
}
```

