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
Authentication
This endpoint requires authentication. The authenticated user must match the userName in the request body.
Request Body
The username of the account creating the post. Must match the authenticated user.
The text content of the post. Maximum length: 800 characters.
Array of media attachments for the post. Can be empty. Show Media object properties
Type of media. Possible values: Image, Video
Valid URL pointing to the media file.
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:
Unique identifier for the post (auto-generated)
User ID of the post creator
Timestamp when the post was created
Initial like count (starts at 0)
Array of media attachments with their IDs, types, and URLs
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.