v1 · API reference

Segments

Named groups of contacts used to target campaigns. Segments decide who a campaign goes to; topics (below) decide what recipients can opt out of.

Base URL: https://www.unitpost.com/api/v1/api/v1

Segments

List segments

GET/api/v1/api/v1/segments

GET /segments
curl -X GET 'https://www.unitpost.com/api/v1/api/v1/segments' \
  -H 'Authorization: Bearer YOUR_API_KEY'
Response · 200
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "segment",
      "id": "id_123",
      "name": "Example",
      "description": "string",
      "type": "static",
      "filter": "string",
      "created_at": "2026-01-01T00:00:00.000Z",
      "updated_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}

Retrieve a list of the segments in your workspace, cursor-paginated. A segment is a saved group of contacts you can target when sending a campaign. Create one with Create a segment, or list a segment's members with List segment members. Requires the segments:read capability.

Parameters3 fields
FieldTypeDescription
limitinteger · queryMax rows to return (default 20, max 100).
afterstring · queryReturn rows after this id (forward paging).
beforestring · queryReturn rows before this id (backward paging).
Response · 200 fields8 fields
FieldTypeDescription
objectrequiredstring
idrequiredstring
namerequiredstring
descriptionrequiredobject
typerequiredenumstatic | dynamic
filterrequiredobject
created_atrequiredstring
updated_atrequiredstring
200401422

Create a segment

POST/api/v1/api/v1/segments

POST /segments
curl -X POST 'https://www.unitpost.com/api/v1/api/v1/segments' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Active customers"
  }'
Response · 201
{
  "object": "segment",
  "id": "id_123",
  "name": "Example",
  "description": "string",
  "type": "static",
  "filter": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Create a segment — a named group of contacts you can target when sending a campaign. Once created, add contacts with Add a member and target it from Create a campaign. To let recipients opt out of a category of mail instead, see Create a topic. Requires the segments:write capability.

Request body4 fields
FieldTypeDescription
namerequiredstring
descriptionstring
typeenumstatic | dynamic
filterobject
Response · 201 fields8 fields
FieldTypeDescription
objectrequiredstring
idrequiredstring
namerequiredstring
descriptionrequiredobject
typerequiredenumstatic | dynamic
filterrequiredobject
created_atrequiredstring
updated_atrequiredstring
201401422

Retrieve a segment

GET/api/v1/api/v1/segments/{id}

GET /segments/{id}
curl -X GET 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123' \
  -H 'Authorization: Bearer YOUR_API_KEY'
Response · 200
{
  "object": "segment",
  "id": "id_123",
  "name": "Example",
  "description": "string",
  "type": "static",
  "filter": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Retrieve a single segment by id, including its name and member count. To page through the contacts inside it, use List segment members. Requires the segments:read capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path
Response · 200 fields8 fields
FieldTypeDescription
objectrequiredstring
idrequiredstring
namerequiredstring
descriptionrequiredobject
typerequiredenumstatic | dynamic
filterrequiredobject
created_atrequiredstring
updated_atrequiredstring
200401404

Update a segment

PATCH/api/v1/api/v1/segments/{id}

PATCH /segments/{id}
curl -X PATCH 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 200
{
  "object": "segment",
  "id": "id_123",
  "name": "Example",
  "description": "string",
  "type": "static",
  "filter": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Update a segment's editable metadata, such as its name. To change who's in the segment, add or remove members with Add a member and Remove a member. Requires the segments:write capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path
Request body3 fields
FieldTypeDescription
namestring
descriptionobject
filterobject
Response · 200 fields8 fields
FieldTypeDescription
objectrequiredstring
idrequiredstring
namerequiredstring
descriptionrequiredobject
typerequiredenumstatic | dynamic
filterrequiredobject
created_atrequiredstring
updated_atrequiredstring
200401404422

Delete a segment

DELETE/api/v1/api/v1/segments/{id}

DELETE /segments/{id}
curl -X DELETE 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Delete a segment. The contacts themselves are untouched — only the grouping is removed. This is blocked with 409 while an active campaign still targets the segment; cancel or finish that campaign first (see List campaigns). Requires the segments:write capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path
204401404409

List segment members

GET/api/v1/api/v1/segments/{id}/contacts

GET /segments/{id}/contacts
curl -X GET 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123/contacts' \
  -H 'Authorization: Bearer YOUR_API_KEY'
Response · 200
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "segment_member",
      "contact_id": "contact_123",
      "subscribed": false,
      "unsubscribed_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}

Retrieve the contacts in a segment, cursor-paginated. Add a contact with Add a member or take one out with Remove a member. Requires the segments:read capability.

Parameters4 fields
FieldTypeDescription
idrequiredstring · path
limitinteger · queryMax rows to return (default 20, max 100).
afterstring · queryReturn rows after this id (forward paging).
beforestring · queryReturn rows before this id (backward paging).
Response · 200 fields4 fields
FieldTypeDescription
objectrequiredstring
contact_idrequiredstring
subscribedrequiredboolean
unsubscribed_atrequiredobject
200401404422

Add a member

POST/api/v1/api/v1/segments/{id}/contacts

POST /segments/{id}/contacts
curl -X POST 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123/contacts' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "contact": "customer@example.com"
  }'
Response · 201
{
  "object": "segment_member",
  "contact_id": "contact_123",
  "subscribed": false,
  "unsubscribed_at": "2026-01-01T00:00:00.000Z"
}

Add a contact to a segment, referenced by contact id or email. The operation is idempotent — adding a contact that's already a member is a no-op and still succeeds. See the current members with List segment members. Requires the segments:write capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path
Request body2 fields
FieldTypeDescription
contactrequiredstring
subscribedboolean
Response · 201 fields4 fields
FieldTypeDescription
objectrequiredstring
contact_idrequiredstring
subscribedrequiredboolean
unsubscribed_atrequiredobject
201401404422

Remove a member

DELETE/api/v1/api/v1/segments/{id}/contacts/{contact}

DELETE /segments/{id}/contacts/{contact}
curl -X DELETE 'https://www.unitpost.com/api/v1/api/v1/segments/seg_123/contacts/con_456' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Remove a contact from a segment, referenced by contact id or email. The contact itself is not deleted — only its membership. Add it back any time with Add a member. Requires the segments:write capability.

Parameters2 fields
FieldTypeDescription
idrequiredstring · path
contactrequiredstring · pathA contact id or email.
204401404