Skip to main content
Performs a soft delete on a post, marking it as deleted without permanently removing it from the database. Only the post owner can delete their own posts.
This is a soft delete operation. The post is not permanently removed from the database. Instead, the isDeleted flag is set to true and the DeletedAt timestamp is recorded. The post can be restored using the restore endpoint.

Endpoint

DELETE /api/posts/{id}

Authentication

This endpoint requires authentication. Only the post owner can delete their post.

Path Parameters

id
long
required
The unique identifier (PostID) of the post to delete

Request Body

userName
string
required
The username of the account requesting deletion. Must be the post owner.

Request Example

curl -X DELETE https://api.example.com/api/posts/12345 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userName": "john_doe"
  }'

Response

Returns 204 No Content when the post is successfully marked as deleted. The following changes are made to the post:
  • isDeleted is set to true
  • DeletedAt is set to the current timestamp

Error Responses

"This account does not exist"
Returned when the username in the request body is not found.
"This post does not exist"
Returned when no post exists with the specified ID.
"This user does not own the post"
Returned when the requesting user is not the owner of the post.
Returned when the post is already marked as deleted.

Build docs developers (and LLMs) love