---
title: "Create a post"
method: POST
path: "/social-media/posts"
tags: ["📸 Social Media"]
---

# Create a post

`POST /social-media/posts`

## Request

- Base URL: `https://api.freeapi.app/api/v1`
- URL: `https://api.freeapi.app/api/v1/social-media/posts`
- Auth: none declared
- TypeScript: <https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/docs/social-media/posts/post.ts> (a function with typed inputs; its response is checked against the schema)

The API allows a logged-in user to create a social media post by providing the necessary details in the request body.

The user can include the content of the post, relevant tags, and attach images (upto 6) as part of the request.

NOTE: As this api requires formData to be used, to send multiple tags client must send them with the respective index.

e.g. if you are passing 4 tags the keys in the, following is onw of the ways to send them:

``` javascript
const formData = new FromData()
// ... other form data appends
tags.forEach((tag, ind) => {
    formData.append(`tag[${ind}]`: tag)
})

```

## Request body `multipart/form-data`

- object
  - `content` string
  - `images` string, binary: Upto 6 images per post are allowed
  - `tags[0]` string
  - `tags[1]` string
  - `tags[2]` string

## Response `201`

Create a post

- object
  - `data` object
    - `__v` number
    - `_id` string
    - `author` object
      - `__v` number
      - `_id` string
      - `account` object
        - `_id` string
        - `avatar` object
          - `_id` string
          - `localPath` string
          - `url` string
        - `email` string
        - `username` string
      - `bio` string
      - `countryCode` string
      - `coverImage` object
        - `_id` string
        - `localPath` string
        - `url` string
      - `createdAt` string
      - `dob` string
      - `firstName` string
      - `lastName` string
      - `location` string
      - `owner` string
      - `phoneNumber` string
      - `updatedAt` string
    - `comments` number
    - `content` string
    - `createdAt` string
    - `images` object[]
      - `_id` string
      - `localPath` string
      - `url` string
    - `isBookmarked` boolean
    - `isLiked` boolean
    - `likes` number
    - `tags` string[]
    - `updatedAt` string
  - `message` string
  - `statusCode` number
  - `success` boolean

---

[API](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi.md) - [All operations](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/llms.txt) - [OpenAPI document](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/revisions/a9f3a290e4dc?raw)
