Skip to main content
Likes a post and creates a notification for the post owner.

Endpoint

POST /api/posts/{id}/like

Authentication

Required. User must be authenticated to like a post.

Path Parameters

id
integer
required
The unique identifier of the post to like (PostID)

Request Body

userName
string
required
The username of the authenticated user liking the post

Behavior

  • Creates a PostLike record with composite key (LikerID, PostID)
  • Increments the post’s LikeCount
  • Creates a notification for the post owner
  • Prevents liking posts from blocked accounts

Request

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

Response

status
integer
201 Created - Post liked successfully
201 Created

Errors

404
error
Post does not exist or action cannot be completed due to a block
409
error
The user already liked the post
{
  "error": "The user already liked post"
}

Build docs developers (and LLMs) love