Prompt
How do I create, update, and cancel bookings programmatically?
Latest observation
Oct 15, 2026
OpenAI APIWeb search: off
To create, update, and cancel bookings programmatically, you generally use your booking system’s API. The exact endpoints and fields depend on the platform, but the workflow is usually:
1) Create a booking
Send a POST request to a bookings endpoint with the required details, such as:
- customer/contact info
- service/resource being booked
- date and time
- duration
- location
- notes or metadata
Example:
POST /bookings
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"customer": {
"name": "Jane Doe",
"email": "jane@example.com"
},
"service_id": "svc_123",
"start_time": "2026-10-20T14:00:00Z",
"duration_minutes": 60,
"location_id": "loc_456"
}
Typical response:
{
"id": "bk_789",
"status": "confirmed",
"start_time": "2026-10-20T14:00:00Z"
}
2) Update a booking
Use PATCH or PUT to modify an existing booking by ID.
PATCHis usually for partial updatesPUToften replaces the full record
Example:
PATCH /bookings/bk_789
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"start_time": "2026-10-20T15:00:00Z",
"notes": "Client requested a later time"
}
3) Cancel a booking
Usually done with a DELETE request or a dedicated cancel endpoint.
Example with a cancel endpoint:
POST /bookings/bk_789/cancel
Authorization: Bearer YOUR_API_KEY
Or with delete:
DELETE /bookings/bk_789
Authorization: Bearer YOUR_API_KEY
Common implementation notes
- Authenticate with an API key, OAuth token, or similar.
- Validate availability before creating or updating.
- Handle time zones carefully.
- Expect conflict errors if a slot is already taken.
- Check whether cancellations are soft (status change) or hard (delete record).
- Use idempotency keys for create requests if the API supports them, to avoid duplicate bookings.
Example in JavaScript
const response = await fetch("https://api.example.com/bookings", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.API_KEY}`
},
body: JSON.stringify({
customer: { name: "Jane Doe", email: "jane@example.com" },
service_id: "svc_123",
start_time: "2026-10-20T14:00:00Z",
duration_minutes: 60
})
});
const booking = await response.json();
console.log(booking);
If you want, I can also give you:
- a Node.js / Python / cURL example,
- or an example for a specific booking platform (e.g. Calendly, Square, Acuity, etc.).