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

## Error Handling {#error-handling}

Consumer Credit Analytics API uses standard HTTP response codes for success and failure notifications. The errors are further classified by error type as follows:

* 200 code corresponds to success
* 40X codes for developer or user-related failures
* 50X codes for Mastercard related issues

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

Apart from the error codes returned by the Consumer Credit Analytics API, error codes can be returned by the Mastercard gateway, which verifies your request's signature and routes to the correct location.

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

## Error Structure {#error-structure}

**Single Error:**

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "ConsumerCreditAnalytics",
        "ReasonCode": "MISSING_REQUIRED_FIELD",
        "Description": "The parameter is required but not provided.",
        "Recoverable": false,
        "Details": "The countryCode parameter is required but was not provided."
      }
    ]
  }
}
```

|      Field      |                                                                                                                                                                          Description                                                                                                                                                                          |
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Source**      | The application that generated this error. Every error message that is generated and returned by the Gateway will have this field equal to Gateway. If the field value is "ConsumerCreditAnalytics", then the error is generated by the Consumer Credit Analytics (CCA) application.                                                                          |
| **ReasonCode**  | A unique constant identifying the error case encountered when the Consumer Credit Analytics (CCA) API is called. For example, parameter.hasConsent.invalid 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 could 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. |
| **Details**     | Provide detailed error information wherever appropriate to help in resolving errors.                                                                                                                                                                                                                                                                          |

## Consumer Credit Analytics API Errors {#consumer-credit-analytics-api-errors}

| Response Code |      Reason Code       |       Error Code       |                                                                               Description                                                                                |                                                           Tip to Resolve                                                            |
|---------------|------------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| 400           | BAD REQUEST            | MISSING_REQUIRED_FIELD | The parameter is required but not provided.                                                                                                                              | Pass the missing parameter.                                                                                                         |
| 400           | BAD REQUEST            | INVALID_FIELD_VALUE    | This error is thrown when an argument passed to the API doesn't pass validation.                                                                                         | Pass a valid value to the specified parameter.                                                                                      |
| 400           | BAD REQUEST            | MAXIMUM_LIMIT_EXCEEDED | This error is thrown when PAN list size exceed max allowed number.                                                                                                       | The maximum list size of customerPAN (or Card Number) input exceeded. Input list must be within allowed limit of - \[20\]           |
| 400           | BAD REQUEST            | BAD REQUEST            | This error is thrown when request is not well-formed, or syntactically incorrect.                                                                                        | This request was rejected because the data passed in API is not in the expected format, or the request is empty.                    |
| 404           | NOT FOUND              | NOT FOUND              | This error is thrown when when a PAN number is not found in Mastercard's database. Check with the consumer for alternate primary Mastercard Debit or Credit Card Number. | Check with the consumer for alternative Mastercard Card Number.                                                                     |
| 415           | UNSUPPORTED_MEDIA_TYPE | INVALID_FORMAT         | This error is thrown when JSON content is missing in the request.                                                                                                        | This request was rejected because request is not in JSON format. Ensure you use JSON to send request.                               |
| 500           | INTERNAL SERVER ERROR  | INTERNAL SERVER ERROR  | An unexpected error occurred in the application. Reach out to Mastercard support with any questions.                                                                     | Retry the request in a few minutes or reach out for help from our [support team](mailto:advisors.help@mastercard.com?subject=CCA:). |

In cases where the customer response contains both successful and unsuccessful records, error codes for unsuccessful records are added to the response at the record level.

|            Error Code            |                                                               Description                                                                |                                               Tip to resolve                                               | Applicable to Score/Metrics/Both |
|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|----------------------------------|
| INVALID_FIELD_VALUE              | This error is thrown when an argument passed to the API doesn't pass validation.                                                         | Pass a valid value to the specified parameter.                                                             | Both                             |
| MISSING_REQUIRED_FIELD           | The parameter is required but not provided.                                                                                              | Pass the missing parameter.                                                                                | Both                             |
| CONSENT_NOT_PROVIDED             | Consent from the consumer is required to access the score for said customer's PAN number.                                                | Obtain consent from the relevant consumer and update the value for consent_flag to get the consumer score. | Both                             |
| PAN_NOT_FOUND                    | This error is thrown when a PAN number is not found in the Mastercard database.                                                          | Check with the consumer for an alternate primary Mastercard Debit or Credit Card number.                   | Both                             |
| NOT_ENOUGH_TRANSACTIONS_TO_SCORE | Not enough transactions to calculate the score.                                                                                          | Check with the consumer for an alternate primary Mastercard Debit or Credit Card number.                   | Score                            |
| CARD_TOO_NEW_TO_SCORE            | Not enough transactions to calculate the score as either the card is too new or, has not recorded any transactions in the past one year. | Check with the consumer for an alternate primary Mastercard Debit or Credit Card number.                   | Score                            |

