Skip to main content
POST
/
api
/
create_post
Create Post
curl --request POST \
  --url https://api.example.com/api/create_post \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "content": "<string>"
}
'
{
  "message": "<string>"
}

Endpoint

POST /api/create_post
Creates a new post for the authenticated user and increments their post count in their profile.

Headers

Authorization
string
required
Authentication token for the user

Request Body

content
string
required
The content of the post. Must not be empty and cannot exceed 512 characters.

Response

message
string
Success message confirming post creation

Success Response

Status Code: 201 Created
{
  "message": "post created"
}

Error Responses

Status Code: 400 Bad Request
{
  "error": "nothing to post"
}
Returned when the content field is empty or missing.
{
  "error": "post content cannot exceed 512 characters"
}
Returned when the content length exceeds 512 characters. Status Code: 401 Unauthorized
{
  "error": "invalid token , please re-login"
}
Returned when the Authorization header is missing.
{
  "error": "unauthorized"
}
Returned when the provided token is invalid or not found.

Example Request

curl -X POST https://api.example.com/api/create_post \
  -H "Authorization: your-auth-token" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "This is my first post!"
  }'

Example Response

{
  "message": "post created"
}

Build docs developers (and LLMs) love