> 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

# RequestReview

# Package: cmsCompliance

# Namespace: CmsComplianceService

# Method link: https://dev.wix.com/docs/api-reference/account-level/enterprise/cms-compliance/compliance-review-request-v1/request-review.md

## Permission Scopes:
Enterprise CMS compliance flow : SCOPE.ENTERPRISE.CMS-COMPLIANCE-MANAGE

## Introduction

Submits a CMS compliance action on a data item for review.

Call this method when a user creates, updates, or unpublishes a CMS data item. Send only the
`action`, `dataItemId`, and `collectionId`. The service fetches the relevant data item
version(s) from CMS itself and emits a `ReviewRequested` domain event carrying the action,
the fetched content, and the submitting identity. Nothing is emitted if a fetch fails.

---

## REST API

### Schema

```
 Method: requestReview
 Description: Submits a CMS compliance action on a data item for review.  Call this method when a user creates, updates, or unpublishes a CMS data item. Send only the `action`, `dataItemId`, and `collectionId`. The service fetches the relevant data item version(s) from CMS itself and emits a `ReviewRequested` domain event carrying the action, the fetched content, and the submitting identity. Nothing is emitted if a fetch fails.
 URL: https://www.wixapis.com/cms-compliance/v1/request-review
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  action, dataItemId, collectionId
 Method parameters: 
   param name: action | type: ReviewAction | description: Compliance action performed on a CMS data item. | required: true 
      - enum:
           CREATE - A data item was created.
           UPDATE - A data item was updated.
           UNPUBLISH - A data item was unpublished.
           DELETE - A data item was deleted. `DELETE` isn't currently supported and returns the
`UNSUPPORTED_ACTION` error. Support is planned for the future.
   param name: collectionId | type: collectionId | description: GUID of the CMS collection the data item belongs to. | required: true | validation: maxLength 256
   param name: dataItemId | type: dataItemId | description: GUID of the CMS data item the action was performed on. Matches the item's `_id` in CMS. | required: true | validation: maxLength 128
 Return type: RequestReviewResponse
  - name: complianceReviewRequest | type: ComplianceReviewRequest | description: Submitted compliance review request, also emitted as a `ReviewRequested` event.  
     - name: id | type: string | description: Compliance review request GUID. Matches the `_id` of the submitted data item.  | validation: format GUID
     - name: action | type: ReviewAction | description: Compliance action the user performed on the data item.  
         - enum:
         -     CREATE: A data item was created.
         -     UPDATE: A data item was updated.
         -     UNPUBLISH: A data item was unpublished.
         -     DELETE: A data item was deleted. `DELETE` isn't currently supported and returns the `UNSUPPORTED_ACTION` error. Support is planned for the future.
     - name: currentDataItem | type: DataItem | description: Published (live) version of the data item: what is stored right now and is subject to change. Returned for `UPDATE` and `UNPUBLISH` actions. Absent for `CREATE`, when nothing is live yet.  
        - name: id | type: string | description: Data item GUID.  When an item is inserted into a collection, the item's GUID is automatically assigned a random value. You can optionally provide a custom GUID in `dataItem.id` when inserting the item. If you specify an GUID that already exists in the collection, the insertion will fail.  | validation: maxLength 128, immutable
        - name: dataCollectionId | type: string | description: GUID of the collection this item belongs to.  This is the user-defined collection identifier set when the collection is created (for example, `EvalCustomers`), not a GUID.  | validation: maxLength 256
        - name: data | type: object | description: Data item contents.  Property-value pairs representing the data item's payload. When retrieving a data item, it also includes the following read-only fields:  + `_id`: Item GUID. + `_createdDate`: Date and time the item was added to the collection. + `_updatedDate`: Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have the same value. + `_ownerId`: GUID of the user who created the item. Can be modified with site owner permissions.  
     - name: proposedDataItem | type: DataItem | description: Draft version of the data item: the change that takes effect once approved. Returned for `CREATE` and `UPDATE` actions. Absent for `UNPUBLISH`, when nothing is being drafted.  
     - name: submittedAt | type: string | description: Date and time the action was submitted.  | validation: format date-time
     - name: submittedByUserId | type: string | description: GUID of the user who submitted the action.  | validation: format GUID
     - name: submittedByAccountId | type: string | description: GUID of the account the action was submitted under.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_ACTION | Description: The `action` is missing or isn't a recognized compliance action.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_ACTION | Description: The `action` is recognized but not currently supported. `DELETE` support is planned for the future.
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_IDENTITY | Description: The request identity doesn't include the required account or user GUID.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: ACCOUNT_NOT_AUTHORIZED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CMS_METASITE_NOT_RESOLVED | Description: Couldn't resolve the account's CMS metasite. Exactly one `ACCOUNT_MASTER_CMS` metasite must exist for the account.


```

### Examples

### Request review for an updated data item
Submits an UPDATE compliance action; the response carries the current and proposed versions of the item.

```curl
curl -X POST \
'https://www.wixapis.com/cms-compliance/v1/request-review' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "action": "UPDATE",
  "dataItemId": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
  "collectionId": "Announcements"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.enterpriseCmsCompliance.enterpriseCmsCompliance.requestReview(action, options)
 Description: Submits a CMS compliance action on a data item for review.  Call this method when a user creates, updates, or unpublishes a CMS data item. Send only the `action`, `dataItemId`, and `collectionId`. The service fetches the relevant data item version(s) from CMS itself and emits a `ReviewRequested` domain event carrying the action, the fetched content, and the submitting identity. Nothing is emitted if a fetch fails.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  action, options.dataItemId, options.collectionId, options
 Method parameters: 
   param name: action | type: ReviewAction | description: Compliance action performed on a CMS data item. | required: true 
      - enum:
           CREATE - A data item was created.
           UPDATE - A data item was updated.
           UNPUBLISH - A data item was unpublished.
           DELETE - A data item was deleted. `DELETE` isn't currently supported and returns the
`UNSUPPORTED_ACTION` error. Support is planned for the future.
   param name: options | type: RequestReviewOptions  none | required: true 
        - name: dataItemId | type: string | description: GUID of the CMS data item the action was performed on. Matches the item's `_id` in CMS. | required: true | validation: maxLength 128
        - name: collectionId | type: string | description: GUID of the CMS collection the data item belongs to. | required: true | validation: maxLength 256
 Return type: PROMISE<RequestReviewResponse>
  - name: complianceReviewRequest | type: ComplianceReviewRequest | description: Submitted compliance review request, also emitted as a `ReviewRequested` event.  
     - name: _id | type: string | description: Compliance review request GUID. Matches the `_id` of the submitted data item.  | validation: format GUID
     - name: action | type: ReviewAction | description: Compliance action the user performed on the data item.  
         - enum:
         -     CREATE: A data item was created.
         -     UPDATE: A data item was updated.
         -     UNPUBLISH: A data item was unpublished.
         -     DELETE: A data item was deleted. `DELETE` isn't currently supported and returns the `UNSUPPORTED_ACTION` error. Support is planned for the future.
     - name: currentDataItem | type: DataItem | description: Published (live) version of the data item: what is stored right now and is subject to change. Returned for `UPDATE` and `UNPUBLISH` actions. Absent for `CREATE`, when nothing is live yet.  
        - name: _id | type: string | description: Data item GUID.  When an item is inserted into a collection, the item's GUID is automatically assigned a random value. You can optionally provide a custom GUID in `dataItem.id` when inserting the item. If you specify an GUID that already exists in the collection, the insertion will fail.  | validation: maxLength 128, immutable
        - name: dataCollectionId | type: string | description: GUID of the collection this item belongs to.  This is the user-defined collection identifier set when the collection is created (for example, `EvalCustomers`), not a GUID.  | validation: maxLength 256
        - name: data | type: object | description: Data item contents.  Property-value pairs representing the data item's payload. When retrieving a data item, it also includes the following read-only fields:  + `_id`: Item GUID. + `_createdDate`: Date and time the item was added to the collection. + `_updatedDate`: Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have the same value. + `_ownerId`: GUID of the user who created the item. Can be modified with site owner permissions.  
     - name: proposedDataItem | type: DataItem | description: Draft version of the data item: the change that takes effect once approved. Returned for `CREATE` and `UPDATE` actions. Absent for `UNPUBLISH`, when nothing is being drafted.  
     - name: submittedAt | type: Date | description: Date and time the action was submitted.  
     - name: submittedByUserId | type: string | description: GUID of the user who submitted the action.  | validation: format GUID
     - name: submittedByAccountId | type: string | description: GUID of the account the action was submitted under.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_ACTION | Description: The `action` is missing or isn't a recognized compliance action.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_ACTION | Description: The `action` is recognized but not currently supported. `DELETE` support is planned for the future.
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_IDENTITY | Description: The request identity doesn't include the required account or user GUID.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: ACCOUNT_NOT_AUTHORIZED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CMS_METASITE_NOT_RESOLVED | Description: Couldn't resolve the account's CMS metasite. Exactly one `ACCOUNT_MASTER_CMS` metasite must exist for the account.


```

### Examples

### Request review for an updated data item
Submits an UPDATE compliance action; the response carries the current and proposed versions of the item.

```javascript
import { enterpriseCmsCompliance } from "@wix/enterprise-cms-compliance";

const action = "UPDATE";

const options = {
  dataItemId: "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
  collectionId: "Announcements",
};

async function requestReview() {
  const response = await enterpriseCmsCompliance.requestReview(action, options);
}

/* Promise resolves to:
 * {
 *   "complianceReviewRequest": {
 *     "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *     "action": "UPDATE",
 *     "currentDataItem": {
 *       "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "dataCollectionId": "Announcements",
 *       "data": {
 *         "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *         "title": "Q3 disclosure",
 *         "status": "published"
 *       }
 *     },
 *     "proposedDataItem": {
 *       "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "dataCollectionId": "Announcements__drafts",
 *       "data": {
 *         "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *         "title": "Q3 disclosure (revised)",
 *         "status": "draft"
 *       }
 *     },
 *     "submittedAt": "2024-01-15T10:30:00.000Z",
 *     "submittedByUserId": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
 *     "submittedByAccountId": "4f907f5d-bb05-4d99-90a4-7f55d34e9fe8"
 *   }
 * }
 */

```

### requestReview (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 { enterpriseCmsCompliance } from '@wix/enterprise-cms-compliance';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { enterpriseCmsCompliance },
  // Include the auth strategy and host as relevant
});


async function requestReview(action,options) {
  const response = await myWixClient.enterpriseCmsCompliance.requestReview(action,options);
};
```

---