Skip to Content
Docs

Create a saved segment

POST
/v1/segments

filter is validated by email_core::parse_filter and stored as submitted; it is re-validated and re-compiled to SQL on every preview/count/broadcast-fanout use, never trusted as pre-compiled.

Authorization

bearerAuth
headerAuthorizationBearer <token>

API key sent as Authorization: Bearer <key>. Looked up by SHA-256 hash (email_core::sha256_hex) against api_keys.hash; revoked keys and keys belonging to a suspended tenant are rejected. See the top-level Authentication section for permission levels.

Request Body

application/json
  1. body
name*string
filter*

email_core::segment::SegmentFilter, validated by parse_filter and compiled to a parameterized SQL predicate by compile_filter. At most 25 conditions; all conditions are ANDed (there is no OR).

Response Body

Created.

application/json
  1. response
id?string
name?string
filter?

email_core::segment::SegmentFilter, validated by parse_filter and compiled to a parameterized SQL predicate by compile_filter. At most 25 conditions; all conditions are ANDed (there is no OR).

created_at?integer
Formatint64
updated_at?integer
Formatint64
Example Request
curl -X POST 'https://api.emitd.com/v1/segments' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "filter": {    "conditions": [      {        "field": "string",        "op": "eq"      }    ]  }}'
Example Response
{  "id": "string",  "name": "string",  "filter": {    "match": "all",    "conditions": [      {        "field": "string",        "op": "eq",        "value": "string"      }    ]  },  "created_at": 0,  "updated_at": 0}