# Code and Formats
source: https://developer.mastercard.com/mastercard-processing-dispute/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.                                                                                                                     |
| 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 provide a consistent experience across all Mastercard APIs, the Mastercard Processing Dispute 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 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 Dispute 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 succeed. 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 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 Error Codes {#mastercard-processing-error-codes}

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

| HTTP Response Status Code |              **Reason Code**               |                                                        **Description**                                                        |                                                                                                                                                                                                                                                                             **How to Resolve**                                                                                                                                                                                                                                                                              |
|---------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 400                       | ANOTHER_OPEN_CASE _ALREADY_EXISTS          | Another open case with id \<caseId\> for the financial transaction with id \<financialDocumentId\> already exists.            | Verify and correct the `financialDocumentId` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 404                       | CASE_DOES_NOT_EXIST                        | Case with id \<case_id\> not found.                                                                                           | Verify and correct the `case_id` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400                       | CASE_SIZE_EXCEEDED                         | Attached files size for the case with id \<case_id\> exceeds the limit.                                                       | The maximum allowed size of all files for a specified case is 15 MB.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 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.                                                                                                                                                                                                                                                                                                                                    |
| 400                       | DOCUMENT_NOT_FOUND                         | For given transaction record id \<financialDocumentId\> document not found.                                                   | Verify and correct the `financialDocumentId` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 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 then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 409                       | IDEMPOTENCY_KEY _ALREADY_IN_PROGRESS       | 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                       | INVALID_FILE_FORMAT                        | Not allowed file format.                                                                                                      | DAM accepts following file formats pdf, jpg, jpeg, tif, and tiff.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 404                       | 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 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                       | INVALID_REASON_CODE                        | The given reason code \<reasonCode\> is not supported.                                                                        | Verify and correct the `reasonCode` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 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                       | NON_FINANCIAL_DOCUMENT                     | Cannot create a case for non-financial document.                                                                              | Verify and correct the `financialDocumentId` value in the request, and then try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 400                       | NOT_ACTIVE_CASE                            | Case with id \<case_id\> is not active.                                                                                       | You cannot add any file to a case that is not in active state in DAM.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 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-dispute/documentation/api-reference/index.md), and try again.                                                                                                                                                                                                                                                                                                                                                               |
| 400                       | REQUEST_BODY_PROCESSING _ERROR             | The given field has invalid value.                                                                                            | 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-dispute/documentation/api-reference/index.md). 3. Sending an invalid JSON body. |
| 400                       | REQUEST_BODY_PROCESSING_ERROR              | There is a problem with parsing request body.                                                                                 | The request body is not a valid JSON object. Specify the JSON request body and try again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 400                       | REQUEST_VALIDATION                         | Invalid field \<field name\> value in object \<object name\>. Validation error: \<validation description\>.                   | Example of Description: "Invalid field `commentText` value in object `DisputeCaseTrustedAmountCreation`. Validation error: Field `commentText` contains illegal characters." Specify the correct field value defined in the [OpenAPI Specification](https://developer.mastercard.com/mastercard-processing-dispute/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-dispute/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 of the error response when you send a `GET` request to the `/case/{case_id}` endpoint for a non-existent case.

```json
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "CASE_DOES_NOT_EXIST",
                "Description": "Case with ID 10001 not found.",
                "Recoverable": false
            }
        ]
    }
}
```

The following is a sample of the error response when you try to add file with an invalid format to a case by sending a `POST` request to the `/case/{case_id}/attachments` endpoint:

```json
{
    "Errors": {
        "Error": [
            {
                "Source": "MASTERCARD PROCESSING",
                "ReasonCode": "INVALID_FILE_FORMAT",
                "Description": "Not allowed file format.",
                "Recoverable": false
            }
        ]
    }
}
```

