Publish a draft
Drafts (action: "draft", or a post created without scheduledAt) never reach a social
platform on their own. Publish one with POST /v0/posts/{id}/publish:
- With no body, the post is published now.
- With a future
scheduledAt, it's scheduled for that time instead. Past times are rejected with422.
# publish now curl -X POST https://api.schedulin.app/v0/posts/post_789/publish \ -H "x-api-key: $SCHEDULIN_API_KEY" # or schedule it curl -X POST https://api.schedulin.app/v0/posts/post_789/publish \ -H "x-api-key: $SCHEDULIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "scheduledAt": "2030-01-15T15:00:00Z" }'
import { SchedulinClient } from "@schedulin/sdk"; const client = new SchedulinClient({ apiKey: process.env.SCHEDULIN_API_KEY }); // publish now await client.posts.publishDraft({ id: "post_789" }); // or schedule it an hour from now await client.posts.publishDraft({ id: "post_789", scheduledAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(), });
import os from datetime import datetime, timedelta, timezone from schedulin import Schedulin client = Schedulin(api_key=os.environ["SCHEDULIN_API_KEY"]) # publish now client.posts.publish_draft(id="post_789") # or schedule it an hour from now client.posts.publish_draft( id="post_789", scheduled_at=datetime.now(timezone.utc) + timedelta(hours=1), )
# CLI (prompts before publishing; pass --yes in scripts) schedulin posts publish post_789 schedulin posts publish post_789 --scheduled-at 2030-01-15T15:00:00Z
Only posts in DRAFT status can be published this way; anything else returns 404. The
response is the updated post with status: "SCHEDULED" and scheduledAt set to the time
you passed, or to now when publishing immediately. It then moves to PROCESSING while
publishing, and finally COMPLETED or FAILED. When it's live, postedAt holds the time
it was published (null until then). Register a webhook for
post.published / post.failed instead of polling.
One post, one channel
Each post belongs to exactly one social account (socialAccountId). There is no
multi-channel post: to publish the same content to Instagram and X, create one post per
account (and publish each one).
for (const socialAccountId of ["acc_123", "acc_456"]) { await client.posts.create({ socialAccountId, caption: "Launch day 🚀", action: "schedule", scheduledAt: "2030-01-15T15:00:00Z", }); }