Skip to content

Idempotency

After this page you can retry any write without doing it twice, and rehearse it first.

Every write needs one string unique to one intent, for example launch-spring-1. Send it as the idempotencyKey argument or the Idempotency-Key header (1 to 128 characters of A-Za-z0-9._:-).

curl https://countviews.com/api/public/v1/call \
-H "Authorization: Bearer $COUNTVIEWS_KEY" \
-H "Idempotency-Key: save-spring-2026-1" \
-d '{"name":"campaign_draft_save","arguments":{"externalRef":"spring-2026","title":"Spring launch", ...}}'
You send You get
a new key the write is done
the same key and the same body the first answer again: replayed: true in the body and the header Idempotent-Replayed. Nothing is done twice
the same key, a different body 409 idempotency_conflict. Use a new key for a new intent
the same key while the first call still runs 409 idempotency_in_flight. Wait a second and repeat the identical call
no key on a write 422 idempotency_key_required
header and argument that differ 422 idempotency_key_mismatch

Retrying after a timeout? The same key. A new intent? A new key.

"dryRun": true or the header Prefer: dry-run runs every check and keeps nothing: no draft, no log entry, no event. It needs no key. Send it once, or the same in both places (otherwise dry_run_mismatch).

{ "name": "campaign_activate", "arguments": { "quoteId": "<quoteId>", "dryRun": true } }

Use it before campaign_activate, campaign_budget_add and campaign_end. Rehearsing a quote or a launch still counts against the hourly spending budget. An invoice on a card or crypto rail cannot be rehearsed: dry_run_unsupported.

Three tools do nothing irreversible unless you send confirm: true. Without it they answer with a preview (confirmed: false) and touch nothing.

Tool Preview shows
campaign_end what ending would return and what stays reserved
company_set the legal details that would be recorded (permanent once accepted)
sandbox_reset what a reset would remove

Show the preview to the person; send confirm: true only on their yes.

409 conflict_retry: another request touched the same thing at the same moment and this one was rolled back whole. Wait one second (Retry-After) and send the identical call with the same key.