Skip to Content

Create segment

POST
/segments

Create a new audience segment.

DYNAMIC segments (the default) are defined by a condition — a boolean tree that is re-evaluated against your contacts, so membership changes on its own as contact data changes. condition is required for these.

STATIC segments hold a manually managed member list; condition is ignored. Add members with POST /segments/{id}/members.

Authorization

ApiKeyAuth
headerAuthorizationBearer <API Key>

API Key authentication. The project is automatically derived from the key.

/v1/track requires a public key (pk_*) — it is the one endpoint intended for client-side use, and a secret key is rejected there with 401.

Every other endpoint requires a secret key (sk_*) and rejects public keys with 401.

So the two key types are not interchangeable in either direction: pick the key that matches the endpoint you are calling.

Request body

application/json
  1. body
name*string
Lengthlength <= 100
description?string
Lengthlength <= 500
type?string

Defaults to DYNAMIC when omitted.

Default"DYNAMIC"
Value in"DYNAMIC""STATIC"
condition?

Required for DYNAMIC segments; ignored for STATIC ones.

trackMembership?boolean

Emit segment.<slug>.entry / segment.<slug>.exit events as contacts join and leave. These can be used as workflow triggers.

Defaultfalse

Response body

Segment created

application/json
  1. response
id?string
name?string
description?string
type?string

DYNAMIC segments are evaluated from condition. STATIC segments hold a manually managed member list.

Value in"DYNAMIC""STATIC"
condition?

Filter condition for DYNAMIC segments. Null for STATIC segments.

trackMembership?boolean

When true, contacts entering or leaving the segment emit segment.<slug>.entry / segment.<slug>.exit events.

memberCount?integer

Cached member count, refreshed by a background job rather than computed per request.

projectId?string
createdAt?string
Formatdate-time
updatedAt?string
Formatdate-time
curl -X POST 'https://api.send.47signals.com/segments' \  -H 'Content-Type: application/json' \  -d '{  "name": "Premium Users",  "condition": {    "logic": "AND",    "groups": [      {        "filters": [          {            "field": "data.plan",            "operator": "equals",            "value": "premium"          }        ]      }    ]  },  "trackMembership": true}'
Example response
{  "id": "string",  "name": "string",  "description": "string",  "type": "DYNAMIC",  "condition": {    "logic": "AND",    "groups": [      {        "filters": [          {            "field": "string",            "operator": "equals",            "value": null,            "unit": "days"          }        ],        "conditions": {}      }    ]  },  "trackMembership": true,  "memberCount": 0,  "projectId": "string",  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}