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

## Error Codes {#error-codes}

### API Request / Response Common Elements and Headers {#api-request--response-common-elements-and-headers}

Every outbound request contains an element requestId which uniquely identifies the request. Every response contains an element responseId which uniquely identifies the response. The responseId may optionally use the corresponding requestId. Note that the format and uniqueness of the requestId and responseId are not validated.

### Retry Strategy {#retry-strategy}

In the case of an operation reporting an error, the response (or an object within the response) contains the element 'errorCode' and optionally the element 'errorDescription'. Unless explicitly stated otherwise, no other element (including 'Required' fields) is present if an error is reported.

The Authentication Service automatically retries 3 times with up to a 5-second wait between each attempt of the Deliver Authentication Code API calls that fail with a:

* Timeout
* Connection failure
* HTTP response code of 302, 500 or 503.

## HTTP Response codes/Reason codes {#http-response-codesreason-codes}

|        Error code        |          Error Description           |                                      Error circumstances                                      |
|--------------------------|--------------------------------------|-----------------------------------------------------------------------------------------------|
| INVALID_JSON             | Invalid JSON                         | The JSON could not be parsed.                                                                 |
| MISSING_REQUIRED_FIELD   | Missing Required Field - {fieldName} | A required field is missing.                                                                  |
| INVALID_FIELD_FORMAT     | Invalid Field_Format - {fieldName}   | This field is not in the correct format. For instance, it should be a number but is a string. |
| INVALID_FIELD_LENGTH     | Invalid Field Length - {FieldName}   | The value does not fall between the minimum and maximum length for the field.                 |
| INVALID_FIELD_VALUE      | Invalid Field Value - {fieldname}    | The value is not allowed for the field.                                                       |
| CRYPTOGRAPHY_ERROR       | Cryptography error                   | There was an error decrypting the encrypted payload.                                          |
| INTERNAL_SERVICE_FAILURE | The system had an internal exception | System had an internal exception.                                                             |

### JSON Samples {#json-samples}

#### Deliver Authentication Code Request {#deliver-authentication-code-request}

```json
{
	"requestId" : "123456",
        "authenticationFlowId" : "51925225218-D98765432104",
        "authenticationCode" : "A1B2C3D4",
        "expirationDateTime" : "2019-07-04T12:08:56.123-07:00",
        "reasonCode" : "PAYMENT_TRANSACTION",
        "fundingAccountInfo" : {
               "panUniqueReference" : "FWSPMC000000000159f71f703d2141efaf04dd26803f922b",
               "tokenUniqueReference":"DWSPMC000000000132d72d4fcb2f4136a0532d3093ff1a45", 
               "encryptedPayload" : {
                        "publicKeyFingerprint" :  "4c4ead5927f0df8117f178eea9308daa58e27c2b",
                         "encryptedKey" : "861c784372f410dee6ac4dd4a06e4dee6f7f203de94136eddc9a1aa471f6104de4195f10836c017721994348f3cb6c952839401e3efd36543eab12dd41b5b756ddc0ae2bde21dede2f9b26d5436a1f9beb8c9d12a68d0aeb318bc24b4815bcbba0cfc7bc861b3facc1be1c21f35d96c6aee4ce95fed5b282c75eec6a2d434ad8dc4540f6fbea212bc64611f8d1254e4217af36cdb410f50fba8b03e7ba1230b5f3e3982bec08226cdbbf892af1dffcefa12413536a05541df132ee3438a83be920809ea5026439aab58d977b88ce58d68f8da1addefc9abe2a57e2f94c3e9d44eb25150c43ac0661132124a5ae628ea35ccde74b3ce93cadfc6c0fa6c7bda584",
                         "oaepHashingAlgorithm" : "SHA512",
                         "iv" : "d60dd037a91d656714500058946cc382",
                         "encryptedData": "4afaa8c8816451ddd680e2ad393b998aef8a2aee3ab9eabbec00952cdd6bb1000007656d95fec9c2a732057ff2d4cac46f7d405d8960b0f4b4ce231eda28f7633d36289d20b730b1960c8b40a080f74ece0795d6c055d36a0300cf5a5b85f65fa80b411b0aee9202060c34e97cdf4e17fa4bf59a81977b39a86bcb7d9f226dcb544171c972897dd8ce355cb640269510709da3f76c94f79c81785d574a30819bccb211fc8ad17c19b1de44ee06992e1054b92a27339715679d3e983eb0bf035f623b056ce7b99436f665ad452083ca417ed1dc595a99cbf6100ca5d223fda4d0c622cda2a031993d4904ab9bac310156"
               }
        }
}
```

##### Decrypted encryptedData {#decrypted-encrypteddata}

```json
{
     "cardAccountData": {
          "accountNumber": "5412346789012345",
          "expiryMonth": "12",
          "expiryYear": "19"
     },
     "financialAccountData": {
          "financialAccountId": "1123456789012345",
          "interbankCardAssociationId": "1234",
          "countryCode": "GBR"
     },
     "tokenData": {
          "token": "5345678901234521",
          "expiryMonth": "10",
          "expiryYear": "20"
     },
     "dataValidUntilTimestamp": "2020-07-04T12:09:56.123-07:00"
}
```

#### Deliver Authentication Code Response {#deliver-authentication-code-response}

```json
{
     "responseId" : "123456",
     "errorCode" : "INVALID_JSON",
     "errorDescription" : "Invalid JSON"
}
```

