> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: createService(service: Service) # Method package: wixBookingsV2 # Method menu location: wixBookingsV2 --> services --> createService # Method Link: https://dev.wix.com/docs/velo/apis/wix-bookings-v2/services/create-service.md # Method Description: Creates a new service. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a class service ```javascript import { services } from 'wix-bookings.v2'; import { categories } from 'wix-bookings.v1'; async function getFirstCategory() { const response = await categories.listCategories(); return response.categories[0] } async function createClass() { const category = await getFirstCategory(); const serviceToBeCreated = { type: services.ServiceType.CLASS, name: "Group Cat Hugging", 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.", tagLine: "Get some purr therapy with our cat hugging service!", defaultCapacity: 30, category: category, media: { mainMedia: { image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000" } }, payment: { rateType: services.RateType.FIXED, fixed: { price: { value: "25", currency: "USD" } }, options: { online: true, inPerson: false, deposit: false, pricingPlan: false } }, onlineBooking: { enabled: true }, } const newService = await services.createService(serviceToBeCreated); console.log('Success! Created a new service:', newService); return newService; } /* Promise resolves to: * { "type": "CLASS", "sortOrder": 3, "name": "Group Cat Hugging", "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.", "tagLine": "Get some purr therapy with our cat hugging service!", "defaultCapacity": 30, "media": { "items": [], "mainMedia": { "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000" } }, "hidden": false, "category": { "name": "Our Services", "sortOrder": 0, "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c" }, "payment": { "rateType": "FIXED", "fixed": { "price": { "value": "25", "currency": "USD" } }, "options": { "online": true, "inPerson": false, "deposit": false, "pricingPlan": false }, "pricingPlanIds": [] }, "onlineBooking": { "enabled": true }, "locations": [ { "type": "BUSINESS" } ], "bookingPolicy": { "revision": "1", "name": "Default policy", "customPolicyDescription": { "enabled": true, "description": "" }, "default": true, "limitEarlyBookingPolicy": { "enabled": false, "earliestBookingInMinutes": 10080 }, "limitLateBookingPolicy": { "enabled": false, "latestBookingInMinutes": 1440 }, "bookAfterStartPolicy": { "enabled": false }, "cancellationPolicy": { "enabled": true, "limitLatestCancellation": false, "latestCancellationInMinutes": 1440 }, "reschedulePolicy": { "enabled": true, "limitLatestReschedule": false, "latestRescheduleInMinutes": 1440 }, "waitlistPolicy": { "enabled": false, "capacity": 10, "reservationTimeInMinutes": 10 }, "participantsPolicy": { "enabled": true, "maxParticipantsPerBooking": 1 }, "resourcesPolicy": { "enabled": false, "autoAssignAllowed": false }, "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0", "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)", "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)" }, "schedule": { "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11" }, "staffMemberIds": [], "staffMembers": [], "resourceGroups": [], "serviceResources": [], "supportedSlugs": [ { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } ], "mainSlug": { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" }, "urls": { "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging", "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging", "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging" }, "revision": "1", "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd", "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)", "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } */ ``` ## Create an appointment service ```javascript import { services } from 'wix-bookings.v2'; import { categories } from 'wix-bookings.v1'; async function getFirstCategory() { const response = await categories.listCategories(); return response.categories[0] } async function createAppointment(staffMemberIds) { const category = await getFirstCategory(); const serviceToBeCreated = { type: services.ServiceType.APPOINTMENT, name: "Personal Cat Hugging", 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.", tagLine: "Get some purr therapy with our cat hugging service!", category: category, media: { mainMedia: { image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/#originWidth=800&originHeight=1000" } }, payment: { rateType: services.RateType.FIXED, fixed: { price: { value: "25", currency: "USD" } }, options: { online: true, inPerson: false, deposit: false, pricingPlan: false }, }, staffMemberIds: staffMemberIds } const newService = await services.createService(serviceToBeCreated); console.log('Success! Created a new service:', newService); return newService; } /* Promise resolves to: * { "type": "APPOINTMENT", "sortOrder": 3, "name": "Group Cat Hugging", "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.", "tagLine": "Get some purr therapy with our cat hugging service!", "defaultCapacity": 30, "media": { "items": [], "mainMedia": { "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000" } }, "hidden": false, "category": { "name": "Our Services", "sortOrder": 0, "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c" }, "payment": { "rateType": "FIXED", "fixed": { "price": { "value": "25", "currency": "USD" } }, "options": { "online": true, "inPerson": false, "deposit": false, "pricingPlan": false }, "pricingPlanIds": [] }, "onlineBooking": { "enabled": true }, "locations": [ { "type": "BUSINESS" } ], "bookingPolicy": { "revision": "1", "name": "Default policy", "customPolicyDescription": { "enabled": true, "description": "" }, "default": true, "limitEarlyBookingPolicy": { "enabled": false, "earliestBookingInMinutes": 10080 }, "limitLateBookingPolicy": { "enabled": false, "latestBookingInMinutes": 1440 }, "bookAfterStartPolicy": { "enabled": false }, "cancellationPolicy": { "enabled": true, "limitLatestCancellation": false, "latestCancellationInMinutes": 1440 }, "reschedulePolicy": { "enabled": true, "limitLatestReschedule": false, "latestRescheduleInMinutes": 1440 }, "waitlistPolicy": { "enabled": false, "capacity": 10, "reservationTimeInMinutes": 10 }, "participantsPolicy": { "enabled": true, "maxParticipantsPerBooking": 1 }, "resourcesPolicy": { "enabled": false, "autoAssignAllowed": false }, "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0", "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)", "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)" }, "schedule": { "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11" }, "staffMemberIds": [], "staffMembers": [], "resourceGroups": [], "serviceResources": [], "supportedSlugs": [ { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } ], "mainSlug": { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" }, "urls": { "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging", "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging", "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging" }, "revision": "1", "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd", "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)", "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } */ ``` ## Create a course service ```javascript import { services } from 'wix-bookings.v2'; import { categories } from 'wix-bookings.v1'; async function getFirstCategory() { const response = await categories.listCategories(); return response.categories[0] } async function createCourse() { const category = await getFirstCategory(); const serviceToBeCreated = { type: services.ServiceType.COURSE, name: "Cat Hugging Training", 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.", tagLine: "Get some purr therapy training with our cat hugging experts", defaultCapacity: 30, category: category, media: { mainMedia: { image: "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/#originWidth=800&originHeight=1000" } }, payment: { rateType: services.RateType.FIXED, fixed: { price: { value: "150", currency: "USD" } }, options: { online: true, inPerson: false, deposit: false, pricingPlan: false }, }, onlineBooking: { enabled: true }, } const newService = await services.createService(serviceToBeCreated); console.log('Success! Created a new service:', newService); return newService; } /* Promise resolves to: * { "type": "COURSE", "sortOrder": 3, "name": "Cat Hugging Training", "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.". "tagLine": "Get some purr therapy training with our cat hugging experts", "defaultCapacity": 30, "media": { "items": [], "mainMedia": { "image": "wix:image://v1/4b3901ffcb8d7ad81a613779d92c9702.jpg/4b3901ffcb8d7ad81a613779d92c9702.jpg#originWidth=800&originHeight=1000" } }, "hidden": false, "category": { "name": "Our Services", "sortOrder": 0, "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c" }, "payment": { "rateType": "FIXED", "fixed": { "price": { "value": "25", "currency": "USD" } }, "options": { "online": true, "inPerson": false, "deposit": false, "pricingPlan": false }, "pricingPlanIds": [] }, "onlineBooking": { "enabled": true }, "locations": [ { "type": "BUSINESS" } ], "bookingPolicy": { "revision": "1", "name": "Default policy", "customPolicyDescription": { "enabled": true, "description": "" }, "default": true, "limitEarlyBookingPolicy": { "enabled": false, "earliestBookingInMinutes": 10080 }, "limitLateBookingPolicy": { "enabled": false, "latestBookingInMinutes": 1440 }, "bookAfterStartPolicy": { "enabled": false }, "cancellationPolicy": { "enabled": true, "limitLatestCancellation": false, "latestCancellationInMinutes": 1440 }, "reschedulePolicy": { "enabled": true, "limitLatestReschedule": false, "latestRescheduleInMinutes": 1440 }, "waitlistPolicy": { "enabled": false, "capacity": 10, "reservationTimeInMinutes": 10 }, "participantsPolicy": { "enabled": true, "maxParticipantsPerBooking": 1 }, "resourcesPolicy": { "enabled": false, "autoAssignAllowed": false }, "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0", "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)", "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)" }, "schedule": { "_id": "8d9560d3-72b9-45c0-a16d-1e73f7d38e11" }, "staffMemberIds": [], "staffMembers": [], "resourceGroups": [], "serviceResources": [], "supportedSlugs": [ { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } ], "mainSlug": { "name": "group-cat-hugging", "custom": false, "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" }, "urls": { "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging", "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging", "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging" }, "revision": "1", "_id": "1204a214-d1fb-41c8-886a-1ec461b990dd", "_createdDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)", "_updatedDate": "Tue Jan 16 2024 17:15:30 GMT+0100 (Central European Standard Time)" } */ ``` ---