curl --request GET \
--url https://api.privy.com/v1/segments/{id}/counts \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.privy.com/v1/segments/{id}/counts"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.privy.com/v1/segments/{id}/counts', 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.privy.com/v1/segments/{id}/counts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.privy.com/v1/segments/{id}/counts"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.privy.com/v1/segments/{id}/counts")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.privy.com/v1/segments/{id}/counts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"total_count": 1930,
"mailable_count": 1284,
"textable_count": 312
}
}{
"error": {
"code": "unauthorized",
"message": "Bearer token is missing or invalid"
}
}{
"error": {
"code": "live_counts_unavailable",
"message": "This Privy account is not eligible for live segment counts yet. Contact Privy support to migrate your account to the latest version."
}
}{
"error": {
"code": "not_found",
"message": "Not found"
}
}{
"error": {
"code": "segment_not_countable",
"message": "This segment cannot be counted live as saved. The counts from its last refresh are on GET /v1/segments/{id}."
}
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded"
}
}{
"error": {
"code": "counts_failed",
"message": "Live segment counts failed for this request. Privy has been notified."
}
}{
"error": {
"code": "counts_unavailable",
"message": "Live segment counts are not available right now. Try again shortly."
}
}Get live segment counts
How many contacts a saved segment reaches today. The counts on
GET /v1/segments/{id} are the ones its last membership refresh left
behind, dated by counts.refreshed_at, and they can lag or still be
zero after a create; this counts the segment’s criteria against the
latest data now. It only reads, and saves and changes nothing. Each
count is a scan of the account’s contacts, so it has its own budget
on top of the request limit: 20 per minute and 600 per UTC day for
each user, charged only when a count runs. A token with no user
shares one such budget per account.
Live counts need the account to be on the latest segment engine.
An account that is not yet is refused with
403 live_counts_unavailable: the merchant can ask Privy support to
migrate the account, and retrying does not help. An account whose
live answers Privy is checking is refused with
403 live_counts_suspended: the suspension lifts on its own within
a week, or sooner through Privy support, and retrying in the same
session does not help. The endpoint needs the account’s new segment
builder, and answers 403 segment_builder_required without it.
When live counts are paused or a count fails for the moment, the
answer is 503 counts_unavailable; retry it after its Retry-After.
When a count runs out of time or memory, which an account’s size can
make happen on every call, the answer is 422 counts_too_large; Privy is
notified, and a retry does not help. When Privy cannot count the
saved criteria, the answer is 500 counts_failed; Privy is notified,
and a plain retry rarely helps.
A saved condition the live engine cannot count as written, or that
reads all-time activity the account does not have, is
422 segment_not_countable: the segment’s criteria are not the
request’s to change, so read its refreshed counts instead.
A live count can differ from the refreshed one, and
from the members GET /v1/segments/{id}/contacts lists, until the
next refresh.
Required scope: segments_read
curl --request GET \
--url https://api.privy.com/v1/segments/{id}/counts \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.privy.com/v1/segments/{id}/counts"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.privy.com/v1/segments/{id}/counts', 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.privy.com/v1/segments/{id}/counts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.privy.com/v1/segments/{id}/counts"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.privy.com/v1/segments/{id}/counts")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.privy.com/v1/segments/{id}/counts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": {
"total_count": 1930,
"mailable_count": 1284,
"textable_count": 312
}
}{
"error": {
"code": "unauthorized",
"message": "Bearer token is missing or invalid"
}
}{
"error": {
"code": "live_counts_unavailable",
"message": "This Privy account is not eligible for live segment counts yet. Contact Privy support to migrate your account to the latest version."
}
}{
"error": {
"code": "not_found",
"message": "Not found"
}
}{
"error": {
"code": "segment_not_countable",
"message": "This segment cannot be counted live as saved. The counts from its last refresh are on GET /v1/segments/{id}."
}
}{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded"
}
}{
"error": {
"code": "counts_failed",
"message": "Live segment counts failed for this request. Privy has been notified."
}
}{
"error": {
"code": "counts_unavailable",
"message": "Live segment counts are not available right now. Try again shortly."
}
}Authorizations
Headers
Path Parameters
Was this page helpful?