Search.../

createService( )

Developer Preview

Creates a new service.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Authorization

Request

This endpoint does not take any parameters

Response Object

The created service.

NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the service was created.

_id
string

Service ID.

_updatedDate
Date

Date and time the service was updated.

bookingPolicy
BookingPolicy

Policy determining under what conditions this service can be booked. For example, whether the service can only be booked up to 30 minutes before it begins.

category
V2Category

The category the service is associated with.

conferencing
Conferencing

Conferencing options for this service.

defaultCapacity
number

Default maximum number of customers that can book the service. The service cannot be booked beyond this capacity.

description
string

Service description, such as High-class hair styling, cuts, straightening and color.

extendedFields
ExtendedFields

Extensions enabling users to save custom data related to the service.

form
Form

The form used when booking the service.

hidden
boolean

Whether the service is hidden from the site.

locations
Array<
Location
>

The locations this service is offered at. In case of multiple (more than 1) location, All locations must be of type BUSINESS. For courses only: Currently, only 1 location is supported, for all location types.

mainSlug
Slug

The main slug for the service. mainSlug is either taken from the current service name or is a custom slug set by the business owner. mainSlug is used to construct the service's URLs.

media
Media

Media associated with the service.

name
string

Service name.

onlineBooking
OnlineBooking

Online booking settings.

payment
Payment

Payment options for booking the service.

revision
string

Revision number, which increments by 1 each time the service is updated. To prevent conflicting changes, the existing revision must be used when updating a service.

schedule
Schedule

The service's schedule, which can be used to manage the service's sessions.

seoData
SeoSchema

Custom SEO data for the service.

sortOrder
number

Order of a service within a category.

staffMemberIds
Array<
string
>

IDs of the staff members providing the service. For appointments only.

supportedSlugs
Array<
Slug
>

A slug is the last part of the URL address that serves as a unique identifier of the service. The list of supported slugs includes past service names for backwards compatibility, and a custom slug if one was set by the business owner.

tagLine
string

Short service description, such as Hair styling.

type
string

Service type.

Supported Values:

  • "APPOINTMENT"
  • "CLASS"
  • "COURSE"
urls
URLs

URLs to various service-related pages, such as the calendar page and the booking page.

Status/Error Codes

Was this helpful?

Create a class service

Create a class with a capacity of 30 people.

Copy Code
1
2import { services } from 'wix-bookings.v2';
3import { categories } from 'wix-bookings.v1';
4
5async function getFirstCategory() {
6 const response = await categories.listCategories();
7 return response.categories[0]
8}
9
10async function createClass() {
11 const category = await getFirstCategory();
12
13 const serviceToBeCreated = {
14 type: services.ServiceType.CLASS,
15 name: "Group Cat Hugging",
16 description: "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",
17 tagLine: "Get some purr therapy with our cat hugging service!",
18 defaultCapacity: 30,
19 category: category,
20 media: {
21 mainMedia: {
22 image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000"
23 }
24 },
25 payment: {
26 rateType: services.RateType.FIXED,
27 fixed: {
28 price: {
29 value: "25",
30 currency: "USD"
31 }
32 },
33 options: {
34 online: true,
35 inPerson: false,
36 deposit: false,
37 pricingPlan: false
38 }
39 },
40 onlineBooking: {
41 enabled: true
42 },
43 }
44
45 const newService = await services.createService(serviceToBeCreated);
46
47 console.log('Success! Created a new service:', newService);
48
49 return newService;
50}
51
52/* Promise resolves to:
53 * {
54 "type": "CLASS",
55 "sortOrder": 3,
56 "name": "Group Cat Hugging",
57 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",
58 "tagLine": "Get some purr therapy with our cat hugging service!",
59 "defaultCapacity": 30,
60 "media": {
61 "items": [],
62 "mainMedia": {
63 "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000"
64 }
65 },
66 "hidden": false,
67 "category": {
68 "name": "Our Services",
69 "sortOrder": 0,
70 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"
71 },
72 "payment": {
73 "rateType": "FIXED",
74 "fixed": {
75 "price": {
76 "value": "25",
77 "currency": "USD"
78 }
79 },
80 "options": {
81 "online": true,
82 "inPerson": false,
83 "deposit": false,
84 "pricingPlan": false
85 },
86 "pricingPlanIds": []
87 },
88 "onlineBooking": {
89 "enabled": true
90 },
91 "locations": [
92 {
93 "type": "BUSINESS"
94 }
95 ],
96 "bookingPolicy": {
97 "revision": "1",
98 "name": "Default policy",
99 "customPolicyDescription": {
100 "enabled": true,
101 "description": ""
102 },
103 "default": true,
104 "limitEarlyBookingPolicy": {
105 "enabled": false,
106 "earliestBookingInMinutes": 10080
107 },
108 "limitLateBookingPolicy": {
109 "enabled": false,
110 "latestBookingInMinutes": 1440
111 },
112 "bookAfterStartPolicy": {
113 "enabled": false
114 },
115 "cancellationPolicy": {
116 "enabled": true,
117 "limitLatestCancellation": false,
118 "latestCancellationInMinutes": 1440
119 },
120 "reschedulePolicy": {
121 "enabled": true,
122 "limitLatestReschedule": false,
123 "latestRescheduleInMinutes": 1440
124 },
125 "waitlistPolicy": {
126 "enabled": false,
127 "capacity": 10,
128 "reservationTimeInMinutes": 10
129 },
130 "participantsPolicy": {
131 "enabled": true,
132 "maxParticipantsPerBooking": 1
133 },
134 "resourcesPolicy": {
135 "enabled": false,
136 "autoAssignAllowed": false
137 },
138 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",
139 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",
140 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"
141 },
142 "schedule": {
143 "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11"
144 },
145 "staffMemberIds": [],
146 "staffMembers": [],
147 "resourceGroups": [],
148 "serviceResources": [],
149 "supportedSlugs": [
150 {
151 "name": "group-cat-hugging",
152 "custom": false,
153 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
154 }
155 ],
156 "mainSlug": {
157 "name": "group-cat-hugging",
158 "custom": false,
159 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
160 },
161 "urls": {
162 "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging",
163 "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging",
164 "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging"
165 },
166 "revision": "1",
167 "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd",
168 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)",
169 "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
170}
171 */
Create an appointment service

Create an appointment provided by specific staff members.

Copy Code
1import { services } from 'wix-bookings.v2';
2import { categories } from 'wix-bookings.v1';
3
4async function getFirstCategory() {
5 const response = await categories.listCategories();
6 return response.categories[0]
7}
8
9async function createAppointment(staffMemberIds) {
10
11 const category = await getFirstCategory();
12
13 const serviceToBeCreated = {
14 type: services.ServiceType.APPOINTMENT,
15 name: "Personal Cat Hugging",
16 description: "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",
17 tagLine: "Get some purr therapy with our cat hugging service!",
18 category: category,
19 media: {
20 mainMedia: {
21 image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/#originWidth=800&originHeight=1000"
22 }
23 },
24 payment: {
25 rateType: services.RateType.FIXED,
26 fixed: {
27 price: {
28 value: "25",
29 currency: "USD"
30 }
31 },
32 options: {
33 online: true,
34 inPerson: false,
35 deposit: false,
36 pricingPlan: false
37 },
38 },
39 staffMemberIds: staffMemberIds
40 }
41
42 const newService = await services.createService(serviceToBeCreated);
43
44 console.log('Success! Created a new service:', newService);
45
46 return newService;
47}
48
49/* Promise resolves to:
50 * {
51 "type": "APPOINTMENT",
52 "sortOrder": 3,
53 "name": "Group Cat Hugging",
54 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",
55 "tagLine": "Get some purr therapy with our cat hugging service!",
56 "defaultCapacity": 30,
57 "media": {
58 "items": [],
59 "mainMedia": {
60 "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000"
61 }
62 },
63 "hidden": false,
64 "category": {
65 "name": "Our Services",
66 "sortOrder": 0,
67 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"
68 },
69 "payment": {
70 "rateType": "FIXED",
71 "fixed": {
72 "price": {
73 "value": "25",
74 "currency": "USD"
75 }
76 },
77 "options": {
78 "online": true,
79 "inPerson": false,
80 "deposit": false,
81 "pricingPlan": false
82 },
83 "pricingPlanIds": []
84 },
85 "onlineBooking": {
86 "enabled": true
87 },
88 "locations": [
89 {
90 "type": "BUSINESS"
91 }
92 ],
93 "bookingPolicy": {
94 "revision": "1",
95 "name": "Default policy",
96 "customPolicyDescription": {
97 "enabled": true,
98 "description": ""
99 },
100 "default": true,
101 "limitEarlyBookingPolicy": {
102 "enabled": false,
103 "earliestBookingInMinutes": 10080
104 },
105 "limitLateBookingPolicy": {
106 "enabled": false,
107 "latestBookingInMinutes": 1440
108 },
109 "bookAfterStartPolicy": {
110 "enabled": false
111 },
112 "cancellationPolicy": {
113 "enabled": true,
114 "limitLatestCancellation": false,
115 "latestCancellationInMinutes": 1440
116 },
117 "reschedulePolicy": {
118 "enabled": true,
119 "limitLatestReschedule": false,
120 "latestRescheduleInMinutes": 1440
121 },
122 "waitlistPolicy": {
123 "enabled": false,
124 "capacity": 10,
125 "reservationTimeInMinutes": 10
126 },
127 "participantsPolicy": {
128 "enabled": true,
129 "maxParticipantsPerBooking": 1
130 },
131 "resourcesPolicy": {
132 "enabled": false,
133 "autoAssignAllowed": false
134 },
135 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",
136 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",
137 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"
138 },
139 "schedule": {
140 "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11"
141 },
142 "staffMemberIds": [],
143 "staffMembers": [],
144 "resourceGroups": [],
145 "serviceResources": [],
146 "supportedSlugs": [
147 {
148 "name": "group-cat-hugging",
149 "custom": false,
150 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
151 }
152 ],
153 "mainSlug": {
154 "name": "group-cat-hugging",
155 "custom": false,
156 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
157 },
158 "urls": {
159 "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging",
160 "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging",
161 "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging"
162 },
163 "revision": "1",
164 "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd",
165 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)",
166 "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
167 }
168 */
169
Create a course service

Create a course that can accommodate 30 people.

Copy Code
1import { services } from 'wix-bookings.v2';
2import { categories } from 'wix-bookings.v1';
3
4async function getFirstCategory() {
5 const response = await categories.listCategories();
6 return response.categories[0]
7}
8
9async function createCourse() {
10
11 const category = await getFirstCategory();
12
13 const serviceToBeCreated = {
14 type: services.ServiceType.COURSE,
15 name: "Cat Hugging Training",
16 description: "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.",
17 tagLine: "Get some purr therapy training with our cat hugging experts",
18 defaultCapacity: 30,
19 category: category,
20 media: {
21 mainMedia: {
22 image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/#originWidth=800&originHeight=1000"
23 }
24 },
25 payment: {
26 rateType: services.RateType.FIXED,
27 fixed: {
28 price: {
29 value: "150",
30 currency: "USD"
31 }
32 },
33 options: {
34 online: true,
35 inPerson: false,
36 deposit: false,
37 pricingPlan: false
38 },
39 },
40 onlineBooking: {
41 enabled: true
42 },
43 }
44
45 const newService = await services.createService(serviceToBeCreated);
46
47 console.log('Success! Created a new service:', newService);
48
49 return newService;
50}
51
52/* Promise resolves to:
53 * {
54 "type": "COURSE",
55 "sortOrder": 3,
56 "name": "Cat Hugging Training",
57 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.".
58 "tagLine": "Get some purr therapy training with our cat hugging experts",
59 "defaultCapacity": 30,
60 "media": {
61 "items": [],
62 "mainMedia": {
63 "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000"
64 }
65 },
66 "hidden": false,
67 "category": {
68 "name": "Our Services",
69 "sortOrder": 0,
70 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"
71 },
72 "payment": {
73 "rateType": "FIXED",
74 "fixed": {
75 "price": {
76 "value": "25",
77 "currency": "USD"
78 }
79 },
80 "options": {
81 "online": true,
82 "inPerson": false,
83 "deposit": false,
84 "pricingPlan": false
85 },
86 "pricingPlanIds": []
87 },
88 "onlineBooking": {
89 "enabled": true
90 },
91 "locations": [
92 {
93 "type": "BUSINESS"
94 }
95 ],
96 "bookingPolicy": {
97 "revision": "1",
98 "name": "Default policy",
99 "customPolicyDescription": {
100 "enabled": true,
101 "description": ""
102 },
103 "default": true,
104 "limitEarlyBookingPolicy": {
105 "enabled": false,
106 "earliestBookingInMinutes": 10080
107 },
108 "limitLateBookingPolicy": {
109 "enabled": false,
110 "latestBookingInMinutes": 1440
111 },
112 "bookAfterStartPolicy": {
113 "enabled": false
114 },
115 "cancellationPolicy": {
116 "enabled": true,
117 "limitLatestCancellation": false,
118 "latestCancellationInMinutes": 1440
119 },
120 "reschedulePolicy": {
121 "enabled": true,
122 "limitLatestReschedule": false,
123 "latestRescheduleInMinutes": 1440
124 },
125 "waitlistPolicy": {
126 "enabled": false,
127 "capacity": 10,
128 "reservationTimeInMinutes": 10
129 },
130 "participantsPolicy": {
131 "enabled": true,
132 "maxParticipantsPerBooking": 1
133 },
134 "resourcesPolicy": {
135 "enabled": false,
136 "autoAssignAllowed": false
137 },
138 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",
139 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",
140 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"
141 },
142 "schedule": {
143 "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11"
144 },
145 "staffMemberIds": [],
146 "staffMembers": [],
147 "resourceGroups": [],
148 "serviceResources": [],
149 "supportedSlugs": [
150 {
151 "name": "group-cat-hugging",
152 "custom": false,
153 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
154 }
155 ],
156 "mainSlug": {
157 "name": "group-cat-hugging",
158 "custom": false,
159 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
160 },
161 "urls": {
162 "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging",
163 "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging",
164 "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging"
165 },
166 "revision": "1",
167 "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd",
168 "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)",
169 "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)"
170 }
171 */
172