> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-auto-generate-llmstxt.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Comment

> Delete comments with the platform-supported soft delete and hard delete APIs.

Use comment deletion when a user removes their own comment or a moderation flow removes a comment. Soft delete marks the comment as deleted while preserving enough state for collections and audit-style views. Hard delete permanently removes the comment where the SDK exposes that operation.

## Platform Support

| Platform   | Soft delete                                                                    | Hard delete                                                                          |
| ---------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| TypeScript | `CommentRepository.softDeleteComment(commentId)` or `deleteComment(commentId)` | `CommentRepository.hardDeleteComment(commentId)` or `deleteComment(commentId, true)` |
| iOS        | `softDeleteComment(withId:)`                                                   | `hardDeleteComment(withId:)`                                                         |
| Android    | `softDeleteComment(commentId)`                                                 | `hardDeleteComment(commentId)`                                                       |
| Flutter    | `comment.delete()`                                                             | Not exposed as a verified separate public delete path                                |

<Warning>
  Hard delete is permanent. Confirm the action in your UI before calling a hard-delete API.
</Warning>

## Parameters

| Operation              | Parameter        | Required | Description                                         |
| ---------------------- | ---------------- | -------- | --------------------------------------------------- |
| Soft delete            | `commentId`      | Yes      | Comment ID to soft delete.                          |
| Hard delete            | `commentId`      | Yes      | Comment ID to hard delete where supported.          |
| Query deleted comments | `referenceId`    | Yes      | Target content ID whose comments should be queried. |
| Query deleted comments | `referenceType`  | Yes      | Target content type, such as `post`.                |
| Query deleted comments | `includeDeleted` | Yes      | Include soft-deleted comments in query results.     |

## Soft Delete

Soft delete a comment when the UI should preserve deleted-state semantics in comment collections.

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

  const deletedComment = await CommentRepository.softDeleteComment(commentId);

  renderResults(deletedComment);
  ```

  ```swift iOS theme={null}
  try await commentRepository.softDeleteComment(withId: "comment-id")
  showSuccessMessage("Comment deleted")
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newCommentRepository()
      .softDeleteComment(commentId = commentId)
      .subscribe(
          { showSuccessMessage(commentId) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final comment = await AmitySocialClient.newCommentRepository()
      .getComment(commentId: commentId);

  await comment.delete();
  ```
</CodeGroup>

## Hard Delete

Hard delete is available in TypeScript, iOS, and Android.

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

  const deletedComment = await CommentRepository.hardDeleteComment(commentId);

  renderResults(deletedComment);
  ```

  ```swift iOS theme={null}
  try await commentRepository.hardDeleteComment(withId: "comment-id")
  showSuccessMessage("Comment permanently deleted")
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newCommentRepository()
      .hardDeleteComment(commentId = commentId)
      .subscribe(
          { showSuccessMessage(commentId) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Query Deleted Comments

Use the query API with deleted comments included when you need moderation or audit views.

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

  const unsubscribe = CommentRepository.getComments(
    {
      referenceType: "post",
      referenceId: postId,
      includeDeleted: true,
      pageSize: 10,
    },
    ({ data: comments, error }) => {
      if (error) {
        handleError(error);
        return;
      }

      renderResults(comments);
    },
  );
  ```

  ```swift iOS theme={null}
  let options = AmityCommentQueryOptions(
      referenceId: "post-id",
      referenceType: .post,
      filterByParentId: false,
      orderBy: .descending,
      includeDeleted: true,
      pageSize: 20
  )

  token = commentRepository
      .getComments(with: options)
      .observe { collection, error in
          if let error {
              handleError(error)
              return
          }

          showSuccessMessage(collection.snapshots.count)
      }
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newCommentRepository()
      .getComments()
      .post(postId = postId)
      .includeDeleted(includeDeleted = true)
      .build()
      .query()
      .subscribe(
          { pagingData -> getPagingData(pagingData) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final comments = await AmitySocialClient.newCommentRepository()
      .getComments()
      .post(postId)
      .includeDeleted(true)
      .query(limit: 10);

  final resultCount = comments.length;
  ```
</CodeGroup>

## Notes

* Handle not-found, permission, and moderation errors from the SDK call.
* Query live collections after deletion if the UI needs to reflect deleted-state changes.
* Use soft delete for reversible moderation workflows; reserve hard delete for cases where permanent removal is intended and supported on that platform.
* The Flutter public comment extension exposes `delete()` for the comment instance; do not rely on a separate Flutter hard-delete path unless your SDK version documents one.

## Related Topics

<CardGroup cols={2}>
  <Card title="Edit Comment" href="/social-plus-sdk/social/content-management/comments/actions/edit-comment" icon="pen">
    Update text, metadata, mentions, links, and image attachments.
  </Card>

  <Card title="Query Comments" href="/social-plus-sdk/social/content-management/comments/retrieval/query-comments" icon="search">
    Query comments with deleted-state filtering.
  </Card>

  <Card title="Get Comment" href="/social-plus-sdk/social/content-management/comments/retrieval/get-comment" icon="message">
    Retrieve a specific comment by ID.
  </Card>

  <Card title="Comment Overview" href="/social-plus-sdk/social/content-management/comments/overview" icon="book">
    Understand comment targets and model fields.
  </Card>
</CardGroup>
