> ## 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.

# Delete Posts

> Delete posts through the public SDK soft-delete and hard-delete surfaces.

Use post deletion when a user or moderator needs to remove a post by ID. Deletion permissions are enforced by the backend according to the actor, target community, and your app settings.

## Platform Support

| Platform   | Soft delete | Hard delete                  | Public SDK method                                                                   |
| ---------- | ----------- | ---------------------------- | ----------------------------------------------------------------------------------- |
| TypeScript | Yes         | Yes                          | `PostRepository.softDeletePost(postId)` and `PostRepository.hardDeletePost(postId)` |
| iOS        | Yes         | Yes                          | `softDeletePost(withId:parentId:)` and `hardDeletePost(withId:parentId:)`           |
| Android    | Yes         | Yes                          | `softDeletePost(postId)` and `hardDeletePost(postId)`                               |
| Flutter    | Yes         | No verified hard-delete flag | `deletePost(postId:)` or `post.delete()`                                            |

<Warning>
  Do not rely on Flutter's `hardDelete` argument for hard deletion in the current public SDK. The public delete path does not pass a hard-delete flag to the request.
</Warning>

## Parameters

| Operation     | Parameter   | Required | Description                                                                    |
| ------------- | ----------- | -------- | ------------------------------------------------------------------------------ |
| Delete a post | `postId`    | Yes      | Post ID to soft delete or hard delete.                                         |
| Delete a post | Delete type | Yes      | Choose soft delete or hard delete where the target SDK exposes both behaviors. |
| Delete a post | `parentId`  | No       | Optional iOS parent post ID for child-post deletion state updates.             |

## Delete a Post

Delete by post ID, choosing soft delete or hard delete only on SDKs that expose the desired behavior.

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

  const softDeletedPost = await PostRepository.softDeletePost(postId);
  const hardDeletedPost = await PostRepository.hardDeletePost(postId);

  renderResults([softDeletedPost, hardDeletedPost]);
  ```

  ```swift iOS theme={null}
  try await postRepository.softDeletePost(withId: "post-id", parentId: nil)
  try await postRepository.hardDeletePost(withId: "post-id", parentId: nil)

  showSuccessMessage()
  ```

  ```kotlin Android theme={null}
  postRepository.softDeletePost(postId = postId)
      .subscribe(
          { showSuccessMessage(postId) },
          { error -> handleGeneralError(error) }
      )

  postRepository.hardDeletePost(postId = postId)
      .subscribe(
          { showSuccessMessage(postId) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  await AmitySocialClient.newPostRepository().deletePost(postId: postId);
  ```
</CodeGroup>

## Parent Post IDs

iOS delete methods accept an optional `parentId`. Pass `nil` for top-level posts. If you are deleting a child post and your app already has its parent post ID, pass that parent ID so local post state can be updated correctly.

## Notes

* Use soft delete when your app needs the deleted state to remain observable.
* Use hard delete only when your app intentionally wants the object invalidated or permanently removed on SDKs that expose the hard-delete path.
* Refresh or remove local UI items after deletion; live collections usually update, but optimistic UI should still handle delete failures.

## Related Topics

<CardGroup cols={3}>
  <Card title="Edit Posts" href="./edit-post" icon="pencil">
    Update existing post content.
  </Card>

  <Card title="Post Review" href="./post-review" icon="shield-check">
    Approve or decline posts in review queues.
  </Card>

  <Card title="Query Posts" href="../retrieval/query-posts" icon="filter">
    Query posts with deleted-state filters.
  </Card>
</CardGroup>
