Post with Node.js

Post to social media
with Node.js.

PostLake's publish API is ordinary JSON over HTTPS. Node 18+ needs no SDK. Match the docs: address a profile, then read each target in the response.

Get started free →

Free tier. No card · one API for every network · full MCP access

In shortIn Node 18+. One fetch to /v1/posts publishes across the profile. Check targets[]; use Idempotency-Key on retries.

When this guide is for you

Your service already runs on Node and you want outbound social posts without nine OAuth integrations.

Before you start

Same setup the docs quickstart uses. Do this once:

  1. Sign up at app.postlake.dev and verify your email (unlocks free credits).
  2. On Channels, create a profile (e.g. my-brand) and connect at least one account. Bluesky is the fastest first channel: no app review. Instagram/TikTok/Facebook need each platform's review before API posting.
  3. Account menu → API Keys → create a key (sk_live_…). It shows once; treat it like a password.

Working example in Node.js

Connect accounts once in the dashboard, then this is the publish call:

const resp = await fetch("https://api.postlake.dev/v1/posts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POSTLAKE_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "hello-node-001",
  },
  body: JSON.stringify({
    text: "Hello from Node 👋",
    profile: "my-brand",
    // platforms: ["bluesky", "linkedin"], // optional filter
  }),
});

const post = await resp.json();
if (!resp.ok) throw new Error(JSON.stringify(post));
console.log(post.id, post.state);
for (const t of post.targets) {
  console.log(t.platform, t.state, t.url ?? t.error);
}

Make it work in Node.js

Tool-specific glue on top of the shared setup above:

  1. Put the key in POSTLAKE_API_KEY. Use the Channels profile name exactly as in the dashboard.
  2. POST with built-in fetch (Node 18+). No npm social packages.
  3. If resp.ok is false, treat it as a request error. If ok, still walk targets for partial failures.
  4. Send Idempotency-Key on every publish so agent or job retries stay safe.

Read the response (don't skip this)

You get one Post with an overall state and a targets[] array. One entry per account. Always check each target; partial success is normal.

{
  "id": "post_a1b2c3",
  "state": "partial",
  "targets": [
    { "platform": "bluesky",  "state": "published", "url": "https://bsky.app/…" },
    { "platform": "linkedin", "state": "failed",
      "error": { "type": "invalid_request", "message": "…", "retryable": false } }
  ]
}

Where the post goes

Same rules as the docs. Pick one addressing style:

See Publishing: where to post.

Do more (same API)

Pitfalls specific to this path

Prefer an assistant over Node.js code? Point it at MCP (https://api.postlake.dev/mcp). Prefer the dashboard? Use Quickstart → No code.

Common questions

How do I post to social media with Node.js?

POST to https://api.postlake.dev/v1/posts with fetch, Bearer API key, and { text, profile }. One response covers every account on that profile. See docs → Publishing.

Is there an npm package I need?

No package required. Native fetch is enough; PostLake is one REST endpoint for every network.

Can an AI agent in Node use PostLake?

Yes, call the API from a tool, or connect the hosted MCP server (https://api.postlake.dev/mcp) over OAuth so the agent posts without a pasted key.

Go deeper in the docs

These guides stay short on purpose. Canonical behaviour lives here:

Also: Media · Errors · MCP · Analytics

Related guides

All guides · Full docs · llms.txt · Markdown

Stuck? The docs are the source of truth, start at Publishing.

Open the dashboard →