> For the complete documentation index, see [llms.txt](https://docs.channex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.channex.io/channel-api-examples/webbeds.md).

# WebBeds

This guide walks through creating a channel connection between Channex and WebBeds over the API: discovering the adapter, validating the hotel code, reading the rooms and rates on both sides, building the mapping, and creating and activating the connection.

A **channel connection** (a *channel*) links rate plans of a Channex property to rooms and rates on the OTA side. Once the connection is active, Channex pushes availability, rates and restrictions to WebBeds and receives bookings back.

Every OTA has its own API and data model, so the connection settings and the mapping settings differ per channel. The flow below is shared by most channels (Booking.com, Expedia, Agoda, Open Channel–based OTAs and others); the payloads shown are the WebBeds ones. Airbnb is the exception — it requires an OAuth authorization step and is covered by a separate guide.

All endpoints require authentication with an API key, sent in the `user-api-key` header.

### Before you start

The hotel must have Channex selected as its channel manager (connectivity provider) on the WebBeds side. Channex connects to WebBeds with its own partner credentials, so the only thing needed from the hotel is its **WebBeds Hotel Code**. If the hotel does not know its code or cannot select Channex, it should ask its WebBeds account manager to enable the connection to Channex.

### The flow at a glance

1. Get the adapter descriptor — what settings and mapping fields WebBeds needs.
2. Collect the settings from the user and run a test connection.
3. Get the mapping details — the rooms and rates on the WebBeds side.
4. Collect the Channex side — the property, its room types and rate plans.
5. Build the mapping structure.
6. Create the connection.
7. Activate it.

### 1. Get the adapter descriptor

Each channel is described by an **adapter descriptor**: the settings it needs (`params`) and the per-mapping fields it needs (`rate_params`).

```
GET /api/v1/channels/adapter?code=WebBeds
```

The full catalog of adapters is available at `GET /api/v1/channels/list`.

Response (abridged):

```json
{
  "data": {
    "code": "WebBeds",
    "title": "WebBeds",
    "kind": "meta",
    "actions": [],
    "params": {
      "hotel_code": {
        "position": 0,
        "type": "string",
        "title": "Hotel Code"
      },
      "email": {
        "position": 3,
        "type": "string",
        "title": "Property Email",
        "rules": [
          {
            "apply": "hidden",
            "when": false,
            "influence_field": "send_email_notifications",
            "with_value": ""
          }
        ]
      },
      "send_email_notifications": {
        "default": false,
        "position": 4,
        "type": "boolean",
        "title": "Send Property Notification"
      },
      "min_stay_type": {
        "default": "Arrival",
        "position": 5,
        "type": "select",
        "options": ["Arrival", "Through"],
        "title": "Min Stay Type"
      }
    },
    "rate_params": {
      "rate_plan_code": { "position": 0, "title": "Rate", "type": "string" },
      "room_type_code": { "position": 1, "title": "Room", "type": "string" },
      "occupancy": { "position": 2, "title": "Occupancy", "type": "integer" },
      "pricing_type": {
        "position": 3,
        "title": "Pricing Type",
        "type": "select",
        "options": ["Standard", "OBP"]
      },
      "primary_occ": { "position": 4, "title": "Primary Occupancy", "type": "boolean" }
    }
  }
}
```

What to read from it:

* **`params`** — the connection settings to collect from the user. Each entry describes one field: `title` (English label), `type` (`string`, `password`, `integer`, `boolean`, `select`, `switch`, `hidden`), `position` (ordering for a UI), `default`, `options` (for `select` and `switch` fields) and conditional display `rules`.
* **`rate_params`** — the fields each rate plan mapping must carry (step 5), described the same way.

For WebBeds, the only setting to collect from the user is **`hotel_code`** — the WebBeds Hotel Code. The remaining settings have sensible defaults; see the settings reference.

### 2. Test the connection

Before creating anything, validate the collected settings with a test connection:

```
POST /api/v1/channels/test_connection
```

```json
{
  "channel": "WebBeds",
  "settings": {
    "hotel_code": "5916685"
  }
}
```

`channel` is the adapter code from the descriptor; `settings` is the object built from `params`. Channex requests the hotel's rate plans from WebBeds with the given Hotel Code.

Response:

```json
{
  "data": {
    "success": true,
    "errors": null
  }
}
```

`success: true` means WebBeds recognises the Hotel Code, the hotel is connected to Channex on the WebBeds side, and it has at least one rate plan. On failure the response is still `200 OK` with `success: false` — check the `success` field, not the status code. A failure usually means a wrong Hotel Code, that the hotel has not selected Channex as its channel manager on WebBeds yet, or that no rate plans are configured for the hotel on WebBeds (error code `no_rate_plans`).

### 3. Get the mapping details

Next, fetch the rooms and rates the hotel exposes on the WebBeds side:

```
POST /api/v1/channels/mapping_details
```

The payload is the same as for the test connection:

```json
{
  "channel": "WebBeds",
  "settings": {
    "hotel_code": "5916685"
  }
}
```

Response (abridged):

```json
{
  "data": {
    "pricing_type": "OBP",
    "rooms": [
      {
        "id": "1441192493",
        "title": "Single Room",
        "max_occupancy": 2,
        "max_children": 1,
        "rates": [
          {
            "id": "BAR",
            "title": "Best Available Rate",
            "max_persons": 1,
            "occupancies": [1]
          },
          {
            "id": "NRF",
            "title": "Not Refundable",
            "max_persons": 1,
            "occupancies": [1]
          }
        ]
      },
      {
        "id": "1441192613",
        "title": "Double Room",
        "max_occupancy": 5,
        "max_children": 2,
        "rates": [
          {
            "id": "BAR",
            "title": "Best Available Rate",
            "max_persons": 3,
            "occupancies": [1, 2, 3]
          },
          {
            "id": "NRF",
            "title": "Not Refundable",
            "max_persons": 3,
            "occupancies": [1, 2, 3]
          }
        ]
      }
    ]
  }
}
```

Every channel returns its own mapping-details shape; this one is WebBeds'.

**`pricing_type`** — always `OBP` (occupancy-based pricing): WebBeds accepts prices per number of guests only, so every rate carries a price per occupancy option.

**`rooms`** — the rooms available for mapping. Each room carries:

| Field           | Description                                                      |
| --------------- | ---------------------------------------------------------------- |
| `id`            | Room type code on the WebBeds side.                              |
| `title`         | Room title.                                                      |
| `max_occupancy` | Maximum number of guests (adults and children) the room accepts. |
| `max_children`  | Maximum number of children the room accepts.                     |
| `rates`         | Rates of the room.                                               |

Each rate carries:

| Field         | Description                                                                      |
| ------------- | -------------------------------------------------------------------------------- |
| `id`          | Rate plan code on the WebBeds side.                                              |
| `title`       | Rate title.                                                                      |
| `max_persons` | Maximum number of adults the room accepts.                                       |
| `occupancies` | Occupancy options of the rate on this room: every value from 1 to `max_persons`. |

The same rate can be offered on several rooms: it appears under each room it is sold on, and a mapping always targets one room + rate pair. Rate plans that WebBeds marks as closed for both rate and availability updates are not listed — nothing can be pushed to them.

### 4. Collect the Channex side

WebBeds connections are one-to-one: **one connection maps exactly one Channex property to one WebBeds hotel**. Pick the property to connect, then fetch its room types and rate plans through the `options` endpoints:

```
GET /api/v1/room_types/options?filter[property_id]={property_id}
GET /api/v1/rate_plans/options?filter[property_id]={property_id}&multi_occupancy=true
```

Enable `multi_occupancy` on the rate plans request: for occupancy-based rate plans it expands each occupancy option into its own entry, which is exactly the granularity WebBeds mappings need.

Prices are pushed to WebBeds in the currency of the mapped Channex rate plan, so map rate plans whose currency matches the currency the hotel uses on WebBeds.

### 5. Build the mapping structure

The mapping is a list of `rate_plans` entries, one per (Channex rate plan occupancy → WebBeds room/rate/occupancy) pair:

```json
{
  "rate_plan_id": "a35f1fd4-63c6-4fbc-8fbe-359869bd9958",
  "settings": {
    "room_type_code": "1441192613",
    "rate_plan_code": "BAR",
    "occupancy": 2,
    "pricing_type": "OBP",
    "primary_occ": true
  }
}
```

**`rate_plan_id`** — the Channex rate plan UUID (from step 4).

**`settings`** — the fields declared by `rate_params` in the adapter descriptor:

| Field            | Description                                                                                                |
| ---------------- | ---------------------------------------------------------------------------------------------------------- |
| `room_type_code` | Room type code on the WebBeds side.                                                                        |
| `rate_plan_code` | Rate plan code on the WebBeds side.                                                                        |
| `occupancy`      | The occupancy option of the WebBeds rate this mapping serves — the number of adults its price is sent for. |
| `pricing_type`   | Always `OBP` — copy it from the mapping details.                                                           |
| `primary_occ`    | Whether this mapping is the primary one for its room + rate pair. See below.                               |

Create one mapping per occupancy option you want to sell, and mark **exactly one mapping of each room + rate pair** as primary.

Channex sends one update per room + rate pair and date to WebBeds:

* the prices of all mapped occupancies of the pair are sent together — when the price of one occupancy changes, the current prices of the other mapped occupancies are sent along with it; the price of the **primary** mapping is also sent as the base amount of the rate;
* availability and restrictions are sent once for the pair — when its mappings carry different values, the values of the **primary** mapping are used.

A full mapping for one WebBeds rate sold at two occupancies:

```json
[
  {
    "rate_plan_id": "a35f1fd4-63c6-4fbc-8fbe-359869bd9958",
    "settings": {
      "room_type_code": "1441192613",
      "rate_plan_code": "BAR",
      "occupancy": 2,
      "pricing_type": "OBP",
      "primary_occ": true
    }
  },
  {
    "rate_plan_id": "2a0c416b-d8e6-4950-b52e-e7821030fd9d",
    "settings": {
      "room_type_code": "1441192613",
      "rate_plan_code": "BAR",
      "occupancy": 1,
      "pricing_type": "OBP",
      "primary_occ": false
    }
  }
]
```

#### Extra adult and extra child prices

A mapping can also carry optional extra-person prices. They are not declared in the descriptor's `rate_params`, but are accepted in the mapping `settings`:

| Field               | Description                                                                                                 |
| ------------------- | ----------------------------------------------------------------------------------------------------------- |
| `extra_adult_price` | Price of an extra adult (extra bed), in major units of the rate plan currency — `15` means 15.00. Optional. |
| `extra_child_price` | Price of an extra child, in major units of the rate plan currency. Optional.                                |

When set, they are sent to WebBeds along with every price update of the mapped room + rate pair. A missing, zero or negative value is not sent.

### 6. Create the connection

```
POST /api/v1/channels
```

The payload is wrapped in a `channel` key:

```json
{
  "channel": {
    "channel": "WebBeds",
    "group_id": "60674dd6-1aeb-4c41-9e0c-8ffb378a4570",
    "title": "WebBeds Channel",
    "properties": ["acb388d9-546b-42fc-9ae2-baf00e7f0d8c"],
    "settings": {
      "hotel_code": "5916685",
      "min_stay_type": "Arrival"
    },
    "rate_plans": [
      {
        "rate_plan_id": "a35f1fd4-63c6-4fbc-8fbe-359869bd9958",
        "settings": {
          "room_type_code": "1441192613",
          "rate_plan_code": "BAR",
          "occupancy": 2,
          "pricing_type": "OBP",
          "primary_occ": true
        }
      },
      {
        "rate_plan_id": "2a0c416b-d8e6-4950-b52e-e7821030fd9d",
        "settings": {
          "room_type_code": "1441192613",
          "rate_plan_code": "BAR",
          "occupancy": 1,
          "pricing_type": "OBP",
          "primary_occ": false
        }
      }
    ]
  }
}
```

| Field        | Description                                                                                                |
| ------------ | ---------------------------------------------------------------------------------------------------------- |
| `channel`    | The adapter code from the descriptor.                                                                      |
| `group_id`   | UUID of the group the connection belongs to. Required.                                                     |
| `title`      | Connection title. Optional — generated from the channel and property names when omitted.                   |
| `properties` | UUIDs of the connected properties. One property for WebBeds.                                               |
| `settings`   | The connection settings built from `params` — the same object the test connection validated.               |
| `rate_plans` | The mapping structure from step 5. Optional — mappings can also be added later by updating the connection. |

The response is `201 Created` with the channel connection resource (abridged):

```json
{
  "data": {
    "type": "channel",
    "id": "ca4ac55f-3be1-4039-9542-21e8285ffbf9",
    "attributes": {
      "id": "ca4ac55f-3be1-4039-9542-21e8285ffbf9",
      "title": "WebBeds Channel",
      "channel": "WebBeds",
      "is_active": false,
      "actions": [],
      "properties": ["acb388d9-546b-42fc-9ae2-baf00e7f0d8c"],
      "settings": {
        "hotel_code": "5916685",
        "min_stay_type": "Arrival"
      },
      "rate_plans": [
        {
          "id": "9d7e45b3-367b-4286-a081-17a6c8d3c62e",
          "rate_plan_id": "a35f1fd4-63c6-4fbc-8fbe-359869bd9958",
          "settings": {
            "room_type_code": "1441192613",
            "rate_plan_code": "BAR",
            "occupancy": 2,
            "pricing_type": "OBP",
            "primary_occ": true
          }
        },
        {
          "id": "0f6fe97e-ab8b-4f0b-a1cd-dc3500f18295",
          "rate_plan_id": "2a0c416b-d8e6-4950-b52e-e7821030fd9d",
          "settings": {
            "room_type_code": "1441192613",
            "rate_plan_code": "BAR",
            "occupancy": 1,
            "pricing_type": "OBP",
            "primary_occ": false
          }
        }
      ]
    },
    "relationships": {
      "group": {
        "data": { "id": "60674dd6-1aeb-4c41-9e0c-8ffb378a4570", "type": "group" }
      },
      "properties": {
        "data": [
          { "id": "acb388d9-546b-42fc-9ae2-baf00e7f0d8c", "type": "property" }
        ]
      }
    }
  }
}
```

Note that the connection **starts disabled**: `is_active` in the create payload has no effect — a new connection is always created with `is_active: false`. Activation is a separate, explicit step.

Only one connection per WebBeds `hotel_code` is allowed on Channex.

### 7. Activate the connection

```
POST /api/v1/channels/{channel_id}/activate
```

No payload. Activation requires the connection to have at least one property and at least one rate plan mapping; activating starts the synchronization — Channex pushes the full current availability, rates and restrictions to WebBeds and begins receiving bookings. WebBeds delivers new, modified and cancelled bookings to Channex itself; no extra setup is needed.

The counterpart is `POST /api/v1/channels/{channel_id}/deactivate`, which stops the synchronization but keeps the connection and its mappings.

### Updating a connection

```
PUT /api/v1/channels/{channel_id}
```

The payload has the same shape as for create (wrapped in `channel`). Two rules matter:

* **`channel` cannot be changed** — a different adapter code is rejected.
* **`rate_plans`, when present, replaces the whole mapping set.** A stored mapping missing from the list is removed, and a mapping sent with `settings: null` is removed as well. Omit `rate_plans` entirely to keep the stored mappings.

### Deleting a connection

```
DELETE /api/v1/channels/{channel_id}
```

An active connection must be deactivated first. Deleting removes the connection and all its mappings; bookings received through it are kept.

### Actions

The WebBeds adapter declares no connection actions — `actions` is empty on the descriptor and on every WebBeds connection.

### WebBeds settings reference

The full set of connection `settings` for WebBeds:

| Setting                    | Description                                                                                                                                                                                                                                                                                                                        |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hotel_code`               | The WebBeds Hotel Code. Required.                                                                                                                                                                                                                                                                                                  |
| `send_email_notifications` | When `true`, Channex sends a notification about each booking.                                                                                                                                                                                                                                                                      |
| `email`                    | The email address the notifications go to.                                                                                                                                                                                                                                                                                         |
| `min_stay_type`            | Which Channex minimum stay restriction is sent to WebBeds: `Arrival` (Min Stay Arrival — counted from the arrival date) or `Through` (Min Stay Through — applied to every stayed-through date). Default `Arrival`.                                                                                                                 |
| `release_period`           | Optional, not declared in the descriptor. How far in advance a booking must be made: a number followed by `d` (days) or `h` (hours), for example `"2d"` or `"36h"`. The minimum is 12 hours, longer values are capped at 720 days, and `"0d"` removes the cutoff. Values that cannot be parsed or are below 12 hours are not sent. |
