Skip to Content
SendlySendly
API ReferenceSegments

Create a segment

POST
/api/v1/segments

Create a DYNAMIC segment (a saved condition, re-evaluated against contacts on every read) or a STATIC one (an explicitly managed membership list). type is fixed at creation — it decides how membership is computed, so it cannot be changed later.

A DYNAMIC segment requires a condition, which is validated and evaluated during the request: the response's member_count tells you immediately how many contacts the filter actually matches.

Requires the segments:write scope — Create, edit, and delete your segments.

headerAuthorizationBearer <API Key>

API key authentication. Use a sk_* (FULL) or pk_* (SENDING_ONLY) key as the bearer token. Public keys (pk_*) are restricted to the email-send endpoints and the self-serve list subscribe/unsubscribe pair; every other endpoint — event tracking included — answers 403 for them. In scope terms (used by /api/v1/* operations): FULL keys hold every scope; SENDING_ONLY keys hold only emails:send.

application/json
  1. body

Body for POST /api/v1/segments. condition is required when type is DYNAMIC.

name*string
Length1 <= length <= 100
description?string
Lengthlength <= 500
type?string
Default"DYNAMIC"
Value in"DYNAMIC""STATIC"
condition?

A filter condition: one or more groups combined with logic.

track_membership?boolean

Emit segment entry/exit events as contacts move in and out. Off by default — it costs a membership write per transition.

Defaultfalse

Response Body

Segment created

application/json
  1. response

A segment as exposed on the v1 API.

id*string
Formatuuid
name*string
description*string|null
type*string
Value in"DYNAMIC""STATIC"
condition*|null
track_membership*boolean
member_count*integer
created_at*string
Formatdate-time
updated_at*string
Formatdate-time
Example Request
curl -X POST 'https://api.sendly.now/api/v1/segments' \  -H 'Content-Type: application/json' \  -d '{  "name": "string"}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "name": "string",  "description": "string",  "type": "DYNAMIC",  "condition": {    "logic": "AND",    "groups": [      {        "filters": [          {            "field": "string",            "operator": "equals",            "value": null,            "unit": "days"          }        ],        "conditions": {}      }    ]  },  "track_membership": true,  "member_count": 0,  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}