> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# ReorderEventPolicies

# Package: eventManagement

# Namespace: PolicyManagement

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/policies-v2/reorder-event-policies?apiView=SDK.md

## Permission Scopes:
Manage Policies: SCOPE.DC-EVENTS.MANAGE-POLICIES

## Introduction

Changes policy order in an event dashboard and agreement checkbox on the checkout form.
By default, policies are arranged by the created date in descending order.

> **Note:** It is possible to use both `beforePolicyId` and `afterPolicyId` at the same time but only the last one defined will be executed.

---

## REST API

### Schema

```
 Method: reorderEventPolicies
 Description: Changes policy order in an event dashboard and agreement checkbox on the checkout form. By default, policies are arranged by the created date in descending order.  > **Note:** It is possible to use both `beforePolicyId` and `afterPolicyId` at the same time but only the last one defined will be executed.
 URL: https://www.wixapis.com/events-policies/v2/policies/reorder
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  policyId, eventId
 Method parameters: 
   param name: eventId | type: eventId | description: Event GUID to which the policy belongs. | required: true | validation: format GUID
   param name: policyId | type: policyId | description: GUID of the policy to reorder. | required: true | validation: format GUID
    - ONE-OF: 
     - name: beforePolicyId | type: string | description: Move the given policy before this specified policy.  | validation: format GUID
     - name: afterPolicyId | type: string | description: Move the given policy after this specified policy.  | validation: format GUID
 Return type: ReorderEventPoliciesResponse
  - name: policies | type: array<Policy> | description: Policies in the new order.  
     - name: id | type: string | description: Policy GUID.  | read-only: true | validation: format 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.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the policy was created in `yyyy-mm-ddThh:mm:sssZ` format.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the policy was updated in `yyyy-mm-ddThh:mm:sssZ` format.  | read-only: true | validation: format date-time
     - name: name | type: string | description: Policy name that is visible in the dashboard and checkout form.  Min: 1 character  <br/> Max: 40 characters  | validation: minLength 1, maxLength 40
     - name: body | type: string | description: Policy body. Usually contains various terms and conditions.  Min: 1 character Max: 50,000 characters  <b>Note:</b> You can format text using various HTML tags such as `<p>`, `<b>`, `<ul>`, etc.  | validation: minLength 1, maxLength 50000
     - name: eventId | type: string | description: GUID of the event to which the policy belongs.  | validation: format GUID, immutable

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_REORDER_INSTRUCTION | Description: Both `beforePolicyId` and `afterPolicyId` can't be specified at the same time.


```

### Examples

### Reorder Policies
```curl
curl -X POST 'https://www.wixapis.com/events/v2/policies/reorder' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH TOKEN>' \
--data-binary '{
  "eventId": "9d720f99-1b5a-4141-9877-d32985391e18",
  "policyId": "7243931d-74e4-4d6a-91f0-4835fa79161e",
  "beforePolicyId": "0edc5dc9-3c0b-4b80-80c7-452d4009bf89"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.events.policies.reorderEventPolicies(policyId, eventId, options)
 Description: Changes policy order in an event dashboard and agreement checkbox on the checkout form. By default, policies are arranged by the created date in descending order.  > **Note:** It is possible to use both `beforePolicyId` and `afterPolicyId` at the same time but only the last one defined will be executed.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  policyId, eventId
 Method parameters: 
   param name: policyId | type: string | description: GUID of the policy to reorder. | required: true | validation: format GUID
   param name: eventId | type: string | description: Event GUID to which the policy belongs. | required: true | validation: format GUID
   param name: options | type: ReorderEventPoliciesOptions  none  
    - ONE-OF: 
     - name: beforePolicyId | type: string | description: Move the given policy before this specified policy.  | validation: format GUID
     - name: afterPolicyId | type: string | description: Move the given policy after this specified policy.  | validation: format GUID
 Return type: PROMISE<ReorderEventPoliciesResponse>
  - name: policies | type: array<Policy> | description: Policies in the new order.  
     - name: _id | type: string | description: Policy GUID.  | read-only: true | validation: format 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.  | read-only: true | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the policy was created in `yyyy-mm-ddThh:mm:sssZ` format.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the policy was updated in `yyyy-mm-ddThh:mm:sssZ` format.  | read-only: true 
     - name: name | type: string | description: Policy name that is visible in the dashboard and checkout form.  Min: 1 character  <br/> Max: 40 characters  | validation: minLength 1, maxLength 40
     - name: body | type: string | description: Policy body. Usually contains various terms and conditions.  Min: 1 character Max: 50,000 characters  <b>Note:</b> You can format text using various HTML tags such as `<p>`, `<b>`, `<ul>`, etc.  | validation: minLength 1, maxLength 50000
     - name: eventId | type: string | description: GUID of the event to which the policy belongs.  | validation: format GUID, immutable

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_REORDER_INSTRUCTION | Description: Both `beforePolicyId` and `afterPolicyId` can't be specified at the same time.


```

### Examples

### Reorder Policies (with elevated permissions)
```javascript
import { policies } from '@wix/events';
import { auth } from '@wix/essentials';

// define event ID and policies to reorder
const policyId = '52f15c5c-ea06-44f4-866a-b1cfa6f4f790';
const eventId = '3d3d5c04-ece0-45a8-85f0-11a58edaa192';
const options = {
  beforePolicyId: '6933ddf1-26c7-46c3-9924-e78c833d6cca'
};

// reorder policies
async function elevatedReorderPoliciesFunction(policyId, eventId, options) {
  const elevatedReorderPolicies = auth.elevate(policies.reorderEventPolicies);
   try {
     const result = await elevatedReorderPolicies(policyId, eventId, options);
     return result;
   } 
   catch (error) {
     console.error(error);
     // Handle the error
   }
 };

/* Returns a promise that resolves to
 the reordered policies.
{
  "policies": [
    {
      "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
      "revision": "2",
      "_createdDate": "2023-03-07T14:15:44.312Z",
      "_updatedDate": "2023-03-07T14:33:00.876Z",
      "name": "Terms and Conditions Event 1",
      "body": "<p><code>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    },
    {
      "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
      "revision": "2",
      "_createdDate": "2023-03-07T13:18:09.185Z",
      "_updatedDate": "2023-03-07T14:33:01.072Z",
      "name": "Terms and Conditions Event 2",
      "body": "<p><code>Nobody will be allowed admission to the Event without a valid ticket or pass.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    },
    {
      "_id": "b9d5f876-f961-497a-9f30-9edae95d8f87",
      "revision": "1",
      "_createdDate": "2023-03-07T14:16:25.452Z",
      "_updatedDate": "2023-03-07T14:16:25.452Z",
      "name": "Terms and Conditions Event 3",
      "body": "<p><code>All tickets or passes should be checked on purchase, as mistakes cannot always be rectified.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    }
  ]
}
*/
```

### Reorder Policies
```javascript
import { policies } from '@wix/events';

// define event ID and policies to reorder
const policyId = '52f15c5c-ea06-44f4-866a-b1cfa6f4f790';
const eventId = '3d3d5c04-ece0-45a8-85f0-11a58edaa192';
const options = {
  beforePolicyId: '6933ddf1-26c7-46c3-9924-e78c833d6cca'
};

// reorder policies
async function reorderPoliciesFunction(){
   try {
     const result = await policies.reorderEventPolicies(policyId, eventId, options);
     return result;
   } 
   catch (error) {
     console.error(error);
     // Handle the error
   }
 };

/* Returns a promise that resolves to
 the reordered policies.
{
  "policies": [
    {
      "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
      "revision": "2",
      "_createdDate": "2023-03-07T14:15:44.312Z",
      "_updatedDate": "2023-03-07T14:33:00.876Z",
      "name": "Terms and Conditions Event 1",
      "body": "<p><code>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    },
    {
      "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
      "revision": "2",
      "_createdDate": "2023-03-07T13:18:09.185Z",
      "_updatedDate": "2023-03-07T14:33:01.072Z",
      "name": "Terms and Conditions Event 2",
      "body": "<p><code>Nobody will be allowed admission to the Event without a valid ticket or pass.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    },
    {
      "_id": "b9d5f876-f961-497a-9f30-9edae95d8f87",
      "revision": "1",
      "_createdDate": "2023-03-07T14:16:25.452Z",
      "_updatedDate": "2023-03-07T14:16:25.452Z",
      "name": "Terms and Conditions Event 3",
      "body": "<p><code>All tickets or passes should be checked on purchase, as mistakes cannot always be rectified.</code></p>",
      "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
    }
  ]
}
*/
```

### reorderEventPolicies (self-managed)
Self-managed 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 reorderEventPolicies(policyId,eventId,options) {
  const response = await myWixClient.policies.reorderEventPolicies(policyId,eventId,options);
};
```

---