Tag contacts

SDK platic.clients.tag()

Add or remove tags on up to 500 contacts per call. Identify them by ID or phone number in clientIds, or use the searchId of a search.

Example

const result = await platic.clients.tag({ tags: ["spring_sale"], searchId: "search_123" });
console.log(result.updatedCount, result.notFound);

Tags must exist in the workspace (create a tag). To remove them, send "operation": "remove". If the contact does not have the tag, nothing changes.

Request body

FieldTypeRequiredDescription
operationstring—add (default) or remove
tagsstring[]✓The tag names, from 1 to 20
clientIdsstring[]one of the twoContact ids or phone numbers, up to 500
searchIdstringone of the twoThe searchId of a search: it applies to all its results
topNnumber—With searchId, only the first N results

You can send clientIds and searchId together; between the two they cannot exceed 500 contacts.

Response

{
  "status": "success",
  "data": {
    "operation": "add",
    "tags": ["spring_sale"],
    "updatedCount": 310,
    "unchangedCount": 2,
    "notFound": []
  }
}
FieldDescription
updatedCountContacts that changed
unchangedCountContacts that were already as you asked. Repeating the call changes nothing
notFoundThe ids or phone numbers that belong to no contact

Each contact that changes sends client.tags.updated with source api.clients.tagged or api.clients.untagged.

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTA field is not valid: operation, tags, clientIds, searchId or topN. If you send neither clientIds nor searchId, details.issues points at clientIds; topN without searchId points at topN
400INVALID_REQUESTThe credential covers several workspaces and ?workspace= is missing, or the supplied workspace is not authorized. details.available lists the available ones and details.requested shows the one you sent
400TAG_NOT_FOUNDWhen adding, a tag does not exist. details.invalidTags says which
400TOO_MANY_CLIENTSMore than 500 contacts. Use topN or split the list
400NO_CLIENTSThe search returned no contacts
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENThe credential does not have the Contacts module (Missing contacts permission), or the user's role is read-only
403INSUFFICIENT_SCOPEAn OAuth token without the platica:write scope tried to write. details.requiredScope says which one is missing
404SEARCH_NOT_FOUNDThe searchId does not exist
410SEARCH_EXPIREDThe searchId expired: search again
4xxUPSTREAM_REFUSEDPlatica refused the operation. The status is the one it answered and details.message carries its text
502UPSTREAM_ERRORPlatica failed to complete the operation. Try again

The general error format is in Errors.