Skip to main content
Creates a new post in the social media feed. Posts can include a text caption (up to 800 characters) and optional media attachments (images or videos).

Endpoint

POST /api/posts

Authentication

This endpoint requires authentication. The authenticated user must match the userName in the request body.

Request Body

userName
string
required
The username of the account creating the post. Must match the authenticated user.
caption
string
required
The text content of the post. Maximum length: 800 characters.
PostMediasLinkInputs
array
required
Array of media attachments for the post. Can be empty.

Request Example

curl -X POST https://api.example.com/api/posts \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userName": "john_doe",
    "caption": "Beautiful sunset at the beach today!",
    "PostMediasLinkInputs": [
      {
        "mediaType": "Image",
        "mediaURL": "https://example.com/images/sunset.jpg"
      }
    ]
  }'

Response

{}
Returns 201 Created when the post is successfully created. The post is stored with the following properties:
PostID
long
Unique identifier for the post (auto-generated)
InitiatorID
long
User ID of the post creator
Caption
string
The post caption text
CreatedAt
datetime
Timestamp when the post was created
LikeCount
integer
Initial like count (starts at 0)
PostMediasLinks
array
Array of media attachments with their IDs, types, and URLs
isDeleted
boolean
Soft delete flag (initially false)

Error Responses

"This account does not exist"
Returned when the specified username is not found in the system.
"Post cannot be made on an account by another"
Returned when the authenticated user does not match the userName in the request body.

Build docs developers (and LLMs) love