# How to schedule social media posts programmatically with the API
> A hands-on tutorial for scheduling posts with the DunSocial API: the exact curl call to POST /api/posts/schedule, the request body & the response.
- Published: 2026-09-08
- Last updated: 2026-09-08
- Author: Sanju (Founder & CEO @ DunSocial)
- Topics: tips, api
---
This is the hands-on follow-up. If you want the landscape of what a social publishing API is & when to use one, read [social media publishing API](/blog/social-media-publishing-api) first. This post is the part where you actually call the endpoint.
## What you need before you start
A Bearer token, either a session token from a signed-in browser or a personal access token prefixed `dun_pat_`, created under Settings. Every request also needs an `X-Workspace-Id` header naming the workspace you are scheduling into. Without both, the request is unauthenticated or unscoped & will not go through.
## The endpoint
`POST https://api.dunsocial.com/api/posts/schedule`
The body is JSON: `socialAccountIds` (an array of connected account ids, not @handles), `content` (the post text), `scheduledAt` (an ISO-8601 timestamp) & an optional `mediaUrls` array if the post carries media.
Swap in your own account ids from the workspace you are scheduling into & a real ISO timestamp for `scheduledAt`.
## What comes back
A 201 response, with one created post object per account listed in `socialAccountIds`. Scheduling to two accounts in one call returns two post objects, one per platform, each with its own post id inside your workspace.
Validation is all-or-nothing across the whole request. If any account id is invalid, or the body is malformed, nothing gets scheduled, not even the accounts that would have been fine on their own. That is deliberate: a partially scheduled announcement across some platforms & not others is worse than a clear failure you can fix & retry.
## Same workspace as everything else
A post scheduled through the API shows up on the exact same visual calendar as a post scheduled from the web app, the CLI or MCP. There is no separate API-only queue to check. Schedule from a script, then open the calendar & see it sitting there next to whatever a teammate scheduled by hand that morning, ready to edit, reschedule or cancel like any other post.
That single workspace is also why the API is a natural fit for release scripts, CI pipelines & AI agents, alongside the CLI & MCP: whichever surface writes the post, it lands on the same calendar & can draw on the same AI Memory. A post you schedule this way, with content you supplied yourself, publishes automatically at `scheduledAt`, no extra click needed, that is the point of calling the API. The human-confirm-before-publish rule applies specifically when AI drafts the copy for you in the composer or over MCP, not to a script scheduling content you already wrote.
## Pricing
DunSocial is $20/mo flat, or $192/yr, with the API included, not a separate add-on. One 14-day trial, no card required. One seat is included; extra seats are $8/mo.
Start the trial, generate a personal access token under Settings & schedule your first post from a script instead of a browser tab.
---
## About this document
This is the Markdown representation of https://www.dunsocial.com/blog/schedule-social-media-posts-programmatically-with-the-api. The HTML version of the same page is at the same URL. You can also request Markdown from any page by sending `Accept: text/markdown`.
Machine-readable summary of the whole site: https://www.dunsocial.com/llms.txt
## Company
- Product: DunSocial, https://www.dunsocial.com
- Legal entity: THISUX PRIVATE LIMITED, Chennai, Tamil Nadu, India
- Support: support@dunsocial.com
- Open the app: https://app.dunsocial.com/login