Tag Contacts
Apply or remove tags from contacts. A contact can have multiple tags.
Apply Tag to Contacts
Apply a tag to one or more contacts. Contacts that already have the tag are skipped.
Endpoint
POST /tags/:id/contacts
Returns: 200 OK
Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer <your-api-key> | Yes |
Content-Type | application/json | Yes |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The tag ID |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_ids | string[] | Yes | Array of contact IDs to tag. Min: 1. |
Response
{
"message": "Contacts added to tag",
"processed": 3,
"skipped": 1
}
| Field | Type | Description |
|---|---|---|
processed | number | Number of contacts newly tagged |
skipped | number | Number of contacts that already had the tag (skipped) |
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X POST "https://api.arsel.sa/v1/tags/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts" \
-H "Authorization: Bearer be_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d"
]
}'
const tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
const response = await fetch(
`https://api.arsel.sa/v1/tags/${tagId}/contacts`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer be_your_api_key",
},
body: JSON.stringify({
contact_ids: [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d",
],
}),
}
);
const result = await response.json();
console.log(`Tagged: ${result.processed}, Already tagged: ${result.skipped}`);
import requests
tag_id = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a"
response = requests.post(
f"https://api.arsel.sa/v1/tags/{tag_id}/contacts",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer be_your_api_key",
},
json={
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d",
],
},
)
result = response.json()
print(f"Tagged: {result['processed']}, Already tagged: {result['skipped']}")
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer be_your_api_key");
var tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
var payload = new
{
contact_ids = new[]
{
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d"
}
};
var json = System.Text.Json.JsonSerializer.Serialize(payload);
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
var response = await client.PostAsync($"https://api.arsel.sa/v1/tags/{tagId}/contacts", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
$ch = curl_init("https://api.arsel.sa/v1/tags/{$tagId}/contacts");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer be_your_api_key"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"contact_ids" => [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d"
]
]));
$response = curl_exec($ch);
echo $response;
curl_close($ch);
Remove Tag from Contacts
Remove a tag from one or more contacts. The contacts themselves are not deleted.
Endpoint
DELETE /tags/:id/contacts
Returns: 200 OK
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_ids | string[] | Yes | Array of contact IDs to untag. Min: 1. |
Response
{
"message": "Contacts removed from tag",
"processed": 2,
"skipped": 0
}
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X DELETE "https://api.arsel.sa/v1/tags/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts" \
-H "Authorization: Bearer be_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c"
]
}'
const tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
const response = await fetch(
`https://api.arsel.sa/v1/tags/${tagId}/contacts`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer be_your_api_key",
},
body: JSON.stringify({
contact_ids: [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
],
}),
}
);
console.log(await response.json());
import requests
tag_id = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a"
response = requests.delete(
f"https://api.arsel.sa/v1/tags/{tag_id}/contacts",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer be_your_api_key",
},
json={
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
],
},
)
print(response.json())
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer be_your_api_key");
var tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
var payload = new
{
contact_ids = new[]
{
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c"
}
};
var json = System.Text.Json.JsonSerializer.Serialize(payload);
var request = new HttpRequestMessage(HttpMethod.Delete, $"https://api.arsel.sa/v1/tags/{tagId}/contacts")
{
Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
};
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$tagId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
$ch = curl_init("https://api.arsel.sa/v1/tags/{$tagId}/contacts");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer be_your_api_key"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"contact_ids" => [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c"
]
]));
$response = curl_exec($ch);
echo $response;
curl_close($ch);