curl --request PATCH \
--url https://api.statisfy.com/v1/campaigns/audiences/{audience_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conditions": {},
"name": "<string>"
}
'import requests
url = "https://api.statisfy.com/v1/campaigns/audiences/{audience_id}"
payload = {
"conditions": {},
"name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({conditions: {}, name: '<string>'})
};
fetch('https://api.statisfy.com/v1/campaigns/audiences/{audience_id}', 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://api.statisfy.com/v1/campaigns/audiences/{audience_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'conditions' => [
],
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.statisfy.com/v1/campaigns/audiences/{audience_id}"
payload := strings.NewReader("{\n \"conditions\": {},\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.statisfy.com/v1/campaigns/audiences/{audience_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conditions\": {},\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/campaigns/audiences/{audience_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conditions\": {},\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"conditions": {},
"id": "<string>",
"name": "<string>",
"shared": true,
"contacts": 123
}Rename an audience or change who it selects
Changes an audience’s name, its conditions, or both, keeping what is not sent, as the app’s audience page saves it. A campaign using it sends to the new selection from its next run, so new conditions on an audience a published campaign uses also need campaigns:publish (a 403 names the campaigns); a rename does not. Returns the audience with how many contacts it selects now. Every audience is the workspace’s, as in the app. Its owner, an admin, or someone it is shared with for editing changes it; its owner or an admin deletes it. A person’s key acts as that person, an org key as the member who created it.
curl --request PATCH \
--url https://api.statisfy.com/v1/campaigns/audiences/{audience_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conditions": {},
"name": "<string>"
}
'import requests
url = "https://api.statisfy.com/v1/campaigns/audiences/{audience_id}"
payload = {
"conditions": {},
"name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({conditions: {}, name: '<string>'})
};
fetch('https://api.statisfy.com/v1/campaigns/audiences/{audience_id}', 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://api.statisfy.com/v1/campaigns/audiences/{audience_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'conditions' => [
],
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.statisfy.com/v1/campaigns/audiences/{audience_id}"
payload := strings.NewReader("{\n \"conditions\": {},\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.statisfy.com/v1/campaigns/audiences/{audience_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conditions\": {},\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/campaigns/audiences/{audience_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conditions\": {},\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"conditions": {},
"id": "<string>",
"name": "<string>",
"shared": true,
"contacts": 123
}Authorizations
An API key, sent as Authorization: Bearer stfy_live_…. See Authentication for how to get one and which scopes it needs.
Body
Who the audience selects: a filter tree in the app's own format, as GET /v1/views/{view_id} shows an audience's conditions (read one, change it, send it back). A condition names a contact field (or a related account's) with an operator and a value; a group combines conditions with and/or; {} is every contact, as the app's All People audience is. It is checked before it is saved: a tree the app cannot read, a field the object doesn't have, or an empty group is a 422. Left out: kept
Response
Successful Response
Was this page helpful?