Skip to content

Instantly share code, notes, and snippets.

@IRediTOTO
Created April 16, 2025 20:18
Show Gist options
  • Save IRediTOTO/b090187a04dc0ae3bad76f84a53c9dcb to your computer and use it in GitHub Desktop.
Save IRediTOTO/b090187a04dc0ae3bad76f84a53c9dcb to your computer and use it in GitHub Desktop.
Bookings API Documentation with TypeScript Types
# Bookings API Documentation with TypeScript Types
Below is the Bookings API documentation converted from Postman collection to Markdown format with TypeScript types:
## Bookings
### 1. Add Booking (Appointment)
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings`
**Request Type:**
```typescript
interface CreateAppointmentBookingRequest {
type: 'appointment';
bookings: Array<{
extras?: Array<{
id: number;
quantity: number;
}>;
customFields?: Record<
string,
{
label: string;
type: string;
value: string;
}
>;
deposit?: boolean;
locale?: string;
utcOffset?: number | null;
persons: number;
customerId?: number | null;
customer?: {
id?: number | null;
firstName: string;
lastName: string;
email: string;
phone?: string;
countryPhoneIso?: string;
externalId?: string | null;
};
duration?: number;
status?: 'approved' | 'pending' | 'canceled' | 'rejected';
packageCustomerService?: {
id: number;
};
}>;
payment?: {
gateway: 'onSite' | 'payPal' | 'stripe' | 'mollie' | 'razorpay' | 'square';
currency: string;
data?: Record<string, any>;
};
recaptcha?: string | null;
locale?: string;
timeZone?: string;
bookingStart: string; // Format: 'YYYY-MM-DD HH:MM'
notifyParticipants: number; // 0 or 1
locationId?: number | null;
providerId: number;
serviceId: number;
utcOffset?: number | null;
recurring?: any[];
package?: any[];
couponCode?: string | null;
runInstantPostBookingActions?: boolean; // Whether to run post booking actions in this API call
}
```
**Response Type:**
```typescript
interface CreateAppointmentBookingResponse {
message: string;
data: {
type: 'appointment';
appointment: Appointment;
booking: Booking;
utcTime: Array<{
start: string;
end: string;
}>;
appointmentStatusChanged: boolean;
recurring: any[];
package: any[];
packageId: number | null;
customer: Customer;
bookable: Service;
paymentId: number;
packageCustomerId: number | null;
payment: Payment;
customerCabinetUrl: string;
};
}
```
**Example Request:**
```json
{
"type": "appointment",
"bookings": [
{
"extras": [],
"customFields": {
"1": {
"label": "text",
"type": "text",
"value": "custom field value"
}
},
"deposit": true,
"locale": "en_US",
"utcOffset": null,
"persons": 1,
"customerId": null,
"customer": {
"id": null,
"firstName": "Rob",
"lastName": "Stark",
"email": "[email protected]",
"phone": "",
"countryPhoneIso": "",
"externalId": null
},
"duration": 1800
}
],
"payment": {
"gateway": "onSite",
"currency": "USD",
"data": {}
},
"recaptcha": null,
"locale": "en_US",
"timeZone": "Europe/Belgrade",
"bookingStart": "2023-09-06 19:30",
"notifyParticipants": 1,
"locationId": 2,
"providerId": 1,
"serviceId": 1,
"utcOffset": null,
"recurring": [],
"package": [],
"couponCode": null,
"runInstantPostBookingActions": false
}
```
### 2. Add Package Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings`
**Request Type:**
```typescript
interface CreatePackageBookingRequest {
type: 'package';
bookings: Array<{
customFields?: Record<
string,
{
label: string;
type: string;
value: string;
}
>;
deposit?: boolean;
locale?: string;
utcOffset?: number | null;
customerId?: number | null;
customer: {
firstName: string;
lastName: string;
email: string;
phone?: string;
countryPhoneIso?: string;
externalId?: string | null;
translations?: string | null;
};
persons: number;
}>;
payment: {
gateway: 'onSite' | 'payPal' | 'stripe' | 'mollie' | 'razorpay' | 'square';
currency: string;
data?: Record<string, any>;
};
locale?: string;
timeZone?: string;
package: Array<{
bookingStart: string; // Format: 'YYYY-MM-DD HH:MM'
serviceId: number;
providerId: number;
locationId: number;
utcOffset: number;
notifyParticipants: number; // 0 or 1
}>;
packageId: number;
packageRules?: Array<{
serviceId: number;
providerId?: number | null;
locationId?: number | null;
}>;
utcOffset?: number;
couponCode?: string | null;
}
```
**Response Type:**
```typescript
interface CreatePackageBookingResponse {
message: string;
data: {
type: 'package';
package: Array<{
type: 'appointment';
appointment: Appointment;
booking: Booking;
utcTime: Array<{
start: string;
end: string;
}>;
appointmentStatusChanged: boolean;
}>;
booking: null;
utcTime: any[];
appointmentStatusChanged: boolean;
recurring: any[];
packageId: number;
customer: Customer;
bookable: Package;
paymentId: number;
packageCustomerId: number;
payment: Payment;
isCart: boolean;
customerCabinetUrl: string;
};
}
```
**Example Request:**
```json
{
"type": "package",
"bookings": [
{
"customer": {
"firstName": "Amelia",
"lastName": "Test",
"email": "[email protected]",
"phone": ""
},
"persons": 1
}
],
"payment": {
"gateway": "onSite",
"currency": "USD",
"data": {}
},
"package": [
{
"bookingStart": "2024-06-05 07:30",
"serviceId": 1,
"providerId": 4,
"locationId": 8,
"utcOffset": 120,
"notifyParticipants": 1
},
{
"bookingStart": "2024-06-04 10:00",
"serviceId": 11,
"providerId": 4,
"locationId": 8,
"utcOffset": 120,
"notifyParticipants": 1
}
],
"packageId": 1
}
```
### 3. Add Event Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings`
**Request Type:**
```typescript
interface CreateEventBookingRequest {
type: 'event';
bookings: Array<{
customer: {
email: string;
externalId?: string | null;
firstName: string;
id?: number | null;
lastName: string;
phone?: string;
countryPhoneIso?: string;
};
customFields?: Record<
string,
{
label: string;
type: string;
value: string;
}
>;
customerId?: number;
persons: number;
ticketsData?: Array<{
eventTicketId: number;
persons: number;
}> | null;
utcOffset?: number | null;
deposit?: boolean;
}>;
payment: {
amount: string;
gateway: 'onSite' | 'payPal' | 'stripe' | 'mollie' | 'razorpay' | 'square';
currency: string;
};
recaptcha?: boolean | string | null;
locale?: string;
timeZone?: string;
couponCode?: string;
eventId: number;
}
```
**Response Type:**
```typescript
interface CreateEventBookingResponse {
message: string;
data: {
type: 'event';
event: Event;
booking: Booking;
utcTime: Array<{
start: string;
end: string;
}>;
appointmentStatusChanged: boolean;
recurring: any[];
package: any[];
packageId: number | null;
customer: Customer;
bookable: Event;
paymentId: number;
packageCustomerId: number | null;
payment: Payment;
customerCabinetUrl: string;
};
}
```
**Example Request:**
```json
{
"type": "event",
"bookings": [
{
"customer": {
"email": "[email protected]",
"firstName": "Amelia",
"lastName": "Test"
},
"persons": 1
}
],
"payment": {
"amount": "20.00",
"gateway": "onSite",
"currency": "USD"
},
"eventId": 96
}
```
### 4. Add Event Ticket Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings`
**Request Type:**
```typescript
interface CreateEventTicketBookingRequest {
type: 'event';
bookings: Array<{
customer: {
email: string;
externalId?: string | null;
firstName: string;
id?: number | null;
lastName: string;
phone?: string;
countryPhoneIso?: string;
};
customFields?: Record<
string,
{
label: string;
type: string;
value: string;
}
>;
customerId?: number;
extras?: any[];
persons: number;
ticketsData: Array<{
eventTicketId: number;
persons: number;
}>;
utcOffset?: number | null;
deposit?: boolean;
}>;
payment: {
amount: string;
gateway: 'onSite' | 'payPal' | 'stripe' | 'mollie' | 'razorpay' | 'square';
currency: string;
};
recaptcha?: boolean | string | null;
locale?: string;
timeZone?: string;
couponCode?: string;
eventId: number;
}
```
**Response Type:** Same as CreateEventBookingResponse
**Example Request:**
```json
{
"type": "event",
"bookings": [
{
"customer": {
"email": "[email protected]",
"externalId": null,
"firstName": "Amelia",
"id": null,
"lastName": "Test",
"phone": "",
"countryPhoneIso": "rs"
},
"customFields": {
"1": {
"label": "text",
"value": "",
"type": "text"
}
},
"customerId": 0,
"persons": 1,
"ticketsData": [
{
"eventTicketId": 28,
"persons": 2
}
],
"utcOffset": null,
"deposit": false
}
],
"payment": {
"amount": "40.00",
"gateway": "onSite",
"currency": "USD"
},
"recaptcha": false,
"locale": "en_US",
"timeZone": "Europe/Belgrade",
"couponCode": "",
"eventId": 66
}
```
### 5. Post Booking Actions
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings/success/{{booking_id}}`
**Pre-request Script:**
```javascript
pm.variables.set('booking_id', 900);
```
**Request Type:**
```typescript
interface PostBookingActionsRequest {
type: 'appointment' | 'event' | 'package';
appointmentStatusChanged: boolean;
recurring: any[];
packageId: number | null;
customerId: number;
paymentId: number;
packageCustomerId: number | null;
}
```
**Response Type:**
```typescript
interface PostBookingActionsResponse {
message: string;
data: any[];
}
```
**Example Request:**
```json
{
"type": "appointment",
"appointmentStatusChanged": false,
"recurring": [],
"packageId": null,
"customerId": 11,
"paymentId": 916,
"packageCustomerId": null
}
```
### 6. Delete Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings/delete/{{booking_id}}`
**Pre-request Script:**
```javascript
pm.variables.set('booking_id', 732);
```
**Response Type:**
```typescript
interface DeleteBookingResponse {
message: string;
data: {
appointment: Appointment;
bookingsWithChangedStatus: Booking[];
bookingDeleted: boolean;
appointmentDeleted: boolean;
};
}
```
### 7. Cancel Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings/cancel/{{booking_id}}`
**Pre-request Script:**
```javascript
pm.variables.set('booking_id', 732);
```
**Request Type:**
```typescript
interface CancelBookingRequest {
type: 'appointment' | 'event';
}
```
**Response Type:**
```typescript
interface CancelBookingResponse {
message: string;
data: {
event?: Event;
appointment?: Appointment;
appointmentStatusChanged: boolean;
booking: Booking;
type: 'appointment' | 'event';
status: 'canceled';
message: string;
};
}
```
**Example Request:**
```json
{
"type": "event"
}
```
### 8. Reschedule Booking
**Method:** POST
**URL:** `{{admin_ajax_url}}/bookings/reassign/{{booking_id}}`
**Pre-request Script:**
```javascript
pm.variables.set('booking_id', 811);
```
**Request Type:**
```typescript
interface RescheduleBookingRequest {
bookingStart: string; // Format: 'YYYY-MM-DD HH:MM'
utcOffset?: number | null;
timeZone?: string;
}
```
**Response Type:**
```typescript
interface RescheduleBookingResponse {
message: string;
data: {
booking: Booking;
newAppointment: Appointment | null;
oldAppointment: Appointment;
oldAppointmentStatusChanged: boolean;
existingAppointment: Appointment | null;
existingAppointmentStatusChanged: boolean;
initialAppointmentDateTime: {
bookingStart: string;
bookingEnd: string;
};
};
}
```
**Example Request:**
```json
{
"bookingStart": "2023-08-25 12:20",
"utcOffset": null,
"timeZone": "Europe/Belgrade"
}
```
## Common Interface Types
```typescript
interface Appointment {
id: number;
bookings: Booking[];
notifyParticipants: number;
internalNotes: string | null;
status: 'approved' | 'pending' | 'canceled' | 'rejected';
serviceId: number;
parentId: number | null;
providerId: number;
locationId: number | null;
provider: Provider | null;
service: Service | null;
location: Location | null;
googleCalendarEventId: string | null;
googleMeetUrl: string | null;
outlookCalendarEventId: string | null;
zoomMeeting: ZoomMeeting | null;
lessonSpace: any | null;
bookingStart: string;
bookingEnd: string;
type: 'appointment';
isRescheduled: boolean | null;
resources: any[];
}
interface Booking {
id: number;
customerId: number;
customer: Customer | null;
status: 'approved' | 'pending' | 'canceled' | 'rejected';
extras: any[];
couponId: number | null;
price: number;
coupon: Coupon | null;
customFields: string; // JSON string
info: string; // JSON string
appointmentId: number | null;
persons: number;
token: string | null;
payments: Payment[];
utcOffset: number | null;
aggregatedPrice: boolean;
isChangedStatus: boolean | null;
isLastBooking: boolean | null;
packageCustomerService: PackageCustomerService | null;
ticketsData: TicketData[];
duration: number | null;
created: string | null;
actionsCompleted: boolean | null;
isUpdated: boolean | null;
}
interface Customer {
id: number;
firstName: string;
lastName: string;
birthday: string | null;
email: string;
phone: string | null;
type: 'customer';
status: string | null;
note: string | null;
zoomUserId: string | null;
countryPhoneIso: string | null;
externalId: string | null;
pictureFullPath: string | null;
pictureThumbPath: string | null;
translations: string | null; // JSON string
gender: string | null;
locale?: string;
timeZone?: string;
}
interface Payment {
id: number;
customerBookingId: number | null;
packageCustomerId: number | null;
parentId: number | null;
amount: number;
gateway: string;
gatewayTitle: string;
dateTime: string;
status: 'pending' | 'paid' | 'refunded';
data: string;
entity: 'appointment' | 'event' | 'package' | null;
created: string | null;
actionsCompleted: boolean | null;
wcOrderId: number | null;
wcOrderUrl: string | null;
wcItemCouponValue: number | null;
wcItemTaxValue: number | null;
transactionId?: string | null;
}
interface Service {
id: number;
name: string;
description: string;
color: string;
price: number;
deposit: number | null;
depositPayment: 'fixed' | 'percentage' | 'disabled' | null;
depositPerPerson: boolean | null;
pictureFullPath: string | null;
pictureThumbPath: string | null;
extras: ServiceExtra[];
coupons: Coupon[];
position: number | null;
settings: string | null; // JSON string
fullPayment: boolean | null;
minCapacity: number;
maxCapacity: number;
duration: number;
timeBefore: number | null;
timeAfter: number | null;
bringingAnyone: boolean | null;
show: boolean | null;
aggregatedPrice: boolean | null;
status: 'visible' | 'hidden' | 'disabled';
categoryId: number;
category: Category | null;
priority: any[];
gallery: any[];
recurringCycle: string | null;
recurringSub: string | null;
recurringPayment: number | null;
translations: string | null;
minSelectedExtras: number | null;
mandatoryExtra: boolean | null;
customPricing: string | null; // JSON string
maxExtraPeople: number | null;
limitPerCustomer: string | null; // JSON string
}
interface Event {
id: number;
name: string;
description: string;
color: string;
price: number;
deposit: number;
depositPayment: 'fixed' | 'percentage' | 'disabled';
depositPerPerson: boolean;
pictureFullPath: string | null;
pictureThumbPath: string | null;
extras: any[];
coupons: Coupon[];
position: number | null;
settings: string; // JSON string
fullPayment: boolean;
bookings: Booking[];
periods: EventPeriod[];
bookingOpens: string | null;
bookingCloses: string | null;
bookingOpensRec: string;
bookingClosesRec: string;
ticketRangeRec: string;
status: 'approved' | 'pending' | 'canceled' | 'rejected';
recurring: any | null;
maxCapacity: number;
maxCustomCapacity: number | null;
show: boolean;
tags: any[];
customTickets: EventTicket[];
gallery: any[];
providers: Provider[];
notifyParticipants: number;
locationId: number | null;
location: Location | null;
customLocation: string | null;
parentId: number | null;
created: string;
zoomUserId: string | null;
organizerId: number | null;
type: 'event';
bringingAnyone: boolean;
bookMultipleTimes: boolean;
translations: string | null;
customPricing: boolean;
closeAfterMin: number | null;
closeAfterMinBookings: boolean | null;
maxExtraPeople: number | null;
initialEventStart: string | null;
initialEventEnd: string | null;
aggregatedPrice?: boolean;
}
interface Package {
id: number;
name: string;
description: string;
color: string;
price: number;
deposit: number;
depositPayment: 'fixed' | 'percentage' | 'disabled';
depositPerPerson: boolean | null;
pictureFullPath: string | null;
pictureThumbPath: string | null;
extras: any[];
coupons: Coupon[];
position: number;
settings: string; // JSON string
fullPayment: boolean;
type: 'package';
status: 'visible' | 'hidden' | 'disabled';
gallery: any[];
bookable: PackageService[];
calculatedPrice: boolean;
discount: number;
endDate: string | null;
durationCount: number | null;
durationType: string | null;
translations: string | null;
sharedCapacity: boolean;
quantity: number;
limitPerCustomer: string; // JSON string
}
interface PackageService {
id: number;
quantity: number;
service: Service;
minimumScheduled: number;
maximumScheduled: number;
providers: Provider[];
locations: Location[];
allowProviderSelection: boolean;
position?: number | null;
}
interface PackageCustomerService {
id: number;
serviceId: number;
providerId: number | null;
locationId: number | null;
bookingsCount: number;
packageCustomer: {
id: number;
packageId: number;
customerId: number;
price: number;
payments: Payment[];
start: string;
end: string;
purchased: string;
status: string | null;
bookingsCount: number;
couponId: number | null;
coupon: Coupon | null;
};
}
interface EventPeriod {
id: number;
eventId: number;
periodStart: string;
periodEnd: string;
zoomMeeting: ZoomMeeting | null;
lessonSpace: any | null;
bookings: any[];
googleCalendarEventId: string | null;
googleMeetUrl: string | null;
outlookCalendarEventId: string | null;
}
interface EventTicket {
id: number;
eventId: number;
name: string;
enabled: boolean;
price: number;
dateRangePrice: string | null;
spots: number;
dateRanges: string; // JSON string
sold: number;
translations: string | null;
}
interface TicketData {
id: number | null;
eventTicketId: number;
customerBookingId: number | null;
persons: number | null;
price: number;
}
interface ZoomMeeting {
id: number;
startUrl: string;
joinUrl: string;
}
interface Location {
id: number;
status: 'visible' | 'hidden' | 'disabled';
name: string;
description: string;
address: string;
phone: string;
latitude: number;
longitude: number;
pictureFullPath: string | null;
pictureThumbPath: string | null;
pin: string;
translations: string | null;
}
interface ServiceExtra {
id: number;
name: string;
description: string | null;
price: number;
maxQuantity: number;
position: number;
duration: number | null;
serviceId: number | null;
aggregatedPrice: boolean | null;
translations: string | null;
}
```
---
This documentation provides a comprehensive overview of the Bookings API endpoints with TypeScript types for request and response structures, making it easier for developers to integrate with the API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment