index

setBooking JSON


Instructions

Post JSON data here to create or modify a booking in a property.

See here for information about using the JSON API.

The JSON data is similar to that returned by getBookings except it can contain only one booking.

If bookId is specified and exists the booking will be modified. If bookId is not set the booking will be added as a new booking.

It is not necessary to send unchanged fields when modifying a booking, it is better to only include the fields which have changed.

Bookings can be cancelled but not deleted by this function.

Invoice Items

New invoice items can be added by not including an invoiceId. Invoice items can be deleted by setting the description, status, qty and price to an empty string in one operation. Charges should have a positive qty Payments should have a negative qty (-1).

Booking Info Items

Booking info items can be added by supplying the code and text or modified by including the infoItemId. To delete an info item, supply the infoItemId with the code and text both present as empty strings.

Actions

For new bookings it is possible to specify the following actions:

The optional notifyUrl parameter can be used to disable the notify Url action.

For existing bookings the following actions can be specified by sending the field with the authentication and bookId fields.

Example Data

New Booking

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "roomId": "12345",
    "unitId": "1",
    "roomQty": "1",
    "status": "1",
    "firstNight": "2014-10-01",
    "lastNight": "2014-10-01",
    "numAdult": "2",
    "numChild": "0",
    "guestTitle": "Mr",
    "guestFirstName": "Joe",
    "guestName": "Smith",
    "guestEmail": "joe@example.com",
    "guestPhone": "+123456789",
    "guestMobile": "09 87654321",
    "guestFax": "0123456",
    "guestAddress": "1 Big Street",
    "guestCity": "London",
    "guestPostcode": "EX 1234",
    "guestCountry": "United_Kingdom",
    "guestArrivalTime": "late, very late",
    "guestVoucher": "give me discount",
    "guestComments": "Non smoking please",
    "guestCardType": "VISA",
    "guestCardNumber": "0000000000000000",
    "guestCardName": "Mr Smith",
    "guestCardExpiry": "01\/17",
    "guestCardCVV": "000",
    "message": "text",
    "custom1": "text",
    "custom2": "text",
    "custom3": "text",
    "custom4": "text",
    "custom5": "text",
    "custom6": "text",
    "custom7": "text",
    "custom8": "text",
    "custom9": "text",
    "custom10": "text",
    "notes": "VIP",
    "flagColor": "ff0000",
    "flagText": "Show booking in red",
    "price": "100.00",
    "deposit": "10.00",
    "tax": "5.00",
    "commission": "15.00",
    "refererEditable": "online",
    "notifyUrl": "true",
    "notifyGuest": "false",
    "notifyHost": "false",
    "assignBooking": "false",
    "invoice": [
        {
            "description": "lodging",
            "status": "",
            "qty": "1",
            "price": "123.45",
            "vatRate": "10",
            "type": "0"
        }
    ],
    "infoItems": [
        {
            "code": "PAYMENT",
            "text": "Paid $100"
        }
    ]
}

Modify Booking

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "bookId": "12345678",
    "firstNight": "2014-09-30",
    "numAdult": "3",
    "invoice": [
        {
            "description": "deposit payment",
            "status": "",
            "qty": "-1",
            "price": "23.45",
            "vatRate": "10",
            "type": "200"
        }
    ],
    "infoItems": [
        {
            "code": "PAYMENT",
            "text": "Paid $200"
        }
    ]
}

Report Invalid Card to Booking.com

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "bookId": "12345678",
    "bookingcomInvalidCard": true
}

Report No Show to Booking.com

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "bookId": "12345678",
    "bookingcomNoShow": true
}

Report Cancellation Request to Booking.com

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "bookId": "12345678",
    "bookingcomReportCancel": true
}

Make a charge to Stripe

{
    "authentication": {
        "apiKey": "apiKeyAsSetInAccountSettings",
        "propKey": "propKeyAsSetForTheProperty"
    },
    "bookId": "12345678",
    "chargeToStripe": {
        "amount": 10,
        "description": "payment for booking"
    }
}

Sample PHP code

<?php

/*
* The following sample uses a PHP array to construct the JSON data and php-curl to post it to the API.
* This sample will change the guestName of booking 12345678 to Jones
*/

$auth = array();
$auth['apiKey'] = 'apiKeyAsSetInAccountSettings';
$auth['propKey'] = 'propKeyAsSetForTheProperty';

$data = array();
$data['authentication'] = $auth;

$data['bookId'] = '12345678';
$data['guestName'] = 'Jones';

$json = json_encode($data);

$url = "https://api.beds24.com/json/getBookings";

$ch=curl_init();
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;	

?>