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
curl -X POST https://api.platic.ai/v1/clients/tags \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "tags": ["spring_sale"], "searchId": "'"$SEARCH_ID"'" }' const result = await platic.clients.tag({ tags: ["spring_sale"], searchId: "search_123" });
console.log(result.updatedCount, result.notFound); Tag the VIP customers in Mexico City with spring_sale.
Your assistant searches with search_clients and tags with tag_clients.
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
| Field | Type | Required | Description |
|---|---|---|---|
operation | string | — | add (default) or remove |
tags | string[] | ✓ | The tag names, from 1 to 20 |
clientIds | string[] | one of the two | Contact ids or phone numbers, up to 500 |
searchId | string | one of the two | The searchId of a search: it applies to all its results |
topN | number | — | 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": []
}
} | Field | Description |
|---|---|
updatedCount | Contacts that changed |
unchangedCount | Contacts that were already as you asked. Repeating the call changes nothing |
notFound | The 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
| Status | details.code | When it happens |
|---|---|---|
400 | INVALID_REQUEST | A 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 |
400 | INVALID_REQUEST | The 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 |
400 | TAG_NOT_FOUND | When adding, a tag does not exist. details.invalidTags says which |
400 | TOO_MANY_CLIENTS | More than 500 contacts. Use topN or split the list |
400 | NO_CLIENTS | The search returned no contacts |
401 | UNAUTHENTICATED | The credential is missing or invalid |
403 | FORBIDDEN | The credential does not have the Contacts module (Missing contacts permission), or the user's role is read-only |
403 | INSUFFICIENT_SCOPE | An OAuth token without the platica:write scope tried to write. details.requiredScope says which one is missing |
404 | SEARCH_NOT_FOUND | The searchId does not exist |
410 | SEARCH_EXPIRED | The searchId expired: search again |
4xx | UPSTREAM_REFUSED | Platica refused the operation. The status is the one it answered and details.message carries its text |
502 | UPSTREAM_ERROR | Platica failed to complete the operation. Try again |
The general error format is in Errors.