Skip to main content

Endpoint

POST /api/users/{creatorUsername}/follow

Authentication

This endpoint requires authentication.

Path Parameters

creatorUsername
string
required
The username of the user to follow

Request Body

userName
string
required
The username of the authenticated user initiating the follow action

Response

status
number
204 No Content on successful follow

Response Details

When a user successfully follows another user:
  • A Follow record is created with a composite key (FollowerID, FollowedUserID)
  • The followed user’s FollowersCount is incremented
  • The follower’s FollowingCount is incremented
  • A notification is triggered for the followed user
  • The composite key prevents duplicate follows in the database

Request Example

cURL
curl -X POST "https://api.example.com/api/users/johndoe/follow" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userName": "janedoe"
  }'

Error Responses

400
error
Bad Request - Invalid request format
404
error
Not Found - User does not exist or action cannot be completed due to a block
409
error
Conflict - Account already follows this user

Error Scenarios

  • 404 Not Found: Returned when the initiating account doesn’t exist, the target user doesn’t exist, or when the action cannot be completed due to a block between users
  • 409 Conflict: Returned when the user is already following the target user
  • 403 Forbidden: Returned when a user attempts to follow themselves

Build docs developers (and LLMs) love