> 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: updateService(_id: string, service: UpdateService, options: UpdateServiceOptions) # Method package: wixBookingsV2 # Method menu location: wixBookingsV2 --> services --> updateService # Method Link: https://dev.wix.com/docs/velo/apis/wix-bookings-v2/services/update-service.md # Method Description: Updates a service. Partial updates are supported. Each time the service is updated, `revision` increments by 1. You must include the number of the existing revision when updating the service. This ensures you're working with the latest service information and prevents unintended overwrites. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update a service with a full update ```javascript import { services } from 'wix-bookings.v2'; async function updateService() { const serviceToBeCreated = { type: services.ServiceType.APPOINTMENT, name: "Cat Hugging Training", 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 training with our cat hugging experts", defaultCapacity: 30, payment: { rateType: services.RateType.FIXED, fixed: { price: { value: "150", currency: "USD" } }, options: { online: true, inPerson: false, deposit: false, pricingPlan: false }, }, onlineBooking: { enabled: true }, } const newName = "Cat Hugging Training - Advanced"; const createdService = await services.createService(serviceToBeCreated); const updatedService = await services.updateService(createdService._id, {...createdService, name: newName}); console.log('Success! Updated a service:', updatedService); return updatedService; } /* Promise resolves to: * { "type": "CLASS", "sortOrder": 0, "name": "Cat Hugging Training - Advanced", "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 training with our cat hugging experts", "defaultCapacity": 30, "hidden": false, "payment": { "rateType": "FIXED", "fixed": { "price": { "value": "150", "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": "8bf39bc0-a05a-49ff-9ee3-fc29d698988d" }, "staffMemberIds": [], "staffMembers": [], "resourceGroups": [], "serviceResources": [], "supportedSlugs": [ { "name": "cat-hugging-training-advanced", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" }, { "name": "cat-hugging-training-1", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:27 GMT+0100 (Central European Standard Time)" } ], "mainSlug": { "name": "cat-hugging-training-advanced", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" }, "urls": { "servicePage": "https://www.example.com/services-v2-test/service-page/cat-hugging-training-advanced", "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/cat-hugging-training-advanced", "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/cat-hugging-training-advanced" }, "revision": "2", "_id": "a262b133-e7a1-4498-a722-8340ed3f3db3", "_createdDate": "Wed Jan 17 2024 09:37:27 GMT+0100 (Central European Standard Time)", "_updatedDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" } */ ``` ## Update a service with a partial update ```javascript import { services } from 'wix-bookings.v2'; /* * Sample serviceId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28' * Sample serviceName value: 'Cat Hugging Training - Advanced' * Sample serviceRevision value: 1 */ async function updateServiceName(serviceId, serviceName, serviceRevision) { const updatedService = await services.updateService(serviceId, { id: serviceId, name: serviceName, revision: serviceRevision }); console.log('Success! Updated the service name:', updatedService, serviceName); return updatedService; } /* Promise resolves to: * { "type": "CLASS", "sortOrder": 0, "name": "Cat Hugging Training - Advanced", "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 training with our cat hugging experts", "defaultCapacity": 30, "hidden": false, "payment": { "rateType": "FIXED", "fixed": { "price": { "value": "150", "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": "8bf39bc0-a05a-49ff-9ee3-fc29d698988d" }, "staffMemberIds": [], "staffMembers": [], "resourceGroups": [], "serviceResources": [], "supportedSlugs": [ { "name": "cat-hugging-training-advanced", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" }, { "name": "cat-hugging-training-1", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:27 GMT+0100 (Central European Standard Time)" } ], "mainSlug": { "name": "cat-hugging-training-advanced", "custom": false, "_createdDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" }, "urls": { "servicePage": "https://www.example.com/services-v2-test/service-page/cat-hugging-training-advanced", "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/cat-hugging-training-advanced", "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/cat-hugging-training-advanced" }, "revision": "2", "_id": "a262b133-e7a1-4498-a722-8340ed3f3db3", "_createdDate": "Wed Jan 17 2024 09:37:27 GMT+0100 (Central European Standard Time)", "_updatedDate": "Wed Jan 17 2024 09:37:28 GMT+0100 (Central European Standard Time)" } */ ``` ---