Rates Rules

  1. Overview
  2. List rates rules
  3. Get a single rates rule
  4. Create a new rates rule
  5. Update a rates rule
  6. Destroy a rates rule

Overview

This resource represents Rates Rules which drive the behavior behind the calculation of Booking’s initial_price (i.e. the contribution from the Rental.). They are applied on top of the rates defined by either Nightly Rate Map or a combination of Rental’s base_rate, Seasons and Periods.

A detailed description of Rates Rules is available here

Parameters

Name Type Read/Write Description
account Integer Read Account’s ID related to the Rates Rule
rates_table Integer Read Rates Table’s ID related to Rates Rule
seasons Array Read Season’s IDs related to the Rates Rule
id Integer Read Rates Rule’s id.
always_applied Boolean Read Rates Rule’s application status.
kind String Read Rates Rule’s kind. List of types described in enums section.
percentage Decimal Read Rates Rule’s percentage discount.
fixed_amount Decimal Read Rates Rule’s fixed price modifier.
period_name String Read Rates Rule’s period name.
variables Object Read Rates Rule’s variables used depending on kind type. List of variables described in enums section
created_at Time Read Rates Rule’s create time.
updated_at Time Read Rates Rule’s update time.
start_date Date Read Rates Rule’s start date.
end_date Date Read Rates Rule’s end date.
Name Type Read/Write Description Constrains
account Integer Read Account’s ID related to the Rates Rule  
rates_table Integer Read Rates Table’s ID related to Rates Rule  
seasons Array Read Season’s IDs related to the Rates Rule  
id Integer Read Rates Rule’s id.  
season_ids Array Write Season ids related to the rates rule. Use only one of these: season_ids, always_applied (if the value is true) or start_date/end_date
always_applied Boolean Read/Write Rates Rule’s application status. Use only one of these: season_ids, always_applied (if the value is true) or start_date/end_date
kind String Read/Write Rates Rule’s kind. List of types described in enums section. Required, myst be a valid rates rule kind
percentage Decimal Read/Write Rates Rule’s percentage discount. must be greater than or equal to -100, conditionally required depending on kind
fixed_amount Decimal Read/Write Rates Rule’s fixed price modifier. conditionally required depending on kind
period_name String Read/Write Rates Rule’s period name. Maximum length: 50
variables Object Read/Write Rates Rule’s variables used depending on kind type. List of variables described in enums section Conditionally required, depending on kind
created_at Time Read Rates Rule’s create time.  
updated_at Time Read Rates Rule’s update time.  
start_date Date Read/Write Rates Rule’s start date. Use only one of these: season_ids, always_applied (if the value is true) or start_date/end_date, required for some kinds
end_date Date Read/Write Rates Rule’s end date. Use only one of these: season_ids, always_applied (if the value is true) or start_date/end_date, required for some kinds

List rates rules

List all rates rules for a given account.

GET /rates_rules

Response

{
  "links": {
    "rates_rules.rates_table": "https://www.bookingsync.com/api/v3/rates_tables/{rates_rules.rates_table}",
    "rates_rules.seasons": "https://www.bookingsync.com/api/v3/seasons/{rates_rules.seasons}"
  },
  "rates_rules": [
    {
      "id": 23,
      "always_applied": false,
      "fixed_amount": null,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "created_at": "2023-12-11T08:26:25Z",
      "updated_at": "2023-12-11T08:26:25Z",
      "start_date": "2023-12-18",
      "end_date": "2024-08-23",
      "links": {
        "rates_table": 12,
        "seasons": [
          1,
          19
        ]
      }
    }
  ]
}

Get a single rates rule

Returns a single rates rule identified by ID.

GET /rates_rules/:rates_rule_id

Response

{
  "links": {
    "rates_rules.rates_table": "https://www.bookingsync.com/api/v3/rates_tables/{rates_rules.rates_table}",
    "rates_rules.seasons": "https://www.bookingsync.com/api/v3/seasons/{rates_rules.seasons}"
  },
  "rates_rules": [
    {
      "id": 23,
      "always_applied": false,
      "fixed_amount": null,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "created_at": "2023-12-11T08:26:25Z",
      "updated_at": "2023-12-11T08:26:25Z",
      "start_date": "2023-12-18",
      "end_date": "2024-08-23",
      "links": {
        "rates_table": 12,
        "seasons": [
          1,
          19
        ]
      }
    }
  ]
}

Create a new rates rule

Creates a rates rule for given rates table.

POST /rates_tables/:rates_table_id/rates_rules

Example JSON request

{
  "rates_rules": [
    {
      "always_applied": false,
      "fixed_amount": null,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "season_ids": [
        1,
        19
      ],
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "start_date": "2023-12-18",
      "end_date": "2024-08-23"
    }
  ]
}

Response

{
  "links": {
    "rates_rules.rates_table": "https://www.bookingsync.com/api/v3/rates_tables/{rates_rules.rates_table}",
    "rates_rules.seasons": "https://www.bookingsync.com/api/v3/seasons/{rates_rules.seasons}"
  },
  "rates_rules": [
    {
      "id": 23,
      "always_applied": false,
      "fixed_amount": null,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "created_at": "2023-12-11T08:26:25Z",
      "updated_at": "2023-12-11T08:26:25Z",
      "start_date": "2023-12-18",
      "end_date": "2024-08-23",
      "links": {
        "rates_table": 12,
        "seasons": [
          1,
          19
        ]
      }
    }
  ]
}

Update a rates rule

Returns an updated rates rule identified by ID.

PUT /rates_rules/:rates_rule_id

Example JSON request

{
  "rates_rules": [
    {
      "always_applied": false,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "season_ids": [
        1,
        19
      ],
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "start_date": "2023-12-18",
      "end_date": "2024-08-23"
    }
  ]
}

Response

{
  "links": {
    "rates_rules.rates_table": "https://www.bookingsync.com/api/v3/rates_tables/{rates_rules.rates_table}",
    "rates_rules.seasons": "https://www.bookingsync.com/api/v3/seasons/{rates_rules.seasons}"
  },
  "rates_rules": [
    {
      "id": 23,
      "always_applied": false,
      "fixed_amount": null,
      "kind": "late_booking",
      "percentage": "-20.0",
      "period_name": "Late Spring",
      "variables": {
        "days": [
          1
        ],
        "length": 5,
        "unit": "days"
      },
      "created_at": "2023-12-11T08:26:25Z",
      "updated_at": "2023-12-11T08:26:25Z",
      "start_date": "2023-12-18",
      "end_date": "2024-08-23",
      "links": {
        "rates_table": 12,
        "seasons": [
          1,
          19
        ]
      }
    }
  ]
}

Destroy a rates rule

Required OAuth scope: :rates_write

Returns empty response with ‘204 No Content’ status code on success.

DELETE /rates_rules/:rates_rule_id