Create a segment
const url = 'https://api.tryletterhead.com/api/v3/contacts/segments?api=true';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"Engaged opens - last 30 days","description":"Contacts who opened in the last 30 days","criteria":{"matchMode":"all","conditions":[{"type":"tag","value":"engaged"}],"suppressionSegmentIds":[]},"channelSlugs":[]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url 'https://api.tryletterhead.com/api/v3/contacts/segments?api=true' \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "Engaged opens - last 30 days", "description": "Contacts who opened in the last 30 days", "criteria": { "matchMode": "all", "conditions": [ { "type": "tag", "value": "engaged" } ], "suppressionSegmentIds": [] }, "channelSlugs": [] }'Creates a company-level contact segment. A segment is a saved audience query; membership is never materialized — the criteria are evaluated live.
This is a company-level (v3) write. Authenticate with a company API key as a Bearer token.
Response
201 Created. The persisted segment is returned under items (see List segments for the segment shape). A duplicate name returns 409.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Query Parameters
Section titled “Query Parameters ”Required. Set to true.
Request Body required
Section titled “Request Body required ”object
Segment name. Max 255 chars. Must be unique within the company.
Free-text description. Max 500 chars.
The saved query.
object
all (AND the conditions) or any (OR the conditions).
At least one condition. Each condition is an object with a type and its value(s).
object
IDs of other segments (same company) whose members are excluded from this segment’s audience.
object
Channels to scope the segment to. Omit or send an empty array to make it available on every channel.
object
Example
{ "name": "Engaged opens - last 30 days", "description": "Contacts who opened in the last 30 days", "criteria": { "matchMode": "all", "conditions": [ { "type": "tag", "value": "engaged" } ], "suppressionSegmentIds": [] }, "channelSlugs": []}Responses
Section titled “ Responses ”Successful response
Still can’t find what you need? Contact support.