# Draft, check and schedule in one call: the scheduled jobs, or each draft's problems and fixes

`POST` `/api/v1/workspaces/{workspace}/posts`

`createPost`

Each draft is created (or changed) as POST …/drafts makes it, checked as POST …/drafts/{id}/check checks it, and when every check passes, each draft with a future post_at (mode schedule) is scheduled as schedulePost schedules it, with no approval step: it posts at its time. The owner sees it on the workspace's schedule. Times must be at least one minute ahead. Only drafts an agent can't post itself go to the owner as before (approval_url): post_now, by-hand posts, unpicked wording options, each Pinterest Pin, each email campaign, or a workspace that can't post yet. When a check fails, nothing is scheduled or requested: the answer has the saved drafts and each one's problems and fixes; apply them and send the drafts again by draft_id and rev. It never posts immediately. Who can call it: An API token with the "drafts" scope, or a member of this workspace, signed in. Refused (402 workspace_inactive) once the workspace's plan has lapsed. Refused (403 posting_paused) while the operator has paused the workspace's posting under the Terms.

**Scopes:** `drafts`

Creates drafts, checks them and schedules each one: it posts at its time with no approval step. Retry with the same idempotency key and body to recover the first answer, not create another plan.

**Parameters**

| Name | In | Required | Type and constraints | Description / example |
| --- | --- | --- | --- | --- |
| `workspace` | path | Yes | `string`; pattern: `"^ws_[a-z0-9]{16}$"` |  Example: `"ws_aaaaaaaaaaaaaaaa"` |
| `Idempotency-Key` | header | No | `string`; pattern: `"^[\\x20-\\x7e]+$"`; minLength: `1`; maxLength: `255` | Any unique string, like a UUID. Sending the same key and request again answers what the first request answered (Idempotent-Replayed: true) and makes nothing twice; the same key with another request is refused (idempotency_key_reused). Example: `"b3f1c7e2-6f0a-4d1e-9c4a-2f8e5d7a1b90"` |

**JSON body**

| Field | Required | Type and constraints | Description |
| --- | --- | --- | --- |
| `drafts` | Yes | array of `object`; minItems: `1`; maxItems: `50` | One plan: the posts to schedule (and any the owner must approve). |
| `note` | No | `string`; maxLength: `2000` | Shown to the owner with any approval request: who posts which part, when, and what they do by hand. |

**Request example**

```http
POST https://app.flaghand.com/api/v1/workspaces/ws_aaaaaaaaaaaaaaaa/posts
Authorization: Bearer tok_<your workspace token>
Idempotency-Key: b3f1c7e2-6f0a-4d1e-9c4a-2f8e5d7a1b90
Content-Type: application/json

{
  "drafts": [
    {
      "kind": "x_post",
      "connection_id": "con_gggggggggggggggg",
      "title": "Notebook update",
      "body": {
        "text": "A small studio update: our new planning notebook is ready.",
        "quote_url": null
      },
      "post_at": "2026-10-26T16:00:00Z",
      "meta": {
        "notes": [
          "Synthetic product announcement for review."
        ]
      },
      "agent_note": "From the October product notes. Not sure about the availability date; please check it.",
      "mode": "schedule"
    }
  ],
  "note": "After approval, the scheduler posts this as Example Studio at 09:00 Pacific on October 26. No manual steps."
}
```

**Response example**

```json
{
  "ok": true,
  "approval_url": null,
  "items": [],
  "note": "After approval, the scheduler posts this as Example Studio at 09:00 Pacific on October 26. No manual steps.",
  "jobs": [
    {
      "id": "job_jjjjjjjjjjjjjjjj",
      "draft_id": "drf_dddddddddddddddd",
      "platform": "x",
      "connection_id": "con_gggggggggggggggg",
      "approval_id": "asq_aaaaaaaaaaaaaaaa",
      "state": "scheduled",
      "run_at": "2026-10-26T16:00:00Z",
      "wait_until": null,
      "result": null,
      "take_down": null,
      "repost": null,
      "move_request": null,
      "error": null,
      "error_code": null,
      "attempts": 0,
      "created_at": "2026-10-25T16:00:00Z",
      "updated_at": "2026-10-25T16:00:00Z",
      "posted_at": null
    }
  ],
  "scheduled": [
    {
      "draft_id": "drf_dddddddddddddddd",
      "rev": 1,
      "mode": "schedule",
      "snapshot_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "unscheduled": [],
  "message": "Scheduled 1 post (jobs): each posts at its time with no approval step. They're on the workspace's schedule; change one with updateScheduledPost or remove it with unschedulePost. Before you reply, read each draft (GET …/drafts/{id}, with its job) and report what it says: the scheduled time, or the post links and live check.",
  "drafts": [
    {
      "id": "drf_dddddddddddddddd",
      "workspace_id": "ws_aaaaaaaaaaaaaaaa",
      "connection_id": "con_gggggggggggggggg",
      "kind": "x_post",
      "title": "Notebook update",
      "labels": [
        "Launch"
      ],
      "body": {
        "text": "A small studio update: our new planning notebook is ready.",
        "quote_url": null
      },
      "post_at": "2026-10-26T16:00:00Z",
      "rev": 1,
      "status": "draft",
      "agent_note": "From the October product notes. Not sure about the availability date; please check it.",
      "request_note": null,
      "requested_at": null,
      "changes_requested_note": null,
      "changes_requested_at": null,
      "created_by": {
        "type": "token",
        "id": "tkn_cccccccccccccccc",
        "name": "Drafting assistant"
      },
      "created_at": "2026-10-25T16:00:00Z",
      "updated_at": "2026-10-25T16:00:00Z",
      "archived": false,
      "meta": {
        "notes": [
          "Synthetic product announcement for review."
        ]
      },
      "legacy_id": null,
      "approval": null,
      "job": {
        "id": "job_jjjjjjjjjjjjjjjj",
        "draft_id": "drf_dddddddddddddddd",
        "platform": "x",
        "connection_id": "con_gggggggggggggggg",
        "approval_id": "asq_aaaaaaaaaaaaaaaa",
        "state": "scheduled",
        "run_at": "2026-10-26T16:00:00Z",
        "wait_until": null,
        "result": null,
        "take_down": null,
        "repost": null,
        "move_request": null,
        "error": null,
        "error_code": null,
        "attempts": 0,
        "created_at": "2026-10-25T16:00:00Z",
        "updated_at": "2026-10-25T16:00:00Z",
        "posted_at": null
      },
      "x_thread_live": null
    }
  ],
  "checks": [
    {
      "draft_id": "drf_dddddddddddddddd",
      "mode": "schedule",
      "ok": true,
      "problems": [],
      "reach": [
        {
          "code": "media",
          "ok": false,
          "text": "The post has no photo or video; native media is usually worth considering, though text-only X posts can do well too.",
          "fixes": [
            {
              "kind": "upload-media",
              "operation_id": "uploadMedia"
            }
          ]
        },
        {
          "code": "alt_text",
          "ok": true,
          "text": "The post has no image or video needing alt text."
        },
        {
          "code": "length",
          "ok": true,
          "text": "The post is short enough to usually show whole without Show more."
        },
        {
          "code": "best_time",
          "ok": true,
          "text": "The proposed time falls in a recommended hour, based on published research."
        }
      ],
      "suggestions": [
        {
          "code": "reach",
          "rule": "media",
          "text": "The post has no photo or video; native media is usually worth considering, though text-only X posts can do well too.",
          "fixes": [
            {
              "kind": "upload-media",
              "operation_id": "uploadMedia"
            }
          ]
        }
      ],
      "snapshot_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "snapshot": {
        "v": 1,
        "workspace_id": "ws_aaaaaaaaaaaaaaaa",
        "draft_id": "drf_dddddddddddddddd",
        "draft_rev": 1,
        "kind": "x_post",
        "platform": "x",
        "connection_id": "con_gggggggggggggggg",
        "account": {
          "external_id": "123456789",
          "handle": "example_studio",
          "display_name": "Example Studio"
        },
        "mode": "schedule",
        "post_at": "2026-10-26T16:00:00Z",
        "waits_for_post_1": false,
        "content": {
          "text": "A small studio update: our new planning notebook is ready.",
          "quote_url": null
        },
        "payload": {
          "parts": [
            {
              "text": "A small studio update: our new planning notebook is ready.",
              "media": []
            }
          ]
        },
        "agent_note": "From the October product notes. Not sure about the availability date; please check it."
      }
    }
  ]
}
```

Success: HTTP 200. Content-Type: application/json.

Response headers: `Idempotent-Replayed`: true when this is the answer an earlier request with the same Idempotency-Key got; nothing new was made..

**Errors:** `invalid_request` (400), `internal` (500), `unauthorized` (401), `invalid_token` (401), `session_expired` (401), `bad_origin` (403), `scope_missing` (403), `invalid_json` (400), `not_found` (404), `workspace_inactive` (402), `idempotency_key_reused` (422), `rev_conflict` (409), `draft_locked` (409). See the [error codes](https://app.flaghand.com/docs/errors.md) for meanings and the shared default error response. Other domain errors from that catalog may apply; the response's code and message are authoritative.

**CLI:** `flaghand posts create`

```sh
flaghand posts create --workspace ws_aaaaaaaaaaaaaaaa --idempotency-key b3f1c7e2-6f0a-4d1e-9c4a-2f8e5d7a1b90 -d '{"drafts":[{"kind":"x_post","connection_id":"con_gggggggggggggggg","title":"Notebook update","body":{"text":"A small studio update: our new planning notebook is ready.","quote_url":null},"post_at":"2026-10-26T16:00:00Z","meta":{"notes":["Synthetic product announcement for review."]},"agent_note":"From the October product notes. Not sure about the availability date; please check it.","mode":"schedule"}],"note":"After approval, the scheduler posts this as Example Studio at 09:00 Pacific on October 26. No manual steps."}' --json
```

**MCP tool:** `createPost` (also reachable through `callWriteOperation`; use `getOperation` to load its full schema).

```json
{
  "name": "callWriteOperation",
  "arguments": {
    "operation_id": "createPost",
    "arguments": {
      "workspace": "ws_aaaaaaaaaaaaaaaa",
      "idempotency_key": "b3f1c7e2-6f0a-4d1e-9c4a-2f8e5d7a1b90",
      "drafts": [
        {
          "kind": "x_post",
          "connection_id": "con_gggggggggggggggg",
          "title": "Notebook update",
          "body": {
            "text": "A small studio update: our new planning notebook is ready.",
            "quote_url": null
          },
          "post_at": "2026-10-26T16:00:00Z",
          "meta": {
            "notes": [
              "Synthetic product announcement for review."
            ]
          },
          "agent_note": "From the October product notes. Not sure about the availability date; please check it.",
          "mode": "schedule"
        }
      ],
      "note": "After approval, the scheduler posts this as Example Studio at 09:00 Pacific on October 26. No manual steps."
    }
  }
}
```

Base URL: `https://app.flaghand.com/api/v1`. Part of the [API reference](https://app.flaghand.com/docs/api.md); every error code is in [errors](https://app.flaghand.com/docs/errors.md).
