Skip to content

Node.js social publishing

Schedule social media posts with Node.js and TypeScript

Use normal server-side JavaScript or TypeScript to read your connected channels and publish through PostSider. Start with raw fetch, then move to the @postsider/node client when the integration becomes part of a real codebase.

Start with a working REST example, or explore the API and product use cases.

How it works

The Node.js flow is just API key, channel ID, post.

There is no browser automation and no separate OAuth implementation in your Node service. Social accounts stay connected in PostSider; your code talks to one API.

01

Load your API key

Keep the PostSider key in an environment variable and use it from a server process, worker or script. Do not ship it to browser code. Node 18+ has fetch built in; TypeScript projects can use the typed @postsider/node client instead.

02

List connected channels

Read the integrations endpoint first so your code knows the PostSider channel ID it should target.

03

Create the post

Send the content, destination and publish mode to the public API. Use a future UTC timestamp when the post should be scheduled.

04

Handle the result

Keep the returned post ID and inspect publishing state later, or add webhooks when your backend needs event-driven updates. Treat API errors, disabled channels and ERROR states as explicit application states, not exceptions to swallow.

Concrete example

Schedule one X post from Node.js and read it back

This is the full first job: resolve the channel, save a complete payload with an Idempotency-Key, create the post, then read the returned ID. Swap the settings block for another provider's fields from the API reference. The same sequence works with the typed @postsider/node client in TypeScript.

// Option A: plain fetch. Option B (below): the typed @postsider/node client.
import { randomUUID } from 'node:crypto';

const BASE = 'https://api.postsider.com/public/v1';
const headers = {
  Authorization: process.env.POSTSIDER_API_KEY, // raw key, no "Bearer"
  'Content-Type': 'application/json',
};

// 1. Resolve the channel ID instead of guessing it.
const channels = await (await fetch(`${BASE}/integrations`, { headers })).json();
const x = channels.find((c) => c.identifier === 'x' && !c.disabled);
if (!x) throw new Error('No enabled X channel');

// 2. Build the request once, keep it, and give it a stable key.
const payload = {
  type: 'schedule',                       // draft | schedule | now
  date: '2026-11-16T14:00:00.000Z',       // future UTC ISO timestamp
  shortLink: false,
  tags: [],
  posts: [{
    integration: { id: x.id },
    value: [{ content: 'Release 2.4 is out. Changelog in the first comment.', image: [] }],
    settings: { __type: 'x', who_can_reply_post: 'everyone' },
  }],
};
const idempotencyKey = randomUUID();      // reuse it on a timeout retry

// 3. Create, then read the exact post back. A 2xx is not publication.
const created = await fetch(`${BASE}/posts`, {
  method: 'POST',
  headers: { ...headers, 'Idempotency-Key': idempotencyKey },
  body: JSON.stringify(payload),
});
if (!created.ok) throw new Error(`PostSider API returned ${created.status}`);
const [{ postId }] = await created.json();

const post = await (await fetch(`${BASE}/posts/${postId}`, { headers })).json();
console.log(post.posts[0].state, post.posts[0].publishDate); // QUEUE = scheduled, not published

// Option B: same calls through the SDK (TypeScript types included).
// import Postsider from '@postsider/node';
// const postsider = new Postsider(process.env.POSTSIDER_API_KEY!);
// const channels = await postsider.integrations();

FAQ

Common questions.

Can I schedule social media posts from Node.js?
Yes. A Node.js service can call the PostSider REST API directly or use the official SDK to create drafts, immediate publications and scheduled posts.
Is there a Node.js or TypeScript SDK?
Yes. @postsider/node is the official TypeScript and Node.js client around the public API. It ships its own types, works in serverless functions and workers, and is not a different API: you can mix SDK calls with direct REST requests.
Can I run social scheduling from a cron job or queue worker?
Yes. The API works from normal server-side Node.js processes, including cron jobs, workers and serverless functions.
Should I call the API from frontend JavaScript?
No. Keep the API key on the server. Browser code would expose the credential to anyone who can inspect the page or network requests.

Use the same publishing system from code

Connect the channels once. Keep the workflow in your stack.

Call REST directly, use the typed SDK, or expose the same publishing actions to an MCP-compatible agent.