Create one reservation from a canonical slot
POST /reservations/add/
What It Does
Create one reservation from a current slot returned by the availability endpoint.
Authentication
Requires an API token with the write scope. Send it as a bearer token or with the configured API key header.
Parameters
This endpoint does not define query or path parameters.
Request Body
Content type: application/json
Required: Yes
Schema: ReservationCreate
| Field | Required | Type | Description |
|---|---|---|---|
serviceId | Yes | string | TheBooking service identifier. |
customerId | Yes | string | TheBooking customer identifier. |
providerId | Yes | integer or string | TheBooking provider identifier. |
availabilityId | Yes | string | Canonical slot identifier returned by GET /availability/get/. |
start | Yes | integer (int64) | Unix timestamp for the slot start. |
end | Yes | integer (int64) | Unix timestamp for the slot end. |
data | No | object | Additional structured data accepted by the route. |
Responses
| Status | Meaning | Description | Body |
|---|---|---|---|
200 | Success | Resource created | OkEnvelope + object |
400 | Invalid request | Invalid request or application rule failure | ErrorEnvelope |
401 | Authentication required | Missing or invalid API token | WpRestError |
403 | Forbidden | Invalid, stale, unbookable, or over-capacity slot; or insufficient token scope. | ErrorEnvelope or WpRestError |
404 | Not found | Resource not found | ErrorEnvelope |
Booking Rules
- Use a slot returned by
GET /availability/get/. The API validates the slot again when the reservation is created. - A previously displayed slot can be rejected if capacity, provider occupancy, lead time, or a connected calendar changed in the meantime.
Request Example
curl -X POST "https://example.com/wp-json/thebooking/v1/API/reservations/add/" \
-H "Authorization: Bearer $TBK_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"serviceId": "service_123",
"customerId": "customer_123",
"providerId": 123,
"availabilityId": "slot_123",
"start": 1779148800,
"end": 1779152400,
"data": {}
}'
JSON Body
{
"serviceId": "service_123",
"customerId": "customer_123",
"providerId": 123,
"availabilityId": "slot_123",
"start": 1779148800,
"end": 1779152400,
"data": {}
}
Success Response Example
{
"status": "OK",
"id": "resource_123"
}