Newsletter

Segments API

6 endpoints under https://api.mailneo.co/api/v2. Every request carries your key in the x-api-key header.

Scopes used on this page: segments:read, segments:write. Each endpoint below states the one it requires. Start with the quickstart →

GET/segments

List segments

Requires segments:read

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.

Query parameters6
limitintegerdefault: 251..100
cursorstring≤ 256 chars
Opaque page cursor from a previous response’s next_cursor. Treat it as a black box: cursors are bound to the sort they were issued under and are validated strictly, so a hand-crafted, modified or foreign cursor — including any cursor issued before the 2026-08 format revision — answers 400 cursor_invalid. On that error, restart from the first page.
order"asc" | "desc"default: desc
updated_sincestring · date-time
sort"updated_at" | "created_at"default: updated_at
namestring≤ 200 chars
curl "https://api.mailneo.co/api/v2/segments?limit=25&order=desc&sort=updated_at" \
  -H "x-api-key: $MAILNEO_API_KEY"
{
  "data": [
    {
      "object": "segment",
      "id": "c00h2k2s00r25rr0111rgq01b",
      "name": "Engaged readers",
      "created_at": "2026-05-11T09:30:00.000Z",
      "updated_at": "2026-06-24T15:45:00.000Z"
    }
  ],
  "meta": {
    "request_id": "24d7938d-23d7-41fa-a2d7-906721d78ed4",
    "has_more": false,
    "next_cursor": null,
    "synced_through": "2026-06-24T15:45:00.000Z"
  }
}
POST/segments

Create a segment

Requires segments:write · Idempotency-Key optional

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.

Query parameters1
dry_runboolean
Report 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
Idempotency-Keystring≤ 255 chars
A 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.
Body parameters4
namestringrequired1..200 chars
conditionsobjectrequired
conditions.operator"AND" | "OR"required
conditions.conditions(object | object)[]required1..100 items
curl -X POST "https://api.mailneo.co/api/v2/segments" \
  -H "x-api-key: $MAILNEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ada Lovelace",
    "conditions": {
      "operator": "AND",
      "conditions": [
        "…"
      ]
    }
  }'
{
  "data": "…",
  "meta": {
    "request_id": "7ec64846-7fc6-49d9-acc6-45207dc646b3",
    "dry_run": false
  }
}
GET/segments/{segmentId}

Retrieve a segment

Requires segments:read

Path parameters1
segmentIdstringrequired1..64 chars
curl "https://api.mailneo.co/api/v2/segments/{segmentId}" \
  -H "x-api-key: $MAILNEO_API_KEY"
{
  "data": {
    "object": "segment",
    "id": "c00h2k2s00r25rr0111rgq01b",
    "name": "Engaged readers",
    "created_at": "2026-05-11T09:30:00.000Z",
    "updated_at": "2026-06-24T15:45:00.000Z"
  },
  "meta": {
    "request_id": "3e6a0e5e-3f6a-4ff1-ac6a-0b383d6a0ccb"
  }
}
PATCH/segments/{segmentId}

Update a segment

Requires segments:write · Idempotency-Key optional

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.

Path parameters1
segmentIdstringrequired1..64 chars
Query parameters1
dry_runboolean
Report 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
Idempotency-Keystring≤ 255 chars
A 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.
Body parameters4
namestring1..200 chars
conditionsobject
conditions.operator"AND" | "OR"required
conditions.conditions(object | object)[]required1..100 items
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": "Ada Lovelace",
    "conditions": {
      "operator": "AND",
      "conditions": [
        "…"
      ]
    }
  }'
{
  "data": "…",
  "meta": {
    "request_id": "ba5b0859-b95b-46c6-a85b-0533b75b03a0",
    "dry_run": false
  }
}
DELETE/segments/{segmentId}

Delete a segment

Requires segments:write

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.

Path parameters1
segmentIdstringrequired1..64 chars
Query parameters1
dry_runboolean
Report 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.
curl -X DELETE "https://api.mailneo.co/api/v2/segments/{segmentId}" \
  -H "x-api-key: $MAILNEO_API_KEY"
{
  "data": {
    "object": "segment",
    "id": "c00h2k2s00r25rr0111rgq01b",
    "deleted": true
  },
  "meta": {
    "request_id": "be9e4457-bd9e-42c4-a09e-477dbf9e45ea",
    "dry_run": false
  }
}
GET/segments/{segmentId}/count

Count the subscribers a segment matches

Requires segments:read

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.

Path parameters1
segmentIdstringrequired1..64 chars
curl "https://api.mailneo.co/api/v2/segments/{segmentId}/count" \
  -H "x-api-key: $MAILNEO_API_KEY"
{
  "data": {
    "object": "segment_count",
    "segment_id": "c00h2k2s00r25rr0111rgq01b",
    "count": 3172,
    "counted_at": "2026-06-24T15:45:00.000Z"
  },
  "meta": {
    "request_id": "bfb7c513-beb7-4380-a1b7-c839c0b7c6a6"
  }
}