Bulk actions

SDK platic.conversations.bulk()

Run one action on a list of up to 100 conversations: assignees, tags, pause, finish or archive. Each conversation is handled on its own, with the same rules as the single action, and gets its own result. One that fails does not stop or undo the others.

Take the IDs from List conversations or Search conversations, review them, and send them here. A search or a filter is never turned into a write by itself.

Example

const { data, meta } = await platic.conversations.bulk({
  action: "tags",
  conversationIds: ["8Yc2kQ1mZ0rTq4Lp7WvX", "Q3m9Zt2Lw8Rk1Vb6Hc0P", "Jd4Xn7Kp2Ys9Ta5Fq1Ue"],
  input: { mode: "patch", add: ["vip"] },
});

for (const result of data.results) {
  if (!result.ok) console.warn(result.id, result.error.code);
}

The SDK sends an Idempotency-Key on every call and reuses it when it retries, so a retry never acts twice on any conversation.

Actions

actionWhat it does to each conversationinput
tagsLike Tag a conversationmode: "replace" with tags, or mode: "patch" with add and remove
assigneesLike Assign a conversation, including the notification to the members addedmode: "replace" with assigneeIds and optional assignedToTeam, or mode: "patch" with add, remove and optional assignedToTeam
pauseLike Pause the agentNone
finishLike Finish a conversationNone
archiveLike Archive a conversationNone

Webhooks and notifications go out for each conversation that changes, as with the single action. Resume, reopen, spam, the agent and the topic are not available in bulk.

Headers

HeaderDescriptionRequired
Idempotency-KeyMakes the whole call safe to retry: a repeat with the same key and body returns the same results (meta.replayed: true) without acting again on any conversation. 1 to 255 visible ASCII characters; a UUID works. See Retries—

Bulk calls do not take If-Resource-Version: sending it returns 400 INVALID_REQUEST.

Query parameters

ParameterTypeDescription
workspacestringThe workspace, for an API key that covers several. Other credentials always act on their own workspace

Request body

FieldTypeRequiredDescription
actionstring✓assignees, tags, pause, finish or archive
conversationIdsstring[]✓1 to 100 conversation IDs, without repeats
inputobject—What the action takes. Required for tags and assignees; leave it out (or send {}) for pause, finish and archive

input for tags

FieldTypeRequiredDescription
modestring✓replace: each conversation ends with exactly tags. patch: add and remove
tagsstring[]With replaceThe tags each conversation ends with, up to 20
addstring[]—With patch: tags to add, up to 20
removestring[]—With patch: tags to remove, up to 20

input for assignees

FieldTypeRequiredDescription
modestring✓replace: each conversation ends with exactly assigneeIds. patch: add and remove
assigneeIdsstring[]With replaceThe members each conversation ends with, by member ID or email, up to 50
addstring[]—With patch: members to assign, by member ID or email, up to 50
removestring[]—With patch: members to unassign, by member ID or email, up to 50
assignedToTeamboolean—true assigns the whole team; false unassigns it. Left out, it does not change

Emails are checked once for the whole call: an email that is not a member of the workspace returns 422 INVALID_ASSIGNEE and nothing runs.

{
  "action": "assignees",
  "conversationIds": ["8Yc2kQ1mZ0rTq4Lp7WvX", "Q3m9Zt2Lw8Rk1Vb6Hc0P"],
  "input": { "mode": "patch", "add": ["luis@acme.com"] }
}
{
  "action": "archive",
  "conversationIds": ["8Yc2kQ1mZ0rTq4Lp7WvX", "Q3m9Zt2Lw8Rk1Vb6Hc0P"]
}

Response

The answer is 200 with one result per ID, in the order you sent them, even when some failed. It does not return the conversations: read them with Get a conversation if you need them.

{
  "status": "success",
  "data": {
    "results": [
      {
        "id": "8Yc2kQ1mZ0rTq4Lp7WvX",
        "ok": true,
        "changed": true,
        "effects": { "interrupted": false, "reusable": false, "memoryCycleClosed": true }
      },
      {
        "id": "Q3m9Zt2Lw8Rk1Vb6Hc0P",
        "ok": false,
        "error": {
          "code": "CASE_OPEN",
          "message": "The conversation has an open case. Close or decline it before archiving the conversation."
        }
      }
    ]
  },
  "meta": {
    "requestId": "req_7f3d",
    "action": "archive",
    "replayed": false
  }
}
FieldDescription
data.results[].idThe conversation ID, as you sent it
data.results[].oktrue if the action worked on this conversation
data.results[].changedWith ok: true. false when the conversation already had that result: nothing was written and no one was notified
data.results[].effectsWith ok: true. What else happened, with the same keys as the single action
data.results[].error.codeWith ok: false. The same codes as the single action, for example CONVERSATION_NOT_FOUND, FORBIDDEN, CASE_OPEN, CONVERSATION_ARCHIVED, STATUS_TRANSITION_NOT_ALLOWED, UNKNOWN_TAG, TOO_MANY_TAGS, INVALID_ASSIGNEE or TOO_MANY_ASSIGNEES. ACTION_FAILED when that conversation failed for another reason: retry it
data.results[].error.messageWhat happened, in words
meta.actionThe action you sent
meta.replayedtrue when this is the stored outcome of an earlier call with the same Idempotency-Key. Nothing ran again
meta.requestIdID of the request, for support

To retry only the conversations that failed, send a new call with their IDs and a new Idempotency-Key.

Retries

One Idempotency-Key covers the whole call.

  • Same key, same body: you get the same results with meta.replayed: true. No conversation is changed again and no one is notified again.
  • Same key, different body (another action, other IDs or another input): 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.

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

Errors

These errors refuse the whole call. Errors for one conversation come inside its result, with 200.

Statusdetails.codeWhen it happens
400INVALID_REQUESTThe body is not valid: an unknown action, no IDs, more than 100 IDs, repeated IDs, an input that does not fit the action, or 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
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENThe credential cannot change conversations
403INSUFFICIENT_SCOPEAn OAuth token without the platica:write scope. details.requiredScope says which one is missing
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
422INVALID_ASSIGNEEWith assignees: an email is not a member of the workspace. details.invalidAssigneeIds lists them. Nothing ran
503ACTION_FAILEDThe outcome could not be confirmed (details.retryable: true). Repeat with the same Idempotency-Key: a conversation that already changed answers changed: false and is not changed twice

The general error format is in Errors.