API reference
Mailprompt API version 1.0.0. This page is rendered from the OpenAPI 3.1 document that the contract tests validate against, so every operation below exists in the running API. The raw document is at /openapi.json.
mp_test_) persist nothing and charge nothing.Authentication, errors, rate limits, pagination, idempotency and webhooks are documented in the developer guide. Every operation is grouped by tag below.
Profiles
3 operations
/v1/profilesList profiles
Cursor-paginated, newest id first. Scoped to the key's account.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of profiles. (ProfileList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/profiles?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/profilesCreate or update a profile by email
Upserts on the normalised email. `properties` is shallow-merged into the existing record. A suppressed profile cannot be resubscribed through the API (`409 conflict`). Returns 201 when created, 200 when updated. In test mode the response is synthetic and nothing is persisted.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
ProfileUpsertRequest
emailstring (email) requiredfirst_namestringlast_namestringphonestringpropertiesobjectconsent_statusstringconsent_sourcestring
200The profile was updated. (Profile)201The profile was created. (Profile)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/profiles' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"email":"[email protected]"}'/v1/profiles/{id}Get a profile
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The profile. (Profile)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/profiles/your_id' \
-H 'Authorization: Bearer mp_live_your_key'Events
1 operation
/v1/eventsTrack one event or a batch of up to 100
`events:write` uses its own rate-limit bucket at 10× the plan rate. Events with a `unique_id` are idempotent per `(account, metric, unique_id)`; duplicates are reported, not re-inserted. In test mode the response is synthetic and no events are stored.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
EventsRequest
eventEventInput requiredmetricstring requiredprofile_idstringemailstring (email)propertiesobjectvalueintegercurrencystringoccurred_atstring (ISO-8601)unique_idstring
202Events accepted. (EventsResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/events' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"event":{"metric":"string"}}'Lists
8 operations
/v1/listsList contact lists
Cursor-paginated, newest id first. Includes archived lists so callers can audit them.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of lists. (ListList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/lists?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/listsCreate a contact list
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
CreateListRequest
namestring requireddescriptionstring | nullconsent_modestringkindstring
201The created list. (ListResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/lists' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string"}'/v1/lists/{id}Get a list with member and consent counts
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The list. (ListResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/lists/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/lists/{id}Rename a list or change its consent mode
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
UpdateListRequest
namestringdescriptionstring | nullconsent_modestring
200The updated list. (ListResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X PATCH 'https://api.mailprompt.ai/v1/lists/your_id' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string"}'/v1/lists/{id}Archive a list
Archived lists keep their members and evidence but are hidden from campaign pickers.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
204List archived. (none)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X DELETE 'https://api.mailprompt.ai/v1/lists/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/lists/{id}/membersList the people on a list
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of members with their consent evidence. (ListMemberPage)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/lists/your_id/members?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/lists/{id}/membersAdd profiles to a list
All profile ids must belong to the key's account; otherwise 404. At most 1,000 ids per request. Test mode persists nothing.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
AddMembersRequest
profile_idsarray of string requiredsourcestringconsent_evidenceone of ConsentEvidence | nullsourcestring requiredconsentedbooleantextShownstringipstringformIdstringimportIdstringatinteger
201Members added (duplicates counted in `already_members`). (ListMembersResponse)202At or above 1,000 people the addition waits for human approval; nothing was added. (ListMembersResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/lists/your_id/members' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"profile_ids":["string"]}'/v1/lists/{id}/members/{profileId}Remove a profile from a list
204 on success, 404 when the list or membership does not exist.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
profileId | path | string | Yes |
204Member removed. (none)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X DELETE 'https://api.mailprompt.ai/v1/lists/your_id/members/profile_123' \
-H 'Authorization: Bearer mp_live_your_key'Segments
7 operations
/v1/segmentsList segments with their cached counts
Counts are the cached values written by the segment evaluator (`counted_at` says when). Live evaluation is not performed on this path.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of segments. (SegmentList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/segments?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/segmentsCreate a draft segment
The definition is validated against this account's real lists, tags, metrics, properties, products, collections and segments. Costs 1 credit and emails nobody.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
CreateSegmentRequest
namestring requireddescriptionstring | nulldefinitionobject required
201The created segment. (SegmentResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)402Not enough credits for this billable write. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/segments' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string","definition":{}}'/v1/segments/{id}Get a segment
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The segment with its definition and summary. (SegmentResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/segments/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/segments/{id}Save a new segment version
If a live flow or scheduled campaign uses the segment, the change returns `approval_required: true` and is not applied until an owner approves it. Costs 1 credit.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
UpdateSegmentRequest
namestringdescriptionstring | nulldefinitionobject
200The updated segment, or the pending approval. (SegmentResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)402Not enough credits for this billable write. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X PATCH 'https://api.mailprompt.ai/v1/segments/your_id' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string"}'/v1/segments/{id}/countCached profile count for a segment
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The cached count. (SegmentCount)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/segments/your_id/count' \
-H 'Authorization: Bearer mp_live_your_key'/v1/segments/{id}/membersPage the people currently in a segment
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of matching profiles. (SegmentMemberPage)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/segments/your_id/members?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/segments/previewValidate and count a segment definition
Uses a 5 second statement timeout and returns `slow: true` instead of hanging. Free.
Request body
PreviewSegmentRequest
segment_idstringdefinitionobject
200Validation result, count, summary and masked sample. (PreviewSegmentResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/segments/preview' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"segment_id":"string"}'Flows
4 operations
/v1/flowsList flows
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of flows. (FlowList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/flows?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/flowsCreate a flow draft
Creates a `draft` only. Costs 10 credits (PLAN §2); `?dry_run=true` returns `{ dry_run: true, credits: 10 }` and changes nothing. Asking for `status: live` is refused with `409 approval_required`: create the draft, request approval, and let a human activate it. Document, segment and list ids referenced by the definition must belong to the key's account (404).
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
dry_run | query | boolean | No | On a billable write, return the credit cost and change nothing. |
Request body
CreateFlowRequest
namestring requireddefinitionFlowDefinitionInput required — The trigger/audience/steps a client sends; the API adds the identity fields.triggerFlowTrigger requiredmetricstring requiredwhereobject
audienceFlowAudience requiredreentryDaysintegerexitOnarray of FlowEventRulequietHoursQuietHoursstartinteger requiredendinteger required
stepsarray of FlowStep required
statusstring
200Dry run result (`?dry_run=true`). (DryRun)201The draft flow. (Flow)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)402Not enough credits for this billable write. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/flows' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string","definition":{"trigger":{"metric":"string"},"audience":"any","steps":[{"wait":{}}]}}'/v1/flows/{id}Get a flow with its definition
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The flow. (Flow)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/flows/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/flows/{id}/request-approvalRequest a human go-live approval for a draft flow
Creates a pending `Approval` (`kind: flow_live`) through the core approval constructor and returns 202. The target id is `{flowId}@v{version}` and the snapshot hash covers the whole definition, exactly what the engine's `goLiveFlow()` checks. Repeating the call with unchanged content returns the pending approval; an expired row is marked `expired` and a fresh one is created. The API never flips a flow live. Core runs the pre-send checklist on every referenced email first; a failing check returns 422 with the failures in `error.details.checks`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
202The pending approval. (Approval)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422The pre-send checklist (PLAN §9 #12) blocked the approval request. `error.code` is `validation_failed`; `error.details.checks` lists each document it rendered and the failing checks, so a client can show the human exactly what to fix. A missing brand kit is reported the same way; a missing or invalid referenced document also returns `422 validation_failed`. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/flows/your_id/request-approval' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13'Campaigns
3 operations
/v1/campaignsList campaigns
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of campaigns. (CampaignList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/campaigns?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/campaignsCreate a campaign draft
Creates a `draft` only. Costs 5 credits; `?dry_run=true` returns the cost and changes nothing. `schedule_at` is refused with `409 approval_required`: create the draft, request approval, and let a human schedule/send it.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
dry_run | query | boolean | No | On a billable write, return the credit cost and change nothing. |
Request body
CreateCampaignRequest — `document_id` is required to create a campaign; it is optional in the
schema only so `?dry_run=true` needs nothing but a name. The content
fields are persisted so the core `campaign_snapshot` can hash them.
namestring requireddocument_idstringsubjectstringsegment_idstringpreheaderstringmarketingboolean — Defaults to true.coupon_rule_idstringvariantsarray of CampaignVarianttest_percentinteger — Defaults to 20.decide_after_minutesinteger — Defaults to 240.schedule_atstring (ISO-8601)
200Dry run result (`?dry_run=true`). (DryRun)201The draft campaign. (Campaign)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)402Not enough credits for this billable write. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/campaigns' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"name":"string"}'/v1/campaigns/{id}/request-approvalRequest a human send approval for a draft campaign
Creates a pending `Approval` (`kind: campaign_send`) through `requestCampaignApproval` and returns 202. The snapshot hash covers the campaign content config plus the segment definition, exactly what `scheduleCampaign()` checks. Expired or stale rows are ignored. Core runs the pre-send checklist first; a failing check returns 422 with the failures in `error.details.checks`. The API never sends email.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
202The pending approval. (Approval)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422The pre-send checklist (PLAN §9 #12) blocked the approval request. `error.code` is `validation_failed`; `error.details.checks` lists each document it rendered and the failing checks, so a client can show the human exactly what to fix. A missing brand kit is reported the same way; a missing or invalid referenced document also returns `422 validation_failed`. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/campaigns/your_id/request-approval' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13'Results
1 operation
/v1/results/summaryRevenue, sends, opens, clicks and bounces for a date range
Defaults to the last 30 days. The range is capped at 366 days. Heavy endpoint: consumes 5 rate-limit tokens. Uses click-based attribution (opens are reported but never used for revenue).
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
from | query | string (ISO-8601) | No | |
to | query | string (ISO-8601) | No |
200The summary. (ResultsSummary)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/results/summary' \
-H 'Authorization: Bearer mp_live_your_key'Account
2 operations
/v1/accountThe key's account, plan and API allowance
200The account. (Account)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/account' \
-H 'Authorization: Bearer mp_live_your_key'/v1/creditsThe account's credit balance
200The balance. (Credits)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/credits' \
-H 'Authorization: Bearer mp_live_your_key'Webhooks
9 operations
/v1/webhooksList webhook endpoints
Every endpoint registered for the key's account. Reads use the `webhooks:read` scope. Signing secrets are never returned; they are shown once at creation or rotation.
200The account's endpoints. (WebhookList)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/webhooks' \
-H 'Authorization: Bearer mp_live_your_key'/v1/webhooksRegister a webhook endpoint
The URL must be https, have no embedded credentials and resolve only to public addresses (the SSRF check runs again on every delivery). Events come from the fixed catalogue. An account can have at most 20 endpoints. The response includes the signing secret exactly once; store it before leaving the page. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
WebhookCreateRequest
urlstring requiredeventsarray of WebhookEventType requireddescriptionstring | null
201Created. `secret` is shown only in this response. (WebhookCreateResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)409State conflict, concurrent idempotent request, or an approval is required / already granted. (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/webhooks' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"url":"string","events":["profile.subscribed"]}'/v1/webhooks/{id}Get a webhook endpoint
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes |
200The endpoint. (WebhookResponse)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/webhooks/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/webhooks/{id}Update a webhook endpoint
Change the URL (re-checked with the https + SSRF guard), the subscribed events or whether the endpoint is enabled. Re-enabling clears the failure streak. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
Request body
WebhookUpdateRequest
urlstringeventsarray of WebhookEventTypeenabledboolean
200The updated endpoint. (WebhookResponse)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)422Zod validation failed; `error.fields` maps field paths to messages. (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X PATCH 'https://api.mailprompt.ai/v1/webhooks/your_id' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13' \
-H 'Content-Type: application/json' \
--data '{"url":"string"}'/v1/webhooks/{id}Delete a webhook endpoint
Stops future deliveries and removes the endpoint's delivery log. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
204Deleted. (none)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X DELETE 'https://api.mailprompt.ai/v1/webhooks/your_id' \
-H 'Authorization: Bearer mp_live_your_key'/v1/webhooks/{id}/deliveriesList the last 30 days of deliveries for an endpoint
Cursor-paginated, newest first. Each row reports the event, status, HTTP status, attempt number, duration and time. Rows older than 30 days are purged. Requires `webhooks:read`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
limit | query | integer | No | |
cursor | query | string | No | Opaque `next_cursor` from the previous page. |
200A page of deliveries. (WebhookDeliveryList)400Malformed request, invalid cursor, oversized body or an API key passed in the query string. (ErrorEnvelope)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X GET 'https://api.mailprompt.ai/v1/webhooks/your_id/deliveries?limit=50' \
-H 'Authorization: Bearer mp_live_your_key'/v1/webhooks/{id}/rotate-secretRotate a webhook signing secret
Replaces the secret and returns the new value exactly once. Deliveries already queued with the old secret will fail verification; update the receiver promptly. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
200The new secret and the updated endpoint. (WebhookSecretResponse)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/webhooks/your_id/rotate-secret' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13'/v1/webhooks/{id}/testQueue a signed webhook.test event
Queues one `webhook.test` delivery for this endpoint. It is signed with the endpoint secret and sent by the delivery worker like any other event; `webhook.test` is not subscribable. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
202The test event is queued. (WebhookTestResponse)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/webhooks/your_id/test' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13'/v1/webhooks/deliveries/{id}/redeliverRedeliver a logged delivery
Re-queues the same event with the same event id and payload, so a receiver can deduplicate it against the original. The retry count starts again. Requires `webhooks:write`.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | |
Idempotency-Key | header | string | No | Up to 100 characters. The first response is stored for 24 hours and replayed for the same method, path and body; a different body returns `409 idempotency_mismatch`; a concurrent duplicate returns `409 conflict`. |
202The delivery is queued again. (WebhookDeliveryResponse)401Missing, malformed, unknown, revoked or expired API key. (ErrorEnvelope)403Missing scope, IP not allowed, unknown/read-only plan. (ErrorEnvelope)404The resource does not exist in this account (cross-store ids are 404). (ErrorEnvelope)429Rate limit or monthly quota exceeded; see `Retry-After`. (ErrorEnvelope)500Unexpected error. No stack traces or internal messages are returned. (ErrorEnvelope)
curl -X POST 'https://api.mailprompt.ai/v1/webhooks/deliveries/your_id/redeliver' \
-H 'Authorization: Bearer mp_live_your_key' \
-H 'Idempotency-Key: 1f0c9d2e-4b7a-4c3e-9d61-2a8b5c0e7f13'