Home Features Pricing Contact Login

REST API

Create reservation

POST
https://camping.care/api/v1/reservations

Autorisation: API Key

The creating of a reservation starts here. With this function you'll get a reservation ID, with this ID you can update and finish the reservation.

Every reservation starts with the status draft. You can update the draft as much as you like. Once you update the status you will be able to update the status, but not the duration, contact, options etc. Read more about the diverent statusses in the get reservation documentation.

Parameters

arrival
Date
Required - Arrival date for the reservation (YYYY-MM-DD)
departure
Date
Required - Departure date for the reservation (YYYY-MM-DD)
accommodation_id
Integer
Required - Accommodation id for the reservation. The specific id from a accommodation can be get by the function get accommodations.
persons
Integer
Required - The total number of persons in the reservation.
age_table_input
String
Required (if age tables are available) - The age table input of persons for the reservation. The age table input is a JSON string. It should be in this format:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[ 
	{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT }, 
	{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT } 
]


If the administration does not use any age tables this parameter is not required. Read more about age tables
card_id
Integer
The id of an discount card. This id can be found with this function. get cards.

Response

201
application/json; charset=utf-8
id
Integer
The id of the reservation
reservation_id
Integer
The reservation id of the administration. This is the ID that is communicated to the guest.
status
String
The status will always be draft. Read more about reservation statusses.
arrival
Date
Arrival date of the reservation (YYYY-MM-DD)
departure
Date
Departure date of the reservation (YYYY-MM-DD)
create_date
Datetime
Creation date of the reservation (YYYY-MM-DD HH:MM:SS)
total
float
Total total price of the reservation
accommodation_id
Integer
The id of the accommodation for this reservation
rows
ARRAY
Reservation rows

Example


/*
* Example create reservation - How to create a reservation calculated price for a from the Camping.care API
* https://camping.care/developer/reservations/calculate_price
*/

try{

    /*
    * Initialize the Camping.care API SDK with your API key.
    *
    * See: https://camping.care/settings/api
    */

    require_once dirname(__FILE__) . '/../../src/campingcare/Autoloader.php';

    $campingcare = new campingcare_api ;
    $campingcare->set_api_key('YOUR API KEY');

    /*
    * Parameters:
    *   arrival:            Arrival date for the reservation (YYYY-MM-DD) (required)
    *   departure:          Departure date for the reservation (YYYY-MM-DD) (required)
    *   accommodation_id:   Accommodation id for the reservation. The specific id from a accommodation can be get by the function get accommodations
    *   persons:            The total number of persons in the reservation. (required)
    *   age_table_input:    The age table input of persons for the reservation. The age table input is a JSON string. (required*) (*if age tables are available)
    *   card_id:            The id of an discount card. This id can be found with this function. get cards.
    */

    $data = array();

    $data["arrival"] = "2018-04-10";
    $data["departure"] = "2018-04-12";

    // get your accommodation_id with the api function 'Get accommodations'
    $data["accommodation_id"] = 75 ;

    // the total number of persons in this reservation
    $data["persons"] = 5;

    // if there are age tables availeble this data is required.
    // More information about age tables can be found in the 'Get age tables' function
    $data["age_table_input"] = array(
        array(
            "id" => 29, // the id of the age table (Childeren for example)
            "count" => 3 // The number of 'Childeren'
        ),

        array(
            "id" => 30, // the id of the age table (Adults for example)
            "count" => 2 // The number of 'Adults'
        )
    );

    // Optional, the card id, if there is one
    $data["card_id"] = 0 ;



    /*
    * All data is returned in a reservation object
    * The structure can be found here: https://camping.care/developer/reservations/get_reservation.
    */
    $created_reservation = $campingcare->create_reservation($data);

    /*
    * In this example we print the data in json format on the page
    */

    echo "Reservation";
    echo "
";
    echo json_encode($created_reservation, JSON_PRETTY_PRINT);
    echo "
"; }catch(Exception $e){ echo "API call failed: " . htmlspecialchars($e->getMessage()); }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using campingcare;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace campingcare_csharp_sdk_tests
{
    public static class reservation_new
    {
        /*
        * Example create reservation - How to create a reservation from the Camping.care API
        * https://camping.care/developer/reservations/create_reservation
        */

        public static async void create_reservation()
        {
            try
            {

                Console.WriteLine("*************************************");
                Console.WriteLine("***       CREATE RESERVATION      ***");
                Console.WriteLine("*************************************");

                /*
                * Initialize the Camping.care API SDK with your API key.
                *
                * See: https://camping.care/settings/api
                */

                campingcare_api camping_care = new campingcare_api();
                camping_care.set_api_key("YOUR API KEY");

                /*
                * Parameters:
                *   arrival:            Arrival date for the reservation (YYYY-MM-DD) (required)
                *   departure:          Departure date for the reservation (YYYY-MM-DD) (required)
                *   accommodation_id:   Accommodation id for the reservation. The specific id from a accommodation can be get by the function get accommodations
                *   persons:            The total number of persons in the reservation. (required)
                *   age_table_input:    The age table input of persons for the reservation. The age table input is a JSON string. (required*) (*if age tables are available)
                *   card_id:            The id of an discount card. This id can be found with this function. get cards.
                */

                var send_data = new List>();


                send_data.Add(new KeyValuePair("arrival", "2018-03-01"));
                send_data.Add(new KeyValuePair("departure", "2018-03-05"));

                // get your accommodation_id with the api function 'Get accommodations'
                send_data.Add(new KeyValuePair("accommodation_id", "36"));

                send_data.Add(new KeyValuePair("persons", "5"));


                // Create a age table array and genreate age table JSON data
                var age_tables = new List();

                campingcare.age_table_struct age_table0 = new age_table_struct();
                age_table0.id = 29;
                age_table0.count = 3;

                campingcare.age_table_struct age_table1 = new age_table_struct();
                age_table1.id = 30;
                age_table0.count = 2;

                age_tables.Add(age_table0);
                age_tables.Add(age_table1);

                string age_table_json_string = JsonConvert.SerializeObject(age_tables);

                send_data.Add(new KeyValuePair("age_table_input", age_table_json_string));


                /*
                * All data is returned in a reservation object
                * The structure can be found here: https://camping.care/developer/reservations/get_reservation.
                */

                var data = await camping_care.create_reservation(send_data);

                /*
                * In this example we print the data in json format in the console
                */


                JObject json = JObject.Parse(data.ToString());

                foreach (var pair in json)
                {
                    Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
                }

            }
            catch (Exception ex)
            {
                LogData(ex.Message);
            }
        }

        private static void LogData(string Message)
        {
            Console.WriteLine("Error: " + Message);
        }
    }
}



Response example

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "id": "457",
    "reservation_id": "205",
    "contact_id": "154",
    "accommodation_id": "33",
    "place_id": "0",
    "status": "draft",
    "payment": "unpaid",
    "arrival": "2018-04-10",
    "departure": "2018-04-12",
    "create_date": "2017-11-18 20:59:53",
    "total": "28",
    "persons": "2",
    "card_id": "0",
    "age_table_input": "[{\"id\":1,\"count\":2}]",
    "rows": [
        {
            "id": "4248",
            "row_id": "457",
            "type": "product_id",
            "type_id": "33",
            "description": "",
            "amount": "1",
            "total": "0",
            "data": null
        },
        {
            "id": "4249",
            "row_id": "457",
            "type": "product_price",
            "type_id": "36",
            "description": "Pre Season",
            "amount": "2",
            "total": "10",
            "data": "{\"start_date\":\"2018-04-10\",\"end_date\":\"2018-04-12\"}"
        },
        {
            "id": "4250",
            "row_id": "457",
            "type": "product_tax",
            "type_id": "34",
            "description": "Tourist tax",
            "amount": "2",
            "total": "4",
            "data": null
        }
    ]
}



Response Error

Returns an array with error information

230
application/json; charset=utf-8
code
Integer
The error code listed in a list below
message
String
The error message listed in a list below

Error Codes

3000
No valid API key
3010
No new reservation made
3011
No admin ID found
3012
Not a valid arrival date, must be (YYYY-MM-DD)
3013
Not a valid departure date, must be (YYYY-MM-DD)
3018
This accommodation_id does not belong to this administration
0%
()

Cancel upload