> 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
# UpdatePolicy
# Package: eventManagement
# Namespace: PolicyManagement
# Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/policies-v2/update-policy.md
## Permission Scopes:
Manage Policies: SCOPE.DC-EVENTS.MANAGE-POLICIES
## Introduction
Updates a policy.
Each time the policy is updated, `revision` increments by 1. The existing `revision` must be included when updating the policy.
This ensures you're working with the latest policy and prevents unintended overwrites.
---
## REST API
### Schema
```
Method: updatePolicy
Description: Updates a policy. Each time the policy is updated, `revision` increments by 1. The existing `revision` must be included when updating the policy. This ensures you're working with the latest policy and prevents unintended overwrites.
URL: https://www.wixapis.com/events/v2/policies/{policy.id}
Method: PATCH
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: policy, policy.name, policy.id, policy.body, policy.eventId, policy.revision
Method parameters:
param name: policy | type: Policy | description: A Policy is a set of terms and conditions attached to a specific event and shown during RSVP or checkout. You can use Policies to communicate refund, cancellation, and ticket-transfer rules by defining a policy name and body that attendees acknowledge. | required: true
- name: id | type: string | description: Policy GUID. | required: true
- name: revision | type: string | description: Revision number, which increments by 1 each time the policy is updated. To prevent conflicting changes, the current revision must be used when updating a policy. | required: true
- name: name | type: string | description: Policy name that is visible in the dashboard and checkout form. Min: 1 character
Max: 40 characters | required: true
- name: body | type: string | description: Policy body. Usually contains various terms and conditions. Min: 1 character Max: 50,000 characters Note: You can format text using various HTML tags such as `
`, ``, ` `, ``, ` `, ``, ` `, ``, ``, etc. | required: true
- name: eventId | type: string | description: GUID of the event to which the policy belongs. | required: true
Return type: UpdatePolicyResponse
- name: policy | type: Policy | description: Updated policy.
- name: id | type: string | description: Policy GUID.
- name: revision | type: string | description: Revision number, which increments by 1 each time the policy is updated. To prevent conflicting changes, the current revision must be used when updating a policy.
- name: createdDate | type: string | description: Date and time the policy was created in `yyyy-mm-ddThh:mm:sssZ` format.
- name: updatedDate | type: string | description: Date and time the policy was updated in `yyyy-mm-ddThh:mm:sssZ` format.
- name: name | type: string | description: Policy name that is visible in the dashboard and checkout form. Min: 1 character
Max: 40 characters
- name: body | type: string | description: Policy body. Usually contains various terms and conditions. Min: 1 character Max: 50,000 characters Note: You can format text using various HTML tags such as ``, etc.
- name: eventId | type: string | description: GUID of the event to which the policy belongs.
```
### Examples
### Update Policy
```curl
curl -X PATCH 'https://www.wixapis.com/events/v2/policies/7243931d-74e4-4d6a-91f0-4835fa79161e' \
-H 'Content-Type: application/json' \
-H 'Authorization:
Max: 40 characters | required: true
- name: body | type: string | description: Policy body. Usually contains various terms and conditions. Min: 1 character Max: 50,000 characters Note: You can format text using various HTML tags such as ``, etc. | required: true
- name: eventId | type: string | description: GUID of the event to which the policy belongs. | required: true
Return type: PROMISE
Max: 40 characters
- name: body | type: string | description: Policy body. Usually contains various terms and conditions. Min: 1 character Max: 50,000 characters Note: You can format text using various HTML tags such as ``, etc.
- name: eventId | type: string | description: GUID of the event to which the policy belongs.
```
### Examples
### Update Policy (with elevated permissions)
```javascript
import { policies } from '@wix/events';
import { auth } from '@wix/essentials';
// define policy ID and policy object to update
const id = '52f15c5c-ea06-44f4-866a-b1cfa6f4f790';
const policy = {
name: 'Terms and Conditions Event 1',
body: 'If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.',
revision: '2',
eventId: '3d3d5c04-ece0-45a8-85f0-11a58edaa192'
};
// update policy
async function elevatedUpdatePolicyFunction(){
const elevatedUpdatePolicy = auth.elevate(policies.updatePolicy);
try {
const result = await elevatedUpdatePolicy(id, policy);
return result;
}
catch (error) {
console.error(error);
// Handle the error
}
};
/* Returns a promise that resolves to
the updated policy.
{
"_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
"revision": "3",
"_createdDate": "2023-03-07T14:15:44.312Z",
"_updatedDate": "2023-03-07T14:51:52.994Z",
"name": "Terms and Conditions Event 1",
"body": "If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
}
*/
```
### Update Policy
```javascript
import { policies } from '@wix/events';
// define policy ID and policy object to update
const id = '52f15c5c-ea06-44f4-866a-b1cfa6f4f790';
const policy = {
name: 'Terms and Conditions Event 1',
body: 'If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.',
revision: '2',
eventId: '3d3d5c04-ece0-45a8-85f0-11a58edaa192'
};
// update policy
async function updatePolicyFunction(){
try {
const result = await policies.updatePolicy(id, policy);
return result;
}
catch (error) {
console.error(error);
// Handle the error
}
};
/* Returns a promise that resolves to
the updated policy.
{
"_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
"revision": "3",
"_createdDate": "2023-03-07T14:15:44.312Z",
"_updatedDate": "2023-03-07T14:51:52.994Z",
"name": "Terms and Conditions Event 1",
"body": "If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
}
*/
```
### updatePolicy (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).
```javascript
import { createClient } from '@wix/sdk';
import { policies } from '@wix/events';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed
const myWixClient = createClient ({
modules: { policies },
// Include the auth strategy and host as relevant
});
async function updatePolicy(_id,policy) {
const response = await myWixClient.policies.updatePolicy(_id,policy);
};
```
---