> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postploy.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Postploy's MCP server for posting is https://api.postploy.com/mcp and signs in with OAuth. The REST API base URL is https://api.postploy.com/public/v1 and takes an API key as a Bearer token. The API calls channels accounts.

# Schedule posts

> Create posts with text, media and threads, hold them for approval, change them and follow them until they go live.

The examples use `curl`. Every endpoint in the [API reference](https://docs.postploy.com/api-reference/posts/create-posts.md) also has JavaScript and Python examples, and a playground.

## Create a post

You need a channel's `id` from [List channels](https://docs.postploy.com/api-reference/channels/list-channels.md), the text and a time.

```bash theme={null}
curl https://api.postploy.com/public/v1/posts \
  -H "Authorization: Bearer $POSTPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "posts": [
      {
        "socialAccountId": "5b0f4c3e-8a2d-4c51-9e7a-1d2f3a4b5c6d",
        "text": "Our spring blend is here. Bright, citrusy and roasted this week.",
        "scheduledAt": "2030-01-15T09:00:00Z",
        "timezone": "Europe/London"
      }
    ]
  }'
```

The response holds the posts you created, in the order you sent them.

| Field | What it's for |
| - | - |
| `socialAccountId` | The channel to post to. Required. |
| `text` | What the post says. |
| `title` | YouTube needs one. Most other platforms ignore it. |
| `mediaIds` | Images or videos from your media library, in the order they show. |
| `scheduledAt` | When the post goes out, to the minute, as ISO 8601 with an offset. It must be in the future. |
| `timezone` | The time zone your team sees the post in, such as `America/New_York`. It's `UTC` if you leave it out, and it doesn't change when the post goes out. |
| `status` | `scheduled` (the default), `draft` or `pending_approval`. See [Drafts and approvals](#drafts-and-approvals). |
| `thread` | For X only. The rest of a thread. See [X threads](#x-threads). |
| `platformFields` | Extra options for the post's platform. See [Platform options](https://docs.postploy.com/api/platform-options.md). |

### Many posts at once

Send up to 50 posts in one request, on any mix of channels. To say the same thing on three channels, send three posts.

Every post is checked against its platform's rules before anything is saved. If one post is invalid, none are saved. The `400` response's `message` names the first problem, and `errors` lists all of them, each with a `path` to the post and field, such as `["posts", 2, "mediaIds", 0]` for the first file of the third post. Fix them and send the request again.

### Publish now

Set `publishNow` to `true` to send every post in the request right away. You can leave out `scheduledAt`.

```json theme={null}
{
  "publishNow": true,
  "posts": [
    { "socialAccountId": "5b0f4c3e-8a2d-4c51-9e7a-1d2f3a4b5c6d", "text": "We're open early today!" }
  ]
}
```

## Check posts first

[Check posts](https://docs.postploy.com/api-reference/posts/check-posts.md) runs the same checks without saving anything. It's useful while you write. Give it a `socialAccountId`, or just a `platform` if you haven't picked a channel yet.

```bash theme={null}
curl https://api.postploy.com/public/v1/posts/validate \
  -H "Authorization: Bearer $POSTPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "posts": [{ "platform": "instagram", "text": "Spring, in a cup." }] }'
```

```json theme={null}
{
  "data": [
    {
      "socialAccountId": null,
      "platform": "instagram",
      "valid": false,
      "errors": [{ "field": "mediaIds", "message": "Instagram posts need at least one image or video" }],
      "warnings": []
    }
  ]
}
```

`errors` stop a post from being saved. `warnings` are worth a look but don't. Each one names its `field` the way you send it, such as `text`, `mediaIds[1]` or `platformFields.tiktok.visibility`. To see the rules themselves, like text length and video limits, use [Get platform rules](https://docs.postploy.com/api-reference/channels/get-platform-rules.md).

## Add images and videos

Posts point to files in your team's media library. To use a file from the web, import it first, then put its `id` in `mediaIds`.

**1. Import the file**

```bash theme={null}
curl https://api.postploy.com/public/v1/media \
  -H "Authorization: Bearer $POSTPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/spring-blend.jpg", "fileName": "spring-blend.jpg" }'
```

The URL must be public and start with `https://`. The file name's extension sets the type: `jpg`, `jpeg`, `png`, `webp`, `gif`, `mp4` or `mov`. Importing the same URL again returns the file you already have.

**2. Attach it**

```json theme={null}
{
  "posts": [
    {
      "socialAccountId": "5b0f4c3e-8a2d-4c51-9e7a-1d2f3a4b5c6d",
      "text": "Our spring blend is here.",
      "mediaIds": ["7a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d"],
      "scheduledAt": "2030-01-15T09:00:00Z"
    }
  ]
}
```

Instagram, TikTok and YouTube posts need at least one image or video. Each platform has its own limits on how many files, how big and how long. [Check posts](#check-posts-first) tells you when a post goes over them.

## X threads

For an X post, `text` is the first post and carries the media. `thread` holds the rest of the thread, in order, up to 25 posts. Each post must fit X's length limit.

```json theme={null}
{
  "socialAccountId": "0c9e8d7f-6a5b-4c3d-8e2f-1a0b9c8d7e6f",
  "text": "We roasted 40 batches to find our spring blend. Here's what we learned 🧵",
  "thread": [
    "1. Lighter roasts brought out the citrus.",
    "2. Two minutes less in the roaster made the biggest difference."
  ],
  "scheduledAt": "2030-01-15T09:00:00Z"
}
```

When you read a post back, `thread` is `[]` for an X post that isn't a thread, and `null` on other platforms. Other platforms don't accept `thread`.

## Drafts and approvals

`status` decides what happens to a post after it's saved:

| `status` | What happens |
| - | - |
| `scheduled` | It goes out at `scheduledAt`. This is the default. |
| `draft` | It's saved and doesn't go out. `scheduledAt` is optional. |
| `pending_approval` | It keeps its time, but waits in the Inbox until someone approves it. |

If your role can't publish, every post you create waits for approval, whatever `status` you send, and `publishNow` is refused. Drafts stay drafts.

### Approve or send back

People who can approve, meaning owners, admins and editors, can do it through the API too:

* [Approve posts](https://docs.postploy.com/api-reference/approvals/approve-posts.md) takes up to 100 ids. Each post is scheduled for its time. Any that can't be approved come back in `failed` with the reason.
* [Send a post back](https://docs.postploy.com/api-reference/approvals/send-a-post-back.md) turns it into a draft, with an optional `reason` and `note` for the writer. They show on the post as `sentBack`.

```bash theme={null}
curl https://api.postploy.com/public/v1/posts/3f6c2a1b-9d8e-4f7a-b6c5-d4e3f2a1b0c9/reject \
  -H "Authorization: Bearer $POSTPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Off-brand", "note": "We don'\''t use exclamation marks in headlines." }'
```

## Change a post

[Update a post](https://docs.postploy.com/api-reference/posts/update-a-post.md) changes any post that hasn't been published. Send only the fields you want to change.

```bash theme={null}
curl -X PATCH https://api.postploy.com/public/v1/posts/3f6c2a1b-9d8e-4f7a-b6c5-d4e3f2a1b0c9 \
  -H "Authorization: Bearer $POSTPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scheduledAt": "2030-01-16T09:00:00Z" }'
```

`mediaIds` and `thread` replace what the post had. Send `"thread": []` to turn a thread back into a single post. A post that's being published right now can't be changed, so you get `409`.

## Delete a post

[Delete a post](https://docs.postploy.com/api-reference/posts/delete-a-post.md) works in two ways:

* A post that's still to come is deleted for good.
* A post whose time has passed, like a published or failed one, moves to the trash.

Deleting never removes a post from the social platform. Posts in the trash stay there until you [restore them](https://docs.postploy.com/api-reference/trash/restore-posts.md), [delete them for good](https://docs.postploy.com/api-reference/trash/delete-posts-for-good.md) or [empty the trash](https://docs.postploy.com/api-reference/trash/empty-trash.md).

## Follow a post

* **Get one post.** [Get a post](https://docs.postploy.com/api-reference/posts/get-a-post.md) returns its `status`, and once it's live, its `link`.
* **Find posts.** [List posts](https://docs.postploy.com/api-reference/posts/list-posts.md) filters by time window, status group, channel or id. `attention=true` returns the posts that need someone: waiting for approval, failed or blocked by a channel that needs reconnecting. A failed post someone dismissed in the Inbox no longer counts.
* **Count posts.** [Count posts](https://docs.postploy.com/api-reference/posts/count-posts.md) gives the number in each status group, for a dashboard or badge.
* **Get told.** Instead of checking again and again, add a [webhook](https://docs.postploy.com/webhooks.md) and get a request the moment a post goes live or fails.

Every post you read has `actions`, which says what you can do with it right now: `edit`, `approve`, `reject`, `retry` and `delete`. Use it to show or hide buttons in your own app.

## Retry a failed post

A failed post has a `failureReason` in plain words, and a `failureKind`:

* `transient`: [Retry a failed post](https://docs.postploy.com/api-reference/posts/retry-a-failed-post.md) sends it again now.
* `permanent`: the platform rejected it. Change the post, then schedule it again.
* `account`: the channel needs reconnecting in Postploy first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.