Archive a conversation

SDK platic.conversations.archive()

Close the conversation: the agent stops, its memory of this conversation is closed once, and status becomes archived. The history stays readable. A conversation with an open case cannot be archived until the case is closed or declined.

Example

import { ConflictError } from "platic-sdk";

try {
  const { meta } = await platic.conversations.archive("8Yc2kQ1mZ0rTq4Lp7WvX");
  console.log(meta.changed, meta.effects.memoryCycleClosed);
} catch (error) {
  if (error instanceof ConflictError && error.code === "CASE_OPEN") {
    console.log("Close or decline the open cases first");
  } else throw error;
}

The SDK sends an Idempotency-Key on every action and reuses it when it retries.

What happens

  • status becomes archived. An initiated, active or finished conversation can be archived.
  • If the agent was writing a reply, it stops. meta.effects.interrupted says so. No message is sent to the contact.
  • The agent's memory of this conversation is closed once. If the agent has memory turned on, Platica summarizes the conversation. meta.effects.memoryCycleClosed is true when this call closed it.
  • The history stays readable with Get a conversation and List messages.
  • meta.effects.reusable says whether the channel reuses this thread. When it is true (team chats, chats created through the API, connected Gmail or Outlook mailboxes), you can reopen it later. On other channels, such as WhatsApp, Instagram or Messenger, the contact's next message opens a new conversation.

If the conversation was already archived, the answer has meta.changed: false: nothing is written and no webhook is sent.

Path parameters

ParameterTypeDescriptionRequired
conversationIdstringThe conversation's id. See How IDs work✓

Headers

HeaderDescriptionRequired
Idempotency-KeyMakes the call safe to retry. 1 to 255 visible ASCII characters; a UUID works. See Retries—

This action does not take If-Resource-Version: sending it returns 400 INVALID_REQUEST.

Query parameters

ParameterTypeDescription
fieldsstringFields of the conversation to return, comma-separated. Replaces the defaults; id is always returned. The fields are the same as in Get a conversation
includestringRelations to resolve in included: agents, channels, assignees
workspacestringThe workspace, for an API key that covers several. Other credentials always act on their own workspace

Request body

No body. Send nothing or {}; any field returns 400 INVALID_REQUEST.

Response

The answer is the conversation after the change, read with fields and include as in Get a conversation, and a meta that says what the action did. This example used ?fields=id,status.

{
  "status": "success",
  "data": {
    "id": "8Yc2kQ1mZ0rTq4Lp7WvX",
    "status": "archived"
  },
  "meta": {
    "fields": ["id", "status"],
    "include": [],
    "requestId": "req_7f3c",
    "resourceVersion": "MTc2NDYxMjAwMC4xMjM0NTY3ODk",
    "action": "archive",
    "changed": true,
    "effects": {
      "interrupted": false,
      "reusable": false,
      "memoryCycleClosed": true
    },
    "replayed": false
  }
}
FieldDescription
dataThe conversation as it is now, with the selected fields
includedRelated records, only when you sent include
meta.actionAlways archive
meta.changedfalse when the conversation was already archived: nothing was written and no webhook was sent
meta.effects.interruptedtrue when the agent was writing a reply and was asked to stop
meta.effects.reusabletrue when the channel reuses this thread, so the conversation can be reopened
meta.effects.memoryCycleClosedtrue when this call closed the agent's memory of the conversation; false when it was already closed
meta.resourceVersionThe conversation's version after the change
meta.replayedtrue when this is the stored outcome of an earlier call with the same Idempotency-Key. Nothing ran again; data and resourceVersion show the conversation as it is now
meta.fields · meta.includeFields and relations applied
meta.requestIdID of the request, for support
meta.warningsOnly when there is something to report. CONVERSATION_NOT_READABLE: the action was applied, but your credential can no longer read the conversation, so data has only id

Retries

Send an Idempotency-Key so a retry after a lost answer is safe. A key belongs to one credential, one action and one conversation.

  • Same key, same body: you get the first outcome with meta.replayed: true. Nothing runs again. fields and include may change: they only choose what the answer shows.
  • Same key, different body: 409 IDEMPOTENCY_KEY_REUSED.
  • First call still running: 409 IDEMPOTENCY_IN_PROGRESS. Retry in a few seconds with the same key.
  • Lifetime: keys are kept for one day. A call that fails does not keep its key, so retrying it runs the action again.

Your access is checked again on every retry. More in Idempotency.

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTThe body, a query parameter or a header is not valid, including If-Resource-Version. details.issues says which
400INVALID_REQUESTThe workspace in ?workspace= is not covered by the credential. details.available lists the ones it covers
400INVALID_FIELDA name in fields does not exist. details.allowed lists the accepted ones
400INVALID_INCLUDEA name in include does not exist. details.allowed lists the accepted ones
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENThe credential cannot change conversations, or your role can read this conversation but not change it
403INSUFFICIENT_SCOPEAn OAuth token without the platica:write scope. details.requiredScope says which one is missing
404CONVERSATION_NOT_FOUNDNo conversation has that id in the workspace, or it is out of your credential's reach
409CASE_OPENThe conversation has open cases. details.caseIds lists them. Close or decline them first
409CONVERSATION_CHANGEDThe conversation changed while it was being archived. Try again
409CONVERSATION_BUSYThe conversation is busy with another change. Try again in a few seconds
409IDEMPOTENCY_KEY_REUSEDThe Idempotency-Key was already used with a different body
409IDEMPOTENCY_IN_PROGRESSThe first call with this Idempotency-Key is still running. Retry shortly with the same key
503ACTION_FAILEDThe outcome could not be confirmed (details.retryable: true). Repeat with the same Idempotency-Key: an action that already ran is not run again

The general error format is in Errors.

Notes

A call that archives the conversation sends conversation.status.updated and conversation.expired, with source: "api.conversation.v2", or "mcp.conversation.v2" when your assistant did it.

You can archive up to 100 conversations in one call with Bulk actions.