# Schedule a post

> Schedule a video or photos to go out on one or more of the brand's own TikTok and Instagram accounts at a set time (at least 10 minutes and at most 60 days ahead). It posts publicly at that time, so it is for use once the person has seen the account, video, caption, time and (TikTok) audience and agreed. For TikTok the audience is the person's own choice from get_post_account. Not for creators' accounts.

```http
POST https://yapfactory.com/api/v1/posts
```

|   |   |
| --- | --- |
| Who can use it | Brands |
| Tier | `outbound`: Reaches other people: an email, a notification or a public post. |
| Scope | `posts:write`, or `write` |
| Idempotency-Key | **Required** |
| Rate limit | Writes: 20 a minute, of which outbound: 10 a minute |
| MCP tool | [`schedule_post`](https://yapfactory.com/developers/tools.md#schedule_post) |

> This reaches other people or the public. If an agent makes the call, it should confirm the details with the person first.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `accounts` | body | `object[]` | yes | The accounts to post to, from list_post_accounts. 1 to 10 items. |
| `accounts[].accountId` | body | `uuid` | yes | The account's id. |
| `accounts[].mode` | body | `"direct" \| "drafts"` | no | direct posts it; drafts sends it to the TikTok app's drafts for the person to finish (TikTok only). Default `"direct"`. |
| `media` | body | `({ deliverableId } \| { upload })[]` | yes | One video, one photo, or several photos (a carousel), in order. 1 to 35 items. |
| `caption` | body | `string` | no | The words under the post, hashtags included. Up to 2200 characters. Default `""`. |
| `publishAt` | body | `datetime` | yes | When it goes out, ISO 8601 with a time zone, e.g. 2026-12-10T18:00:00Z. |
| `timeZone` | body | `string` | no | The person's IANA time zone, for how times are shown to them, e.g. Europe/London. Up to 60 characters. Default `"UTC"`. |
| `tiktok` | body | `object` | no | Needed when posting directly to a TikTok account. |
| `tiktok.privacy` | body | `"PUBLIC_TO_EVERYONE" \| "MUTUAL_FOLLOW_FRIENDS" \| "FOLLOWER_OF_CREATOR" \| "SELF_ONLY"` | yes | Who can see it: the person's choice, from get_post_account. |
| `tiktok.allowComments` | body | `boolean` | no | Let people comment, if get_post_account says the account allows it. Default `false`. |
| `tiktok.allowDuet` | body | `boolean` | no | Let people Duet it (videos only). Default `false`. |
| `tiktok.allowStitch` | body | `boolean` | no | Let people Stitch it (videos only). Default `false`. |
| `tiktok.disclose` | body | `boolean` | no | Disclose commercial content. Default `false`. |
| `tiktok.yourBrand` | body | `boolean` | no | Promotional content for your own brand. Default `false`. |
| `tiktok.brandedContent` | body | `boolean` | no | A paid partnership for another brand (can't be Only me). Default `false`. |
| `instagram` | body | `object` | no |  |
| `instagram.shareToFeed` | body | `boolean` | no | Reels also show in the main feed. Default `true`. |

## Posting your own file

1. Ask for an upload link with [`POST /posts/uploads`](https://yapfactory.com/developers/api/prepare_post_upload.md). It returns `uploadUrl`, `method`, `headers` and an `upload` object.
2. Send the file's bytes to `uploadUrl` with that method and those headers. The link works once and for that size only.
3. Schedule it: pass the `upload` object, unchanged, as an item in `media`.

```bash
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: video/mp4" \
  --data-binary @launch.mp4
```

media, with an uploaded file:

```json
{
  "media": [
    {
      "upload": {
        "key": "posts/…/launch.mp4",
        "url": "https://…/launch.mp4",
        "filename": "launch.mp4",
        "sizeBytes": 18400000
      }
    }
  ]
}
```

## TikTok's rules

- `tiktok.privacy` is required for a TikTok account in `direct` mode, and must be one of `privacyOptions` from [`GET /posts/accounts/{accountId}`](https://yapfactory.com/developers/api/get_post_account.md). The person chooses it; there's no default.
- Comments, Duet and Stitch start off. Turn one on only if the same call says the account allows it.
- `mode: "drafts"` sends the video to the TikTok app's drafts instead, for the person to finish there.

## Example request

```bash
curl -X POST "https://yapfactory.com/api/v1/posts" \
  -H "Authorization: Bearer $YAP_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "accounts": [
      {
        "accountId": "8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f",
        "mode": "direct"
      }
    ],
    "media": [
      {
        "deliverableId": "c9f0f895-fb98-4ab3-8e3c-1d2f3a4b5c6d"
      }
    ],
    "caption": "Fell asleep before the alarm app even loaded.",
    "publishAt": "2026-12-10T18:00:00Z",
    "timeZone": "Europe/London",
    "tiktok": {
      "privacy": "PUBLIC_TO_EVERYONE",
      "allowComments": true,
      "disclose": true,
      "yourBrand": true
    }
  }'
```

## Response

`201` with the result in `data`: the same object the MCP tool returns.

```json
{
  "data": {
    "posts": [
      {
        "id": "92eb5ffe-e6ae-4fec-8ad7-1c4c4e2f8a55",
        "accountId": "0cc175b9-c0f1-46a8-b1c3-99e2697726ae",
        "status": "scheduled",
        "publishAt": "2026-12-10T18:00:00.000Z",
        "url": "https://yapfactory.com/brand/accounts?tab=calendar&post=92eb5ffe-e6ae-4fec-8ad7-1c4c4e2f8a55"
      }
    ]
  }
}
```

An example: fields that don't apply are `null`, and new fields can be added at any time, so ignore ones you don't know. Every response carries `Request-Id` and the `RateLimit-*` headers.

## Errors

| Code | Status | When |
| --- | --- | --- |
| `invalid_request` | 400 | A field failed validation (see `meta.issues`), an unknown query parameter, or no `Idempotency-Key`. |
| `unauthorized` | 401 | No token, or it's wrong, expired, revoked or from the other environment. |
| `insufficient_scope` | 403 | The token doesn't have `posts:write` (or `write`). |
| `forbidden` | 403 | Only for brands, or the account can't do this yet (email not confirmed, paused). |
| `conflict` | 409 | Its current state doesn't allow this. `message` says why, in words you can show. |
| `idempotency_conflict` | 409 | The same `Idempotency-Key` came with a different body. |
| `rate_limited` | 429 | Over the limit. Wait for `Retry-After` seconds. |
| `internal` | 500 | Our fault. Retry later, and send us the `requestId` if it keeps happening. |

Every error has the same shape. See [Errors](https://yapfactory.com/developers/errors.md) for what to do about each one.

---

HTML version: https://yapfactory.com/developers/api/schedule_post
