Services API
API for managing services offered by your business
GET /services
Get all services
Query Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
page | number | Current page | 1 |
limit | number | Items per page | 20 |
category | string | Filter by category | - |
active | boolean | Show only active services | true |
Response
json
{
"success": true,
"data": [
{
"id": "svc_123456",
"name": "Haircut",
"description": "Short, long, styled, and blow-dry haircut",
"category": "hair",
"duration": 60,
"price": 300,
"priceType": "fixed",
"image": "https://example.com/haircut.jpg",
"isActive": true,
"totalBookings": 150,
"createdAt": "2023-01-15T08:30:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 25,
"totalPages": 2
}
}GET /services/:id
Get service details by ID
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Service ID (e.g., svc_123456) |
Response
json
{
"success": true,
"data": {
"id": "svc_123456",
"name": "Haircut",
"description": "Short, long, styled, and blow-dry haircut",
"category": "hair",
"duration": 60,
"price": 300,
"priceType": "fixed",
"image": "https://example.com/haircut.jpg",
"isActive": true,
"staff": [
{
"id": "staff_789",
"name": "Daeng",
"price": 350
},
{
"id": "staff_012",
"name": "Khiew",
"price": 300
}
],
"settings": {
"allowOnlineBooking": true,
"requireDeposit": false,
"depositAmount": 0,
"cancellationWindow": 24
},
"stats": {
"totalBookings": 150,
"thisMonth": 25,
"averageRating": 4.8
},
"createdAt": "2023-01-15T08:30:00Z",
"updatedAt": "2024-01-10T12:00:00Z"
}
}POST /services
Create a new service
Request Body
json
{
"name": "Haircut",
"description": "Short, long, styled, and blow-dry haircut",
"category": "hair",
"duration": 60,
"price": 300,
"priceType": "fixed",
"image": "https://example.com/haircut.jpg",
"staff": ["staff_789", "staff_012"],
"settings": {
"allowOnlineBooking": true,
"requireDeposit": false
}
}| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Service name |
description | string | ❌ | Description |
category | string | ❌ | Category |
duration | number | ✅ | Duration (minutes) |
price | number | ✅ | Price |
priceType | string | ❌ | fixed, per_hour, custom |
image | string | ❌ | Image URL |
staff | string[] | ❌ | List of staff IDs who provide this service |
settings | object | ❌ | Additional settings |
Response
json
{
"success": true,
"data": {
"id": "svc_789012",
"name": "Haircut",
"duration": 60,
"price": 300,
"createdAt": "2024-01-15T09:00:00Z"
},
"message": "Service created successfully"
}PATCH /services/:id
Update service information
Request Body
json
{
"name": "Premium Haircut",
"price": 350,
"duration": 75,
"isActive": true
}Response
json
{
"success": true,
"data": {
"id": "svc_123456",
"name": "Premium Haircut",
"price": 350,
"duration": 75,
"updatedAt": "2024-01-15T09:30:00Z"
},
"message": "Service updated successfully"
}DELETE /services/:id
Delete a service (Soft delete)
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
archive | boolean | ❌ | Archive instead of delete (default: true) |
Response
json
{
"success": true,
"message": "Service deleted successfully"
}Example Code
Get Services by Category
typescript
async function getServicesByCategory(category: string) {
const response = await fetch(
`https://api.booking-platform.com/v1/services?category=${category}&active=true`,
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
},
}
);
const { data } = await response.json();
return data;
}
// Usage
const hairServices = await getServicesByCategory('hair');Create a New Service
typescript
async function createService(serviceData: {
name: string;
duration: number;
price: number;
category?: string;
}) {
const response = await fetch('https://api.booking-platform.com/v1/services', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify(serviceData),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.message);
}
return response.json();
}Update Service Price
typescript
async function updateServicePrice(serviceId: string, newPrice: number) {
const response = await fetch(
`https://api.booking-platform.com/v1/services/${serviceId}`,
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ price: newPrice }),
}
);
return response.json();
}Next Steps
- Staff API — View staff details
- API Tester — Test API directly