POST Create bookings in bulk
Use this endpoint to create bookings in bulk
The two parameters delete_all_on_error and stop_on_first_error can be used to achieve transaction-like behavior. If a booking in your solution consists of multiple bookings in Timekit terms, it may be important that all Timekit bookings are in sync with your booking.
The webhooks settings are to override the default webhooks set on app-level. There should be a corresponding webhooks.[X].enabled=false settings for any app-level webhooks that you want disabled, in order to only get one webhook triggered for a bulk transaction. Notice that the disabling of the webhook is present on all but one of the bookings since you will probably still want to be notified at least once on updates to your booking. You should probably always disable all webhooks except on the last booking because if the first booking has no error and the next has (at some subsequent state e.g. ‘cancel’), the webhook might still get triggered even though we reset the state.
Endpoint
POST https://api.timekit.io/v2/bookings/bulk
Parameters
| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
bookings |
body | array_object | yes | The bookings to create, at most 30 per request. Each item takes the same fields as create a booking, except that only these top-level keys are accepted: graph (required), resource_id, project_id, action, customer, settings, related, meta, webhooks, and the event fields (start, end, what, where, description and so on). Other keys, such as widget_id or reservation_id, or custom customer fields, are rejected with a 422. |
|
delete_all_on_error |
body | boolean | false | If true all booking in the request will be deleted if an error occurs | |
stop_on_first_error |
body | boolean | false | If set to true execution will stop on the first error | |
relate_bookings |
body | boolean | false | Create relation between the bulked bookings. |
Request examples
curlcurl -X POST \
-u :live_api_key_7nzvc7wsBQQISLeFSVhROys9V1bUJ1z7 \
-d '{
"bookings": [
{
"graph": "confirm_decline",
"resource_id": "2f9cca48-1b78-4ea4-8626-9934c984a6a4",
"start": "2018-08-20T12:49:58+01:00",
"end": "2018-08-20T13:49:58+01:00",
"what": "Doloremque earum ut illum et incidunt aut.",
"where": "8195 Koss Garden Apt. 873",
"description": "Nesciunt culpa tempora illum et laborum vel vel.",
"action": "create",
"customer": {
"name": "Dr. Arlene Lebsack Sr.",
"email": "umosciski@gmail.com",
"timezone": "Atlantic\/Cape_Verde"
},
"webhooks" : {
"created": {
"enabled": false
},
"confirmed": {
"enabled": false
}
}
},
{
"graph": "confirm_decline",
"resource_id": "2f9cca48-1b78-4ea4-8626-9934c984a6a4",
"start": "2018-08-21T12:49:58+01:00",
"end": "2018-08-21T13:49:58+01:00",
"what": "Doloremque earum ut illum et incidunt aut.",
"where": "8195 Koss Garden Apt. 873",
"description": "Nesciunt culpa tempora illum et laborum vel vel.",
"action": "create",
"customer": {
"name": "Dr. Arlene Lebsack Sr.",
"email": "umosciski@gmail.com",
"timezone": "Atlantic\/Cape_Verde"
},
"webhooks" : {
"created": {
"enabled": false
},
"confirmed": {
"enabled": false
}
}
},
{
"graph": "confirm_decline",
"resource_id": "2f9cca48-1b78-4ea4-8626-9934c984a6a4",
"start": "2018-08-22T12:49:58+01:00",
"end": "2018-08-22T13:49:58+01:00",
"what": "Doloremque earum ut illum et incidunt aut.",
"where": "8195 Koss Garden Apt. 873",
"description": "Nesciunt culpa tempora illum et laborum vel vel.",
"customer": {
"name": "Dr. Arlene Lebsack Sr.",
"email": "umosciski@gmail.com",
"timezone": "Atlantic\/Cape_Verde"
},
"action": "create"
}
],
"delete_all_on_error": true,
"stop_on_first_error": true
}' \
https://api.timekit.io/v2/bookings/bulk
Response examples
201
json{
"data": [
{
"id": "b7dd8206-4849-4454-ac4f-fc361bc751f0",
"state": "tentative",
"graph": "confirm_decline",
"completed": false,
"created_at": "2017-10-20 16:01:07",
"updated_at": "2017-10-20 16:01:08"
},
{
"id": "3d2f3a37-ff69-4dd1-bbdb-1bfa5fc96d4f",
"state": "tentative",
"graph": "confirm_decline",
"completed": false,
"created_at": "2017-10-20 16:01:08",
"updated_at": "2017-10-20 16:01:08"
},
{
"id": "c7b69629-5467-4121-a82d-e9e1c8acb956",
"state": "tentative",
"graph": "confirm_decline",
"completed": false,
"created_at": "2017-10-20 16:01:08",
"updated_at": "2017-10-20 16:01:08"
}
]
}