# Code and Formats
source: https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md

## HTTP Response and Reason Codes {#http-response-and-reason-codes}

We use standard HTTP response codes for success and failure notifications, and our errors are further classified by error_type. In general, 200 HTTP codes correspond to success, 40X codes are for developer or user-related failures, and 50X codes are for Mastercard-related issues.

| HTTP Response |      Reason Code      |                                                                                                                                                   General Reason                                                                                                                                                   |
|---------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 200           | OK                    | Everything worked as expected.                                                                                                                                                                                                                                                                                     |
| 400           | BAD REQUEST           | General error when the request could not be fulfilled due to errors such as validation errors or missing required data.                                                                                                                                                                                            |
| 401           | UNAUTHORIZED          | Missing or invalid authentication token.                                                                                                                                                                                                                                                                           |
| 403           | FORBIDDEN             | The user is not authorized to perform the operation or the resource is unavailable for some reason, such as time constraints.                                                                                                                                                                                      |
| 404           | NOT FOUND             | The requested resource is not found or the data is not available.                                                                                                                                                                                                                                                  |
| 500           | INTERNAL SERVER ERROR | The Mastercard Send API server encountered an unexpected condition which prevented it from fulfilling the request. It indicates an error that the caller cannot address from their end. Requests resulting in a 500 response code will generally include the Mastercard Send API Errors structure in the response. |

## Error Response Structure {#error-response-structure}

| Error Code (Reason Code) |              Description               |                                                                                                                                                                                            Detail/Example                                                                                                                                                                                             |
|--------------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| BAD_REQUEST              | Invalid Input                          | There was an issue with the passed parameters/body of the request. Examples include, invalid or missing transaction/cardholder billing currency code, invalid or missing transaction date, invalid or missing transaction amount. Please refer to [Parameters](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/parameters/index.md) for accepted input fields. |
| UNAUTHORIZED             | Invalid client id.                     | You do not have access to this service. Please review if you have submitted a request to access the prodcution environment and that your request is approved by Mastercard through the My Projects Dashboard.                                                                                                                                                                                         |
| FORBIDDEN                | Data is not accessible                 | Rate issuance for future date not supported.Resubmit for a date within the last 365 days inclusive of current day.                                                                                                                                                                                                                                                                                    |
| NOT_FOUND                | Data not available                     | Rates are not available for the selected date. Please review if the date provided is within 365 days.                                                                                                                                                                                                                                                                                                 |
| INTERNAL_SERVER_ERROR    | Error occured while processing request | Unexpected error, please contact support team at <https://developer.mastercard.com/support>.                                                                                                                                                                                                                                                                                                          |

## Service Error Response Structure {#service-error-response-structure}

#### Bad Request: {#bad-request}

* JSON

```JSON
{
  "Errors": {
    "Error": [
      {
        "Source": "Enhanced Currency Conversion Calculator",
        "ReasonCode": "BAD_REQUEST",
        "Description": "Invalid input",
        "Recoverable": false,
        "Details": "Date format is invalid (Expected date format yyyy-MM-dd)."
      }
    ]
  }
}
```

#### Authorization Error: {#authorization-error}

* JSON

```JSON
{ 
   "Errors":{ 
      "Error":[ 
         { 
            "Source":"Enhanced Currency Conversion Calculator",
            "ReasonCode":"UNAUTHORIZED",
            "Description":"Invalid Client ID",
            "Recoverable":false,
            "Details":"You do not have access to this service. Please visit the Enhanced Currency Conversion Calculator page for details."
         }
      ]
   }
```

#### Forbidden Error: {#forbidden-error}

* JSON

```JSON
{
   "Errors":{
      "Error":[
         {
            "Source":"Enhanced Currency Conversion Calculator",
            "ReasonCode":"FORBIDDEN",
            "Description":"Data is not accesssible",
            "Recoverable":false,
            "Details":"Rate is not accessible for this date - Please use a date within the last 365 days inclusive of current day."
         }
      ]
   }
}
```

#### Data not Found: {#data-not-found}

* JSON

```JSON
{
   "Errors":{
      "Error":[
         {
            "Source":"Enhanced Currency Conversion Calculator",
            "ReasonCode":"NOT_FOUND",
            "Description":"Data not available",
            "Recoverable":false,
            "Details":"Rates are not available for the selected date. Please review if the date provided is within 365 days"
         }
      ]
   }
}
```

#### Server Error: {#server-error}

* JSON

```JSON
{ 
   "Errors":{ 
      "Error":[ 
         { 
            "Source":"Enhanced Currency Conversion Calculator",
            "ReasonCode":"INTERNAL_SERVER_ERROR",
            "Description":"Error occurred in while processing request",
            "Recoverable":true,
            "Details":"Unexpected error, please contact support team at https://developer.mastercard.com/support"
         }
      ]
   }
}
```

The description of the fields of concern returned in the error response are covered below.  

|    Field    |            Description            |
|-------------|-----------------------------------|
| Source      | The source of the error           |
| ReasonCode  | The http status code of the error |
| Description | The http status code description  |
| Details     | The specific error details        |

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

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

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

## ISO Currency Codes {#iso-currency-codes}

Currencies are identified using the 3-character [ISO 4217 alpha-3 currency codes](https://www.iso.org/iso-4217-currency-codes.html) defined by ISO. For example, US dollar is `USD`. This applies to:

* Transaction Currency \[trans_curr\]
* Cardholder Billing Currency \[crdhld_bill_curr\]

## Date and Time Formats {#date-and-time-formats}

Date values have 10 characters, specified in the format YYYY-MM-DD. For example, June 19th 2020 is `2020-06-19`. This applies to:

* Transaction Date \[rate_date\]
