Search.../

createPolicy( )

Creates a policy.

Description

The createPolicy() function returns a Promise that resolves to the newly-created policy.

You can create up to 3 policies per event. If you try to create more than 3, you'll get the "Maximum number of policies for the event has been reached" error.

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

Created policy.

NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time when the policy was created.

_id
string

Policy ID.

_updatedDate
Date

Date and time of the policy's latest update in.

body
string

Policy body, usually containing various terms and conditions.

Min: 1 character

Max: 50000 characters.

Note: You can format text using various HTML tags such as <p>, <b>, <ul>, etc.

eventId
string

ID of the event to which the policy belongs.

name
string

Policy name that is visible in the dashboard and checkout form.

Min: 1 character

Max: 40 characters

revision
string

Revision number, which increments by 1 each time the policy is updated. The existing revision must be used when updating a policy to prevent conflicting changes. You'll get an error if you try to use the previous revision.

Status/Error Codes

Was this helpful?

Create Policy (dashboard page code)

Copy Code
1import { policies } from 'wix-events.v2';
2
3//define policy object
4const policy = {
5 body: 'Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.',
6 eventId: '9d720f99-1b5a-4141-9877-d32985391e18',
7 name: 'Terms and Conditions Event 1'
8};
9
10//create policy
11async function myCreatePolicyFunction(){
12 try {
13 const result = await policies.createPolicy(policy);
14 return result;
15 }
16 catch (error) {
17 console.error(error);
18 // Handle the error
19 }
20 };
21
22/* Returns a promise that resolves to
23 the created policy.
24{
25 "_id": "0907cf78-5177-4482-a627-b17ef06badec",
26 "revision": "1",
27 "_createdDate": "2023-03-07T12:48:25.917Z",
28 "_updatedDate": "2023-03-07T12:48:25.917Z",
29 "name": "Terms and Conditions Event 1",
30 "body": "Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.",
31 "eventId": "9d720f99-1b5a-4141-9877-d32985391e18"
32}
33*/
34
Create Policy (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { policies } from 'wix-events.v2';
3import { elevate } from 'wix-auth';
4
5//define policy object
6const policy = {
7 body: 'Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.',
8 eventId: '9d720f99-1b5a-4141-9877-d32985391e18',
9 name: 'Terms and Conditions Event 1'
10};
11
12//create policy
13export const elevatedCreatePolicyFunction = webMethod(Permissions.Anyone, async () => {
14 const elevatedCreatePolicy = elevate(policies.createPolicy);
15 try {
16 const result = await elevatedCreatePolicy(policy);
17 return result;
18 }
19 catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23 });
24
25/* Promise resolves to:
26 * {
27 * "_id": "0907cf78-5177-4482-a627-b17ef06badec",
28 * "revision": "1",
29 * "_createdDate": "2023-03-07T12:48:25.917Z",
30 * "_updatedDate": "2023-03-07T12:48:25.917Z",
31 * "name": "Terms and Conditions Event 1",
32 * "body": "Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.",
33 * "eventId": "9d720f99-1b5a-4141-9877-d32985391e18"
34 * }
35 */