Search.../

createPolicy( )

Developer Preview

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.

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function createPolicy(policy: Policy): Promise<Policy>

createPolicy Parameters

NAME
TYPE
DESCRIPTION
policy
Policy

Policy info.

Returns

Created policy.

Return Type:

Promise<
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.

Was this helpful?

Create Policy

Copy Code
1import { policies } from 'wix-events.v2';
2import * as wixAuth from 'wix-auth';
3
4//define policy object
5const policy = {
6 body: 'Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.',
7 eventId: '9d720f99-1b5a-4141-9877-d32985391e18',
8 name: 'Terms and Conditions Event 1'
9};
10
11//create policy
12async function elevatedCreatePolicyFunction(){
13 const elevatedCreatePolicy = wixAuth.elevate(policies.createPolicy);
14 try {
15 const result = await elevatedCreatePolicy(policy);
16 return result;
17 }
18 catch (error) {
19 console.error(error);
20 // Handle the error
21 }
22 };
23
24/* Returns a promise that resolves to
25 the created policy.
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*/