Idempotency
A request may have succeeded even if you did not receive the response. To retry without duplicating the change, send Idempotency-Key on the first request and keep that key for retries. This works on supported operations.
- Generate a key for the operation; a UUID meets the formats accepted by supported routes.
- If the connection drops, the request times out or you receive a
5xx, repeat it with the same key and the same content. - Use a new key for a different operation. Reusing it with different content returns
409.
GET requests can be repeated and do not need a key. See Errors to decide when to retry.
Example
The SDK generates the key and keeps it during its retries. With REST API, send it in the header:
curl https://api.platic.ai/v1/agents \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Idempotency-Key: 5f1c7a52-3d0e-4b8a-a6f4-2c5e8d1b7a90" \
-H "Content-Type: application/json" \
-d '{ "name": "Sales" }' // The SDK adds an Idempotency-Key to every change and reuses it on each retry
const agent = await platic.agents.create({ name: "Sales" }); Where it applies
| Operation | What the key does |
|---|---|
| Changes to agents (create, update, publish, copy, escalations…) | A repeat returns the stored result. A key reused with other content answers 409 with details.code: "IDEMPOTENCY_KEY_REUSED" |
| Install an agent template | The whole request becomes repeatable |
| Create a file | After a network cut, the same request returns the same fileId and uploadId without duplicating the file |
| Upload a file | On a repeat, the second response carries upload: null: the sessionUri address is delivered only once |
| Webhooks (create, update, test, delete) | Up to 60 characters from A-Z a-z 0-9 _ . : -. A key reused with another body answers 409 with details.code: "REQUEST_ID_CONFLICT" |
| Conversation actions (update, tags, assignees, pause, resume, wait, finish, archive, reopen, agent, spam and bulk) | 1 to 255 visible ASCII characters. A repeat answers the first outcome with meta.replayed: true and does not run the action again. A key reused with another body answers 409 IDEMPOTENCY_KEY_REUSED; while the first request is still running, 409 IDEMPOTENCY_IN_PROGRESS. Keys are kept for a day |
| Reply to a post | The key must be a UUID, or the answer is 400. A repeat doesn't publish twice. While the first is still publishing, the answer is 409 COMMENT_PUBLISH_IN_PROGRESS; if an earlier attempt couldn't be confirmed, 409 COMMENT_PUBLISH_RESULT_UNKNOWN: check the thread before retrying |
Conversation actions
Every action on a V2 conversation takes an optional Idempotency-Key. Send one on resume and bulk in particular: without it, a retry after a lost answer can make the agent reply twice, or run the action again on every conversation.
curl -X POST https://api.platic.ai/v2/conversations/$CONVERSATION_ID/resume \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Idempotency-Key: 9b2f4c1e-7a35-4d0b-8e6f-1c3a5b7d9e20" \
-H "Content-Type: application/json" \
-d '{ "instruction": "Offer the Monday 10:00 appointment." }' - The key is bound to the workspace, the credential, the action, the conversation and the body. A repeat with the same key and body answers the first outcome, with
meta.replayed: true; nothing is written, sent or notified again. fieldsandincludedon't count as part of the body: a repeat can ask for other fields.- An action whose result already holds (pausing a paused conversation) answers
meta.changed: falseeven without a key. - A
503 ACTION_FAILEDor503 CONTINUE_FAILEDhasdetails.retryable: true: repeat with the same key.
The SDK sends a key on every action and keeps it for its retries. MCP tools build it from the requestId argument.
Don't overwrite a newer change
Reads and actions return meta.resourceVersion, the conversation's version. Send it back in If-Resource-Version on update and when replacing the tags or the assignees (PUT). If the conversation changed since that version, the answer is 412 VERSION_MISMATCH with details.currentVersion, and nothing changes: read it again, decide again and repeat. Without the header, the last write wins. Adding or removing tags and assignees (PATCH) doesn't need it.
curl -X PUT https://api.platic.ai/v2/conversations/$CONVERSATION_ID/tags \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "If-Resource-Version: $RESOURCE_VERSION" \
-H "Content-Type: application/json" \
-d '{ "tags": ["vip", "billing"] }' const { data, meta } = await platic.conversations.get(conversationId, { fields: ["tags"] });
await platic.conversations.tags.set(
conversationId,
{ tags: [...(data.tags ?? []), "vip"] },
{ expectedVersion: meta.resourceVersion },
); In the SDK and in MCP tools the version goes in expectedVersion; a stale one throws PreconditionFailedError in the SDK. See SDK errors.
If you do not send a key, the API retries an agent change once when the service returns 503. It generates a key for that internal retry. This key does not protect a new request you make: send your own key from the first attempt.