Idempotency Keys for Social Automation: Never Double-Post on a Timeout
A scheduled post fires. The request to publish it goes out. The network hangs. After 30 seconds, our client times out. We retry. The tweet publishes. Then the original request completes too — and a second, identical tweet goes out. That's a double-post. On a personal account it's embarrassing. On a client account at an agency it's a support ticket and a credibility hit. Either way, it's the single most visible failure mode in any posting system, and it's caused by one of the most common conditions in distributed systems: ambiguous outcomes under timeout. At HelperX , we ship scheduled posts, replies, and DMs across hundreds of accounts. Every one of those actions can time out, retry, and double-execute. This article is about how we prevent that with idempotency keys — the same pattern payment systems use to prevent double-charges, applied to social actions. The problem, precisely A timeout is ambiguous. When a publish request times out, the action is in one of three states: Never reached the server. The post didn't publish. Safe to retry. Reached the server, failed there. The post didn't publish. Safe to retry. Reached the server, succeeded, response lost. The post did publish. Retrying publishes it again. The client cannot distinguish states 1 and 2 from state 3. They all look identical: "I sent a request and didn't get a response." Naive retry logic treats all three the same and retries — which is correct for 1 and 2 but catastrophic for 3. This is the classic "exactly-once is impossible" problem. You can't guarantee an action executes exactly once over an unreliable network. But you can guarantee it takes effect exactly once, using idempotency. The idempotency key idea An idempotency key is a unique identifier the client generates before sending the request and includes with it. The server uses the key to recognize a retry and avoid re-executing: First request with key K → server executes, stores "K succeeded, result was R." Retry with same key K → server sees K