Core

Segments API

6 endpoints under https://api.mailneo.co/api/v2. Every request carries your key in the X-API-Key header. The scopes used here: segments:read, segments:write. Each endpoint below states the one it requires. Start with the guide →

Segments
listSegments

List segments

Saved subscriber filters. Cursor-paginated; pass updated_since with the synced_through value from your previous run to fetch only what changed.

The stored filter definition is not published — see the segment object. Use GET /segments/{segmentId}/count for the number of subscribers a segment matches.

https://api.mailneo.co/api/v2
GET/segmentssegments:read

Example request

curl "https://api.mailneo.co/api/v2/segments?limit=25&order=desc&sort=updated_at" \
  -H "X-API-Key: $MAILNEO_API_KEY"
Authorization
Required scope
segments:read. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Query parameters6
NameTypeRequiredNotes
limitintegerNodefault 25 · 1–100
cursorstringNomax 256 chars
order"asc" | "desc"Nodefault "desc"
updated_sincestring · date-timeNoISO 8601
sort"updated_at" | "created_at"Nodefault "updated_at"
namestringNomax 200 chars
Response · 200

Success

data[]Each element of the array.

FieldTypeAlways presentNotes
object"segment"Yes
idstringYes
namestringYes
created_atstringYes
updated_atstringYes

meta

FieldTypeAlways presentNotes
request_idstringYes
has_morebooleanYes
next_cursorstring · nullableYes
synced_throughstringNo
Segmentswrite
createSegment

Create a segment

Creates one saved subscriber filter. Names are NOT required to be unique — the app does not enforce it either — so two segments may share a name and are told apart by id.

The conditions definition is a strict, validated language, not free-form JSON: a group (operator: AND/OR) of conditions, nestable two levels. Each condition names a field, an operator and usually a value. Supported fields and their operators:

- email, name, firstName, lastNameequals, not_equals, contains, not_contains, starts_with, ends_with; is_set/is_not_set on firstName/lastName only (the other two always have a value). - statusequals, not_equals, in, not_in over ENABLED, DISABLED, BLOCKLISTED. - scoreequals, not_equals, greater_than, less_than, greater_than_or_equals, less_than_or_equals, in, not_in; numbers only. - tagscontains/not_contains (one tag), equals/not_equals (all of), in/not_in (any of), is_set/is_not_set. - listsin/not_in over list ids, meaning a CONFIRMED subscription to any of them. Every id must be a list in your team. - subscription_statusequals over UNCONFIRMED, CONFIRMED, UNSUBSCRIBED. - createdAt, updatedAt, lastContactedAtequals (whole day), before, after, between; ISO 8601 date strings. - lastOpenedAt, lastClickedAtbefore/after (newsletter open/click activity relative to a date). - customFields.<path> or attributes.<path>equals, not_equals, contains, is_set, is_not_set on a key inside the subscriber's custom-field JSON. Paths are not checked against a catalog (the keys are your own); a path no subscriber carries simply matches no one.

Counts of opens, clicks and bounces (opens_count and friends) are deliberately NOT accepted: the API cannot evaluate them, so a segment saved with one could not be counted by GET /segments/{segmentId}/count. Create those in the dashboard.

Everything this endpoint accepts is guaranteed evaluatable by the count endpoint. The stored definition is not echoed back and is not published on segment reads.

https://api.mailneo.co/api/v2
POST/segmentssegments:write

Example request

curl -X POST "https://api.mailneo.co/api/v2/segments" \
  -H "X-API-Key: $MAILNEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "<string>",
    "conditions": {
      "operator": "AND",
      "conditions": [
        "<string>"
      ]
    }
  }'
Authorization
Required scope
segments:write. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Idempotency
Idempotency-Key is optional.
Query parameters1
NameTypeRequiredNotes
dry_runbooleanNoReport what this call WOULD do and commit nothing. Returns data: null and a meta.impact block. Requires the resource's :read scope in addition to the scope this endpoint declares. Must be exactly true or false.
Header parameters1
NameTypeRequiredNotes
Idempotency-KeystringNoA caller-chosen unique string, at most 255 characters. Retrying with the same key replays the first response instead of repeating the work; the replay carries Idempotent-Replayed: true. Reusing a key with a different body is a 409 idempotency_key_reused. Keys are remembered for 24 hours. · max 255 chars
Request body

name

FieldTypeAlways presentNotes
namestringYesmax 200 chars

conditions

FieldTypeAlways presentNotes
operator"AND" | "OR"Yes
conditions(object | object)[]Yes
Response · 200

Success

data

FieldTypeAlways presentNotes
dataobject | object · nullableYes

meta

FieldTypeAlways presentNotes
request_idstringYes
dry_runbooleanYes
impactobjectNo
impact.object"impact"Yes
impact.would_createintegerYes
impact.would_updateintegerYes
impact.would_deleteintegerYes
impact.affected_countintegerYes
impact.affected_idsstring[]Yes
impact.quotaobject · nullableYes
impact.quota.kindstringYes
impact.quota.would_consumeintegerYes
impact.quota.limitinteger · nullableYes
impact.quota.currentintegerYes
Response · 201

Created

data

FieldTypeAlways presentNotes
dataobject | object · nullableYes

meta

FieldTypeAlways presentNotes
request_idstringYes
dry_runbooleanYes
impactobjectNo
impact.object"impact"Yes
impact.would_createintegerYes
impact.would_updateintegerYes
impact.would_deleteintegerYes
impact.affected_countintegerYes
impact.affected_idsstring[]Yes
impact.quotaobject · nullableYes
impact.quota.kindstringYes
impact.quota.would_consumeintegerYes
impact.quota.limitinteger · nullableYes
impact.quota.currentintegerYes
Segments
getSegment

Retrieve a segment

https://api.mailneo.co/api/v2
GET/segments/{segmentId}segments:read

Example request

curl "https://api.mailneo.co/api/v2/segments/{segmentId}" \
  -H "X-API-Key: $MAILNEO_API_KEY"
Authorization
Required scope
segments:read. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Path parameters1
NameTypeRequiredNotes
segmentIdstringYesmax 64 chars
Response · 200

Success

data

FieldTypeAlways presentNotes
object"segment"Yes
idstringYes
namestringYes
created_atstringYes
updated_atstringYes

meta

FieldTypeAlways presentNotes
request_idstringYes
Segmentswrite
updateSegment

Update a segment

Merge-patch at the field level: omit a field to leave it alone. conditions is REPLACED wholesale, never merged — send the complete definition you want, in the same language POST /segments accepts. Neither field is nullable, so null is a 400.

Campaigns that target this segment pick up the new definition on their next send: the audience is evaluated at send time, not saved when the campaign is.

https://api.mailneo.co/api/v2
PATCH/segments/{segmentId}segments:write

Example request

curl -X PATCH "https://api.mailneo.co/api/v2/segments/{segmentId}" \
  -H "X-API-Key: $MAILNEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "<string>",
    "conditions": {
      "operator": "AND",
      "conditions": [
        "<string>"
      ]
    }
  }'
Authorization
Required scope
segments:write. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Idempotency
Idempotency-Key is optional.
Path parameters1
NameTypeRequiredNotes
segmentIdstringYesmax 64 chars
Query parameters1
NameTypeRequiredNotes
dry_runbooleanNoReport what this call WOULD do and commit nothing. Returns data: null and a meta.impact block. Requires the resource's :read scope in addition to the scope this endpoint declares. Must be exactly true or false.
Header parameters1
NameTypeRequiredNotes
Idempotency-KeystringNoA caller-chosen unique string, at most 255 characters. Retrying with the same key replays the first response instead of repeating the work; the replay carries Idempotent-Replayed: true. Reusing a key with a different body is a 409 idempotency_key_reused. Keys are remembered for 24 hours. · max 255 chars
Request body

name

FieldTypeAlways presentNotes
namestringNomax 200 chars

conditions

FieldTypeAlways presentNotes
operator"AND" | "OR"Yes
conditions(object | object)[]Yes
Response · 200

Success

data

FieldTypeAlways presentNotes
dataobject | object · nullableYes

meta

FieldTypeAlways presentNotes
request_idstringYes
dry_runbooleanYes
impactobjectNo
impact.object"impact"Yes
impact.would_createintegerYes
impact.would_updateintegerYes
impact.would_deleteintegerYes
impact.affected_countintegerYes
impact.affected_idsstring[]Yes
impact.quotaobject · nullableYes
impact.quota.kindstringYes
impact.quota.would_consumeintegerYes
impact.quota.limitinteger · nullableYes
impact.quota.currentintegerYes
Segmentswrite
deleteSegment

Delete a segment

Permanent, and there is no undo — call with ?dry_run=true first.

A segment is a saved filter: deleting it touches no subscriber, and nothing else in the database references it, so nothing cascades and nothing is detached. The one thing to check first is newsletter campaigns — a campaign that targets this segment keeps its id in the campaign's settings, and a send whose targeting names a segment that no longer exists deliberately delivers to NOBODY (it fails closed rather than widening to the whole list). A scheduled campaign pointed at this segment will therefore go out empty. Retarget those campaigns before deleting.

https://api.mailneo.co/api/v2
DELETE/segments/{segmentId}segments:write

Example request

curl -X DELETE "https://api.mailneo.co/api/v2/segments/{segmentId}" \
  -H "X-API-Key: $MAILNEO_API_KEY"
Authorization
Required scope
segments:write. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Path parameters1
NameTypeRequiredNotes
segmentIdstringYesmax 64 chars
Query parameters1
NameTypeRequiredNotes
dry_runbooleanNoReport what this call WOULD do and commit nothing. Returns data: null and a meta.impact block. Requires the resource's :read scope in addition to the scope this endpoint declares. Must be exactly true or false.
Response · 200

Success

dataMay be null.

FieldTypeAlways presentNotes
object"segment"Yes
idstringYes
deletedtrueYes

meta

FieldTypeAlways presentNotes
request_idstringYes
dry_runbooleanYes
impactobjectNo
impact.object"impact"Yes
impact.would_createintegerYes
impact.would_updateintegerYes
impact.would_deleteintegerYes
impact.affected_countintegerYes
impact.affected_idsstring[]Yes
impact.quotaobject · nullableYes
impact.quota.kindstringYes
impact.quota.would_consumeintegerYes
impact.quota.limitinteger · nullableYes
impact.quota.currentintegerYes
Segmentsread_costly
countSegment

Count the subscribers a segment matches

Evaluates the segment against the current subscriber set and returns the number of matches. Every matching subscriber is counted whatever their status; save a segment with a status condition if you want a narrower number.

This is a live aggregate over the subscriber table, not a stored value, so it is slower than an ordinary read. Cache the result rather than polling it.

Segments that filter on newsletter opens, clicks or bounces cannot be evaluated here and return 400 filter_unsupported: those records are not part of the public API, and returning a number computed without them would be silently wrong.

https://api.mailneo.co/api/v2
GET/segments/{segmentId}/countsegments:read

Example request

curl "https://api.mailneo.co/api/v2/segments/{segmentId}/count" \
  -H "X-API-Key: $MAILNEO_API_KEY"
Authorization
Required scope
segments:read. A key without it is refused before the endpoint runs.
Credential
X-API-Key: mk_live_...Authorization: Bearer mk_live_...
Path parameters1
NameTypeRequiredNotes
segmentIdstringYesmax 64 chars
Response · 200

Success

data

FieldTypeAlways presentNotes
object"segment_count"Yes
segment_idstringYes
countintegerYes
counted_atstringYes

meta

FieldTypeAlways presentNotes
request_idstringYes

Next Steps