# Schedule and resume a 15-video campaign

Two destinations per video produce 30 schedules. Use two simulation accounts to rehearse.

![Batch review](../media/campaign.webp)

## Prepare the manifest

Get `projectId` from `projects_list` and two IDs from `accounts_list`. Place `video-01.mp4` through `video-15.mp4` in the campaign directory. Set the three variables below to the returned IDs. Run once to create `campaign.json` and retain the file. Times are future UTC instants with an explicit display zone. For a ready asset in the same project use `{"mediaId":"ID"}` in `source`.

```sh
export PROJECT_ID='PROJECT_ID' ACCOUNT_A='ACCOUNT_ID_A' ACCOUNT_B='ACCOUNT_ID_B'
node --input-type=module <<'JS'
import { writeFileSync } from 'node:fs'
import { randomUUID } from 'node:crypto'
const { PROJECT_ID: projectId, ACCOUNT_A, ACCOUNT_B } = process.env
const start = Date.now() + 3600000
const items = Array.from({length: 15}, (_, index) => {
  const itemId = 'video-' + String(index + 1).padStart(2, '0')
  const at = new Date(start + index * 60000).toISOString()
  return { itemId, source: {file: itemId + '.mp4'}, caption: itemId,
    targets: [ACCOUNT_A, ACCOUNT_B].map(accountId => ({account: {accountId}, at})) }
})
writeFileSync('campaign.json', JSON.stringify({version: 1, batchId: randomUUID(), projectId,
  timezone: 'America/Sao_Paulo', items}, null, 2), {flag: 'wx'})
JS
```

For YouTube include target `options` with `title`, `visibility` and `madeForKids`. For TikTok inspect the diagnosis and allowed privacy options and send each confirmation to the owner. The installer includes FFprobe for local file inspection.

## With the CLI

```sh
opensocial batch plan campaign.json --dry-run --json
opensocial batch apply campaign.json --jsonl
opensocial batch status BATCH_UUID --json
```

Check `canApply` and all 30 entries before applying. After an interruption, inspect status and repeat the same `apply` with the same file. Each destination row identifies media, account, publication and time. The summary reports `scheduled` and `pendingApproval`. CLI exit codes are 0 for success, 1 for execution failure, 2 for invalid input or plan, and 3 for partial or pending work.

## With MCP and REST

1. In local MCP, `batches_plan_file` with `{"path":"campaign.json"}` resolves local files and returns `manifest` and `plan`. In REST or HTTP MCP use a manifest with media IDs or `source.upload` descriptors containing name, SHA-256 and video metadata. Local paths stay on the client. Send `{"manifest": ...}` to `batches_plan`.

2. If valid, send the same manifest to `batches_register`. For each local file, call `batches_upload_file` with `batchId`, `itemId` and `path`. Over HTTP call `batches_upload` with `batchId` and `itemId` and PUT the bytes when an `uploadUrl` is returned. Reuse media already marked `ready`.

3. For each video/account pair call `batches_apply` with `batchId`, `itemId` and `accountId`. Supply idempotency keys on writes. Read `batches_status` with `batchId`. Retain IDs across logins and resume pending entries only. For `awaiting_owner` return the review link. For `unknown` check the remote result before resending.
