> 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
# CreatePolicy
# Package: eventManagement
# Namespace: PolicyManagement
# Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/policies-v2/create-policy.md
## Permission Scopes:
Manage Policies: SCOPE.DC-EVENTS.MANAGE-POLICIES
## Introduction
Creates a policy.
An event may have up to 3 policies.
Attempts to create more than 3 returns a `"POLICIES_LIMIT_REACHED"` error.
---
## REST API
### Schema
```
Method: createPolicy
Description: Creates a policy. An event may have up to 3 policies. Attempts to create more than 3 returns a `"POLICIES_LIMIT_REACHED"` error.
URL: https://www.wixapis.com/events/v2/policies
Method: POST
# 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.body, policy.eventId
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: 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: CreatePolicyResponse
- name: policy | type: Policy | description: Created 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.
Possible Errors:
HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POLICIES_LIMIT_REACHED | Description: Number of policies exceeds the server's limit of 3.
```
### Examples
### Create Policy
```curl
curl -X POST 'https://www.wixapis.com/events/v2/policies' \
-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.
Possible Errors:
HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POLICIES_LIMIT_REACHED | Description: Number of policies exceeds the server's limit of 3.
```
### Examples
### Create Policy (with elevated permissions)
```javascript
import { policies } from '@wix/events';
import { auth } from '@wix/essentials';
const elevatedCreatePolicy = auth.elevate(policies.createPolicy);
//define policy object
const policy = {
body: 'Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.',
eventId: '9d720f99-1b5a-4141-9877-d32985391e18',
name: 'Terms and Conditions Event 1'
};
//create policy
async function myCreatePolicyFunction(){
try {
const result = await elevatedCreatePolicy(policy);
return result;
}
catch (error) {
console.error(error);
// Handle the error
}
};
/* Returns a promise that resolves to
the created policy.
{
"_id": "0907cf78-5177-4482-a627-b17ef06badec",
"revision": "1",
"_createdDate": "2023-03-07T12:48:25.917Z",
"_updatedDate": "2023-03-07T12:48:25.917Z",
"name": "Terms and Conditions Event 1",
"body": "Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.",
"eventId": "9d720f99-1b5a-4141-9877-d32985391e18"
}
*/
```
### Create Policy
```javascript
import { policies } from '@wix/events';
//define policy object
const policy = {
body: 'Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.',
eventId: '9d720f99-1b5a-4141-9877-d32985391e18',
name: 'Terms and Conditions Event 1'
};
//create policy
async function myCreatePolicyFunction(){
try {
const result = await policies.createPolicy(policy);
return result;
}
catch (error) {
console.error(error);
// Handle the error
}
};
/* Returns a promise that resolves to
the created policy.
{
"_id": "0907cf78-5177-4482-a627-b17ef06badec",
"revision": "1",
"_createdDate": "2023-03-07T12:48:25.917Z",
"_updatedDate": "2023-03-07T12:48:25.917Z",
"name": "Terms and Conditions Event 1",
"body": "Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.",
"eventId": "9d720f99-1b5a-4141-9877-d32985391e18"
}
*/
```
### createPolicy (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 createPolicy(policy) {
const response = await myWixClient.policies.createPolicy(policy);
};
```
---