Book Products

Current Version: 0.1.0

Global Overview

This API is closely related to the product availability API

Create Booking

POST /api2/book_products

This endpoint allows to create a booking based on a list of products. It requires the createBoeking permission. Modifying the status of a booking after it has been created requires the editBoeking permission.

Example request:

POST /api2/book_products HTTP/1.1
Host: demo.recras.nl
Content-Type: application/json

{
   "status": "reservering",
   "customer": {
      "email": "foo@bar.nl",
      "company_id:" 2,
      "first_name": "foo",
      "last_name": "bar",
      "phone_number": "050-2112222"
   },
   "products":[
      {"amount":1,"product_id":2,"datetime":"2030-01-01 10:00:00"},
      {"amount":1,"product_id":4,"datetime":"2030-01-01 10:00:00", "location_id": 4}
   ],
   "should_invoice": true
}
JSON Parameters:
  • status (string) – required One of reservering (reservation), definitief (confirmed), or pending_online (pending payment). Use pending_online when you handle payment yourself and want Recras to keep the booking provisional until you confirm or cancel it via the set_status links. Pending bookings that are not transitioned before their expiry are automatically cancelled.

  • customer (object) – required Customer object

  • customer.email (string) – required Email

  • customer.company_id (int) – Company id (will be used for the booking as well)

  • customer.first_name (string) – First Name

  • customer.last_name (string) – Last Name

  • customer.phone_number (string) – Phone Number

  • products (array) – required A list of products

  • products[].amount (int) – required The amount to book of this product

  • products[].product_id (int) – required The id of the product to book

  • products[].datetime (datetime) – required ISO8601 or RFC3339 formatted datetime for the start of this product. Should be a valid “startmoment”

  • products[].location_id (int) – Optional location_id for the product

  • should_invoice (boolean) – Defaults to true, and can only be set to false if the global Recras setting permits this.

  • expiry (date) – Only valid for pending_online. YYYY-MM-DD date after which Recras will automatically cancel the booking if it has not been transitioned to definitief or geannuleerd yet. Must not be in the past and must not be after the booking’s start date. Defaults to today, meaning the booking will be cancelled overnight if not transitioned today.

Example response:

HTTP/1.1 201 OK
Content-Type: application/json

{
      "id": 51,
      "ref": "67-1",
      "qr_code": "B:67-1:1:8bfbcfef8aecbb20cb881f1596efd59d9d746ce51cf6008868f19a4528073361",
      "_links": {
          "recras:booking:set_status:confirmed": {
              "href": "/api2/boekingen/51/set_status/definitief",
              "method": "POST"
          },
          "recras:booking:set_status:cancelled": {
              "href": "/api2/boekingen/51/set_status/geannuleerd",
              "method": "POST"
          }
      }
}
Status Codes:
JSON Parameters:
  • id (int) – The id of the created booking

  • ref (string) – The booking reference

  • qr_code (string) – String for a QR-code to scan in the POS

  • _links (object) – An object with HATEOAS Links