# Code and Formats
source: https://developer.mastercard.com/traditional-fulfillment-service/documentation/code-and-formats/index.md

## Error Handling {#error-handling}

The Traditional Fulfillment Service API uses 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 the developer or user-related failures, and 50X codes are for runtime or system errors.

This section contains information about the response codes and error messages that can be returned by the APIs.

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

Apart from the error codes returned by the Traditional Fulfillment Service APIs, other error codes can be returned by the Mastercard gateway, which verifies your request's signature and routes it to the correct location.

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

## Application Error Codes {#application-error-codes}

### Error Structure {#error-structure}

4xx/5xx error response messages have the following format (the Error array may contain multiple error items):

```json

{
   "Errors": {
     "Error": [
       {
         "Source": "<Source api of the error, e.g. mrs-catalog-api or rewards-order-management",
         "ReasonCode": "<Unique code>",
         "Description": "<Description of the error>",
         "Recoverable": "true/false",
         "Details": "null"
       }
     ]
   }
 }
```

|      Field      |                                                                                                                                                                              Description                                                                                                                                                                              |
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Source**      | The application (mrs-catalog-api) that generates this error. Every error message that is generated and returned by the gateway will have this field equal to Gateway. When the value of the source field is something else, it means the error was generated elsewhere. For example, the mrs-catalog-api.                                                             |
| **ReasonCode**  | A unique constant identifying the error case encountered when the Traditional Fulfillment Service API is called. For example, INVALID_INPUT, INAVALID_CATALOG_HIERARCHY_ID, INVALID_PROGRAM.                                                                                                                                                                          |
| **Description** | Description of the `ReasonCode` field with additional details.                                                                                                                                                                                                                                                                                                        |
| **Recoverable** | Indicates whether this error will always be returned for this request, or whether retrying could change the outcome. For example, if the request contains an invalid request parameter, retrying will never result 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**     | Provide detailed error information wherever appropriate to help in resolving errors.                                                                                                                                                                                                                                                                                  |

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

|      HTTP Response Code       |                                                                                                                                                  Description                                                                                                                                                  |
|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **200 OK**                    | The request was completed successfully.                                                                                                                                                                                                                                                                       |
| **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**          | Error code response for missing or invalid authentication token. (for example, A client with a clientId does not have access)                                                                                                                                                                                 |
| **404 NOT FOUND**             | The requested resource is not found.                                                                                                                                                                                                                                                                          |
| **500 INTERNAL SERVER ERROR** | The server encountered an unexpected condition that 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 Traditional Fulfillment Service API Errors structure in the response. |

## Traditional Fulfillment Service Error Codes {#traditional-fulfillment-service-error-codes}

### GET /catalogs {#get---catalogs}

|          Reason Code           |                                                Description                                                 |
|--------------------------------|------------------------------------------------------------------------------------------------------------|
| INVALID_INPUT                  | Returned for an invalid request. See the "Description" element in the response for more details.           |
| INVALID_LANGUAGE               | Returned for an invalid request. See the "Description" element in response for more details.               |
| INVALID_PRODUCT_CODE           | Returned for an invalid request. See the "Description" element in response for more details.               |
| UNAUTHORIZED                   | A client with a clientId does not have access.                                                             |
| MISSING_REQUIRED_FIELD         | Returned for an invalid request. See the "Description" element in the response for more details.           |
| INVALID_PROGRAM                | Program with programId is not found.                                                                       |
| REWARD_CATALOGS_DETAILS_FAILED | Unable to get reward catalogs details. Please look into the `Details` field and reach to the support team. |

### GET /catalogs/{catalog_id}/items {#get---catalogscatalog_iditems}

|          Reason Code           |                                                Description                                                 |
|--------------------------------|------------------------------------------------------------------------------------------------------------|
| INVALID_INPUT                  | Returned for an invalid request. See the "Description" element in the response for more details.           |
| INVALID_LANGUAGE               | Returned for an invalid request. See the "Description" element in response for more details.               |
| INVALID_CATALOG_HIERARCHY_ID   | Returned for an invalid request. See the "Description" element in response for more details.               |
| INVALID_PRODUCT_CODE           | Returned for an invalid request. See the "Description" element in response for more details.               |
| UNAUTHORIZED                   | A client with a clientId does not have access.                                                             |
| MISSING_REQUIRED_FIELD         | Returned for an invalid request. See the "Description" element in the response for more details.           |
| INVALID_PROGRAM                | Program with programId is not found.                                                                       |
| INVALID_CATALOG_HIERARCHY_ID   | Invalid Reward Catalog HierarchyId.                                                                        |
| REWARD_CATALOGS_DETAILS_FAILED | Unable to get reward catalogs details. Please look into the `Details` field and reach to the support team. |

### POST /vendors/{vendor_id}/orders/status {#post---vendorsvendor_idordersstatus}

| Reason Code  |                  Description                   |
|--------------|------------------------------------------------|
| UNAUTHORIZED | A client with a clientId does not have access. |

