Wiki
Clone wikiAPI-2.0 / Create_booking_for_customer
Method: POST
Path: /customer/bookings
Create a new booking as logged-in customer.
IMPORTANT: do not call this API endpoint simultaneously for different bookings with the same discount_code
to prevent discount code (discount, giftcard, reward) overuse.
Request schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Create booking request", "type": "object", "properties": { "location_id": { "type": ["integer", "null"] }, "original_booking_id": { "type": ["integer", "null"] }, "address": { "type": "string", "minLength": 1, "maxLength": 255 }, "city": { "type": ["string", "null"], "minLength": 1, "maxLength": 100 }, "state": { "type": ["string", "null"], "minLength": 1, "maxLength": 3 }, "zip": { "type": ["string", "null"], "minLength": 1, "maxLength": 10 }, "phone": { "type": ["string", "null"], "minLength": 1, "maxLength": 20 }, "sms_notifications": { "type": ["boolean", "null"] }, "frequency_id": { "type": "integer", "minimum": 1 }, "service_date": { "type": "string", "pattern": "\\A\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\z" }, "arrival_window": { "title": "arrival window in minutes", "type": "integer", "minimum": 0, "maximum": 1440 }, "services": { "type": "array", "items": { "title": "Service", "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "hourly": { "type": ["object", "null"], "properties": { "quantity": { "type": "integer", "minimum": 1, "maximum": 100 }, "minutes": { "type": "integer", "minimum": 30, "maximum": 1440, "multipleOf": 30 } }, "required": ["quantity", "minutes"] }, "extras": { "type": ["array", "null"], "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "quantity": { "type": "integer", "minimum": 1, "maximum": 10000 }, "recurring": { "type": ["boolean", "null"] } }, "required": ["id", "quantity"] } }, "pricing_parameters": { "type": ["array", "null"], "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "quantity": { "type": "integer", "minimum": 0, "maximum": 250000 } }, "required": ["id", "quantity"] } } }, "required": ["id"] }, "minItems": 1 }, "discount_code": { "type": ["string", "null"], "minLength": 1, "maxLength": 255 }, "tip": { "type": ["number", "null"], "minimum": 0, "maximum": 100000 }, "tip_recurring": { "type": ["boolean", "null"] }, "payment_method": { "type": "string", "enum": ["stripe", "paypal", "cash", "check"] }, "customer_notes": { "type": ["string", "null"], "minLength": 1 }, "custom_fields": { "type": ["array", "null"], "items": { "oneOf": [{ "title": "Single-Line or Multi-Line values or Date (\\A\\d{4}-\\d{2}-\\d{2}\\z) or DateTime (\\A\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\z) or Checkbox (true or false)", "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "value": { "type": "string", "minLength": 0 } }, "required": ["id", "value"], "additionalProperties": false }, { "title": "Radio buttons, drop downs or checkboxes values", "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "values": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": 1 }, "other": { "type": ["string", "null"] } }, "required": ["id"] }, "minItems": 0 } }, "required": ["id", "values"], "additionalProperties": false }] } } }, "required": [ "address", "frequency_id", "service_date", "arrival_window", "services", "payment_method" ] }
Request attributes are similar to those in Create booking as non-logged-in with few exceptions:
- not required and not expected attributes:
user
not needed in logged-in mode since booking created by logged-in customerstripe_token
not needed even forpayment_method
="stripe". Customer supposed to have at least one credit card registered with account's Stipe, otherwise expect validation erron on attempt create booking usingpayment_method
="stripe".
original_booking_id
(optional) is a reference to booking that was used as "template" to create this booking (this is how "Book This Again" works). Iforiginal_booking_id
provided backend will copy over to the new booking a number of only-staff-can-enter attributes fromoriginal_booking_id
booking. Note:original_booking_id
must be customer's booking, otherwise expect validation error- if you are going to create new booking with
original_booking_id
, useoriginal_booking_id
to estimate price (see Price estimation for booking)
Example request:
For production, replace https://acme-sandbox.l27.co
with https://<your subdomain>.launch27.com
Replace BEARER_FROM_LOGIN with bearer
from Login
curl -H "Content-Type: application/json" \ -H 'Authorization: Bearer BEARER_FROM_LOGIN' \ -X POST -k \ -d '{"address":"595 Market St", "city":"San Francisco", "state":"CA", "zip":"94105", "phone":"462-485-0790", "frequency_id": 2, "service_date": "2019-08-20T09:30:00", "arrival_window":0, "services":[{"id":1}], "payment_method":"cash" }' \ https://acme-sandbox.l27.co/latest/customer/bookings
Example of response
{ "id": 10, "ga_transaction": { "id": "fin76576d5fdadg6f86ag69", "affilation": "awoo12", "revenue": 150, }, "ga_item": { "id": "fin76576d5fdadg6f86ag69", "name": "Booking", "price": 150, "quantity": 1 } }
Where:
id
is unique ID of created bookingga_transaction
andga_item
contain data for GA ecommerce tracking:id
is unique digest code of created bookingname
is alwaysBooking
affilation
is account's subdomainrevenue
is final price of created bookingprice
is final price of created bookingquantity
is always 1
Updated