Create a Booking with a Source

  1. Preface
  2. Requirements
  3. Find a source by name
  4. Create source if not existing
  5. Create a booking with a source

Preface

For a Property Manager and Owner, having the source of a booking, where it originate from, is a really valuable information. To do so, BookingSync API allows you to link a booking with a given source.

Requirements

To use this scenario, you will need to have the bookings_write or bookings_write_owned scope.

Find a source by name

To assign a source when creating a booking, you first need to find it’s ID.

Sources are managed per BookingSync account, so you need to use the List Source endpoint to see, if your desired source is already present.

GET /sources

Response

{
  "links": {
    "sources.account": "https://www.bookingsync.com/api/v3/accounts/{sources.account}",
    "sources.bookings": "https://www.bookingsync.com/api/v3/bookings/{sources.bookings}"
  },
  "sources": [
    {
      "id": 1,
      "name": "Airbnb",
      "position": 1,
      "created_at": "2023-12-11T08:26:21Z",
      "updated_at": "2023-12-11T08:26:21Z",
      "links": {
        "account": 1,
        "bookings": [
          1,
          3
        ]
      }
    }
  ]
}

Create source if not existing

If the source you are looking for could not be found, you should create a new source.

POST /sources

Example JSON request

{
  "sources": [
    {
      "name": "Booking.com"
    }
  ]
}

Response

{
  "links": {
    "sources.account": "https://www.bookingsync.com/api/v3/accounts/{sources.account}",
    "sources.bookings": "https://www.bookingsync.com/api/v3/bookings/{sources.bookings}"
  },
  "sources": [
    {
      "id": 2,
      "name": "Booking.com",
      "position": 2,
      "created_at": "2023-12-11T08:26:21Z",
      "updated_at": "2023-12-11T08:26:21Z",
      "links": {
        "account": 1,
        "bookings": [

        ]
      }
    }
  ]
}

Create a booking with a source

Now that you have the source ID that you want to use, you can create your booking with the source_id parameter.

POST /rentals/:rental_id/bookings

Example JSON request

{
  "bookings": [
    {
      "adults": 2,
      "booked": true,
      "children": 3,
      "client_id": 1,
      "currency": "EUR",
      "final_price": "3000.0",
      "initial_price": "3000.0",
      "source_id": 2,
      "start_at": "2023-12-18T08:26:21Z",
      "end_at": "2023-12-25T08:26:21Z"
    }
  ]
}

Response

{
  "links": {
    "bookings.account": "https://www.bookingsync.com/api/v3/accounts/{bookings.account}",
    "bookings.bookings_fees": "https://www.bookingsync.com/api/v3/bookings_fees/{bookings.bookings_fees}",
    "bookings.bookings_tags": "https://www.bookingsync.com/api/v3/bookings_tags/{bookings.bookings_tags}",
    "bookings.bookings_taxes": "https://www.bookingsync.com/api/v3/bookings_taxes/{bookings.bookings_taxes}",
    "bookings.client": "https://www.bookingsync.com/api/v3/clients/{bookings.client}",
    "bookings.rental": "https://www.bookingsync.com/api/v3/rentals/{bookings.rental}",
    "bookings.rental_agreement": "https://www.bookingsync.com/api/v3/rental_agreements/{bookings.rental_agreement}",
    "bookings.rentals_tags": "https://www.bookingsync.com/api/v3/rentals_tags/{bookings.rentals_tags}",
    "bookings.source": "https://www.bookingsync.com/api/v3/sources/{bookings.source}"
  },
  "bookings": [
    {
      "id": 1,
      "adults": 2,
      "booked": true,
      "bookings_payments_count": 0,
      "children": 3,
      "currency": "EUR",
      "discount": null,
      "downpayment": null,
      "final_price": "3000.0",
      "initial_price": "3000.0",
      "locked": null,
      "notes": "",
      "paid_amount": "0.0",
      "review_requests_count": 0,
      "status": "Booked",
      "unavailable": false,
      "created_at": "2023-12-11T08:26:21Z",
      "updated_at": "2023-12-11T08:26:21Z",
      "start_at": "2023-12-18T08:26:21Z",
      "end_at": "2023-12-25T08:26:21Z",
      "canceled_at": null,
      "tentative_expires_at": null,
      "links": {
        "account": 1,
        "bookings_fees": [

        ],
        "bookings_tags": [

        ],
        "bookings_taxes": [

        ],
        "client": 1,
        "rental": 1,
        "rental_agreement": null,
        "rentals_tags": [

        ],
        "source": 2
      }
    }
  ],
  "meta": {
  }
}