# Self-assessment tutorial: Derived Pricing API

In this Self-assessment tutorial, you will use the Derived Pricing API to:

* Setting a leading occupancy for a room/rate
* Setting derived pricing rules for other possible occupancies that this room/rate can accommodate


When successfully implemented, whenever a price is set for a specific room/rate/date combination:

* The price will be for the leading occupancy
* The derived pricing rules will determine the prices for the other occupancy levels


### Who is this for?

You should read this if you're any of the following:

* a developer who works for an existing Connectivity Partner which had certified for Rates & Availability API and is preparing to implement derivedprices
* a developer who wants to estimate the time needed to implement the derivedprices
* a developer who wants to try out derivedprices on test environment


### Before you start

You will need the below to complete the following:

* A test property with an active room type that can cater to 2 or more guests
* Already using OTA_HotelRateAmountNotif or availability to set rates over API


## Step 1 - Specify standard price

For this step, set a price for the maximum occupancy of the room. Don't set an additional price for a single adult.

##### B.XML example:


```xml
<date value="2019-08-28">
  <rate id="12345"/>
  <price>4500.00</price>
</date>
```

##### OTA example:


```xml
<BaseByGuestAmts>
  <BaseByGuestAmt AmountAfterTax="4500" DecimalPlaces="2"/>
</BaseByGuestAmts>
```

When you have specified prices for your rooms, you can specify the desired offsets.

## Step 2 - Specify offsets

Send a request to the following endpoint to specify offset


```http
POST https://supply-xml.booking.com/hotels/xml/derivedprices
```

##### Sample request body


```xml
<request>
  <rooms>
    <room id="1000202">
      <rates>
        <rate id="12345" leading_occupancy="2">
          <occupancy persons="3" percentage="25" round="1" />
          <occupancy persons="4" additional="10" />
          <occupancy persons="5" percentage="-15" />
          <occupancy persons="6" additional="-5" round="0" />
        </rate>
      </rates>
    </room>
  </rooms>
</request>
```

The above request will do the following for the room/rate product of room with ID 1000202 (`<room id="1000202">`) and rate with ID 12345

| XML | DESCRIPTION |
|  --- | --- |
| `<rate id="12345" leading_occupancy="2">` | leading occupancy will be set to 2 persons |
| `<occupancy persons="3" percentage="25" round="1" />` | For a 3-persons bookingthe price will correspond to 25% morealways rounded down to 0 decimal places |
| `<occupancy persons="4" additional="10" />` | For a 4-persons bookingthe price will correspond to an additional amount of 10 in the currency set |
| `<occupancy persons="5" percentage="-15" />` | For a 5-persons bookingthe price will correspond to 15% less |
| `<occupancy persons="6" additional="-5" round="0" />` | For a 6-persons bookingthe price will correspond to an amount decreased by 5, in the currency setnever rounded down |


ul
li
the price will correspond to 25% more
li
always rounded down to 0 decimal places
##### Sample response


```xml
<ok></ok>
<!-- RUID: [UmFuZG9tSVYkc2RlIyh9YWDBx32oy3x3Ccs+urTlxzG2rsOzD1t9dXjyrNEjkjXKN0kEqyEPcel6V+ZiSJd0BvJNx9uCzmGE] -->
```