> 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

# GetCommentContext

# Package: comments

# Namespace: CommentsContextHost

# Method link: https://dev.wix.com/docs/api-reference/crm/community/feedback-moderation/comments/comment-context/get-comment-context.md

## Permission Scopes:
Read Comments: SCOPE.DC_COMMENTS.READ.COMMENTS

## Introduction

Retrieves the comment permissions resolved for the current identity in the specified context.

Unlike category `permissionsSettings`, which describe the configured policy, the returned
permissions are the resolved result for the caller: they account for the identity's roles,
including site owner and moderator overrides.

Specify `REGISTRATION_DATA` in `fields` to also return the site's registration policy
(`registrationData`). Registration data resolution is best effort: when the site's sign-on
policy can't be resolved, the field is omitted and the rest of the response is returned.

---

## REST API

### Schema

```
 Method: getCommentContext
 Description: Retrieves the comment permissions resolved for the current identity in the specified context.  Unlike category `permissionsSettings`, which describe the configured policy, the returned permissions are the resolved result for the caller: they account for the identity's roles, including site owner and moderator overrides.  Specify `REGISTRATION_DATA` in `fields` to also return the site's registration policy (`registrationData`). Registration data resolution is best effort: when the site's sign-on policy can't be resolved, the field is omitted and the rest of the response is returned.
 URL: https://www.wixapis.com/comments/v1/contexts/{appId}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  appId, contextId
 Method parameters: 
   param name: appId | type:   none | required: true 
   query param name: contextId | type: contextId | description: GUID of the context where the comments are made. For example, a blog post GUID or a comments category GUID, depending on the hosting app. | required: true | validation: maxLength 128
   query param name: contextType | type: contextType | description: Type of the context, as defined by the hosting app. For example, Wix Blog uses `postPage`. Pass the value your integration uses.  | validation: maxLength 128
   query param name: fields | type: array<fields> | description: Additional fields to return. Supports `REGISTRATION_DATA`.  If omitted, `registrationData` isn't returned.  | validation: maxItems 1
                 - enum:
                 -     REGISTRATION_DATA: The site registration (sign-on) policy, resolved from a separate service.
 Return type: GetCommentContextResponse
  - name: context | type: CommentContext | description: Retrieved comment context, with permissions resolved for the current identity.  
     - name: appId | type: string | description: GUID of the app that hosts the comments, such as Wix Blog or Wix Comments. See **Integrations** in the Comments introduction for the value each Wix app uses.  | validation: format GUID
     - name: contextId | type: string | description: GUID of the context where the comments are made. For example, a blog post GUID or a comments category GUID, depending on the hosting app.  | validation: minLength 1, maxLength 128
     - name: contextType | type: string | description: Type of the context, as defined by the hosting app. For example, Wix Blog uses `postPage`. Returned as passed in the request.  | validation: maxLength 128
     - name: permissions | type: Permissions | description: Comment permissions resolved for the current identity in this context, including site owner and moderator overrides.  
        - name: viewContext | type: boolean | description: Permission to view comments  
        - name: createComment | type: boolean | description: Permission to create comments  
        - name: createReply | type: boolean | description: Permission to create reply  
        - name: updateAnyComment | type: boolean | description: Permission to update any comment  
        - name: deleteAnyComment | type: boolean | description: Permission to delete any comment  
        - name: rateResource | type: boolean | description: Permission to rate a resource  
        - name: markComment | type: boolean | description: Permission to mark a comment  
        - name: voteComment | type: boolean | description: Permission to vote on a comment  
        - name: reportComment | type: boolean | description: Permission to report a comment  
        - name: reactToComment | type: boolean | description: Permission to react to a comment  
     - name: registrationData | type: RegistrationData | description: Site registration (sign-on) policy, resolved for the site. Returned only when the request `fields` include `REGISTRATION_DATA`, and omitted when the policy could not be resolved.  | read-only: true 
        - name: requireOwnerApproval | type: boolean | description: Whether new member signups require owner approval before becoming active.  
        - name: requireEmailVerification | type: boolean | description: Whether new members must verify their email address.  


```

### Examples

### Get a comment context
Retrieve the resolved permissions for the current identity in a Wix Blog post context, requesting the site registration policy as an additional field.

```curl
curl -X GET \
'https://www.wixapis.com/comments/v1/contexts/14bcded7-0066-7c35-14d7-466cb3f09103?contextId=64ad407e0bf87891bba7de3a&contextType=postPage&fields=REGISTRATION_DATA' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.comments.commentContexts.getCommentContext(appId, contextId, options)
 Description: Retrieves the comment permissions resolved for the current identity in the specified context.  Unlike category `permissionsSettings`, which describe the configured policy, the returned permissions are the resolved result for the caller: they account for the identity's roles, including site owner and moderator overrides.  Specify `REGISTRATION_DATA` in `fields` to also return the site's registration policy (`registrationData`). Registration data resolution is best effort: when the site's sign-on policy can't be resolved, the field is omitted and the rest of the response is returned.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  appId, contextId
 Method parameters: 
   param name: appId | type: string | description: GUID of the app that hosts the comments, such as Wix Blog or Wix Comments. See **Integrations** in the Comments introduction for the value each Wix app uses. | required: true | validation: format GUID
   param name: contextId | type: string | description: GUID of the context where the comments are made. For example, a blog post GUID or a comments category GUID, depending on the hosting app. | required: true | validation: maxLength 128
   param name: options | type: GetCommentContextOptions  none  
        - name: contextType | type: string | description: Type of the context, as defined by the hosting app. For example, Wix Blog uses `postPage`. Pass the value your integration uses.  | validation: maxLength 128
        - name: fields | type: array<GetCommentContextRequestedFields> | description: Additional fields to return. Supports `REGISTRATION_DATA`.  If omitted, `registrationData` isn't returned.  | validation: maxItems 1
             - enum:
             -     REGISTRATION_DATA: The site registration (sign-on) policy, resolved from a separate service.
 Return type: PROMISE<CommentContext>
  - name: appId | type: string | description: GUID of the app that hosts the comments, such as Wix Blog or Wix Comments. See **Integrations** in the Comments introduction for the value each Wix app uses.  | validation: format GUID
  - name: contextId | type: string | description: GUID of the context where the comments are made. For example, a blog post GUID or a comments category GUID, depending on the hosting app.  | validation: minLength 1, maxLength 128
  - name: contextType | type: string | description: Type of the context, as defined by the hosting app. For example, Wix Blog uses `postPage`. Returned as passed in the request.  | validation: maxLength 128
  - name: permissions | type: Permissions | description: Comment permissions resolved for the current identity in this context, including site owner and moderator overrides.  
     - name: viewContext | type: boolean | description: Permission to view comments  
     - name: createComment | type: boolean | description: Permission to create comments  
     - name: createReply | type: boolean | description: Permission to create reply  
     - name: updateAnyComment | type: boolean | description: Permission to update any comment  
     - name: deleteAnyComment | type: boolean | description: Permission to delete any comment  
     - name: rateResource | type: boolean | description: Permission to rate a resource  
     - name: markComment | type: boolean | description: Permission to mark a comment  
     - name: voteComment | type: boolean | description: Permission to vote on a comment  
     - name: reportComment | type: boolean | description: Permission to report a comment  
     - name: reactToComment | type: boolean | description: Permission to react to a comment  
  - name: registrationData | type: RegistrationData | description: Site registration (sign-on) policy, resolved for the site. Returned only when the request `fields` include `REGISTRATION_DATA`, and omitted when the policy could not be resolved.  | read-only: true 
     - name: requireOwnerApproval | type: boolean | description: Whether new member signups require owner approval before becoming active.  
     - name: requireEmailVerification | type: boolean | description: Whether new members must verify their email address.  


```

### Examples

### Get the current identity's comment permissions
Use visitor or member authentication. The response reflects the caller's resolved permissions, including owner and moderator overrides.

```javascript
import { commentContexts } from "@wix/comments";

export async function getCommentContextExample() {
  const response = await commentContexts.getCommentContext(
    "14bcded7-0066-7c35-14d7-466cb3f09103",
    "64ad407e0bf87891bba7de3a",
    {
      contextType: "postPage",
      fields: ["REGISTRATION_DATA"],
    },
  );
  return response;
}

/* Promise resolves to:
{
  appId: "14bcded7-0066-7c35-14d7-466cb3f09103",
  contextId: "64ad407e0bf87891bba7de3a",
  contextType: "postPage",
  permissions: {
    viewContext: true,
    createComment: true,
    createReply: true,
    updateAnyComment: false,
    deleteAnyComment: false,
    rateResource: false,
    markComment: false,
    voteComment: false,
    reportComment: true,
    reactToComment: true
  },
  registrationData: {
    requireOwnerApproval: false,
    requireEmailVerification: true
  }
}
*/

```

### getCommentContext (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 { commentContexts } from '@wix/comments';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function getCommentContext(appId,contextId,options) {
  const response = await myWixClient.commentContexts.getCommentContext(appId,contextId,options);
};
```

---