# POST /v1/content/:containerId/publish (/docs/api/reference/publishing/publish-content)



<Endpoint method="POST" path="/v1/content/:containerId/publish" auth="Bearer" scope="publish:write" phase="1" />

Publish now. Same machinery as [`schedule`](/docs/api/reference/publishing/schedule-content) — Layers sets `scheduledFor = now` internally so the publish path and scheduler share one code path. If you need a pre-publish cancel window, schedule with a short lead (`scheduledFor: now + 30s` on your side) and [`DELETE /v1/scheduled-posts/:id`](/docs/api/reference/publishing/cancel-post) within that window.

<Callout type="warn">
  Nothing publishes until the container's approval flag is set. If the project has `requires_approval: true` and the container is not yet `approved`, this call returns `403 APPROVAL_REQUIRED` — flipping approval later will still publish, but at that later time, not immediately. See [Approval](/docs/api/concepts/approval).
</Callout>

<Parameters
  title="Path"
  rows="[
  { name: 'containerId', type: 'string', required: true, description: 'Completed content container id.' },
]"
/>

<Parameters
  title="Headers"
  rows="[
  { name: 'Idempotency-Key', type: 'string (UUID)', description: 'Same key + same body replays the cached response for 24 hours. Especially important here — accidental retries double-post.' },
]"
/>

<Parameters
  title="Body"
  rows="[
  { name: 'targets', type: 'Target[]', required: true, description: 'Same shape as schedule. At least one required.' },
]"
/>

See the [schedule](/docs/api/reference/publishing/schedule-content#target) reference for the full `Target` shape and the platform-to-mode validity matrix.

## Example request [#example-request]

<Tabs items="['curl', 'TypeScript', 'Python']">
  <Tab value="curl">
    ```bash
    curl https://api.layers.com/v1/content/cnt_01HXZM3K4N5P6QRS7TUV8WXYZ9/publish \
      -H "Authorization: Bearer lp_live_01HX9Y6K7EJ4T2_4QZpN..." \
      -H "Idempotency-Key: 3a7b2f11-9e4c-4a12-9d8a-b5c7e2f0a111" \
      -H "Content-Type: application/json" \
      -d '{
        "targets": [
          { "socialAccountId": "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A", "mode": "direct_publish" }
        ]
      }'
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    const result = await layers.publishing.publishNow(
      {
        containerId: "cnt_01HXZM3K4N5P6QRS7TUV8WXYZ9",
        targets: [
          { socialAccountId: "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A", mode: "direct_publish" },
        ],
      },
      { idempotencyKey: crypto.randomUUID() },
    );
    ```
  </Tab>

  <Tab value="Python">
    ```python
    result = layers.publishing.publish_now(
        container_id="cnt_01HXZM3K4N5P6QRS7TUV8WXYZ9",
        targets=[
            {"socialAccountId": "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A", "mode": "direct_publish"},
        ],
        idempotency_key=str(uuid.uuid4()),
    )
    ```
  </Tab>
</Tabs>

## Response [#response]

<Response status="200" description="Queued for immediate publish">
  ```json
  {
    "scheduledPostIds": ["sp_01HXZP5K6M7P8QRS9TUVAWXYZB"],
    "gateStatus": "queued",
    "scheduledFor": "2026-04-18T19:18:42Z"
  }
  ```
</Response>

## Errors [#errors]

Same as [`schedule`](/docs/api/reference/publishing/schedule-content#errors). Common ones:

| Status | Code                | When                                                                              |
| ------ | ------------------- | --------------------------------------------------------------------------------- |
| 422    | `VALIDATION`        | Empty `targets`, invalid `mode` for the platform.                                 |
| 403    | `APPROVAL_REQUIRED` | Container not approved and project still in the approval window.                  |
| 404    | `NOT_FOUND`         | Container or account not in your organization.                                    |
| 409    | `CONFLICT`          | Container not `completed`.                                                        |
| 409    | `CONTENT_REJECTED`  | Container's `approval_status` is `rejected`. Regenerate or replace the container. |

## See also [#see-also]

* [`POST /v1/content/:id/schedule`](/docs/api/reference/publishing/schedule-content) — schedule for later
* [`DELETE /v1/scheduled-posts/:id`](/docs/api/reference/publishing/cancel-post) — cancel within the 30-second window
* [`GET /v1/scheduled-posts/:id`](/docs/api/reference/publishing/get-scheduled-post) — watch it publish
