> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Flagging

> Flag, unflag, and check flag status for posts and comments.

Use content flagging APIs when users need to report posts or comments for review. The SDK supports flagging, unflagging, and checking whether the current user has flagged a loaded item.

<Info>
  TypeScript, iOS, and Android support reasoned flagging for posts and comments. Flutter supports post and comment flag/unflag actions, but the current public post/comment flag builders do not accept a reason parameter.
</Info>

## SDK surfaces

<CardGroup cols={2}>
  <Card title="Posts" icon="flag">
    Flag and unflag posts through the post repository or post model extension, depending on platform.
  </Card>

  <Card title="Comments" icon="message-square-warning">
    Flag and unflag comments through the comment repository or comment model extension.
  </Card>

  <Card title="Reasons" icon="list-checks">
    Use predefined reasons such as spam, harassment, violence, or a custom "Others" detail where supported.
  </Card>

  <Card title="Status" icon="circle-check">
    Check whether the current user has flagged a loaded post or comment before rendering an unflag action.
  </Card>
</CardGroup>

## Flag reasons

| Reason                 | TypeScript                                   | iOS                     | Android                                       | Flutter                                                         |
| ---------------------- | -------------------------------------------- | ----------------------- | --------------------------------------------- | --------------------------------------------------------------- |
| Community guidelines   | `ContentFlagReasonEnum.CommunityGuidelines`  | `.communityGuidelines`  | `AmityContentFlagReason.CommunityGuidelines`  | Reason enum exists; post/comment flag builders do not accept it |
| Harassment or bullying | `ContentFlagReasonEnum.HarassmentOrBullying` | `.harassmentOrBullying` | `AmityContentFlagReason.HarassmentOrBullying` | Reason enum exists; post/comment flag builders do not accept it |
| Spam or scams          | `ContentFlagReasonEnum.SpamOrScams`          | `.spamOrScams`          | `AmityContentFlagReason.SpamOrScams`          | Reason enum exists; post/comment flag builders do not accept it |
| Other custom detail    | Any custom string                            | `.others("...")`        | `AmityContentFlagReason.Others("...")`        | Reason enum exists; post/comment flag builders do not accept it |

## Parameters

| Operation         | Parameter              | Required | Description                                                                                                                       |
| ----------------- | ---------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Flag a post       | `postId`               | Yes      | Post ID to report.                                                                                                                |
| Flag a post       | `reason`               | Depends  | Required on TypeScript, iOS, and Android reasoned flagging APIs; not accepted by the current public Flutter post flag builder.    |
| Flag a comment    | `commentId`            | Yes      | Comment ID to report.                                                                                                             |
| Flag a comment    | `reason`               | Depends  | Required on TypeScript, iOS, and Android reasoned flagging APIs; not accepted by the current public Flutter comment flag builder. |
| Unflag content    | `postId` / `commentId` | Yes      | Content ID whose current-user report should be removed.                                                                           |
| Check flag status | `postId` / `commentId` | Yes      | Content ID or loaded model used to check whether the current user has flagged the item.                                           |

## Flag a post

Flag a post with a supported reason where the platform exposes reasoned flagging.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ContentFlagReasonEnum, PostRepository } from '@amityco/ts-sdk';

  const didFlag = await PostRepository.flagPost(
    postId,
    ContentFlagReasonEnum.SpamOrScams,
  );

  if (didFlag) {
    showSuccessMessage('Post flagged');
  }
  ```

  ```swift iOS theme={null}
  let repository = AmityPostRepository()

  try await repository.flagPost(
      withId: "post-id",
      reason: .spamOrScams
  )
  ```

  ```kotlin Android theme={null}
  val disposable = AmitySocialClient.newPostRepository()
      .flagPost(
          postId = postId,
          reason = AmityContentFlagReason.SpamOrScams,
      )
      .subscribe(
          { showSuccessMessage() },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final didFlag = await post.report().flag();

  if (didFlag) {
    // Show flagged state.
  }
  ```
</CodeGroup>

## Flag a comment

Flag a comment with a supported reason where the platform exposes reasoned flagging.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk';

  const didFlag = await CommentRepository.flagComment(
    commentId,
    ContentFlagReasonEnum.HarassmentOrBullying,
  );

  if (didFlag) {
    showSuccessMessage('Comment flagged');
  }
  ```

  ```swift iOS theme={null}
  let repository = AmityCommentRepository()

  try await repository.flagComment(
      withId: "comment-id",
      reason: .harassmentOrBullying
  )
  ```

  ```kotlin Android theme={null}
  val disposable = AmitySocialClient.newCommentRepository()
      .flagComment(
          commentId = commentId,
          reason = AmityContentFlagReason.HarassmentOrBullying,
      )
      .subscribe(
          { showSuccessMessage() },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final didFlag = await comment.report().flag();

  if (didFlag) {
    // Show flagged state.
  }
  ```
</CodeGroup>

## Unflag content

Unflag content when the current user removes their own report from a post or comment.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { CommentRepository, PostRepository } from '@amityco/ts-sdk';

  const didUnflagPost = await PostRepository.unflagPost(postId);
  const didUnflagComment = await CommentRepository.unflagComment(commentId);
  ```

  ```swift iOS theme={null}
  let postRepository = AmityPostRepository()
  let commentRepository = AmityCommentRepository()

  try await postRepository.unflagPost(withId: "post-id")
  try await commentRepository.unflagComment(withId: "comment-id")
  ```

  ```kotlin Android theme={null}
  val postDisposable = AmitySocialClient.newPostRepository()
      .unflagPost(postId = postId)
      .subscribe()

  val commentDisposable = AmitySocialClient.newCommentRepository()
      .unflagComment(commentId = commentId)
      .subscribe()
  ```

  ```dart Flutter theme={null}
  final didUnflagPost = await post.report().unflag();
  final didUnflagComment = await comment.report().unflag();
  ```
</CodeGroup>

## Check flag status

Check flag status before rendering a flag or unflag action for the loaded item.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { CommentRepository, PostRepository } from '@amityco/ts-sdk';

  const isPostFlagged = await PostRepository.isPostFlaggedByMe(postId);
  const isCommentFlagged = await CommentRepository.isCommentFlaggedByMe(commentId);
  ```

  ```swift iOS theme={null}
  let postRepository = AmityPostRepository()
  let commentRepository = AmityCommentRepository()

  let isPostFlagged = try await postRepository.isFlaggedByMe(withId: "post-id")
  let isCommentFlagged = try await commentRepository.isCommentFlaggedByMe(withId: "comment-id")
  ```

  ```kotlin Android theme={null}
  val loadedPost = post ?: return
  val loadedComment = comment ?: return

  val isPostFlagged = loadedPost.isFlaggedByMe()
  val isCommentFlagged = loadedComment.isFlaggedByMe()
  ```

  ```dart Flutter theme={null}
  final isPostFlagged = post.isFlaggedByMe;
  final isCommentFlagged = comment.isFlaggedByMe;
  ```
</CodeGroup>

<Warning>
  Flagging creates report state; it does not delete, hide, approve, or decline content by itself. For review workflows, use the moderation tools available in Console and the SDK APIs for the content type you are moderating.
</Warning>

## Related topics

<CardGroup cols={2}>
  <Card title="Post Review" href="../posts/moderation/post-review" icon="clipboard-check">
    Approve or decline posts in review workflows.
  </Card>

  <Card title="Delete Post" href="../posts/moderation/delete-post" icon="trash">
    Remove posts after a moderation decision.
  </Card>

  <Card title="Delete Comment" href="../comments/actions/delete-comment" icon="message-square-x">
    Remove comments after a moderation decision.
  </Card>

  <Card title="Community Moderation" href="../../communities-spaces/organization/community-moderation" icon="shield-check">
    Manage community roles, bans, and permissions.
  </Card>
</CardGroup>
