Skip to content
cleo.Developers
Build reliably/Idempotency & retries
Cleo documentation

Idempotency & retries

Recover from an interrupted request without accidentally placing a second call.

Content reviewed · Maintained by Cleo Powered · Report a documentation issue · Verification basis

One key per intended call

Every create request requires an Idempotency-Key header. Generate it once and save it with the complete request before making the network call.

HTTP headers
Authorization: Bearer <API_KEY>\nIdempotency-Key: 2dc65313-6bd6-41e8-b63e-6d932f1da807\nContent-Type: application/json

The UUID above is illustrative. Generate your own value for each new call. Unlike the secret API key, it is a request identifier and does not grant access. Save the API origin, complete payload, idempotency key, and returned call ID together.

The key is scoped to your Agent Project. Sending the same request with the same key returns the original call. Creating a new key represents a new intended call.

Replaying an existing failed or cancelled call returns that same record; it does not restart it. Replays still require valid authentication and current access permissions.

Recover an uncertain request

A timeout, disconnected connection, or server error can occur after a call was created. A missing response is not proof that nothing happened.

  1. Keep the original request payload and idempotency key.
  2. If you received a call ID, use it to sync the existing call.
  3. If no ID was returned, replay the identical create request with the same key, API origin, and Agent Project.
  4. Use the returned call ID to continue following that call.

A replacement API key in the same project can recover the call. A key from a different project cannot reuse that project’s idempotency history.

For cURL, restore the original key before running the same create command:

Bash
export IDEMPOTENCY_KEY="PASTE_THE_ORIGINAL_IDEMPOTENCY_KEY"

For the Python snippet, paste that key when prompted instead of pressing Enter. For the downloaded self-call script, supply --idempotency-key YOUR_ORIGINAL_KEY with the same phone number and base URL. Do not switch between the script’s task and the JSON-file task when recovering; their payloads differ.

Handle conflicts

409 idempotency_conflict means the key was already used with different call details. Restore the original payload to recover the existing call. Use a new key only when you intentionally want another call.

Task text, destination, context, protected_context, constraints, success criteria, result schema, and duration are all part of the frozen request. Keep them unchanged for recovery.

Documentation
Get an API key

Explore the docs

IntroductionSubmit a phone errand, follow the call, and inspect its outcome.Bot account onboardingRegister from Muse or another bot, verify your phone, receive an API key, and set your dashboard password by email.API overviewWhich endpoints are available, how they authenticate, and what is supported today.Make your first callCall your own phone, refresh its status, and inspect the returned call data.AuthenticationCreate a key in Cleo and authenticate requests with a bearer token.Create a callQueue one bounded phone task and receive durable task and call IDs.Get a callRead the most recently saved state of a call.Sync a callRefresh a call from the calling service and retrieve its latest saved state.Cancel a callCancel queued work or request a stop, then follow confirmation.The call objectThe shared response returned by create, get, sync, and cancel.Health checksCheck API liveness and readiness without an API key or placing a call.Results & schemasUnderstand result_schema, returned metadata, and what result_schema_valid does and does not establish.Task and call lifecycleFollow a call from acceptance to its final outcome.Idempotency & retriesRecover from an interrupted request without accidentally placing a second call.Safety & permissionsHow Cleo evaluates a call task before it can dial.Errors & troubleshootingUnderstand API errors and choose a safe next step.LimitsKeep call tasks bounded and leave room for API rate limits.Verification & limitationsReproduce our public health and schema checks and understand what has not been tested.Bot integrationsChoose a route for connecting your assistant to Cleo's public API.ChatGPTConfigure a private GPT Action with Cleo OpenAPI and bearer authentication.ClaudeConnect Claude client tools or a Claude Code shell workflow.Grok & Grok BotConnect xAI function tools and check Grok Bot execution requirements.OpenClawInstall a local skill for an approved Cleo calling workflow.GeminiMap Gemini function declarations to Cleo REST operations.Copilot StudioAdd Cleo through a REST API tool, custom connector, or flow.n8nBuild an authenticated HTTP workflow with durable call recovery.ZapierBuild a private Zapier integration for approved Cleo calls.