Add contacts to the audience
SDK platic.campaigns.audience.add()
Add contacts to a campaign audience using one source:
clients: phone number and name. Contacts that do not exist in the workspace are created.searchId: all results of a contact search.tag: all contacts with that tag.clientIds: a list of ids.
Example
curl https://api.platic.ai/v1/campaigns/$CAMPAIGN_ID/audience \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"clients": [{ "phoneNumber": "5215512345678", "name": "Ana López" }]
}' await platic.campaigns.audience.add("campaign_123", [{ phoneNumber: "5215512345678", name: "Ana López" }]); Path parameters
| Parameter | Type | Description | Requirement |
|---|---|---|---|
campaignId | string | Unique identifier of the campaign | required |
Request body
{
"clients": [
{ "phoneNumber": "521234567890", "name": "John Smith" },
{ "phoneNumber": "521234567891", "name": "Maria Garcia" }
]
} From a search, a tag, or ids
{ "searchId": "srch_4f9a2c", "dryRun": true } With dryRun: true, it counts how many contacts would be added without changing the audience.
Body parameters
Send exactly one source: clients, searchId, tag, or clientIds.
| Parameter | Type | Description | Requirement |
|---|---|---|---|
clients | array | List of contacts to add by phone. At least 1 item | one source |
searchId | string | The searchId from search contacts: adds all its results, not just the page you saw. It lasts 12 hours | one source |
topN | number | With searchId, only the first N results | optional |
tag | string | Adds all the contacts with that tag | one source |
clientIds | string[] | Contact ids from the workspace, up to 5,000 | one source |
dryRun | boolean | true to only count how many would come in. It does not apply to clients | optional |
clients[] object
| Parameter | Type | Description | Requirement |
|---|---|---|---|
phoneNumber | string | Phone number in international format | required |
name | string | Name of the contact | required |
Response
{
"status": "success",
"message": "2 client(s) added to campaign (1 created, 1 updated)",
"data": {
"addedCount": 2,
"createdCount": 1,
"updatedCount": 1,
"clients": [
{ "phoneNumber": "521234567890", "name": "John Smith" },
{ "phoneNumber": "521234567891", "name": "Maria Garcia" }
]
}
} Response fields
| Field | Type | Description |
|---|---|---|
addedCount | number | Total contacts processed |
createdCount | number | New contacts created in the workspace |
updatedCount | number | Existing contacts updated with the campaign's tag |
clients | array | List of contacts sent in the request |
Response with a source
{
"status": "success",
"message": "312 contacts were added to the audience",
"data": {
"source": "search",
"dryRun": false,
"message": "312 contacts were added to the audience",
"added": 312,
"skipped": 4
}
} source identifies the source: search, tag, or client_ids. Platica can include the added, created, updated, and skipped counts when it reports them.
With dryRun, preview shows how many contacts would be added and errors includes up to 10 problems.
A missing searchId returns 404 SEARCH_NOT_FOUND. An expired one returns 410 SEARCH_EXPIRED. Run a new search in either case.
Notes
- If the contact already exists (same
phoneNumber), its name is updated and the campaign's tag is added. - If the contact does not exist, a minimal record is created with
phoneNumber,name,tags,owners,customFields,creationDate, andlastUpdate. - The tag assigned to the contacts has the format
campaign-{campaignId}.