# Code and Formats
source: https://developer.mastercard.com/ethoca-alerts-for-merchants/documentation/code-and-formats/index.md

## Error Response Handling {#error-response-handling}

The Alerts for Merchants API supports an array/list of requests and responses.

* The [HTTP response status codes](https://developer.mastercard.com/ethoca-alerts-for-merchants/documentation/code-and-formats/index.md#http-response-status-codes) provide information about the entire request/response as a whole.
* [outcomeResponses](https://developer.mastercard.com/ethoca-alerts-for-merchants/documentation/code-and-formats/index.md#outcomeresponses-response-objects) response objects that provide information about the following:
  * `alertId` (alert reference ID for which the merchant has shared the outcomes)
  * `status` (*success* , if Alert service has successfully processed the outcome, otherwise *failure*)

## HTTP Response Status Codes {#http-response-status-codes}

| Status code |      Response      |                                                                                                                                                                                                   Description                                                                                                                                                                                                    |
|-------------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 200         | OK                 | The request has succeeded and the response includes a payload.                                                                                                                                                                                                                                                                                                                                                   |
| 400         | BAD REQUEST        | Applicable for any request errors, whether outside or inside the array/list. As soon as a request error is encountered within an individual element of the request array/list, this HTTP response status is returned with no response payload. See [400 Bad Request](https://developer.mastercard.com/ethoca-alerts-for-merchants/documentation/code-and-formats/index.md#400-bad-request) for more information. |
| 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 could not be found.                                                                                                                                                                                                                                                                                                                                                                       |
| 405         | METHOD NOT ALLOWED | The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. POST is the only method allowed for this service.                                                                                                                                                                                                                                                        |
| 415         | UNSUPPORTED        | The server does not support the request payload's media type.                                                                                                                                                                                                                                                                                                                                                    |
| 429         | TOO MANY REQUESTS  | Too many requests hit the API too quickly.                                                                                                                                                                                                                                                                                                                                                                       |
| 500         | SERVER ERRORS      | Something went wrong on Mastercard's end. (These are rare).                                                                                                                                                                                                                                                                                                                                                      |

## Response Result Status Object {#response-result-status-object}

The response objects provide additional information about each element in the array/list regarding successful (HTTP STATUS 200) responses. The following table show details about response objects for `outcomeResponses`.

|       Scenario        | ResultStatus Code | Status Message |
|-----------------------|-------------------|----------------|
| Valid outcome is sent | OK                | SUCCESS        |

### outcomeResponses response objects {#outcomeresponses-response-objects}

If multiple errors exist, then the **ResultStatus Message** contains content related to all errors, separated by a space.

|                            Scenario                             |      ResultStatus Code       |                                ResultStatus Message                                |
|-----------------------------------------------------------------|------------------------------|------------------------------------------------------------------------------------|
| An outcome batch is sent by partner with more than 25 outcomes. | `REQUEST_VALIDATION_FAILURE` | Minimum 1 or Maximum 25 messages record at a time.                                 |
| Invalid combination for outcome and refund status is sent.      | `INTERNAL_SERVER_ERROR`      | Not a valid value refunded for given outcome and `alertType`.                      |
| Invalid date format is sent for `actionTimestamp`.              | `REQUEST_VALIDATION_FAILURE` | Date Format is not valid.                                                          |
| Empty value for `alertId` is sent.                              | `REQUEST_VALIDATION_FAILURE` | Invalid `alertId` value `null` - `alertId` is mandatory.                           |
| Value for `alertId` contains more than 25 characters.           | `REQUEST_VALIDATION_FAILURE` | Min and max size of `alertId` is 25.                                               |
| Invalid value for `currencyCode`.                               | `REQUEST_VALIDATION_FAILURE` | Invalid `amountStopped.currencyCode` value '' - `currencyCode` is mandatory.       |
| Invalid length for `currencyCode`.                              | `REQUEST_VALIDATION_FAILURE` | Size must be between 0 and 3.                                                      |
| Invalid length for comments.                                    | `REQUEST_VALIDATION_FAILURE` | Size must be between 0 and 1024.                                                   |
| Invalid value for outcome.                                      | `REQUEST_VALIDATION_FAILURE` | Invalid outcome value '' - Not valid value.                                        |
| Invalid value for refund amount.                                | `REQUEST_VALIDATION_FAILURE` | Invalid `refund.amount.value` value 'null' - Amount value is mandatory.            |
| Invalid value for refund `currencycode`.                        | `REQUEST_VALIDATION_FAILURE` | Invalid `refund.amount.currencyCode` value '' - Amount currency code is mandatory. |
| Invalid value for `acquirerReferenceNumber`.                    | `REQUEST_VALIDATION_FAILURE` | Size must be between 0 and 64.                                                     |
| Invalid value for `refundstatus`.                               | `REQUEST_VALIDATION_FAILURE` | Refund status is mandatory.                                                        |
| Invalid value for refund timestamp.                             | `REQUEST_VALIDATION_FAILURE` | Date Format is not valid.                                                          |
| Invalid refund `transactionId`.                                 | `REQUEST_VALIDATION_FAILURE` | Size must be between 0 and 64.                                                     |
| Refund amount not provided for terminal outcomes.               | `REQUEST_VALIDATION_FAILURE` | Refund status is mandatory.                                                        |
| Outcome batch is sent with size 0.                              | `REQUEST_VALIDATION_FAILURE` | Minimum 1 or Maximum 25 messages record at a time.                                 |
| Stopped amount is zero.                                         | `REQUEST_VALIDATION_FAILURE` | Value must be positive.                                                            |

## Gateway Errors {#gateway-errors}

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