Skip to main content

Delete Post

Delete a post.

Endpoint

DELETE /api/Post/{postId}

Authentication: Required (must be post author or admin)

Path Parameters

ParameterTypeRequiredDescription
postIdstringYesPost ID

Response

Success (200 OK)

{
"success": true,
"message": "Post deleted successfully"
}

Error (403 Forbidden)

{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "You can only delete your own posts"
}
}

Example

const response = await fetch(`http://localhost:5000/api/Post/${postId}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${token}`
}
});

const data = await response.json();

Effects

Deleting a post will:

  • Remove the post from all feeds
  • Delete associated media files
  • Remove all reactions and comments
  • Update user statistics

Soft Delete

Posts are soft-deleted initially and can be restored within 30 days by admins.

Next Steps