# How to schedule a post with the DunSocial TypeScript SDK > Call dun.posts.schedule with content, socialAccountIds & a scheduledAt Date. posts.publish queues a post now, & posts.wait polls until it is published, failed or cancelled. media.upload hides the three-step upload & returns an asset id for mediaIds. Updated: 2026-10-05. ## Schedule & publish ```ts const [post] = await dun.posts.schedule({ content: 'Shipping from the SDK.', socialAccountIds: ['acc_x'], scheduledAt: new Date(Date.now() + 60 * 60 * 1000) }); const [live] = await dun.posts.publish({ content: 'Live now.', socialAccountIds: ['acc_x'], mediaIds: ['media_1'] }); ``` Each call returns one post per account. Note that `mediaIds` in the SDK map to `mediaUrls` in the raw API. ## Publish queues, it doesn't finish `publish` queues the post with a `scheduled` status. It doesn't mean the platform has accepted it. To wait for the outcome, call `wait`: ```ts const published = await dun.posts.wait(live.id); ``` `wait` polls until the post is `published`, `failed` or `cancelled`, so you can act on the real result. ## Validate first The validate route returns HTTP 200 even when a post is invalid, so check the `valid` flag: ```ts const result = await dun.posts.validate({ content: 'Hello Reddit', socialAccountIds: ['acc_reddit'], metadata: { reddit: { subreddit: 'startups', title: 'Hello', kind: 'self' } } }); if (!result.valid) console.log(result.issues); ``` Pass `throwOnInvalid: true` if you'd rather it raise a `DunSocialError`. DunSocial's platform metadata is the same as in the API, so a Reddit, Instagram, Pinterest, TikTok, Discord or Slack post needs its block here too. ## Upload media in one call `media.upload` hides the three API steps of requesting a URL, uploading bytes & completing the asset: ```ts const asset = await dun.media.upload({ file: new Uint8Array(await file.arrayBuffer()), filename: 'cover.png', mimeType: 'image/png', altText: 'Release cover' }); await dun.posts.schedule({ content: 'New cover.', socialAccountIds: ['acc_x'], mediaIds: [asset.id], scheduledAt: new Date(Date.now() + 3600_000) }); ``` It accepts a `Uint8Array`, an `ArrayBuffer` or a `Blob`. If the presigned URL expired, call `upload()` again, since a failed PUT creates no gallery row. DunSocial keeps the uploaded asset in the gallery, so the same asset id works for later posts. ## X threads Threads are X only, with 2 to 25 tweets & a singular `socialAccountId`: ```ts await dun.posts.scheduleThread({ socialAccountId: 'acc_x', scheduledAt: new Date(Date.now() + 3600_000), tweets: [{ content: '1 / 2' }, { content: '2 / 2' }] }); ``` DunSocial applies the same 2 to 25 tweet rule here as in the API. ## Facebook Pages Pages need no metadata block. List them with `dun.accounts.list({ platform: 'facebook' })`, then schedule text, one link or photos to the Page. DunSocial lists Facebook Pages as accounts like any other, so the SDK needs no special handling. ## Why this is safe to automate Everything you schedule from the SDK shows up on the DunSocial calendar, where a person can review, edit or cancel it before it goes out. For unattended jobs, prefer `schedule` over `publish`, & validate first so a bad payload never reaches the queue. ## Related guides - [How to use the DunSocial TypeScript SDK](https://www.dunsocial.com/hub/dunsocial-api-and-sdk-guides/how-to-use-the-dunsocial-typescript-sdk.md) - [How to schedule a post with the DunSocial API](https://www.dunsocial.com/hub/dunsocial-api-and-sdk-guides/how-to-schedule-a-post-with-the-dunsocial-api.md) - [How to upload media with the DunSocial API](https://www.dunsocial.com/hub/dunsocial-api-and-sdk-guides/how-to-upload-media-with-the-dunsocial-api.md) - [How to bulk schedule social media posts](https://www.dunsocial.com/hub/social-media-scheduler/how-to-bulk-schedule-social-media-posts.md) ## About this document This is the Markdown representation of https://www.dunsocial.com/hub/dunsocial-api-and-sdk-guides/how-to-schedule-a-post-with-the-dunsocial-typescript-sdk. 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