# Responses

Every API request is expected to yield a response. The HTTP status code of the response is `200`. This is true regardless of whether the API request processing is successful, or if it fails, e.g. due to errors during reservation processing or validation of an inventory update message. In the event of a failure, the response body contains details about the error.

> **Important:** In the event of errors involving rate codes or category codes, details of the affected codes must be returned in the response body. These codes will also be unsynchronized as a result of the error, i.e. disabled.

## Synchronous simple response

This response object represents the default response, in case of success.

```javascript
{
   "success": true,
   "asyncConfirmation": false
}
```

## Synchronous error response

In case of error, the response object will extend the simple response object with details about the error or errors. In case of any errors with rate codes or category codes, details of the affected codes must also be returned. See the [Error codes](#error-codes) table below for further details about specific errors, including guidance on system behaviour.

### Example #1

```javascript
{
   "success": false,
   "errors":[
      {
         "code":8,
         "message":"Invalid 'clientToken' or 'connectionToken'."
      }
   ]
}
```

### Example #2

```javascript
{
   "success": false,
   "errors":[
      {
         "code":9,
         "message":"Invalid rate code",
         "rateCode":"ABC"
      }
   ]
}
```

### Example #3

```javascript
{
   "success": false,
   "errors":[
      {
         "code":10,
         "message":"Invalid category code",
         "categoryCode":"XYZ"
      }
   ]
}
```

### Example #4

```javascript
{
   "success": false,
   "errors":[
      {
         "code":9,
         "message":"Invalid rate code",
         "rateCode":"ABC"
      },
      {
         "code":10,
         "message":"Invalid category code",
         "categoryCode":"XYZ"
      }
   ]
}
```

| Property            | Type                       | Contract     | Description                                                                                                                                               |
| ------------------- | -------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `success`           | `bool`                     | required     | Determinines the result of the operation.                                                                                                                 |
| `asyncConfirmation` | `bool`                     | optional     | Determinines if there will be following asynchronous response.                                                                                            |
| ~~`error`~~         | [~~`Error`~~](#error)      | ~~optional~~ | ~~In case of `"success": false`, this property holds information about the error that occurred.~~ [**Deprecated!**](/channel-manager-api/deprecations.md) |
| `errors`            | array of [`Error`](#error) | optional     | In case of `"success": false`, this property holds information about the error or errors that occurred.                                                   |

### Error

| Property       | Type     | Contract   | Description                                                                                                                                                       |
| -------------- | -------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`         | `int`    | required   | Determines the type of error (see [Error codes](#error-codes)).                                                                                                   |
| `message`      | `string` | required   | Error message with more details about the error.                                                                                                                  |
| `categoryCode` | `string` | optional\* | Category code which caused the error. This is *required* for category errors and rate category errors. The category will be automatically unsynchronized in Mews. |
| `rateCode`     | `string` | optional\* | Rate code which caused the error. This is *required* for rate errors and rate category errors. The rate will be automatically unsynchronized in Mews.             |

> **\*Important**: If the error is a category error (code 10) or rate category error (code 11), then `categoryCode` must be specified. If the error is a rate error (code 9) or rate category error (code 11), then `rateCode` must be specified.

### Error codes

| Code    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `1`     | <p><strong>System error</strong><br>Unspecified system error. Message may be re-sent after an interval of time.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `2`     | <p><strong>Reservation not found</strong><br>The specified reservation could not be found in the system. When this error code is returned, it should be acknowledged and the reservation should <em>not</em> be re-tried.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `3`     | <p><strong>Connection not found</strong><br>The specified connection, i.e. property integration, could not be found in the system.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ~~`4`~~ | <p><del><strong>Space not found</strong></del><br><del>The specified space type could not be found in the system.</del> (deprecated - use code 10 instead)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ~~`5`~~ | <p><del><strong>Rate not found</strong></del><br><del>The specified rate plan could not be found in the system.</del> (deprecated - use code 9 instead)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `6`     | <p><strong>Validation error</strong><br>The message is incorrectly formed or contains an invalid field, or a field contains an invalid value.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `7`     | <p><strong>Processing error</strong><br>Business logic error occurred when processing the message, for example the message contains a negative amount that must be positive, or a reservation contains a start date that is later than its end date. The <code>message</code> field contains details of the specific processing error.</p>                                                                                                                                                                                                                                                                                                                      |
| `8`     | <p><strong>Invalid authentication</strong><br>The request has failed authentication, e.g. an authentication token is invalid or has expired.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `9`     | <p><strong>Rate error</strong> OR <strong>Disabled operation</strong><br>This error code has a different meaning, depending on which side is sending the error.<br><br><strong>Rate error</strong> (CHM side): The specified rate code is invalid, or the rate cannot be accepted. The affected rate code must be supplied in the <code>rateCode</code> property. This rate code will then be unsynchronized.<br><br><strong>Disabled operation</strong> (Mews side): This API operation is not enabled for this integration, e.g. the property administrator has disabled the ability to receive reservations via the Channel Manager integration in Mews.</p> |
| `10`    | <p><strong>Category error</strong><br>Space category error, e.g. space category XX availability updates cannot be accepted due to the settings in the Channel Manager. The affected category code must be supplied in the <code>categoryCode</code> property. The category will then be deleted from the rate.</p>                                                                                                                                                                                                                                                                                                                                              |
| `11`    | <p><strong>Rate category error</strong><br>Rate category error, e.g. the specified space category was removed from the specified rate plan in the Channel Manager. The affected rate code and category code must be supplied. The category will be deleted from the rate.</p>                                                                                                                                                                                                                                                                                                                                                                                   |
| `12`    | <p><strong>Availability error</strong><br>Availability configuration error, e.g. availability updates are blocked by the Channel Manager. This error automatically disables availability updates.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `13`    | <p><strong>Prices error</strong><br>Prices configuration error, e.g. price updates are blocked by the Channel Manager. This error automatically disables price updates.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `14`    | <p><strong>Restrictions error</strong><br>Restrictions configuration error, e.g. restriction updates are blocked by the Channel Manager. This error automatically disables restrictions updates.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mews.com/channel-manager-api/guidelines/responses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
