# Code and Formats
source: https://developer.mastercard.com/fld-fraud-submission/documentation/code-and-formats/index.md

## Errors Overview {#errors-overview}

The error message returned will depend on which API generated the error and at what point the request failed. Error messages will be in one of two formats.

* [**Gateway Error Messages**](https://developer.mastercard.com/fld-fraud-submission/documentation/code-and-formats/index.md#gateway-error-message): Returned by the API gateway and occur when OAuth authentication fails.

* [**API Error Messages**](https://developer.mastercard.com/fld-fraud-submission/documentation/code-and-formats/index.md#api-error-messages): Returned by the FLD application and occur during technical or business decline scenarios.

Note: To ensure forward-compatibility, client implementations must add support for new elements in future API responses.

## Gateway Error Messages {#gateway-error-messages}

All errors returned by the gateway follow the same data format.

    {
       "Errors":{
          "Error":[
             {
                "Source":"Gateway",
                "ReasonCode":"<Unique code>",
                "Description":"<Description of the error>",
                "Recoverable":true/false,
                "Details":null
             }
          ]
       }
    }

|      Field      |                                                                                                                                                                   Description                                                                                                                                                                   |
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Source**      | The application that generated the error. The gateway will generate and return every error message with this field set to `Gateway`. If the source field shows a different value, another application generates the error.                                                                                                                      |
| **ReasonCode**  | A unique constant identifying the error case encountered during transaction processing. For example, use `INVALID_SIGNATURE` when the request signature does not match the expected one.                                                                                                                                                        |
| **Description** | Description of the `ReasonCode` field with additional details.                                                                                                                                                                                                                                                                                  |
| **Recoverable** | Indicates if the error is always returned for the current request, or if retrying might change the result. For example, if the request contains an invalid signature, retrying never results 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**     | Always null, present for backwards compatibility.                                                                                                                                                                                                                                                                                               |

Note: For more information about gateway error messages including the error codes, refer to [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/).

## API Error Messages {#api-error-messages}

Once the request payload hits the FLD application, it goes through a series of validations. If a validation fails, FLD does not process the request any further and returns a failure response to the initiator. Categorize these failures as shown:

* **Technical Declines**: These are typically failures related to schema validations, such as issues with data type, format, or attribute length.
* **Business Declines**: These are on account of business validation errors such as conditionality check, list of accepted attribute values, presence of record in transaction or fraud repository.

FLD returns the appropriate response code in the response payload in the event of a technical or business decline. FLD returns the response code '000' if it processes the request payload successfully after completing all related validations.

The following table shows the response code and corresponding response message for different scenarios. The technical declines may range between "100" and "199" and the business declines may range between "200" and "299".

| **Response Code** | **Response Message** | **Type of Decline** |
|-------------------|----------------------|---------------------|
| 000               | Success              | N/A                 |
| 001               | Pending              | N/A                 |
| 100 to 199        | Failure              | Technical           |
| 200 to 299        | Failure              | Business            |

While the response code provides the initiator with information about the type of decline, the error code and its corresponding error message provides the specific reason for the failure at a granular level. FLD may return one or more error code and corresponding error messages (in an array list) for a particular response code.

#### Sample failure response payload {#sample-failure-response-payload}

    {
       "refId":"ecb2d942-eabd-42b6-87fd-69c19692bdc6",
       "timestamp":"2021-03-16T20:34:40-06:00",
       "responseCode":"100",
       "responseMessage":"Failure",
       "errorDetails":{
          "Errors":{
             "Error":[
                {
                   "ReasonCode":"60004",
                   "Description":"cardNumber attribute value length not in range. Minimum Length:12 and Maximum Length: 19."
                },
                {
                   "ReasonCode":"60003",
                   "Description":"transactionAmount incorrect datatype of attribute value."
                }
             ]
          }
       }
    }

#### Failure scenarios {#failure-scenarios}

Following are the error codes:

* [Mastercard Build FDA](https://developer.mastercard.com/fld-fraud-submission/documentation/fda/index.md)
* [Issuer Build FDA](https://developer.mastercard.com/fld-fraud-submission/documentation/fda_iss/index.md)
* [Mastercard Build FDC](https://developer.mastercard.com/fld-fraud-submission/documentation/fdc/index.md)
* [Issuer Build FDC](https://developer.mastercard.com/fld-fraud-submission/documentation/fdc_iss/index.md)
* [Fraud Data Delete](https://developer.mastercard.com/fld-fraud-submission/documentation/fdd/index.md)
* [Fraud Suspend to Confirm](https://developer.mastercard.com/fld-fraud-submission/documentation/fde/index.md)
* [Get Status](https://developer.mastercard.com/fld-fraud-submission/documentation/fds/index.md)
