This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
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.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateService(
_id: string,
service: UpdateService,
options: UpdateServiceOptions,
): Promise<Service>;
Service ID.
Update a service given the entire service, with the changes applied.
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)"
}
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.