curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}
Snapchat Ads
Audience Members
Add people to, or remove them from, a Snapchat customer-list segment by sending SHA-256 hashes of their email, phone or mobile ad id.
POST
/
ads
/
snapchat
/
audiences
/
{id}
/
users
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}
Add people to a customer-list segment created with Create Audience (
type: customerList), or remove them. You send each person as a SHA-256 hash of one normalized identifier; Snapchat matches the hashes to accounts; the raw values never leave your system.
DELETE /ads/snapchat/audiences/{id}/users takes the same body and removes the people instead.
- One identifier per request: send emails, phones and mobile ad ids in separate requests.
- Each request carries at most 10,000 rows and a body of at most 10 MiB. Send a larger list as several requests.
- A segment is usable in a boost once Snapchat has matched enough people. Audiences shows
status.readywhen it is. - The id must be a customer-list segment on the ad account named by
accountId. Any other id, including a deleted or unknown one, returns a400withcode: 101, and nothing is sent.
Hashed identifiers are personal data
A hashed email or phone number is still personal data under GDPR and similar laws. When you upload a list:- You are the data controller. You need a lawful basis, usually the consent of the people on the list, to use their data for advertising, as your privacy policy and Snapchat’s advertising terms require.
- Ayrshare is a processor. We pass the hashes to Snapchat and keep nothing but the counts: no row of the body is logged, cached or stored, and the response never echoes a row.
- You hash before sending. Ayrshare never hashes for you. A value that is not a hash is refused before anything is sent to Snapchat.
How to hash
Normalize each value the way Snapchat’s customer list rules describe, then hash it with SHA-256 and send the result as 64 lowercase hex characters. In short:EMAIL: trim spaces and lowercase, for examplejane@example.com.PHONE: digits only, with the country code, without a leading00or the national leading0, for example14155551234or448444124653.MADID: the mobile ad id (IDFA or Android advertising id) in lowercase, keeping the hyphens.
Header Parameters
Path Parameters
The customer-list segment id, from Create Audience or Audiences.
Body Parameters
The one identifier the rows hold:
["EMAIL"], ["PHONE"] or ["MADID"]. These are the same names Facebook and Instagram take.One row per person: an array with the person’s SHA-256 hash, as 64 lowercase hex characters. At most 10,000 rows.A cell that is not such a hash, a row of the wrong width, an unsupported key or more than one key returns a
400 with code: 101 before anything is sent to Snapchat. The message names the row and column, never the value, for example data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.Response
Counts only:received: rows Snapchat took.invalid: rows Snapchat did not take.batches: how many uploads the rows were sent in.
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}