Skip to content
← Back to all posts

What Postkey does when a post fails on one network

· 2 min read · Postkey team

Say you send one post to Instagram, LinkedIn and X, and LinkedIn rejects it because the user's token expired last night. Instagram and X accepted it. What should the API return?

Plenty of integrations answer "an error", because that's the easy thing to build: one request, one result. It's also wrong. Two posts are live. If your app shows a red banner, the user hits retry, and now there are two copies on Instagram and two on X.

So we report each network separately.

One result per network

Every target in a Postkey post publishes on its own, and the response lists what happened to each one:

curl -X POST https://api.postkey.dev/v1/posts \
  -H "x-access-key: $POSTKEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Spring menu is up. The rhubarb tart is back.",
    "platforms": [
      { "platform": "instagram", "accountId": "int_ig_123" },
      { "platform": "linkedin", "accountId": "int_li_456" },
      { "platform": "twitter", "accountId": "int_x_789" }
    ],
    "publishNow": true
  }'
Response
{
  "success": true,
  "postId": "post_31d0a",
  "status": "partial",
  "platforms": [
    { "platform": "instagram", "accountId": "int_ig_123", "success": true, "platformPostUrl": "https://www.instagram.com/p/…" },
    { "platform": "linkedin", "accountId": "int_li_456", "success": false },
    { "platform": "twitter", "accountId": "int_x_789", "success": true, "platformPostUrl": "https://x.com/…" }
  ]
}

The overall status is published when everything went out, failed when nothing did, and partial for anything in between. In most apps you'll want to show partial as "posted to 2 of 3" with a way to fix the third, not as an error.

The failed network costs nothing

Postkey bills in credits, and a failed action doesn't use any. In the example above the LinkedIn credit is refunded on its own. You don't have to compare an invoice against your error logs at the end of the month.

Retrying only LinkedIn

Once the user has reconnected LinkedIn, call retry on the same post:

curl -X POST https://api.postkey.dev/v1/posts/post_31d0a/retry \
  -H "x-access-key: $POSTKEY_API_KEY"

This publishes the failed targets and skips the ones that already went out. Instagram and X don't get a second copy. A retry is charged like any other publish and refunded the same way if it fails again. You can also schedule it instead of running it right away.

Finding out without polling

If you subscribe a webhook you get one event per post when it's finished: post.published, post.partial or post.failed, with every network's result inside. We chose one event per post over one per network because your handler almost always wants the whole picture before it tells the user anything.

An expired token also fires account.reauthorization_required. That's the one to hook up first, because it tells you which user needs a reconnect link before they notice their posts have stopped.

Credit costs for each action are on the credits page in the docs.

Publish to 9 networks with one API call

Your users connect their accounts with a link. Failed posts are refunded.

Reserve your free API key

No card required.

Reserve your free API key.

No card required.

Or read the docs first
  • Unlimited accounts
  • Failed posts refunded
  • Official APIs only
  • Fast support from the founder