Add & Remove List Contacts
Add contacts to a list, or remove them from it. A contact can belong to several lists at once.
To read the members of a list, use GET /contacts?list_id=:id — there is no list-scoped read endpoint.
Add Contacts to List
Add one or more contacts to a list. Contacts already in the list are skipped.
Endpoint
POST /lists/: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 list ID |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_ids | string[] | Yes | Array of contact IDs to add. Min: 1. |
Response
{
"message": "Contacts added to list",
"processed": 3,
"skipped": 1
}
| Field | Type | Description |
|---|---|---|
processed | number | Number of contacts newly added to the list |
skipped | number | Number of contacts that were already in the list (skipped) |
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X POST "https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts" \
-H "Authorization: Bearer $ARSEL_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 response = await fetch("https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
contact_ids: [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d",
],
}),
});
const data = await response.json();
if (!response.ok) {
throw new Error(`${data.name}: ${data.message}`);
}
console.log(data);
import os
import requests
response = requests.post(
"https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts",
headers={"Authorization": f"Bearer {os.environ['ARSEL_API_KEY']}"},
json={
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d",
],
},
)
response.raise_for_status()
print(response.json())
using System.Net.Http.Headers;
using System.Text;
var client = new HttpClient(); // share one instance across requests
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ARSEL_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts")
{
Content = new StringContent(
"""
{
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d"
]
}
""",
Encoding.UTF8,
"application/json"),
};
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"{(int)response.StatusCode}: {body}");
Console.WriteLine(body);
<?php
$ch = curl_init("https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ARSEL_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"contact_ids" => [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6d",
],
]),
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) {
throw new Exception("{$data['name']}: {$data['message']}");
}
print_r($data);
Remove Contacts from List
Remove one or more contacts from a list. The contacts themselves are not deleted — only the list association is removed.
Endpoint
DELETE /lists/:id/contacts
Returns: 200 OK
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_ids | string[] | Yes | Array of contact IDs to remove. Min: 1. |
Response
{
"message": "Contacts removed from list",
"processed": 2,
"skipped": 0
}
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X DELETE "https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts" \
-H "Authorization: Bearer $ARSEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c"
]
}'
const response = await fetch("https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
contact_ids: [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
],
}),
});
const data = await response.json();
if (!response.ok) {
throw new Error(`${data.name}: ${data.message}`);
}
console.log(data);
import os
import requests
response = requests.delete(
"https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts",
headers={"Authorization": f"Bearer {os.environ['ARSEL_API_KEY']}"},
json={
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
],
},
)
response.raise_for_status()
print(response.json())
using System.Net.Http.Headers;
using System.Text;
var client = new HttpClient(); // share one instance across requests
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ARSEL_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Delete, "https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts")
{
Content = new StringContent(
"""
{
"contact_ids": [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c"
]
}
""",
Encoding.UTF8,
"application/json"),
};
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"{(int)response.StatusCode}: {body}");
Console.WriteLine(body);
<?php
$ch = curl_init("https://api.arsel.sa/v1/lists/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/contacts");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ARSEL_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"contact_ids" => [
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6b",
"01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6c",
],
]),
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) {
throw new Exception("{$data['name']}: {$data['message']}");
}
print_r($data);
Error Responses
- 401 Unauthorized
{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid API Key"
}