Count contacts in a segment
GET
/api/v3/contacts/segments/{segmentId}/count
const url = 'https://api.tryletterhead.com/api/v3/contacts/segments/1/count?api=true';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.tryletterhead.com/api/v3/contacts/segments/1/count?api=true' \ --header 'Authorization: Bearer <token>'Returns the number of contacts that currently match a segment’s criteria.
This is a company-level (v3) read. Authenticate with a company API key as a Bearer token.
Response
200 OK with an empty items array. The match count is returned in the response envelope’s total, not in items.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” segmentId
required
integer
The segment’s identifier. This is the numeric id returned by List segments — not a UUID.
Query Parameters
Section titled “Query Parameters ” api
required
boolean
Set to true.
channel
string
Count only contacts subscribed to the given channel identifier (slug). Omit for the full company audience.
Responses
Section titled “ Responses ”200 OK
Media type application/json
object
items
Array<object>
object
message
string
total
integer
Example
{ "items": [], "message": "Segment count retrieved.", "total": 1284}Still can’t find what you need? Contact support.