How to Avoid Duplicate Posts When an API Call Retries

Why n8n, Zapier, Make and scripts post twice after a timeout, and how an idempotency key built from the source item plus a duplicate guard stops it.

Two identical API requests for the same social post, where the second one is answered from a stored copy instead of creating a new post

Guide · By PostBoost team · · Markdown

To avoid duplicate posts when an API call retries, send an idempotency key with every create request and reuse the same key on every retry of that post. The server runs the first request and answers any repeat with the first response, so a retry after a timeout can no longer create a second post. In an automation, build the key from the source item (the sheet row, the Airtable record, the feed item), not inside the step that retries. Then keep a content check behind it for the cases a key cannot see.

This guide explains where the double posts come from in n8n, Zapier, Make and plain scripts, how to build a key that survives a re-run, and exactly what PostBoost's API answers in each case, so your workflow can tell "done" from "try again" from "stop".

Why a retry posts twice

A POST that creates a post is not safe to repeat. The IETF draft that defines the Idempotency-Key header puts it plainly: POST and PATCH are not idempotent, and a client whose POST timed out cannot tell whether the resource was created (IETF draft).

That is the whole problem. Your HTTP step waits 30 seconds, gives up, and marks itself failed. On the server the post was created in second 31. Every automation tool is built to retry that step:

  • n8n: with Retry On Fail on, "the node reruns until it succeeds" (n8n node settings).
  • Zapier: Autoreplay retries failed steps in a Zap run; its help page lists it as an account-wide setting on Professional plans and higher (Zapier Help).
  • Make: incomplete executions caused by RateLimitError, ConnectionError and ModuleTimeoutError are retried on a backoff schedule of 1 min, 10 min, 10 min, 30 min, 30 min, 30 min, 3 hours and 3 hours (Make Help). Added up, the last attempt comes about 7 hours 51 minutes after the first failure, so a duplicate can appear long after you stopped watching.

Retries are not the only source. A trigger can fire twice for one event, a webhook sender redelivers when your endpoint answered slowly, and a cron job that runs longer than its interval overlaps with the next run. All of them send the same post twice.

The fix: one key per post, the same key on every retry

An idempotency key is a value the client sends with the request so the server can recognise a repeat of it. The first request with a key runs; any later request with the same key gets the stored answer and changes nothing. The IETF draft recommends a UUID or a similar random identifier.

The rule that matters in practice: one key per post, and the same key every time that post is sent. A fresh random value made inside the step that retries can come out different on the next attempt, and then the server sees two unrelated requests. The safest key is derived from the thing you are posting about:

Source Key
Google Sheets row sheet-<row number>-<date>-<time>
Airtable record airtable-<record id>
RSS or blog feed feed-<item guid>
Incoming webhook hook-<delivery id>
Your own database post-<your row's primary key>

A key made from the source item comes out the same when the step retries, when the whole workflow is replayed and when two overlapping runs pick up the same row. The automation recipes for n8n use exactly this pattern: the Google Sheets recipe sends sheet-{{ $json.row_number }}-{{ $json.date }}-{{ $json.time }} and the Airtable one sends airtable-{{ $json.id }}.

What PostBoost does with the key

Every POST to the PostBoost API accepts an Idempotency-Key header of 1 to 255 visible ASCII characters (no spaces). PostBoost keeps the response for 24 hours:

What you send What you get
First request with the key Runs normally (201 with the post for create-post)
Same key, same body The stored response again, with Idempotent-Replayed: true; nothing is created
Same key while the first request is still running 409 with Retry-After: 1
Same key, different body 422: the key was already used with a different request body
First attempt answered 5xx or 429 Not stored: a retry with the same key runs again
Key longer than 255 characters, or with spaces or non-ASCII characters 400

Keys are scoped to your user, the workspace, the method and the path, so the same key on the media upload and on create-post does not collide. Key order inside the JSON body does not matter for "same body"; values and list order do.

A scheduled create with a key looks like this:

curl -X POST "https://postboost.co/app/api/$WORKSPACE_UUID/posts" \
  -H "Authorization: Bearer $POSTBOOST_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: airtable-rec8KzQ2mN4pX7aB" \
  -H "X-PostBoost-Client: content-calendar/1.0" \
  -d '{
    "accounts": [12],
    "versions": [{ "account_id": 0, "is_original": true,
      "content": [{ "body": "Our spring menu starts Monday.", "media": [] }] }],
    "schedule": true,
    "date": "2026-12-01",
    "time": "09:00",
    "timezone": "UTC"
  }'

Send it twice and the second answer is the same 201 with the same post uuid, plus Idempotent-Replayed: true. Your workflow can treat both the same way: the post exists, store its uuid, move on. The API request builder writes this request for you in curl and the nine SDKs; add the Idempotency-Key header to what it generates.

Make's whole retry schedule above, about 7 hours 51 minutes end to end, fits inside the 24-hour window.

Teach the workflow to read the answer

Retrying blindly is how a small hiccup becomes a pile of identical posts. Branch on the status and the code field instead:

Response Meaning Do
201 (with or without Idempotent-Replayed) The post exists Save the uuid, stop
409 with Retry-After The first request is still running Wait the given seconds, retry with the same key
409, code: duplicate_post Same content for this account in the last 24 hours Stop; the response names the existing_post_uuid
422 with an idempotency message Your key was reused for different content Fix how the key is built; do not retry
422, code: account_unauthorized or account_token_missing A scheduled post targets a disconnected account Reconnect the account first; a retry will not help
429, code: account_daily_cap_reached The account already has its daily number of posts on the post's publish date (UTC) Stop, or schedule it for another day; a retry will not help
429, code: x_monthly_cap_reached The workspace's monthly X allowance is used up Stop; a retry will not help until the allowance renews
429 without a code, or 5xx Rate limit or server error Back off, retry with the same key

Two of these trip people up. A 429 is not always "try again later": the daily cap and the X allowance are hard stops, and the body says which in code. And a 409 comes in two kinds: the short in-progress one, which is safe to retry, and duplicate_post, which is not.

The second net: PostBoost's duplicate guard

The key protects requests that carry one. For everything else, PostBoost refuses a create or update with 409 and code: duplicate_post when the content for an account matches a post created for that account in the last 24 hours. It compares what that account would publish: the text with markup, spacing and case ignored, the media, and the link. The response includes existing_post_uuid, so you can point a person at the post that is already there. When you really want the same text again, for example a weekly reminder, send "allow_duplicate": true or the X-Allow-Duplicate: true header.

Know where the guard stops, because that is where duplicates still slip through:

  • Regenerated text. If an AI step writes the caption and the whole workflow re-runs, the second caption is worded differently and counts as new content. With a key built from the source item, the second request is refused with 422 instead, because the same key arrived with a different body.
  • Re-uploaded media. The guard compares media ids. A re-run that uploads the same image again gets a new id, so the post no longer matches. Upload once and reuse the id, or send the upload (POST /{workspaceUuid}/media) with its own Idempotency-Key; the replay returns the same media item.
  • Older than 24 hours. Both the key and the guard look back 24 hours. A workflow that re-reads a whole sheet next week needs its own memory of what it already posted.

Remember what you already posted

For anything older than a day, keep your own record. Two simple ways:

  1. Write the result back. After a 201, store the post uuid in the source row (a "PostBoost post" column in the sheet or Airtable base) and filter out rows that already have one at the start of every run.
  2. Let the tool remember. In n8n, the Remove Duplicates node's Remove Items Processed in Previous Executions operation with Keep Items Where: Value Is New drops items whose value was seen in an earlier execution; set Value to Dedupe On to the row or record id. It stores 10,000 items by default (n8n Remove Duplicates).

The same thinking applies in the other direction. PostBoost's webhooks send the same delivery id on every retry and manual resend, so store the ids you have handled and skip repeats. Verify each delivery first; the webhook signature verifier and the guide on how to verify a webhook signature show how.

AI agents retry too

An agent that calls PostBoost through the connector at /mcp gets the same protection: its create-post tool takes an idempotency_key argument and uses the same store and replay rules, and the duplicate guard applies to the connector's post tools as well. Tell the agent to create one key per post and reuse it when it retries. The full set of rules for unattended agents is in how to let an AI agent post to social media safely, and /features/agents shows the setup.

Check what actually happened

GET /{workspaceUuid}/activity lists every API write in the workspace for 90 days with its outcome. A replayed request shows as replayed and a refused copy as blocked_duplicate, so after a rough night you can count how many retries the key absorbed. Label each workflow with an X-PostBoost-Client header (as in the curl above) and filter the log by client. The full rules are in the guardrails docs, and the ready-made workflows are on /features/automations and in the automation recipes.

If a post did go out twice anyway, the cause is usually upstream of the API: two different keys for one item, or a key generated inside the retrying step. Check the two requests in the activity log; different keys for the same source row point straight at the fix.

Do this in PostBoost

Free tools for this guide

FAQ

Why does my automation post the same thing twice?

Usually because a request timed out after the server had already created the post, and a retry sent it again. n8n's Retry On Fail, Zapier's Autoreplay and Make's automatic retries all resend a step that looked failed. A trigger that fires twice or two runs of a scheduled job that overlap do the same.

What is an idempotency key?

A unique value the client sends with a POST so the server can recognise a retry of the same request. The first request runs; a repeat with the same key gets the first response back and changes nothing. The IETF draft for the Idempotency-Key header recommends a UUID or similar random value.

Should the idempotency key be a new UUID each time?

A new one per post, but the same one on every retry of that post. In an automation the safest key comes from the source item, such as the spreadsheet row, the Airtable record id or the RSS item guid, because a re-run of the whole workflow then produces the same key again.

How long does PostBoost remember an idempotency key?

24 hours. Within that time the same key with the same body returns the stored response with the header Idempotent-Replayed: true. The same key with a different body is refused with 422, and a repeat while the first call is still running gets 409 with Retry-After: 1. Responses with a 5xx or 429 status are not stored, so a retry after one runs again.

What does PostBoost do if the same post is sent without a key?

The duplicate guard refuses it with 409 and code duplicate_post when the text, media and link for an account match a post created for that account in the last 24 hours. Case, spacing and media order are ignored. Send allow_duplicate: true only when you really want the repeat.

Does the duplicate guard catch everything?

No. It compares content, so a caption an AI step rewrote on the re-run, or an image uploaded again under a new media id, counts as new content. That is why the idempotency key matters: it identifies the request, not the text.

Sources

Related guides

Try PostBoost free

API, webhooks and MCP on every plan, including Free. No credit card required.