Mailtea Segments API
The Segments API from Mailtea — 2 operation(s) for segments.
The Segments API from Mailtea — 2 operation(s) for segments.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/mailtea-app:mailtea-app-segments-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Mailtea Segments API
version: 0.24.0
summary: Send transactional and marketing email, manage contacts and audiences, verify sending domains, render templates, and subscribe to webhook events.
description: Every endpoint lives under `/v1` and takes a Bearer token (`mt_pat_…` personal access token, `mt_svc_…` service key, or `mt_test_…` test key) in the `Authorization` header. The required scopes are listed per operation. This document is generated from the API reference at https://docs.mailtea.app/docs/api-reference.
termsOfService: https://mailtea.app/terms
contact:
name: Mailtea
url: https://mailtea.app
email: support@mailtea.app
license:
name: AGPL-3.0-only
identifier: AGPL-3.0-only
servers:
- url: https://api.mailtea.app
description: Mailtea cloud
tags:
- name: Segments
paths:
/v1/segments:
get:
operationId: listSegments
summary: List Segments
description: 'List audience segments for a publication with cursor-based pagination
List all audience segments for a publication, ordered by newest first. Results are paginated using cursor-based pagination.'
tags:
- Segments
externalDocs:
url: https://docs.mailtea.app/docs/api-reference/segments/list-segments
parameters:
- name: publication_id
in: query
required: true
description: Filter to a specific publication.
schema:
type: string
- name: limit
in: query
required: false
description: Number of results per page. 1–100, default `20`.
schema:
type: number
- name: after
in: query
required: false
description: Pagination cursor from a previous response's `next_cursor`.
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
object:
type: string
description: Always `"list"`.
data:
type: array
description: Array of segment objects.
items:
type: object
properties:
object:
type: string
description: Always `"segment"`.
id:
type: string
description: Unique segment identifier.
publication_id:
type: string
description: The publication this segment belongs to.
name:
type: string
description: Segment name.
description:
type: string
description: Segment description.
status_filter:
type:
- string
- 'null'
description: Contact status filter, or `null` if not set.
query_filter:
type:
- string
- 'null'
description: Custom query filter, or `null` if not set.
inactive_days:
type:
- number
- 'null'
description: Inactivity filter in days, or `null` if not set.
created_at:
type: string
description: ISO 8601 creation timestamp.
updated_at:
type: string
description: ISO 8601 last-updated timestamp.
has_more:
type: boolean
description: Whether additional pages exist.
next_cursor:
type: string
description: Cursor to pass as the `after` query parameter for the next page. Only present when `has_more` is `true`.
example:
object: list
data:
- object: segment
id: seg_abc123
publication_id: pub_abc123
name: Engaged Subscribers
description: Subscribers who opened at least one email
status_filter: active
query_filter: null
inactive_days: null
created_at: '2026-03-29T10:00:00.000Z'
updated_at: '2026-03-29T10:00:00.000Z'
- object: segment
id: seg_def456
publication_id: pub_abc123
name: Unsubscribed
description: All unsubscribed contacts
status_filter: unsubscribed
query_filter: null
inactive_days: null
created_at: '2026-03-29T09:00:00.000Z'
updated_at: '2026-03-29T09:00:00.000Z'
has_more: false
'400':
description: Missing required `publication_id` query parameter.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized — missing or invalid token.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden — publication not owned by your organization.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth:
- contacts:read
- bearerAuth:
- issues:write
x-mailtea-scopes:
- contacts:read
- issues:write
post:
operationId: createSegment
summary: Create Segment
description: 'Create a new audience segment for a publication
Create a new audience segment for a publication. Segments let you group contacts by status, by a custom query filter, or by how long they have gone without opening or clicking, for targeted sends.'
tags:
- Segments
externalDocs:
url: https://docs.mailtea.app/docs/api-reference/segments/create-segment
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
publication_id:
type: string
description: The publication to create the segment in.
name:
type: string
description: Segment name. 1–200 characters.
description:
type: string
description: Human-readable description. Max 1000 characters.
status_filter:
type: string
description: 'Filter contacts by status: `active`, `unsubscribed`, or `suppressed`.'
query_filter:
type: string
description: Custom query filter expression. Max 2000 characters.
inactive_days:
type: integer
description: Select contacts with no open or click in the last N days. An integer, 1 to 3650. A contact who has never opened or clicked counts as inactive, so this finds the silent part of your list for a sunset or re-engagement send; it is not a filter for engaged readers. See [Inactive contacts](/docs/documentation/segments-topics#inactive-contacts) for how engagement is tracked.
required:
- publication_id
- name
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
object:
type: string
description: Always `"segment"`.
id:
type: string
description: Unique segment identifier.
publication_id:
type: string
description: The publication this segment belongs to.
name:
type: string
description: Segment name.
description:
type: string
description: Segment description.
status_filter:
type:
- string
- 'null'
description: Contact status filter, or `null` if not set.
query_filter:
type:
- string
- 'null'
description: Custom query filter, or `null` if not set.
inactive_days:
type:
- number
- 'null'
description: Inactivity filter in days, or `null` if not set.
created_at:
type: string
description: ISO 8601 creation timestamp.
updated_at:
type: string
description: ISO 8601 last-updated timestamp.
example:
object: segment
id: seg_abc123
publication_id: pub_abc123
name: Engaged Subscribers
description: Subscribers who opened at least one email
status_filter: active
query_filter: null
inactive_days: null
created_at: '2026-03-29T10:00:00.000Z'
updated_at: '2026-03-29T10:00:00.000Z'
'400':
description: Validation failed — missing or invalid fields.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized — missing or invalid token.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden — insufficient permissions or publication not owned by your organization.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Publication not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth:
- contacts:write
x-mailtea-scopes:
- contacts:write
/v1/segments/{id}:
delete:
operationId: deleteSegment
summary: Delete Segment
description: 'Permanently delete an audience segment
Permanently delete an audience segment. This action cannot be undone.
A segment that a draft, scheduled or sending post targets cannot be deleted. The request is refused with `409` and nothing is deleted, so no post is ever widened to the whole publication by accident. Point those posts at another segment, or set their `segment_id` to `null`, with Update Post, then delete again. A scheduled post has to go back to draft first, in Mailtea Studio or with the MCP `issue.unschedule` tool. A post that is sending frees the segment when it finishes, and sent or failed posts never block a delete.'
tags:
- Segments
externalDocs:
url: https://docs.mailtea.app/docs/api-reference/segments/delete-segment
parameters:
- name: id
in: path
required: true
description: The segment ID.
schema:
type: string
- name: publication_id
in: query
required: true
description: The publication the segment belongs to.
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
object:
type: string
description: Always `"segment"`.
id:
type: string
description: The deleted segment's identifier.
deleted:
type: boolean
description: Always `true`.
example:
object: segment
id: seg_abc123
deleted: true
'400':
description: Missing required `publication_id` query parameter.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized — missing or invalid token.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden — insufficient permissions or publication not owned by your organization.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Segment not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: 'Posts still target this segment (`code: "segment_in_use"`). The body lists them in `posts` (at most 10, oldest first), each with `id`, `title` and `status` (`draft`, `scheduled` or `sending`). Sent and failed posts never block a delete. Nothing is deleted.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth:
- contacts:write
x-mailtea-scopes:
- contacts:write
get:
operationId: retrieveSegment
summary: Retrieve Segment
description: 'Retrieve a single audience segment by ID
Retrieve a single audience segment by its ID.'
tags:
- Segments
externalDocs:
url: https://docs.mailtea.app/docs/api-reference/segments/retrieve-segment
parameters:
- name: id
in: path
required: true
description: The segment ID.
schema:
type: string
- name: publication_id
in: query
required: true
description: The publication the segment belongs to.
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
object:
type: string
description: Always `"segment"`.
id:
type: string
description: Unique segment identifier.
publication_id:
type: string
description: The publication this segment belongs to.
name:
type: string
description: Segment name.
description:
type: string
description: Segment description.
status_filter:
type:
- string
- 'null'
description: Contact status filter, or `null` if not set.
query_filter:
type:
- string
- 'null'
description: Custom query filter, or `null` if not set.
inactive_days:
type:
- number
- 'null'
description: Inactivity filter in days, or `null` if not set.
created_at:
type: string
description: ISO 8601 creation timestamp.
updated_at:
type: string
description: ISO 8601 last-updated timestamp.
example:
object: segment
id: seg_abc123
publication_id: pub_abc123
name: Engaged Subscribers
description: Subscribers who opened at least one email
status_filter: active
query_filter: null
inactive_days: null
created_at: '2026-03-29T10:00:00.000Z'
updated_at: '2026-03-29T10:00:00.000Z'
'400':
description: Missing required `publication_id` query parameter.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized — missing or invalid token.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden — publication not owned by your organization.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Segment not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth:
- contacts:read
- bearerAuth:
- issues:write
x-mailtea-scopes:
- contacts:read
- issues:write
patch:
operationId: updateSegment
summary: Update Segment
description: 'Update an audience segment''s name, description, or filters
Update an existing audience segment. You can change its name, description, status filter, query filter, and inactivity filter. Pass `null` for `status_filter`, `query_filter` or `inactive_days` to clear it. Clearing all three turns the segment into a member list.
Setting `status_filter`, `query_filter` or `inactive_days` on a segment that already has contacts added to it returns `400`: a segment is a member list or a filter, never both. Remove its contacts first. See Segments & topics.'
tags:
- Segments
externalDocs:
url: https://docs.mailtea.app/docs/api-reference/segments/update-segment
parameters:
- name: id
in: path
required: true
description: The segment ID.
schema:
type: string
- name: publication_id
in: query
required: true
description: The publication the segment belongs to.
schema:
type: string
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: Updated segment name. 1–200 characters.
description:
type: string
description: Updated description. Max 1000 characters.
status_filter:
type:
- string
- 'null'
description: 'Updated status filter: `active`, `unsubscribed`, `suppressed`, or `null` to clear.'
query_filter:
type:
- string
- 'null'
description: Updated query filter, or `null` to clear. Max 2000 characters.
inactive_days:
type:
- integer
- 'null'
description: Select contacts with no open or click in the last N days. An integer, 1 to 3650. A contact who has never opened or clicked counts as inactive, so this finds the silent part of your list for a sunset or re-engagement send; it is not a filter for engaged readers. See [Inactive contacts](/docs/documentation/segments-topics#inactive-contacts) for how engagement is tracked. Pass `null` to clear it.
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
object:
type: string
description: Always `"segment"`.
id:
type: string
description: Unique segment identifier.
publication_id:
type: string
description: The publication this segment belongs to.
name:
type: string
description: Segment name.
description:
type: string
description: Segment description.
status_filter:
type:
- string
- 'null'
description: Contact status filter, or `null` if cleared.
query_filter:
type:
- string
- 'null'
description: Custom query filter, or `null` if cleared.
inactive_days:
type:
- number
- 'null'
description: Inactivity filter in days, or `null` if cleared.
created_at:
type: string
description: ISO 8601 creation timestamp.
updated_at:
type: string
description: ISO 8601 last-updated timestamp.
example:
object: segment
id: seg_abc123
publication_id: pub_abc123
name: Highly Engaged
description: Subscribers who opened at least one email
status_filter: active
query_filter: opened_count:>5
inactive_days: null
created_at: '2026-03-29T10:00:00.000Z'
updated_at: '2026-03-29T12:00:00.000Z'
'400':
description: Validation failed — invalid fields or missing `publication_id`.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized — missing or invalid token.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden — insufficient permissions or publication not owned by your organization.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Segment not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth:
- contacts:write
x-mailtea-scopes:
- contacts:write
components:
schemas:
Error:
type: object
description: Every error body carries `error`; validation failures add `details` and some refusals add a machine-readable `code`.
properties:
error:
type: string
code:
type: string
details:
type: array
items:
type: object
required:
- error
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: A Mailtea API key. Scopes such as `contacts:write` are properties of the key, chosen when it is created; each operation lists the scope it needs under `x-mailtea-scopes`. See https://docs.mailtea.app/docs/api-reference/authentication.
externalDocs:
description: API reference
url: https://docs.mailtea.app/docs/api-reference