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

# Publishing

> Connect TikTok, Instagram and YouTube accounts, and post finished videos to them now or at a time.

Once a video is cut and rendered, post it from the same place. Connect your accounts once, then schedule posts from the API, the CLI, the SDK or your agent over MCP. VidJutsu keeps the schedule, sends each post at its time, and reads back how it did.

## Connect an account

`POST /social-accounts/connect` answers a sign-in link. Open it in a browser, sign in to the platform and allow posting. `handoff_url` is the same sign-in as a QR code, for a person who is signed in to the platform on their phone. Both links last about 30 minutes (`expires_at`), so get a fresh one for each connect.

```sh theme={null}
curl -s -X POST https://api.vidjutsu.ai/social-accounts/connect \
  -H "Authorization: Bearer $VIDJUTSU_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"platform": "youtube", "return_to": "page"}'
```

`platform` is `tiktok`, `instagram` or `youtube`. After the sign-in the browser lands on a plain "connected, you can close this tab" page (`return_to: "page"`, the default), which suits an agent working for someone, or on the web app's Settings › Accounts (`"app"`). The answer's `next` says what to do in the meantime.

An agent can't sign in for the person: send them the link and wait. Then list the accounts:

```sh theme={null}
vidjutsu accounts
```

```json theme={null}
{"accounts": [{"id": "sa_...", "platform": "youtube", "handle": "@clipsdaily", "display_name": "Clips Daily",
               "state": "connected", "approve_before_posting": false, "connected_at": "..."}]}
```

Your plan sets how many accounts you can connect; the trial doesn't include publishing. An account's `state` is `connected`, `needs_reconnect`, `paused_unpaid`, `disconnected` or `disconnected_unpaid`. One with `reconnect_url` needs the person to sign in to the platform again (platforms expire sign-ins now and then); open that link the same way. `DELETE /social-accounts/{social_account_id}` disconnects one: its scheduled posts are canceled, and its past posts and their numbers stay.

## Schedule a post

`POST /posts` takes what to post, the accounts and, optionally, a caption and a time. Leave `at` out to post now.

```sh theme={null}
curl -s -X POST https://api.vidjutsu.ai/posts \
  -H "Authorization: Bearer $VIDJUTSU_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "media": {"job_id": "job_..."},
    "accounts": [{"id": "sa_youtube", "options": {"title": "Day 1 of 30", "visibility": "private"}}],
    "caption": "Day 1 of 30",
    "at": "2026-12-01T15:00:00Z",
    "idempotency_key": "day-1"
  }'
```

* **`media`** is a finished render (`{"job_id": ...}`, a render that has succeeded) or a file in your library (`{"hash": ..., "type": "video"}`, or `"image"`). It is checked when you schedule, so a bad id fails now, not at posting time.
* **`accounts`** is one or more social account ids, or `{id, options}` to set [platform options](#platform-options) for that account.
* **`at`** is an ISO time with a zone (`Z` or `+01:00`), up to a year ahead.
* **`idempotency_key`** makes a retry return the same post instead of posting twice.

It answers 201 with the post. The same from the CLI and the SDK:

```sh theme={null}
vidjutsu post schedule --job job_... --accounts sa_youtube \
  --caption "Day 1 of 30" --at 2026-12-01T15:00:00Z --options options.json
```

```ts theme={null}
const { post } = await client.schedulePost({
  media: { job_id: render.job_id },
  accounts: [{
    id: "sa_youtube",
    options: { title: "Day 1 of 30", visibility: "private" },
  }],
  caption: "Day 1 of 30",
  at: "2026-12-01T15:00:00Z",
});
```

Agents use the `schedule_post` tool with the same fields.

## Platform options

Options are flat and per account. Each platform reads its own.

| Platform | Options |
| - | - |
| YouTube | `title` (required, maximum length 100), `visibility` (required: `private`, `unlisted` or `public`), `tags` (optional) |
| TikTok | `privacy_level`, `allow_comment`, `allow_duet`, `allow_stitch`, `ai_generated`, `commercial_content` (`none`, `brand_organic` for your own brand, `brand_content` for someone else's) |
| Instagram | `ai_generated` |

For each YouTube account, send `{id, options}` with its own visibility choice. There is no default. Use `private` to limit viewing to the owner and people they invite, `unlisted` to let anyone with the link view, or `public` to make the video available to anyone. You can set visibility from the API, CLI, SDK or MCP without opening the editor. This does not override an account's [owner approval setting](#approval-before-posting).

With the CLI, `--options` is a JSON file mapping account ids to their options. For the example above, put this in `options.json`:

```json theme={null}
{"sa_youtube": {"title": "Day 1 of 30", "visibility": "private"}}
```

## Follow a post

`GET /posts/{post_id}` shows where it is. `GET /posts` lists your posts, the soonest scheduled first, then the newest; filter with `state`.

| `state` | Meaning |
| - | - |
| `pending_approval` | An account it goes to has approval on: it waits for [approval](#approval-before-posting). |
| `scheduled` | Waiting for its time. `scheduled_for` is that time in milliseconds (UTC). |
| `publishing` | Being sent to the platforms. |
| `published` | Live on every account. Each target's `url` is the live post. |
| `partial` | Live on some accounts; each failed target has its `error`. |
| `failed` | It didn't go out. Each target's `error` says why. |
| `canceled` | Canceled before it went out. |
| `paused_unpaid` | Held while a payment is overdue. See [When a payment is overdue](#when-a-payment-is-overdue). |

Each target in `targets` has its own `state` (`pending`, `publishing`, `published`, `failed` or `canceled`), `url` and `error`, so one account failing doesn't hide the others.

## Change or cancel a post

Until a post goes out (while it is `scheduled`, `pending_approval` or `paused_unpaid`) you can move it, post it now or cancel it:

```sh theme={null}
vidjutsu post reschedule po_... --at 2026-12-02T15:00:00Z
vidjutsu post reschedule po_... --at now
vidjutsu post cancel po_...
```

A published post stays on the platform. Delete it there if you need to.

## Read the numbers

`GET /posts/{post_id}/stats` answers, per account, the views, likes, comments, shares, saves, impressions and reach the platform reports, with `captured_at`. A number a platform doesn't report is null. They are read about an hour, a day and a week after the post goes out, so early on they can be empty.

```sh theme={null}
vidjutsu post stats po_...
```

## Approval before posting

Each account has `approve_before_posting`, off unless you turn it on. With it on, posts to that account wait as `pending_approval` until someone approves them; an approved post goes out at its time, or right away if that time has passed. Use it when an agent schedules posts and a person wants the last word.

```sh theme={null}
vidjutsu accounts approval sa_1 --on     # POST /social-accounts/{social_account_id} {"approve_before_posting": true}
```

The account owner reviews and approves a held post in the signed-in web app. For YouTube, the review shows the requested visibility. An API key can schedule the post but cannot approve it.

## When a payment is overdue

Nothing is lost when a payment is late:

* From the first day, posts wait as `paused_unpaid` instead of going out. Your schedule, history and numbers stay.
* After 7 days still unpaid, your accounts are disconnected.
* Once the payment is fixed, paused posts go out, and disconnected accounts come back with one sign-in from their `reconnect_url`.

## Errors

| Status | `code` | When |
| - | - | - |
| 402 | `upgrade_required` | Publishing isn't in your plan. `reason` is `not_in_plan:publish` or `not_in_plan:connect_accounts`, and `upgrade_url` is the link to move to a plan that has it. |
| 403 | `forbidden` | The API key doesn't have the `publish` or `connect_accounts` [scope](https://docs.vidjutsu.ai/authentication.md#key-scopes) (`reason: "missing_scope"`). |

See [Errors](https://docs.vidjutsu.ai/errors.md) for the rest.


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