# Codes and Formats source: https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md ## Overview {#overview} | Section | Description | |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| | [HTTP Status → Reason Code Mapping](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#http-status-and-reason-codes) | Which reason codes each HTTP status can carry, and which endpoints return them. | | [Error Response Structure](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#error-response-structure) | The `Errors` envelope every error response uses. | | [Error Support Matrix](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#error-support-matrix) | Which endpoints may return which error codes. | | [Conversion-rate-summary Errors](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#conversion-rate-summary-get-summary-rates) | Errors for `GET /summary-rates`. | | [Conversion-rate-issued Errors](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#conversion-rate-issued-get-rate-statuses) | Errors for `GET /rate-statuses`. | | [Currency List Errors](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#currency-list-errors-get-mc-currencies--get-ecb-currencies) | Errors for `GET /mc-currencies` and `GET /ecb-currencies`. | | [Gateway Error Codes](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#gateway-error-codes) | Errors returned by Mastercard's gateway before your request reaches this service. | | [ISO Currency Codes](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#iso-currency-codes) | Currency code format used by the API. | | [Date and Time Formats](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#date-and-time-formats) | Date format used by the API. | ## HTTP Status and Reason Codes {#http-status-and-reason-codes} We use standard HTTP response codes for success and failure notifications, and our errors are further classified by reason code. 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 Status | Reason Code(s) | Returned By | General Meaning | |-------------|-------------------------|----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 200 | --- | All endpoints | Everything worked as expected. | | 400 | `BAD_REQUEST` | `summary-rates`, `rate-statuses` | The request could not be fulfilled due to a missing or invalid parameter. | | 401 | `UNAUTHORIZED` | All endpoints | Missing, invalid, or expired OAuth 1.0a signature or Consumer Key. | | 403 | `FORBIDDEN` | `summary-rates`, `rate-statuses` | The requested date falls outside the 365-day window this service supports. | | 404 | `NOT_FOUND` | All endpoints | The requested date is in the future, rates are not yet published, or currency data is temporarily unavailable. | | 500 | `INTERNAL_SERVER_ERROR` | All endpoints | An unexpected condition on Mastercard's side prevented the request from completing. Not represented in the OpenAPI specification's example responses, but can occur for any endpoint. | ## Error Response Structure {#error-response-structure} All error responses use the following envelope: * JSON ```JSON { "Errors": { "Error": [ { "Source": "Enhanced Currency Conversion Calculator API", "ReasonCode": "BAD_REQUEST", "Description": "Invalid input", "Recoverable": false, "Details": "Date format is invalid (Expected date format yyyy-MM-dd)" } ] } } ``` | Field | Description | |-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Source | The name of the application that generated the error --- either this service, or `Gateway` (see [Gateway Error Codes](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/code-and-formats/index.md#gateway-error-codes)). | | ReasonCode | A unique constant identifying the error case, for example `NOT_FOUND`. | | Description | A short, human-readable description of the reason code. | | Recoverable | Whether retrying the identical request could produce a different outcome. `false` means the request itself needs to change. | | Details | Specific, actionable detail about what to change and resubmit. | ## Error Support Matrix {#error-support-matrix} | Endpoint | Path | Supported Errors | |------------------------------|-----------------------|--------------------------------------------------| | getEnhancedConversionDetails | `GET /summary-rates` | All error codes | | isEcbMcRateIssued | `GET /rate-statuses` | All error codes | | getEnhancedMCCurrencyData | `GET /mc-currencies` | All error codes except BAD_REQUEST and FORBIDDEN | | getEcbCurrenciesList | `GET /ecb-currencies` | All error codes except BAD_REQUEST and FORBIDDEN | ## Conversion-rate-summary (`GET /summary-rates`) {#conversion-rate-summary-get-summary-rates} | HTTP Status | Error Code (Reason Code) | Description | Typical Cause | Resolution | |-------------|--------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 400 | BAD_REQUEST | Invalid input | A required parameter (`rate_date`, `trans_curr`, `trans_amt`, `crdhld_bill_curr`) is missing, or `rate_date` is not in `yyyy-MM-dd` format. | Confirm all four required query parameters are present and that `rate_date` matches `yyyy-MM-dd`. See [Parameters](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/parameters/index.md). | | 401 | UNAUTHORIZED | Invalid Client ID | The OAuth 1.0a signature is missing, invalid, or was generated with an expired/incorrect key. | Confirm your Consumer Key and `.p12` file are for the correct environment and have not expired. Refer to [Authentication](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-basics/index.md#authentication) for details. | | 403 | FORBIDDEN | Data is not accessible | `rate_date` is more than 365 days in the past. | Resubmit with a `rate_date` within the last 365 days inclusive of the current day. | | 404 | NOT_FOUND | Data not available | `rate_date` is in the future, or falls on a date rates were not published for (for example, before the API's data history begins). | Use [Checking Daily Rate Availability](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/use-cases/rate-availability-check/index.md) to confirm rates are published before calling this endpoint, or resubmit with a valid current or past date. | | 500 | INTERNAL_SERVER_ERROR | Server encountered an unexpected condition | Retry the request. If the problem persists, contact [Support](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/support/index.md). | | All endpoints \| An unexpected condition on Mastercard's side prevented the request from completing. Not represented in the OpenAPI specification's example responses, but can occur for any endpoint. \| ## Conversion-rate-issued (`GET /rate-statuses`) {#conversion-rate-issued-get-rate-statuses} | HTTP Status | Error Code (Reason Code) | Description | Typical Cause | Resolution | |-------------|--------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 400 | BAD_REQUEST | Date format is invalid | `request_date` is not in `yyyy-MM-dd` format. | Resubmit with `request_date` in `yyyy-MM-dd` format, or omit it to default to the current day. | | 401 | UNAUTHORIZED | Invalid Client ID | The OAuth 1.0a signature is missing, invalid, or was generated with an expired/incorrect key. | Refer to [Authentication](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-basics/index.md#authentication) for details. | | 403 | FORBIDDEN | Data is not accessible | `request_date` is more than 365 days in the past. | Resubmit with a `request_date` within the last 365 days inclusive of the current day. | | 404 | NOT_FOUND | Data not available | `request_date` is in the future. | Resubmit with the current day or a past date. | | 500 | INTERNAL_SERVER_ERROR | Server encountered an unexpected condition | Retry the request. If the problem persists, contact [Support](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/support/index.md). | | ## Currency List Errors (`GET /mc-currencies` / `GET /ecb-currencies`) {#currency-list-errors-get-mc-currencies--get-ecb-currencies} These endpoints take no input parameters, so there are no `400` cases. | HTTP Status | Error Code (Reason Code) | Description | Typical Cause | Resolution | |-------------|--------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 401 | UNAUTHORIZED | Invalid Client ID | The OAuth 1.0a signature is missing, invalid, or was generated with an expired/incorrect key. | Refer to [Authentication](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-basics/index.md#authentication) for details. | | 404 | NOT_FOUND | Data not available | No active currency data is available from the source service. | Retry the request. If the problem persists, contact [Support](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/support/index.md). | | 500 | INTERNAL_SERVER_ERROR | Server encountered an unexpected condition | Retry the request. If the problem persists, contact [Support](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/support/index.md). | | ## Gateway Error Codes {#gateway-error-codes} In addition to the service-level errors above, errors can also be returned by Mastercard's API gateway, which validates your request's signature and routes it to the correct location --- before your request ever reaches the Enhanced Currency Conversion Calculator API service. When an error originates from the gateway rather than the service, the `Source` field in the `Errors` envelope will show `Gateway` instead of `Enhanced Currency Conversion Calculator API`. You can find the full list of gateway-level errors, such as `UNAUTHORIZED` and `FORBIDDEN`, and their resolutions on the [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/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\] * Rate Issued Date \[request_date\] ## Next Steps {#next-steps} | Category | Description | |--------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------| | [Testing](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/testing/index.md) | Positive and negative test cases for every endpoint. | | [API Reference](https://developer.mastercard.com/enhanced-currency-conversion-calculator/documentation/api-reference/index.md) | Try the Sandbox APIs directly from your browser. |