Layers

POST /v1/content/:containerId/publish

Publish a container immediately. Convenience wrapper around schedule with scheduledFor set to now + 30 seconds.

View as Markdown
POST/v1/content/:containerId/publish
Phase 1stableidempotent
Auth
Bearer
Scope
publish:write

Publish now. Same machinery as schedule — 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 within that window.

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.

Path
  • containerId
    stringrequired
    Completed content container id.
Headers
  • Idempotency-Key
    string (UUID)optional
    Same key + same body replays the cached response for 24 hours. Especially important here — accidental retries double-post.
Body
  • targets
    Target[]required
    Same shape as schedule. At least one required.

See the schedule reference for the full Target shape and the platform-to-mode validity matrix.

Example request

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" }
    ]
  }'
const result = await layers.publishing.publishNow(
  {
    containerId: "cnt_01HXZM3K4N5P6QRS7TUV8WXYZ9",
    targets: [
      { socialAccountId: "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A", mode: "direct_publish" },
    ],
  },
  { idempotencyKey: crypto.randomUUID() },
);
result = layers.publishing.publish_now(
    container_id="cnt_01HXZM3K4N5P6QRS7TUV8WXYZ9",
    targets=[
        {"socialAccountId": "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A", "mode": "direct_publish"},
    ],
    idempotency_key=str(uuid.uuid4()),
)

Response

200Queued for immediate publish
{
  "scheduledPostIds": ["sp_01HXZP5K6M7P8QRS9TUVAWXYZB"],
  "gateStatus": "queued",
  "scheduledFor": "2026-04-18T19:18:42Z"
}

Errors

Same as schedule. Common ones:

StatusCodeWhen
422VALIDATIONEmpty targets, invalid mode for the platform.
403APPROVAL_REQUIREDContainer not approved and project still in the approval window.
404NOT_FOUNDContainer or account not in your organization.
409CONFLICTContainer not completed.
409CONTENT_REJECTEDContainer's approval_status is rejected. Regenerate or replace the container.

See also

On this page