Create Booking
curl --request POST \
--url https://api.example.com/wp-json/latepoint-api/v1/bookings \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"service_id": 123,
"agent_id": {},
"start_date": "<string>",
"start_time": "<string>",
"customer_id": 123,
"customer.first_name": "<string>",
"customer.last_name": "<string>",
"customer.email": "<string>",
"customer.phone": "<string>",
"location_id": 123,
"duration": 123,
"price": "<string>",
"status": "<string>",
"notes": "<string>",
"send_confirmation": true
}
'import requests
url = "https://api.example.com/wp-json/latepoint-api/v1/bookings"
payload = {
"service_id": 123,
"agent_id": {},
"start_date": "<string>",
"start_time": "<string>",
"customer_id": 123,
"customer.first_name": "<string>",
"customer.last_name": "<string>",
"customer.email": "<string>",
"customer.phone": "<string>",
"location_id": 123,
"duration": 123,
"price": "<string>",
"status": "<string>",
"notes": "<string>",
"send_confirmation": True
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
service_id: 123,
agent_id: {},
start_date: '<string>',
start_time: '<string>',
customer_id: 123,
'customer.first_name': '<string>',
'customer.last_name': '<string>',
'customer.email': '<string>',
'customer.phone': '<string>',
location_id: 123,
duration: 123,
price: '<string>',
status: '<string>',
notes: '<string>',
send_confirmation: true
})
};
fetch('https://api.example.com/wp-json/latepoint-api/v1/bookings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/wp-json/latepoint-api/v1/bookings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'service_id' => 123,
'agent_id' => [
],
'start_date' => '<string>',
'start_time' => '<string>',
'customer_id' => 123,
'customer.first_name' => '<string>',
'customer.last_name' => '<string>',
'customer.email' => '<string>',
'customer.phone' => '<string>',
'location_id' => 123,
'duration' => 123,
'price' => '<string>',
'status' => '<string>',
'notes' => '<string>',
'send_confirmation' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/wp-json/latepoint-api/v1/bookings"
payload := strings.NewReader("{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/wp-json/latepoint-api/v1/bookings")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/wp-json/latepoint-api/v1/bookings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}"
response = http.request(request)
puts response.read_body{
"status": "error",
"error": {
"code": "invalid_request",
"message": "Invalid input data",
"details": {
"service_id": "The specified service does not exist",
"start_time": "Invalid time format, use HH:MM",
"customer.email": "Invalid email"
}
}
}
{
"status": "error",
"error": {
"code": "time_slot_unavailable",
"message": "The requested time slot is not available",
"details": {
"requested_time": "2024-01-20 14:30",
"agent_id": 3,
"conflicting_booking_id": 145,
"available_slots": [
"2024-01-20 15:30",
"2024-01-20 16:30"
]
}
}
}
{
"status": "error",
"error": {
"code": "validation_failed",
"message": "The provided data failed validation",
"details": {
"start_date": "Date cannot be in the past",
"agent_id": "Agent is not available on this date",
"customer.phone": "Invalid phone format"
}
}
}
{
"status": "error",
"error": {
"code": "forbidden",
"message": "You do not have permission to create bookings"
}
}
Bookings
Create Booking
Creates a new booking in the LatePoint system with automatic availability validation.
POST
/
wp-json
/
latepoint-api
/
v1
/
bookings
Create Booking
curl --request POST \
--url https://api.example.com/wp-json/latepoint-api/v1/bookings \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"service_id": 123,
"agent_id": {},
"start_date": "<string>",
"start_time": "<string>",
"customer_id": 123,
"customer.first_name": "<string>",
"customer.last_name": "<string>",
"customer.email": "<string>",
"customer.phone": "<string>",
"location_id": 123,
"duration": 123,
"price": "<string>",
"status": "<string>",
"notes": "<string>",
"send_confirmation": true
}
'import requests
url = "https://api.example.com/wp-json/latepoint-api/v1/bookings"
payload = {
"service_id": 123,
"agent_id": {},
"start_date": "<string>",
"start_time": "<string>",
"customer_id": 123,
"customer.first_name": "<string>",
"customer.last_name": "<string>",
"customer.email": "<string>",
"customer.phone": "<string>",
"location_id": 123,
"duration": 123,
"price": "<string>",
"status": "<string>",
"notes": "<string>",
"send_confirmation": True
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
service_id: 123,
agent_id: {},
start_date: '<string>',
start_time: '<string>',
customer_id: 123,
'customer.first_name': '<string>',
'customer.last_name': '<string>',
'customer.email': '<string>',
'customer.phone': '<string>',
location_id: 123,
duration: 123,
price: '<string>',
status: '<string>',
notes: '<string>',
send_confirmation: true
})
};
fetch('https://api.example.com/wp-json/latepoint-api/v1/bookings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/wp-json/latepoint-api/v1/bookings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'service_id' => 123,
'agent_id' => [
],
'start_date' => '<string>',
'start_time' => '<string>',
'customer_id' => 123,
'customer.first_name' => '<string>',
'customer.last_name' => '<string>',
'customer.email' => '<string>',
'customer.phone' => '<string>',
'location_id' => 123,
'duration' => 123,
'price' => '<string>',
'status' => '<string>',
'notes' => '<string>',
'send_confirmation' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/wp-json/latepoint-api/v1/bookings"
payload := strings.NewReader("{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/wp-json/latepoint-api/v1/bookings")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/wp-json/latepoint-api/v1/bookings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service_id\": 123,\n \"agent_id\": {},\n \"start_date\": \"<string>\",\n \"start_time\": \"<string>\",\n \"customer_id\": 123,\n \"customer.first_name\": \"<string>\",\n \"customer.last_name\": \"<string>\",\n \"customer.email\": \"<string>\",\n \"customer.phone\": \"<string>\",\n \"location_id\": 123,\n \"duration\": 123,\n \"price\": \"<string>\",\n \"status\": \"<string>\",\n \"notes\": \"<string>\",\n \"send_confirmation\": true\n}"
response = http.request(request)
puts response.read_body{
"status": "error",
"error": {
"code": "invalid_request",
"message": "Invalid input data",
"details": {
"service_id": "The specified service does not exist",
"start_time": "Invalid time format, use HH:MM",
"customer.email": "Invalid email"
}
}
}
{
"status": "error",
"error": {
"code": "time_slot_unavailable",
"message": "The requested time slot is not available",
"details": {
"requested_time": "2024-01-20 14:30",
"agent_id": 3,
"conflicting_booking_id": 145,
"available_slots": [
"2024-01-20 15:30",
"2024-01-20 16:30"
]
}
}
}
{
"status": "error",
"error": {
"code": "validation_failed",
"message": "The provided data failed validation",
"details": {
"start_date": "Date cannot be in the past",
"agent_id": "Agent is not available on this date",
"customer.phone": "Invalid phone format"
}
}
}
{
"status": "error",
"error": {
"code": "forbidden",
"message": "You do not have permission to create bookings"
}
}
Description
This endpoint allows you to create a new booking in your LatePoint system. It includes automatic availability validation, creation of new customers if necessary, and application of configured business rules.Authentication
string
required
Your LatePoint API key. You can get it from the admin panel.
Request Body
Required Fields
integer
required
ID of the service to book
integer|string
required
ID of the agent who will provide the service. Use “any” or “-1” for automatic agent assignment based on availability
string
required
Booking date (format: YYYY-MM-DD)
string
required
Start time (format: HH:MM in 24-hour format)
Customer Information
integer
ID of an existing customer. If provided, new customer fields are ignored
string
Customer first name (required if customer_id is not provided)
string
Customer last name (required if customer_id is not provided)
string
Customer email (required if customer_id is not provided)
string
Customer phone
Optional Fields
integer
Location ID (uses default location if not specified)
integer
Custom duration in minutes (uses service default duration)
string
Custom price (uses service default price)
string
default:"pending"
Initial booking statusPossible values:
pending- Pendingapproved- Approvedcancelled- Cancelled
string
Additional notes for the booking
boolean
default:"true"
Whether to send confirmation email to customer
Respuesta
Success Response (201 Created)
string
Response status (“success”)
object
Created booking object
Show Created Booking Structure
Show Created Booking Structure
integer
Unique ID of the created booking
string
Unique code generated for the booking
string
Booking status
string
Start date (YYYY-MM-DD)
string
Start time (HH:MM)
string
Calculated end time (HH:MM)
integer
Duration in minutes
string
Total booking price
object
Customer information (created or existing)
object
Agent information
object
Service information
object
Location information
string
Creation date and time (ISO 8601)
Examples
Create Booking with Existing Customer
curl -X POST "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings" \
-H "X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ" \
-H "Content-Type: application/json" \
-d '{
"service_id": 2,
"agent_id": 1,
"customer_id": 2,
"start_date": "2025-09-01",
"start_time": "14:30",
"status": "approved",
"notes": "Consulta de seguimiento"
}'
const bookingData = {
service_id: 7,
agent_id: 3,
customer_id: 45,
start_date: '2024-01-20',
start_time: '14:30',
status: 'approved',
notes: 'Consulta de seguimiento'
};
const response = await fetch('https://your-site.com/wp-json/latepoint-api/v1/bookings', {
method: 'POST',
headers: {
'X-API-Key': 'lp_live_1234567890abcdef',
'Content-Type': 'application/json'
},
body: JSON.stringify(bookingData)
});
const result = await response.json();
console.log(result);
import requests
import json
booking_data = {
'service_id': 7,
'agent_id': 3,
'customer_id': 45,
'start_date': '2024-01-20',
'start_time': '14:30',
'status': 'approved',
'notes': 'Consulta de seguimiento'
}
response = requests.post(
'http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings',
headers={
'X-API-Key': 'lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ',
'Content-Type': 'application/json'
},
data=json.dumps(booking_data)
)
result = response.json()
print(result)
<?php
$booking_data = [
'service_id' => 7,
'agent_id' => 3,
'customer_id' => 45,
'start_date' => '2024-01-20',
'start_time' => '14:30',
'status' => 'approved',
'notes' => 'Consulta de seguimiento'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($booking_data),
CURLOPT_HTTPHEADER => [
'X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ',
'Content-Type: application/json'
]
]);
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
print_r($result);
?>
Create Booking with New Customer
curl -X POST "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings" \
-H "X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ" \
-H "Content-Type: application/json" \
-d '{
"service_id": 2,
"agent_id": 1,
"start_date": "2025-09-01",
"start_time": "16:00",
"customer": {
"first_name": "Ana",
"last_name": "López",
"email": "ana.lopez@email.com",
"phone": "+52 555 987 6543"
},
"status": "pending",
"send_confirmation": true
}'
const bookingData = {
service_id: 7,
agent_id: 3,
start_date: '2024-01-20',
start_time: '16:00',
customer: {
first_name: 'Ana',
last_name: 'López',
email: 'ana.lopez@email.com',
phone: '+52 555 987 6543'
},
status: 'pending',
send_confirmation: true
};
const response = await fetch('https://your-site.com/wp-json/latepoint-api/v1/bookings', {
method: 'POST',
headers: {
'X-API-Key': 'lp_live_1234567890abcdef',
'Content-Type': 'application/json'
},
body: JSON.stringify(bookingData)
});
const result = await response.json();
import requests
import json
booking_data = {
'service_id': 7,
'agent_id': 3,
'start_date': '2024-01-20',
'start_time': '16:00',
'customer': {
'first_name': 'Ana',
'last_name': 'López',
'email': 'ana.lopez@email.com',
'phone': '+52 555 987 6543'
},
'status': 'pending',
'send_confirmation': True
}
response = requests.post(
'https://your-site.com/wp-json/latepoint-api/v1/bookings',
headers={
'X-API-Key': 'lp_live_1234567890abcdef',
'Content-Type': 'application/json'
},
data=json.dumps(booking_data)
)
result = response.json()
Example Response
Successfully Created Booking
{
"status": "success",
"data": {
"id": 156,
"booking_code": "LP-2024-002",
"status": "approved",
"start_date": "2024-01-20",
"start_time": "14:30",
"end_time": "15:30",
"duration": 60,
"price": "75.00",
"customer": {
"id": 45,
"first_name": "Juan",
"last_name": "Pérez",
"email": "juan.perez@email.com",
"phone": "+52 555 123 4567"
},
"agent": {
"id": 3,
"display_name": "Dr. María García",
"email": "maria.garcia@clinica.com"
},
"service": {
"id": 7,
"name": "Consulta General",
"duration": 60,
"price": "75.00"
},
"location": {
"id": 1,
"name": "Clínica Principal",
"address": "Av. Reforma 123, CDMX"
},
"notes": "Consulta de seguimiento",
"created_at": "2024-01-15T10:30:00Z"
}
}
Error Codes
{
"status": "error",
"error": {
"code": "invalid_request",
"message": "Invalid input data",
"details": {
"service_id": "The specified service does not exist",
"start_time": "Invalid time format, use HH:MM",
"customer.email": "Invalid email"
}
}
}
{
"status": "error",
"error": {
"code": "time_slot_unavailable",
"message": "The requested time slot is not available",
"details": {
"requested_time": "2024-01-20 14:30",
"agent_id": 3,
"conflicting_booking_id": 145,
"available_slots": [
"2024-01-20 15:30",
"2024-01-20 16:30"
]
}
}
}
{
"status": "error",
"error": {
"code": "validation_failed",
"message": "The provided data failed validation",
"details": {
"start_date": "Date cannot be in the past",
"agent_id": "Agent is not available on this date",
"customer.phone": "Invalid phone format"
}
}
}
{
"status": "error",
"error": {
"code": "forbidden",
"message": "You do not have permission to create bookings"
}
}
Validations
Automatic Validations
The system performs the following validations automatically:- Agent Availability: Verifies that the agent is available at the requested time
- Working Hours: Validates that the time is within the agent’s working hours
- Service Duration: Verifies there is enough time to complete the service
- Valid Dates: Does not allow bookings on past dates
- Unique Email: If creating a new customer, verifies the email is not already in use
Business Rules
Existing vs New Customer: If you provide
customer_id, all customer fields are ignored. If you don’t provide customer_id, the first_name, last_name and email fields are required.Availability Check: Always verify availability using the
/availability endpoint before creating a booking to avoid conflicts.Booking Codes: Booking codes are automatically generated following the pattern
LP-YYYY-NNN where YYYY is the year and NNN is a sequential number.Recommended Flow
1. Check Availability
// First check availability
const availabilityResponse = await fetch(
`/wp-json/latepoint-api/v1/availability?service_id=7&agent_id=3&date=2024-01-20&duration=60`
);
const availability = await availabilityResponse.json();
if (availability.data.available_slots.includes('14:30')) {
// Proceed with booking creation
}
2. Create the Booking
// Create the booking if available
const bookingResponse = await fetch('/wp-json/latepoint-api/v1/bookings', {
method: 'POST',
headers: {
'X-API-Key': 'tu_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify(bookingData)
});
3. Handle the Response
if (bookingResponse.ok) {
const result = await bookingResponse.json();
console.log('Booking created:', result.data.booking_code);
} else {
const error = await bookingResponse.json();
console.error('Error:', error.error.message);
}
Common Use Cases
1. Quick Booking (Existing Customer)
// For customers already in the system
const quickBooking = {
service_id: 7,
agent_id: 3,
customer_id: 45,
start_date: '2024-01-20',
start_time: '14:30',
status: 'approved'
};
2. First Booking (New Customer)
// For new customers
const newCustomerBooking = {
service_id: 7,
agent_id: 3,
start_date: '2024-01-20',
start_time: '14:30',
customer: {
first_name: 'Ana',
last_name: 'López',
email: 'ana.lopez@email.com',
phone: '+52 555 987 6543'
},
send_confirmation: true
};
3. Booking with Custom Configuration
// With custom duration and price
const customBooking = {
service_id: 7,
agent_id: 3,
customer_id: 45,
start_date: '2024-01-20',
start_time: '14:30',
duration: 90, // 90 minutes instead of default 60
price: '100.00', // Custom price
notes: 'Extended session with complete evaluation'
};```
⌘I
