Alex Reservations - Cancel Booking API
REST API endpoint for cancelling reservations that were created from external platforms such as TheFork, OpenTable, or any integration tool like Zapier.
Base URL: https://your-domain.com/wp-json/alexr/v1
Authentication
All requests must include a valid API key. Two methods are supported:
Option 1: X-API-Key header (recommended)
X-API-Key: your-api-key-here
Option 2: Authorization Bearer header
Authorization: Bearer your-api-key-here
Authentication errors
| HTTP Code | Error Code | Description |
|---|---|---|
| 401 | rest_missing_api_key |
No API key provided in the request headers |
| 401 | rest_invalid_api_key |
The API key does not exist or has been deactivated |
Endpoint
Cancel Booking
POST /wp-json/alexr/v1/bookings/{uuid}/cancel
Cancels a booking that was created from an external platform. Only bookings with a non-empty platform field can be cancelled via this endpoint.
Parameters
| Field | Type | Location | Required | Description |
|---|---|---|---|---|
uuid |
string | URL path | Yes | The booking UUID returned when the booking was created |
send_notifications |
boolean | JSON body | No | Whether to send a cancellation email/SMS to the guest. Default: false |
Example request
curl -X POST https://your-domain.com/wp-json/alexr/v1/bookings/bo_a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel \
-H "Content-Type: application/json" \
-H "X-API-Key: a1b2c3d4e5f6..." \
-d '{
"send_notifications": false
}'
Successful response
HTTP 200 OK
{
"success": true,
"booking_id": 456,
"uuid": "bo_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "cancelled",
"platform": "TheFork",
"platform_booking_id": "TF-123456"
}
If the booking was already cancelled, the response includes an informational message:
{
"success": true,
"message": "Booking is already cancelled",
"booking_id": 456,
"uuid": "bo_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "cancelled",
"platform": "TheFork",
"platform_booking_id": "TF-123456"
}
No error is raised for already-cancelled bookings — the operation is idempotent.
Error responses
HTTP 403 Forbidden - Booking was not created from an external platform
{
"success": false,
"error": "Only bookings created from an external platform can be cancelled via API"
}
HTTP 404 Not Found - Booking not found or does not belong to the API key's restaurant
{
"success": false,
"error": "Booking not found"
}
HTTP 401 Unauthorized - Missing or invalid API key
{
"code": "rest_missing_api_key",
"message": "API key is required. Send it via X-API-Key header or Authorization: Bearer <key>.",
"data": { "status": 401 }
}
How it works
Platform restriction
Only bookings that have a platform value (i.e. bookings originally created via the API with a platform identifier such as "TheFork" or "OpenTable") can be cancelled through this endpoint. Bookings created from the dashboard or the booking widget have a NULL platform and will return a 403 Forbidden error.
This restriction prevents accidental cancellations of internally managed reservations through external integrations.
Notifications
By default, no email or SMS notifications are sent when cancelling a booking via API. This avoids duplicating notifications that the external platform (TheFork, OpenTable) may already send to the guest.
Set send_notifications: true to have Alex Reservations send its own cancellation notifications. When enabled, the following are triggered:
- Email: Booking cancellation email
- SMS: SMS notification
- WhatsApp: WhatsApp notification (if configured)
Idempotency
Calling this endpoint on a booking that is already cancelled does not raise an error. The response will include "status": "cancelled" and an additional "message" field indicating the booking was already in that state. No duplicate action is recorded.
Zapier integration example
When integrating cancellations from TheFork via Zapier:
- Trigger: Reservation cancelled in TheFork (via Zapier's TheFork integration)
- Action: Webhooks by Zapier > POST request
-
Configuration:
-
URL:
https://your-domain.com/wp-json/alexr/v1/bookings/{{uuid}}/cancel - Payload Type: JSON
-
Headers:
X-API-Key: your-api-key-here - Body:
-
URL:
{
"send_notifications": false
}
Note: The
uuidin the URL must be the Alex Reservations UUID returned when the booking was originally created (HTTP 201). Make sure to store this value when processing the create booking response in your Zap.
Response codes summary
| HTTP Code | Meaning |
|---|---|
| 200 | Booking cancelled successfully (or was already cancelled) |
| 401 | Authentication error (missing or invalid API key) |
| 403 | Booking cannot be cancelled via API (not an external platform booking) |
| 404 | Booking not found or does not belong to this restaurant |