cURL
curl --request POST \
--url https://letterby.com/api/v4/audiences \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"name": "<string>",
"listId": "<string>",
"filters": "{\"points\": {\"gte\": 100}, \"AND\": [{\"email\": {\"contains\": \"@gmail.com\"}}]}",
"mode": "manual"
}
'import requests
url = "https://letterby.com/api/v4/audiences"
payload = {
"name": "<string>",
"listId": "<string>",
"filters": "{\"points\": {\"gte\": 100}, \"AND\": [{\"email\": {\"contains\": \"@gmail.com\"}}]}",
"mode": "manual"
}
headers = {
"apiKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apiKey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
listId: '<string>',
filters: '{"points": {"gte": 100}, "AND": [{"email": {"contains": "@gmail.com"}}]}',
mode: 'manual'
})
};
fetch('https://letterby.com/api/v4/audiences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://letterby.com/api/v4/audiences",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'listId' => '<string>',
'filters' => '{"points": {"gte": 100}, "AND": [{"email": {"contains": "@gmail.com"}}]}',
'mode' => 'manual'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apiKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://letterby.com/api/v4/audiences"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://letterby.com/api/v4/audiences")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://letterby.com/api/v4/audiences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apiKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audience": {
"id": "<string>",
"name": "<string>",
"filters": "<string>",
"mode": "smart",
"listId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"subs": [
{
"id": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phoneNumber": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"points": 123,
"referrals": 123,
"listId": "<string>",
"isVerified": true,
"unsubscribed": true,
"data": {},
"address": "<string>",
"isGDPR": true,
"name": "<string>",
"instagram": "<string>",
"twitter": "<string>",
"website": "<string>",
"company": "<string>",
"country": "<string>",
"city": "<string>",
"list": {
"id": "<string>",
"name": "<string>",
"url": "<string>",
"mode": "<string>",
"referrals": true,
"color": "<string>",
"title": "<string>",
"desc": "<string>"
},
"audiences": "<array>",
"referralLink": "<string>",
"privateLink": "<string>"
}
]
}
}
}{
"error": "Name and listId are required"
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Audiences
Create Audience
Creates a new audience
POST
/
audiences
cURL
curl --request POST \
--url https://letterby.com/api/v4/audiences \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"name": "<string>",
"listId": "<string>",
"filters": "{\"points\": {\"gte\": 100}, \"AND\": [{\"email\": {\"contains\": \"@gmail.com\"}}]}",
"mode": "manual"
}
'import requests
url = "https://letterby.com/api/v4/audiences"
payload = {
"name": "<string>",
"listId": "<string>",
"filters": "{\"points\": {\"gte\": 100}, \"AND\": [{\"email\": {\"contains\": \"@gmail.com\"}}]}",
"mode": "manual"
}
headers = {
"apiKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apiKey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
listId: '<string>',
filters: '{"points": {"gte": 100}, "AND": [{"email": {"contains": "@gmail.com"}}]}',
mode: 'manual'
})
};
fetch('https://letterby.com/api/v4/audiences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://letterby.com/api/v4/audiences",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'listId' => '<string>',
'filters' => '{"points": {"gte": 100}, "AND": [{"email": {"contains": "@gmail.com"}}]}',
'mode' => 'manual'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apiKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://letterby.com/api/v4/audiences"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://letterby.com/api/v4/audiences")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://letterby.com/api/v4/audiences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apiKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"listId\": \"<string>\",\n \"filters\": \"{\\\"points\\\": {\\\"gte\\\": 100}, \\\"AND\\\": [{\\\"email\\\": {\\\"contains\\\": \\\"@gmail.com\\\"}}]}\",\n \"mode\": \"manual\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audience": {
"id": "<string>",
"name": "<string>",
"filters": "<string>",
"mode": "smart",
"listId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"subs": [
{
"id": "<string>",
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phoneNumber": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"points": 123,
"referrals": 123,
"listId": "<string>",
"isVerified": true,
"unsubscribed": true,
"data": {},
"address": "<string>",
"isGDPR": true,
"name": "<string>",
"instagram": "<string>",
"twitter": "<string>",
"website": "<string>",
"company": "<string>",
"country": "<string>",
"city": "<string>",
"list": {
"id": "<string>",
"name": "<string>",
"url": "<string>",
"mode": "<string>",
"referrals": true,
"color": "<string>",
"title": "<string>",
"desc": "<string>"
},
"audiences": "<array>",
"referralLink": "<string>",
"privateLink": "<string>"
}
]
}
}
}{
"error": "Name and listId are required"
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Authorizations
API key to authorize requests
Body
application/json
Name of the audience
ID of the list this audience belongs to
JSON string containing Prisma where clause for Sub model. Required if mode is 'smart'
Example:
"{\"points\": {\"gte\": 100}, \"AND\": [{\"email\": {\"contains\": \"@gmail.com\"}}]}"
Audience mode
Available options:
manual, smart Response
Audience created successfully
Show child attributes
Show child attributes