Skip to content
DunSocial Docs

Posts

Schedule, publish, validate, and wait for a terminal status.

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']
});

const published = await dun.posts.wait(live.id);

publish queues the row (status: scheduled). wait(id) polls until published, failed, or cancelled.

Validate

POST /api/posts/validate returns HTTP 200 even when the post is invalid:

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 to raise DunSocialError instead.

Threads

X only. Two to 25 tweets. Singular socialAccountId.

await dun.posts.scheduleThread({
socialAccountId: 'acc_x',
scheduledAt: new Date(Date.now() + 3600_000),
tweets: [
  { content: '1 / 2' },
  { content: '2 / 2' }
]
});

SDK mediaIds map to API mediaUrls. Platform metadata (Reddit, Instagram, Pinterest, TikTok) is the same as the API posts guide.