# Idempotency

Source: https://ampost.io/docs/idempotency · Full reference: https://ampost.io/llms-full.txt

## Idempotency

`POST /api/posts` (`posts_create`), `POST /api/posts/bulk` (`posts_import_csv`), `POST /api/posts/{postId}/publish` (`posts_publish`), `POST /api/posts/{postId}/retry` (`posts_retry`), `POST /api/posts/{postId}/approve` (`posts_approve`), `POST /api/accounts/connect` (`accounts_connect`), `POST /api/platform-sets` (`platform_sets_create`), `POST /api/webhooks/endpoints` (`webhooks_create`) and `POST /api/feedback` (`feedback_submit`) accept an idempotency key: the `Idempotency-Key` header on REST, the `idempotencyKey` argument on MCP. Send a new key (a UUID) with every create, publish, retry and connect, and send the same key again when you retry that call after a timeout or network error. Without a key, a retried `posts_create` with `publishNow: true` creates and publishes a second post.

- A retry with the same key and the same request within 24 hours returns the first response (same status and body) without running again; REST adds `Idempotent-Replayed: true`.
- The same key with a different request (other operation, path or body): 409 `IDEMPOTENCY_KEY_REUSED`. Use a new key for a new action.
- The same key while the first request is still running: 409 `IDEMPOTENCY_REQUEST_IN_PROGRESS`. Wait a few seconds and retry with the same key.
- Only successes are kept. After an error (for example `VALIDATION_FAILED` or `RATE_LIMITED`) the key is free again, so fix the request and retry with the same key.
- Keys belong to the Ampost user, so all of the user's API keys share them. A key is 1-255 visible ASCII characters.
