POST /v1/content/:containerId/publish
Publish a container immediately. Convenience wrapper around schedule with scheduledFor set to now + 30 seconds.
/v1/content/:containerId/publish- 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.
containerIdstringrequiredCompleted content container id.
Idempotency-Keystring (UUID)optionalSame key + same body replays the cached response for 24 hours. Especially important here — accidental retries double-post.
targetsTarget[]requiredSame 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
{
"scheduledPostIds": ["sp_01HXZP5K6M7P8QRS9TUVAWXYZB"],
"gateStatus": "queued",
"scheduledFor": "2026-04-18T19:18:42Z"
}Errors
Same as schedule. 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
POST /v1/content/:id/schedule— schedule for laterDELETE /v1/scheduled-posts/:id— cancel within the 30-second windowGET /v1/scheduled-posts/:id— watch it publish