openapi: 3.1.0
info:
  title: MessagePipe Send API
  version: "1.0"
  description: >
    Public high-throughput send API (spec §C.7). Accepts email / SMS / chat / push
    sends (single and bulk), returns 202 with a queued send; delivery is async.
    Authenticated with a workspace API key as a Bearer token (`mp_live_...`).
servers:
  - url: https://api.messagepipe.dev
    description: Development
  - url: http://localhost:8080
    description: Local
security:
  - apiKey: []
tags:
  - { name: Send, description: Submit messages for delivery (§C.7.1) }
  - { name: Sends, description: Inspect and retry sends }
  - { name: Templates, description: List and fetch templates }
  - { name: Contacts, description: "Contacts and their consent (Campaigns C0). Test API keys are refused." }
  - { name: Suppressions, description: Addresses that must not be mailed }
  - { name: Credits, description: "The credit balance every send spends from: transactional, campaign and test sends alike. Test API keys are refused." }
  - { name: Inbound, description: "Received email (the Inbox API): replies to your sends and mail to your receiving domains. Scopes inbound:read / inbound:write. See docs/inbound-email.md." }
  - { name: System, description: Health }
  # >>> generated:tags (scripts/openapi_gateway.py; do not edit by hand)
  - name: Brands
    description: Brands (sender identities) and their sender domains
  - name: Content
    description: Campaign templates, brand layouts, preview, pre-flight checks and test sends
  - name: Campaigns
    description: 'Campaigns and newsletters: drafts, pre-flight, send, schedule, pause, cancel and results'
  - name: Consent statements
    description: Versioned consent wording; evidence once used
  - name: Signup forms
    description: Hosted and embeddable signup forms that record express consent against a registered statement
  - name: Imports
    description: CSV contact import with a consent attestation and a dry run
  - name: Segments
    description: Dynamic (rule-based) and static (hand-picked) groups of contacts
  - name: Topics
    description: Subscription topics on a brand
  - name: Workspace settings
    description: Suppression mode and unsubscribe scope
  # <<< generated:tags
paths:
  /healthz:
    get:
      tags: [System]
      x-speakeasy-ignore: true
      summary: Liveness / readiness (Postgres + Redis)
      security: []
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/Health" } } } }
        "503": { description: A dependency is unavailable }
  /v1/email/send:
    post:
      x-mp-scope: "send:email"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Email]
      operationId: sendEmail
      summary: Send a single email
      x-speakeasy-name-override: send
      description: >
        Requires the `send:email` scope. Provide either `template` or both `subject` and
        `html`. Field names are matched exactly; a known field spelled differently (`From`,
        `Subject`) is a 400 with `details.constraint` `key:case`.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/EmailSend" } } }
      responses:
        "200": { description: "Recorded but not sent: the address is suppressed or has no valid consent. `status` is `suppressed` and `suppression.code` says why. Nothing was queued and no credit was used.", content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "202": { description: Accepted (queued), content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/sms/send:
    post:
      x-mp-scope: "send:sms"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [SMS]
      operationId: sendSMS
      summary: Send a single SMS
      x-speakeasy-name-override: send
      description: |
        Requires the `send:sms` scope. Provide either `template` or `body`.

        When the send goes through a MessagePipe managed SMS provider, `to` must be an E.164 number and the
        message is billed from the managed SMS bucket at accept time: `segments x credits(country, message_type)`,
        where the credit weight of the destination country comes from the active rate sheet. A destination
        without a price (or managed SMS not on sale) is refused with 422 `sms_destination_not_supported` and
        nothing is charged; too few credits is 402 `credits_exhausted`, naming the credits needed and available.
        Sends through your own provider keys cost one credit and are not affected.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/TextSend" } } }
      responses:
        "202": { description: Accepted (queued), content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "422": { $ref: "#/components/responses/UnprocessableSMS" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/chat/send:
    post:
      x-mp-scope: "send:chat"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Chat]
      operationId: sendChat
      x-speakeasy-name-override: send
      summary: Send a single chat message
      description: Requires the `send:chat` scope. Provide either `template` or `body`.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/TextSend" } } }
      responses:
        "202": { description: Accepted (queued), content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/push/send:
    post:
      x-mp-scope: "send:push"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Push]
      operationId: sendPush
      x-speakeasy-name-override: send
      summary: Send a single push notification
      description: Requires the `send:push` scope. `to` must carry a `device_token` or `user_id`. Provide either `template` or both `title` and `body`.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/PushSend" } } }
      responses:
        "202": { description: Accepted (queued), content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/email/send-bulk:
    post:
      x-mp-scope: "send:email"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Email]
      operationId: sendBulkEmail
      x-speakeasy-name-override: sendBulk
      summary: Send up to 1,000 emails in one request
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/BulkRequest" } } }
      responses:
        "207": { description: Per-message result, content: { application/json: { schema: { $ref: "#/components/schemas/BulkResult" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
  /v1/sms/send-bulk:
    post:
      x-mp-scope: "send:sms"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [SMS]
      operationId: sendBulkSMS
      x-speakeasy-name-override: sendBulk
      summary: Send up to 1,000 SMS in one request
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/BulkRequest" } } }
      responses:
        "207": { description: Per-message result, content: { application/json: { schema: { $ref: "#/components/schemas/BulkResult" } } } }
  /v1/chat/send-bulk:
    post:
      x-mp-scope: "send:chat"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Chat]
      operationId: sendBulkChat
      x-speakeasy-name-override: sendBulk
      summary: Send up to 1,000 chat messages in one request
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/BulkRequest" } } }
      responses:
        "207": { description: Per-message result, content: { application/json: { schema: { $ref: "#/components/schemas/BulkResult" } } } }
  /v1/push/send-bulk:
    post:
      x-mp-scope: "send:push"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit per message from the channel's bucket (a managed SMS costs segments x the destination's credit weight). A suppressed or no-consent recipient costs nothing."
      x-mp-gateway: false
      tags: [Push]
      operationId: sendBulkPush
      x-speakeasy-name-override: sendBulk
      summary: Send up to 1,000 push notifications in one request
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/BulkRequest" } } }
      responses:
        "207": { description: Per-message result, content: { application/json: { schema: { $ref: "#/components/schemas/BulkResult" } } } }
  /v1/push/devices:
    post:
      x-mp-scope: "send:push"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Push, Device]
      operationId: registerDevice
      x-speakeasy-name-override: register
      summary: Register (or refresh) a device token for a user
      description: >
        Requires the `send:push` scope. Stores an FCM/APNs device token against
        your own `user_id` so pushes can target `to.user_id`. Re-posting the same
        token refreshes it and re-points it at the given user. A push to a
        `user_id` fans out to all of that user's registered devices, billed as
        one send; invalid/expired tokens are pruned automatically.
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/DeviceRegistration" } } }
      responses:
        "200": { description: Registered, content: { application/json: { schema: { $ref: "#/components/schemas/DeviceRegistered" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
    delete:
      x-mp-scope: "send:push"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Push, Device]
      operationId: deleteDevice
      x-speakeasy-name-override: remove
      summary: Remove a registered device token
      description: Requires the `send:push` scope. Pass the token as the `token` query parameter or in the JSON body.
      parameters:
        - { name: token, in: query, required: false, schema: { type: string } }
      responses:
        "200": { description: Removed, content: { application/json: { schema: { type: object, properties: { status: { type: string, example: deleted } } } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/sends:
    get:
      x-mp-scope: "none"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Sends]
      operationId: listSends
      x-speakeasy-name-override: list
      summary: List recent sends (filterable, cursor-paginated)
      parameters:
        - { name: channel, in: query, schema: { type: string, enum: [email, sms, chat, push] } }
        - { name: status, in: query, schema: { type: string, enum: [queued, dispatching, sent, delivered, failed, bounced, suppressed] } }
        - { name: provider, in: query, schema: { type: string } }
        - { name: template_id, in: query, schema: { type: string } }
        - { name: recipient, in: query, schema: { type: string } }
        - { name: tag, in: query, schema: { type: string } }
        - { name: from, in: query, schema: { type: string, format: date-time } }
        - { name: to, in: query, schema: { type: string, format: date-time } }
        - { name: limit, in: query, schema: { type: integer, default: 50, minimum: 1, maximum: 200 } }
        - { name: cursor, in: query, schema: { type: string } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/SendList" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
  /v1/sends/{id}:
    get:
      x-mp-scope: "none"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Sends]
      operationId: getOneSend
      x-speakeasy-name-override: get
      summary: Get a send and its event history
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/SendDetail" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/sends/{id}/retry:
    post:
      x-mp-scope: "send:{channel}"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 credit, as a new send of the same channel."
      x-mp-gateway: false
      tags: [Sends]
      operationId: retrySend
      x-speakeasy-name-override: retry
      summary: Retry a failed send (creates a new send with the same content)
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "202": { description: Accepted (queued), content: { application/json: { schema: { $ref: "#/components/schemas/SendAccepted" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "422": { $ref: "#/components/responses/UnprocessableSMS" }
  /v1/templates:
    get:
      x-mp-scope: "templates:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Templates]
      operationId: listTemplates
      x-speakeasy-name-override: list
      summary: List templates (optionally filtered by channel)
      description: Requires the `templates:read` scope.
      parameters:
        - { name: channel, in: query, schema: { type: string, enum: [email, sms, chat, push] } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/TemplateList" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/templates/{id}:
    get:
      x-mp-scope: "templates:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Templates]
      operationId: getOneTemplate
      x-speakeasy-name-override: get
      summary: Get a template by id
      description: Requires the `templates:read` scope.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/Template" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/contacts:
    post:
      x-mp-scope: "contacts:write"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: upsertContact
      x-speakeasy-name-override: upsert
      summary: Create or update a contact
      description: >
        Requires `contacts:write`. Matches an existing contact by `email`, `phone` or `external_id`
        (email and phone are normalised first) and merges the supplied fields into it; otherwise
        creates one. Returns 201 when created, 200 when updated. An identity the contact lacks is
        added; a different value for one it already has, or identities that belong to two
        contacts, is 409 `identity_conflict` (changing identity is not supported yet).
        Attribute types are inferred from the first value seen for a key (string, number, boolean,
        list of strings) and fixed after that; `null` removes an attribute. At most 50 attributes
        per request. With a `consent` object the contact and its consent are written together.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/ContactInput" } } }
      responses:
        "200": { description: Updated, content: { application/json: { schema: { $ref: "#/components/schemas/Contact" } } } }
        "201": { description: Created, content: { application/json: { schema: { $ref: "#/components/schemas/Contact" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409": { $ref: "#/components/responses/Conflict" }
        "429": { $ref: "#/components/responses/RateLimited" }
    get:
      x-mp-scope: "contacts:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: findContacts
      x-speakeasy-name-override: find
      summary: Find a contact by email, phone or external_id
      description: Requires `contacts:read`. Exactly one query parameter. `data` holds zero or one contact.
      parameters:
        - { name: email, in: query, schema: { type: string } }
        - { name: phone, in: query, schema: { type: string } }
        - { name: external_id, in: query, schema: { type: string } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { type: object, properties: { data: { type: array, items: { $ref: "#/components/schemas/Contact" } } } } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/contacts/{id}:
    get:
      x-mp-scope: "contacts:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: getContact
      x-speakeasy-name-override: get
      summary: Get a contact with its consent summary
      description: Requires `contacts:read`. `consent` lists records for this project's brands only. An erased contact returns status `erased` with no identity.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/Contact" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    patch:
      x-mp-scope: "contacts:write"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: updateContact
      x-speakeasy-name-override: update
      summary: Update a contact's profile
      description: Requires `contacts:write`. Accepts `first_name`, `last_name`, `locale`, `timezone`, `country`, `attributes`. `null` clears a field. Email, phone and external_id cannot be changed.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/ContactPatch" } } }
      responses:
        "200": { description: Updated, content: { application/json: { schema: { $ref: "#/components/schemas/Contact" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/contacts/{id}/consent:
    post:
      x-mp-scope: "consent:write"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: writeConsent
      x-speakeasy-name-override: writeConsent
      summary: Record consent (or a withdrawal) with its evidence
      description: >
        Requires `consent:write`. A subscribe write must carry the evidence in the request: the
        registered `statement` the person saw, `basis`, `method`, `captured_at`,
        `channel_context` (with `ip` and `user_agent` for web/app, or a `channel_context_reason`
        for server/pos/phone), plus the basis-specific fields. Everything missing is reported at
        once in 422 `consent_evidence_incomplete` (`details.missing`); unacceptable evidence is
        422 `consent_evidence_invalid` (`details.reason`). Valid writes earn tier B (customer-reported),
        or C when `backfill` is true. A record's tier never goes down. A topic with
        `double_opt_in: required` becomes `pending`. A request either subscribes or
        unsubscribes (`method: api_withdrawal`, no evidence needed), never both.
        409 `recent_recipient_withdrawal` when the recipient unsubscribed themselves (one-click,
        mailbox provider, complaint) within the last 24 hours.
        `warnings` may include `address_suppressed` (the consent is recorded, but sends to the
        address will be refused) and `evidence_below_topic_minimum`.
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
        - { $ref: "#/components/parameters/IdempotencyKey" }
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/ConsentWrite" } } }
      responses:
        "200": { description: Recorded, content: { application/json: { schema: { $ref: "#/components/schemas/ConsentWriteResult" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409": { $ref: "#/components/responses/Conflict" }
        "422": { $ref: "#/components/responses/Unprocessable" }
    get:
      x-mp-scope: "contacts:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: getConsent
      x-speakeasy-name-override: getConsent
      summary: Current consent records and recent history
      description: Requires `contacts:read`. The last 50 events, newest first, for this project's brands.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/ConsentState" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/contacts/{id}/consent/evidence:
    get:
      x-mp-scope: "contacts:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: getConsentEvidence
      x-speakeasy-name-override: getConsentEvidence
      summary: Export the proof of consent
      description: >
        Requires `contacts:read`. Every event with all evidence fields, the canonical JSON that
        was hashed, its place in the workspace hash chain (`sealed: false` until the asynchronous
        sealer reaches it; `chain.hash_ok` is a recomputation of the hash), and the exact
        statement text shown. Up to 1000 events; `truncated` says when there are more.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      responses:
        "200": { description: OK, content: { application/json: { schema: { type: object, additionalProperties: true } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/contacts/{id}/erase:
    post:
      x-mp-scope: "contacts:erase"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Contacts]
      operationId: eraseContact
      x-speakeasy-name-override: erase
      summary: Erase a contact (irreversible)
      description: >
        Requires `contacts:erase`. Body `{"confirm": "<contact id>"}`. In one transaction: the
        address is suppressed (keyed hash only) so the person cannot be mailed again, live consent
        is withdrawn and deleted, the contact is reduced to a tombstone, and the consent events
        are pseudonymised (the hash chain still verifies). Send history follows the send
        retention schedule and is not changed by this call. Repeating it is a no-op.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      requestBody:
        required: true
        content: { application/json: { schema: { type: object, required: [confirm], properties: { confirm: { type: string } } } } }
      responses:
        "200": { description: Erased, content: { application/json: { schema: { $ref: "#/components/schemas/EraseResult" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/suppressions:
    get:
      x-mp-scope: "suppressions:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Suppressions]
      operationId: listSuppressions
      x-speakeasy-name-override: list
      summary: List suppressions, or check one address
      description: >
        Requires `suppressions:read`. Suppressions store only a keyed hash of the address, so the
        list cannot show addresses (`address_key_prefix` is a fragment of the hash). Pass
        `address` to ask whether it is suppressed. Active rows only unless `include_removed=true`.
      parameters:
        - { name: address, in: query, schema: { type: string } }
        - { name: channel, in: query, schema: { type: string, enum: [email, sms, chat, push], default: email } }
        - { name: reason, in: query, schema: { type: string } }
        - { name: source, in: query, description: How the suppression was created, schema: { type: string, enum: [manual, import, bounce, complaint, unsubscribe, global] } }
        - { name: brand, in: query, description: A brand id, or `none` for workspace-wide suppressions, schema: { type: string } }
        - { name: source_send_id, in: query, description: Suppressions caused by one send, schema: { type: string } }
        - { name: created_from, in: query, description: YYYY-MM-DD or RFC 3339 (inclusive), schema: { type: string } }
        - { name: created_to, in: query, description: YYYY-MM-DD (the whole day is included) or RFC 3339 (exclusive), schema: { type: string } }
        - { name: include_removed, in: query, schema: { type: boolean } }
        - { name: limit, in: query, schema: { type: integer, default: 50, minimum: 1, maximum: 200 } }
        - { name: cursor, in: query, schema: { type: string } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/SuppressionList" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
    post:
      x-mp-scope: "suppressions:write"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Suppressions]
      operationId: createSuppression
      x-speakeasy-name-override: create
      summary: Suppress an address
      description: >
        Requires `suppressions:write`. `reason` is `manual` or `unsubscribed` (bounces and
        complaints come only from provider feedback). `brand` scopes an `unsubscribed` suppression
        to one brand. 201 when created; 200 with the existing row when already suppressed.
      parameters: [ { $ref: "#/components/parameters/IdempotencyKey" } ]
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/SuppressionInput" } } }
      responses:
        "200": { description: Already suppressed, content: { application/json: { schema: { $ref: "#/components/schemas/Suppression" } } } }
        "201": { description: Created, content: { application/json: { schema: { $ref: "#/components/schemas/Suppression" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/suppressions/{id}:
    delete:
      x-mp-scope: "suppressions:write"
      x-mp-role: key
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Suppressions]
      operationId: removeSuppression
      x-speakeasy-name-override: remove
      summary: Remove a suppression
      description: >
        Requires `suppressions:write`. Body `{"reason": "..."}` is required and recorded with the
        key that removed it. Removing a `complaint` or `hard_bounce` suppression needs an API key
        created by a workspace owner or admin (403 otherwise) and `"confirm_protected": true` in the body
        (400, constraint `confirm:protected_reason`, otherwise); the audit event records `confirmed_protected`.
      parameters: [ { name: id, in: path, required: true, schema: { type: string } } ]
      requestBody:
        required: true
        content: { application/json: { schema: { type: object, required: [reason], properties: { reason: { type: string, minLength: 3, maxLength: 500 }, confirm_protected: { type: boolean, description: "Required to remove a complaint or hard_bounce suppression" } } } } }
      responses:
        "200": { description: Removed (or already removed), content: { application/json: { schema: { $ref: "#/components/schemas/Suppression" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/credits:
    get:
      x-mp-scope: "credits:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Credits]
      operationId: getCredits
      x-speakeasy-name-override: balance
      summary: Credit balance per channel
      description: >
        One balance per credit bucket, shared by transactional sends, campaign messages and test sends.
        The buckets are `email`, `sms`, `push` and `chat` (sends through your own provider keys), followed
        by `email_managed` and `sms_managed`: sends through MessagePipe's managed providers (managed
        email on Amazon SES, managed SMS) are billed from these, not from the plain channel. A bucket
        you hold no credits in reports zero. A send is billed from the bucket of the provider it is
        routed to first; if it fails over to a provider of the other kind it stays billed from the first
        provider's bucket. Requires the `credits:read` scope.
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/CreditBalanceList" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/credits/transactions:
    get:
      x-mp-scope: "credits:read"
      x-mp-role: key
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Credits]
      operationId: listCreditTransactions
      x-speakeasy-name-override: listTransactions
      summary: Credit ledger (grants, top-ups, refunds, adjustments)
      description: >
        Newest first. Spend on individual messages is not a ledger row: it is the send itself
        (`GET /v1/sends`) and, for a campaign, its report. Requires the `credits:read` scope.
      parameters:
        - { name: channel, in: query, description: "Credit bucket to filter by. `email_managed` and `sms_managed` are the buckets managed sends are billed from; `email_inbound` is received email.", schema: { type: string, enum: [email, sms, push, chat, email_managed, sms_managed, email_inbound] } }
        - { name: before, in: query, description: "Return entries older than this timestamp (use `next_before`).", schema: { type: string, format: date-time } }
        - { name: limit, in: query, schema: { type: integer, default: 50, minimum: 1, maximum: 200 } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/CreditLedgerList" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "422": { $ref: "#/components/responses/Unprocessable" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /v1/inbound/messages:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: listInboundMessages
      summary: List received messages
      description: Newest first, for the API key's project. Metadata only; fetch one message for its bodies. Requires `inbound:read`.
      parameters:
        - { name: thread_id, in: query, schema: { type: string } }
        - { name: send_id, in: query, description: Messages that reply to this send., schema: { type: string } }
        - { name: from, in: query, description: Sender address (case-insensitive)., schema: { type: string } }
        - { name: mailbox, in: query, description: "A mailbox id: messages filed under it. `none`: messages filed under no mailbox.", schema: { type: string } }
        - { name: unread, in: query, schema: { type: boolean } }
        - { name: archived, in: query, schema: { type: boolean } }
        - { name: cursor, in: query, schema: { type: string } }
        - { name: limit, in: query, schema: { type: integer, default: 25, minimum: 1, maximum: 100 } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/InboundMessageList" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/inbound/messages/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: getInboundMessage
      summary: Get a received message with its bodies
      description: >
        `text`, `html` and `reply_text` (the new text with quoted history and signature removed, a
        heuristic) are present while `content_status` is `stored`. `html` is returned as received: sanitize
        it before rendering. Requires `inbound:read`.
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/InboundMessage" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "503": { description: Message bodies cannot be read right now }
    patch:
      x-mp-scope: "inbound:write"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: updateInboundMessage
      summary: Mark a message read/unread or archived
      description: Requires `inbound:write`.
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, properties: { read: { type: boolean }, archived: { type: boolean } } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/InboundMessage" } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      x-mp-scope: "inbound:write"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: deleteInboundMessage
      summary: Delete a received message
      description: Removes the message, its content and its metadata now. Requires `inbound:write`.
      responses:
        "204": { description: Deleted }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/inbound/messages/{id}/raw:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: getInboundMessageRaw
      summary: Download the raw message (RFC 5322)
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
      responses:
        "200": { description: The message as received, content: { message/rfc822: { schema: { type: string, format: binary } } } }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/inbound/messages/{id}/attachments/{aid}:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: getInboundAttachment
      summary: Download an attachment
      description: Always served as `application/octet-stream` with `Content-Disposition attachment`; the original type is in `X-Original-Content-Type`.
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
        - { name: aid, in: path, required: true, schema: { type: string } }
      responses:
        "200": { description: The attachment, content: { application/octet-stream: { schema: { type: string, format: binary } } } }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/inbound/erase:
    post:
      x-mp-scope: "inbound:write"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: eraseInboundAddress
      summary: Remove all received mail from an address
      description: Deletes every message from the address and its threads in the project (a data-subject request). Requires `inbound:write`.
      requestBody:
        required: true
        content: { application/json: { schema: { type: object, required: [address], properties: { address: { type: string, format: email } } } } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { type: object, properties: { address: { type: string }, messages_removed: { type: integer } } } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/inbound/threads:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: listInboundThreads
      summary: List conversations
      description: A thread is one conversation between the project and one external address. Requires `inbound:read`.
      parameters:
        - { name: external_address, in: query, schema: { type: string } }
        - { name: mailbox, in: query, description: "A mailbox id: threads that belong to it. `none`: threads of no mailbox.", schema: { type: string } }
        - { name: cursor, in: query, schema: { type: string } }
        - { name: limit, in: query, schema: { type: integer, default: 25, minimum: 1, maximum: 100 } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/InboundThreadList" } } } }
        "403": { $ref: "#/components/responses/Forbidden" }
  /v1/inbound/threads/{id}:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: getInboundThread
      summary: Get a thread with its messages
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/InboundThread" } } } }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/inbound/threads/{id}/reply:
    post:
      x-mp-scope: "inbound:write"
      x-mp-role: key
      x-mp-rate-class: send
      x-mp-idempotency: optional
      x-mp-charges-credits: true
      x-mp-credit-cost: "1 email credit, as a send through /v1/email/send (the key also needs send:email)."
      x-mp-gateway: false
      tags: [Inbound]
      operationId: replyInboundThread
      summary: Reply in a thread
      description: >
        Sends an email to the thread's address through POST /v1/email/send, with In-Reply-To/References of
        the newest received message, subject "Re: <thread subject>" unless given, and reply tracking on, so
        the answer comes back into the same thread. The body is an email send body without `to`. In a thread
        that belongs to a mailbox with `reply_from` on that the project may send from (`sendable`), `from`
        defaults to the mailbox; otherwise to the project's default sender.
        Same charges, checks and idempotency as a send. Requires `inbound:write` and `send:email`.
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
      requestBody:
        required: true
        content: { application/json: { schema: { type: object, additionalProperties: true } } }
      responses:
        "202": { description: Accepted (the send), content: { application/json: { schema: { type: object, additionalProperties: true } } } }
        "400": { $ref: "#/components/responses/BadRequest" }
        "402": { $ref: "#/components/responses/CreditsExhausted" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /v1/inbound/mailboxes:
    get:
      x-mp-scope: "inbound:read"
      x-mp-role: key
      x-mp-rate-class: none
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: "0"
      x-mp-gateway: false
      tags: [Inbound]
      operationId: listInboundMailboxes
      summary: List the project's mailboxes
      description: >
        Named addresses (one@example.com) on the project's receiving domains. Received mail is filed under the
        mailboxes it was addressed to, and a reply to a send made from a mailbox address is filed under that
        mailbox. Mailboxes are created in the dashboard. Requires `inbound:read`.
      responses:
        "200": { description: OK, content: { application/json: { schema: { type: object, properties: { data: { type: array, items: { $ref: "#/components/schemas/InboundMailbox" } } } } } } }
        "403": { $ref: "#/components/responses/Forbidden" }
  # >>> generated:paths (scripts/openapi_gateway.py; do not edit by hand)
  /v1/brands:
    get:
      tags:
      - Brands
      operationId: brandsList
      x-speakeasy-group: brands
      x-speakeasy-name-override: list
      summary: List brands in a workspace
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: project_id
        in: query
        schema:
          type: string
      - name: status
        in: query
        schema:
          type: string
          enum:
          - active
          - archived
          - all
      responses:
        '200':
          description: Brands
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Brands
      operationId: brandsCreate
      x-speakeasy-group: brands
      x-speakeasy-name-override: create
      summary: Create a brand
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - project_id
              - name
              - postal_address
              properties:
                project_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                slug:
                  type: string
                postal_address:
                  type: string
                default_from_name:
                  type:
                  - string
                  - 'null'
                default_from_email:
                  type:
                  - string
                  - 'null'
                reply_to:
                  type:
                  - string
                  - 'null'
                contact_url:
                  type:
                  - string
                  - 'null'
                privacy_url:
                  type:
                  - string
                  - 'null'
                default_locale:
                  type: string
                logo_url:
                  type:
                  - string
                  - 'null'
                primary_color:
                  type:
                  - string
                  - 'null'
                routing:
                  description: 'Provider routing override for this brand''s MARKETING mail: provider types
                    in failover order (1 to 5, each an active email provider in the workspace). null clears
                    it. If none of the listed providers can take a send, the send fails (no_providers);
                    it never falls back to the workspace routing.'
                  oneOf:
                  - type: 'null'
                  - type: object
                    required:
                    - providers
                    properties:
                      providers:
                        type: array
                        minItems: 1
                        maxItems: 5
                        items:
                          type: string
                        example:
                        - ses
                        - postmark
                send_capacity_per_min:
                  description: The brand's sending capacity in messages per minute; a campaign's throttle
                    defaults to it. null = platform default.
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 1000000
                tracking_enabled:
                  description: Open and click tracking for this brand's campaigns. false = no tracked links
                    or open pixel, whatever a campaign says. Default true.
                  type: boolean
                timezone:
                  description: The brand's default IANA timezone (America/Toronto). The fallback for a send
                    in each recipient's timezone when the contact has none and the campaign names no fallback.
                    null clears it.
                  type:
                  - string
                  - 'null'
                  maxLength: 64
                utm_tagging:
                  description: 'Default for the brand''s campaigns: append utm_source, utm_medium=email
                    and utm_campaign to each outgoing http(s) link. A campaign can override it. Default
                    false.'
                  type: boolean
                utm_source:
                  description: The utm_source value for the brand's campaigns. null = the brand's slug.
                  type:
                  - string
                  - 'null'
                  maxLength: 100
                archive_enabled:
                  description: Publish a public archive page and RSS feed of the campaigns marked for it
                    (CMP-3.12.4). Default false. The first time it is turned on the brand gets an `archive_key`,
                    the opaque id in the archive addresses `/archive/{archive_key}` and `/archive/{archive_key}/feed.xml`
                    on the public edge; it is kept when the archive is turned off and on again.
                  type: boolean
                archive_indexable:
                  description: 'Let search engines index the archive. Default false: every archive page
                    and the feed say noindex.'
                  type: boolean
                web_version_footer:
                  description: Add a "View in browser" link to the default compliance footer of campaigns
                    composed after this is set (CMP-3.8.9). Default false. `{{view_in_browser_url}}` works
                    in any template either way.
                  type: boolean
                voice_guide:
                  description: 'Brand voice for AI compose (CMP-3.7.7): a short guide, at most 1000 characters.
                    Always part of the AI prompt. null clears it.'
                  type:
                  - string
                  - 'null'
                  maxLength: 1000
                voice_do:
                  description: Words and phrases AI compose should use (at most 30, 60 characters each).
                  type: array
                  maxItems: 30
                  items:
                    type: string
                    maxLength: 60
                voice_dont:
                  description: Words and phrases AI compose must never use; a suggestion containing one
                    is discarded (at most 30, 60 characters each).
                  type: array
                  maxItems: 30
                  items:
                    type: string
                    maxLength: 60
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/domains:
    get:
      tags:
      - Brands
      operationId: brandsListAllDomains
      x-speakeasy-group: brands
      x-speakeasy-name-override: listAllDomains
      summary: Every active brand's sender domains in one answer (any member)
      description: 'brand_id, domain, purpose and state only, for forms that offer a brand''s verified domains.
        The DNS records are on the brand''s own domain list.


        Requires the `audience:read` scope and acts as the viewer role.'
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: '{data[]}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}:
    get:
      tags:
      - Brands
      operationId: brandsGet
      x-speakeasy-group: brands
      x-speakeasy-name-override: get
      summary: Brand detail
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The brand
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Brands
      operationId: brandsUpdate
      x-speakeasy-group: brands
      x-speakeasy-name-override: update
      summary: Update a brand
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                slug:
                  type: string
                postal_address:
                  type: string
                default_from_name:
                  type:
                  - string
                  - 'null'
                default_from_email:
                  type:
                  - string
                  - 'null'
                reply_to:
                  type:
                  - string
                  - 'null'
                contact_url:
                  type:
                  - string
                  - 'null'
                privacy_url:
                  type:
                  - string
                  - 'null'
                default_locale:
                  type: string
                logo_url:
                  type:
                  - string
                  - 'null'
                primary_color:
                  type:
                  - string
                  - 'null'
                routing:
                  description: 'Provider routing override for this brand''s MARKETING mail: provider types
                    in failover order (1 to 5, each an active email provider in the workspace). null clears
                    it. If none of the listed providers can take a send, the send fails (no_providers);
                    it never falls back to the workspace routing.'
                  oneOf:
                  - type: 'null'
                  - type: object
                    required:
                    - providers
                    properties:
                      providers:
                        type: array
                        minItems: 1
                        maxItems: 5
                        items:
                          type: string
                        example:
                        - ses
                        - postmark
                send_capacity_per_min:
                  description: The brand's sending capacity in messages per minute; a campaign's throttle
                    defaults to it. null = platform default.
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 1000000
                tracking_enabled:
                  description: Open and click tracking for this brand's campaigns. false = no tracked links
                    or open pixel, whatever a campaign says. Default true.
                  type: boolean
                timezone:
                  description: The brand's default IANA timezone (America/Toronto). The fallback for a send
                    in each recipient's timezone when the contact has none and the campaign names no fallback.
                    null clears it.
                  type:
                  - string
                  - 'null'
                  maxLength: 64
                utm_tagging:
                  description: 'Default for the brand''s campaigns: append utm_source, utm_medium=email
                    and utm_campaign to each outgoing http(s) link. A campaign can override it. Default
                    false.'
                  type: boolean
                utm_source:
                  description: The utm_source value for the brand's campaigns. null = the brand's slug.
                  type:
                  - string
                  - 'null'
                  maxLength: 100
                archive_enabled:
                  description: Publish a public archive page and RSS feed of the campaigns marked for it
                    (CMP-3.12.4). Default false. The first time it is turned on the brand gets an `archive_key`,
                    the opaque id in the archive addresses `/archive/{archive_key}` and `/archive/{archive_key}/feed.xml`
                    on the public edge; it is kept when the archive is turned off and on again.
                  type: boolean
                archive_indexable:
                  description: 'Let search engines index the archive. Default false: every archive page
                    and the feed say noindex.'
                  type: boolean
                web_version_footer:
                  description: Add a "View in browser" link to the default compliance footer of campaigns
                    composed after this is set (CMP-3.8.9). Default false. `{{view_in_browser_url}}` works
                    in any template either way.
                  type: boolean
                voice_guide:
                  description: 'Brand voice for AI compose (CMP-3.7.7): a short guide, at most 1000 characters.
                    Always part of the AI prompt. null clears it.'
                  type:
                  - string
                  - 'null'
                  maxLength: 1000
                voice_do:
                  description: Words and phrases AI compose should use (at most 30, 60 characters each).
                  type: array
                  maxItems: 30
                  items:
                    type: string
                    maxLength: 60
                voice_dont:
                  description: Words and phrases AI compose must never use; a suggestion containing one
                    is discarded (at most 30, 60 characters each).
                  type: array
                  maxItems: 30
                  items:
                    type: string
                    maxLength: 60
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Brands
      operationId: brandsArchive
      x-speakeasy-group: brands
      x-speakeasy-name-override: archive
      summary: Archive a brand (developer+); history is kept
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '204':
          description: Archived
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}/domains:
    get:
      tags:
      - Brands
      operationId: brandsListDomains
      x-speakeasy-group: brands
      x-speakeasy-name-override: listDomains
      summary: List a brand's sender domains with state and DNS records
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: Domains
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Brands
      operationId: brandsAddDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: addDomain
      summary: Register a sender domain
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - domain
              properties:
                domain:
                  type: string
                purpose:
                  type: string
                  enum:
                  - marketing
                  - transactional
                  - both
                provider_types:
                  type: array
                  items:
                    type: string
                dkim_selectors:
                  type: array
                  items:
                    type: string
      responses:
        '201':
          description: Created, with the DNS records to publish
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}/domains/{d}:
    get:
      tags:
      - Brands
      operationId: brandsGetDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: getDomain
      summary: 'One sender domain: state, last check result, DNS records'
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: d
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The domain
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}/domains/{d}/check:
    post:
      tags:
      - Brands
      operationId: brandsCheckDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: checkDomain
      summary: Queue a DNS check (developer+); returns the pending job if one is already queued
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: d
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '202':
          description: 'Queued: job_id, domain_id, status'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}/tracking-domain:
    get:
      tags:
      - Brands
      operationId: brandsGetTrackingDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: getTrackingDomain
      summary: 'The brand''s tracking domain: current claim, DNS records to add, retired names'
      description: 'Campaign links and the open pixel are served from this host once it is active, instead
        of the shared MessagePipe host. `available` is false on deployments without custom tracking domains.


        Requires the `audience:read` scope and acts as the viewer role.'
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: '{available, current: {id, domain, status, dns_verified_at, tls_verified_at, last_check_at,
            last_check_error, dns: {cname, txt}} | null, retired: [{domain, retired_at}]}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
      - Brands
      operationId: brandsSetTrackingDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: setTrackingDomain
      summary: Claim a tracking domain for the brand
      description: 'Needs a subdomain you control (links.example.com). Returns the CNAME and TXT records
        to add. Replaces an unproven claim; one in use is retired and keeps serving the links already sent.
        A name this workspace retired earlier is taken back.


        Requires the `audience:admin` scope and acts as the workspace admin role. The key must have been
        created by a workspace owner or admin.'
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - domain
              properties:
                domain:
                  type: string
                  example: links.example.com
      responses:
        '201':
          description: Claimed, pending proof
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Not a usable name (apex, IP address, reserved host)
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Already in use (by another account, or another brand in this workspace), or the feature
            is not available
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Brands
      operationId: brandsRemoveTrackingDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: removeTrackingDomain
      summary: Stop using the brand's tracking domain
      description: 'Retires the active domain (it keeps serving links already sent) and drops an unproven
        claim. New campaigns use the shared host.


        Requires the `audience:admin` scope and acts as the workspace admin role. The key must have been
        created by a workspace owner or admin.'
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '204':
          description: Done
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/brands/{id}/tracking-domain/check:
    post:
      tags:
      - Brands
      operationId: brandsCheckTrackingDomain
      x-speakeasy-group: brands
      x-speakeasy-name-override: checkTrackingDomain
      summary: Check the DNS records and HTTPS for the brand's tracking domain
      description: 'Verifies the CNAME to the edge and the TXT token, then makes an HTTPS request that must
        reach the edge with a valid certificate. When all pass the domain becomes active. Safe to repeat;
        a domain that keeps failing becomes `degraded`: campaigns fall back to the shared host, links already
        sent keep working, and it recovers by itself when the checks pass.


        Requires the `audience:admin` scope and acts as the workspace admin role. The key must have been
        created by a workspace owner or admin.'
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: The claim with its status and, if not active, what is missing
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: The brand has no tracking domain
        '409':
          description: Another workspace has already proven control of this domain
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates:
    get:
      tags:
      - Content
      operationId: campaignTemplatesList
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: list
      summary: List campaign templates (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: project_id
        in: query
        schema:
          $ref: '#/components/schemas/Id'
      - name: state
        in: query
        schema:
          type: string
          enum:
          - draft
          - active
          - archived
      - name: brand_id
        in: query
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: data[]
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Content
      operationId: campaignTemplatesCreate
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: create
      summary: Create a campaign template
      description: 'Stored as a template version with metadata.kind = campaign. MJML is compiled on save.
        These do not appear in /templates and the generic template routes refuse them.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - project_id
              - name
              - content
              properties:
                project_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                brand_id:
                  $ref: '#/components/schemas/Id'
                  description: Optional; when set, publishing runs the pre-flight with this brand
                gallery:
                  type: boolean
                  description: 'POST only: true puts the template in the workspace''s template gallery ("save
                    as template"); the list and the template carry `gallery`'
                base_version:
                  type: integer
                  description: 'PUT only: the version being edited; a stale value is a 409'
                content:
                  $ref: '#/components/schemas/CampaignContent'
      responses:
        '200':
          description: The template (201)
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: A template with that name exists in the project
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates/{id}:
    get:
      tags:
      - Content
      operationId: campaignTemplatesGet
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: get
      summary: One campaign template with its latest version (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The template
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
      - Content
      operationId: campaignTemplatesUpdate
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: update
      summary: Save content
      description: 'While the latest version is a draft it is edited in place; after publishing, the next
        save starts a new version. Published versions are never changed.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - base_version
              - content
              properties:
                project_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                brand_id:
                  $ref: '#/components/schemas/Id'
                  description: Optional; when set, publishing runs the pre-flight with this brand
                gallery:
                  type: boolean
                  description: 'POST only: true puts the template in the workspace''s template gallery ("save
                    as template"); the list and the template carry `gallery`'
                base_version:
                  type: integer
                  description: 'PUT only: the version being edited; a stale value is a 409'
                content:
                  $ref: '#/components/schemas/CampaignContent'
      responses:
        '200':
          description: The template
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: A newer version exists (details.latest_version), or the template is archived
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates/{id}/archive:
    post:
      tags:
      - Content
      operationId: campaignTemplatesArchive
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: archive
      summary: Archive a campaign template
      description: Requires the `content:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: '{id, state}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates/{id}/publish:
    post:
      tags:
      - Content
      operationId: campaignTemplatesPublish
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: publish
      summary: Publish the latest version
      description: 'With a brand bound, the pre-flight runs and any error blocks publishing (400, details.findings).
        Without one, the brand-dependent checks are skipped and the response says so.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: '{id, state, current_version, preflight: ran|skipped_no_brand, findings[]}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Someone saved a newer version while the checks ran
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates/{id}/versions:
    get:
      tags:
      - Content
      operationId: campaignTemplatesListVersions
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: listVersions
      summary: Version history (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: data[]
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaign-templates/{id}/versions/{v}:
    get:
      tags:
      - Content
      operationId: campaignTemplatesGetVersion
      x-speakeasy-group: campaignTemplates
      x-speakeasy-name-override: getVersion
      summary: One version (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: v
        in: path
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: version, content, published_at
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns:
    get:
      tags:
      - Campaigns
      operationId: campaignsList
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: list
      summary: List campaigns and newsletters, newest first, with the progress of their latest run
      description: Requires the `campaigns:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: campaigns:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: status
        in: query
        schema:
          type: string
          enum:
          - all
          - draft
          - scheduled
          - running
          - paused
          - completed
          - cancelled
          - failed
      responses:
        '200':
          description: '{data[]}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Campaigns
      operationId: campaignsCreate
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: create
      summary: Create a draft campaign
      description: 'The brand, topic, segment and template must exist in the workspace and fit together
        (the topic belongs to the brand).


        Requires the `campaigns:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - name
              - brand_id
              - topic_id
              properties:
                name:
                  type: string
                kind:
                  type: string
                  enum:
                  - campaign
                  - newsletter
                brand_id:
                  type: string
                topic_id:
                  type: string
                segment_id:
                  type:
                  - string
                  - 'null'
                template_id:
                  type:
                  - string
                  - 'null'
                layout_id:
                  type:
                  - string
                  - 'null'
                from_name:
                  type:
                  - string
                  - 'null'
                from_email:
                  type:
                  - string
                  - 'null'
                reply_to:
                  type:
                  - string
                  - 'null'
                throttle_per_min:
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 1000000
                warmup_ramp:
                  type: boolean
                tz_send_enabled:
                  type: boolean
                  description: Send in each recipient's timezone (CMP-3.8.6). Start it with scheduled_local
                    instead of scheduled_at. Not combinable with an A/B test.
                tz_send_fallback:
                  type:
                  - string
                  - 'null'
                  maxLength: 64
                  description: IANA timezone for recipients without a usable one; null uses the brand's
                    timezone.
                utm_tagging:
                  type:
                  - boolean
                  - 'null'
                  description: UTM auto-tagging for this campaign. null = follow the brand's setting.
                utm_campaign:
                  type:
                  - string
                  - 'null'
                  maxLength: 100
                  description: utm_campaign value. null = a slug of the campaign name.
                utm_content:
                  type:
                  - string
                  - 'null'
                  enum:
                  - position
                  - text
                  - null
                  description: 'Per-link utm_content: `position` (link-1, link-2, ...) or `text` (a slug
                    of the link text). null = none.'
      responses:
        '201':
          description: The campaign
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}:
    get:
      tags:
      - Campaigns
      operationId: campaignsGet
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: get
      summary: Campaign detail with its latest run and per-status recipient counts
      description: '`run` carries the spam-rate circuit breaker''s state (CMP-3.9.6): `breaker_state` (ok,
        throttled, paused), `breaker_reason` (complaint_rate_throttle, complaint_rate, bounce_rate), `breaker_at`,
        `breaker_metrics` (the rates and counts the decision was made on), `throttle_factor` (0.25 once
        throttled), `resumed_by` and `resume_reason` after a manual resume, and `breaker_events`, the run''s
        history of trips and resumes. For a run with a warm-up ramp, `warmup` is the pinned schedule (`caps`
        per 24h window, `reason`) and `warmup_progress` is today''s position (`day`, `days`, `cap_today`
        after the breaker''s factor, `sent_today`, `window_ends_at`). For a timezone send, `tz_send` is
        what was pinned at the start (`local_at`, `fallback`, `from_contact`, `from_fallback`, `first_release`,
        `last_release`) plus `warmup_held`: how many recipients were due but held because the warm-up daily
        cap was used up (the worker records this when it meets the cap; delay from the speed limit, the
        breaker or a pause is not counted). A contact''s timezone changed after the run started is not applied
        to that run.


        Requires the `campaigns:read` scope and acts as the viewer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The campaign and its run
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Campaigns
      operationId: campaignsUpdate
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: update
      summary: Edit a draft
      description: 'Only a draft, or a campaign that failed to start, can be edited; a scheduled campaign
        has to be cancelled first (409). Every save bumps `revision`. A client that autosaves (the app''s
        editor) sends `base_revision`, the revision it was editing: a stale one is refused with 409 (`details.constraint:
        stale`, `details.latest_revision`) and nothing is overwritten, the same rule as `base_version` on
        campaign templates. Clients that omit it overwrite, as before.


        Requires the `campaigns:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                kind:
                  type: string
                  enum:
                  - campaign
                  - newsletter
                brand_id:
                  type: string
                topic_id:
                  type: string
                segment_id:
                  type:
                  - string
                  - 'null'
                template_id:
                  type:
                  - string
                  - 'null'
                layout_id:
                  type:
                  - string
                  - 'null'
                from_name:
                  type:
                  - string
                  - 'null'
                from_email:
                  type:
                  - string
                  - 'null'
                reply_to:
                  type:
                  - string
                  - 'null'
                throttle_per_min:
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 1000000
                warmup_ramp:
                  type: boolean
                  description: 'Opt in to the warm-up ramp (CMP-3.8.5): a daily cap that starts at 1,000
                    and doubles each day, pinned on the run when it starts. Pre-flight recommends it above
                    50,000 recipients from a new sending domain.'
                tz_send_enabled:
                  type: boolean
                  description: Send in each recipient's timezone (CMP-3.8.6). Start it with scheduled_local
                    instead of scheduled_at. Not combinable with an A/B test (400).
                tz_send_fallback:
                  type:
                  - string
                  - 'null'
                  maxLength: 64
                  description: IANA timezone for recipients without a usable one; null uses the brand's
                    timezone.
                utm_tagging:
                  type:
                  - boolean
                  - 'null'
                  description: UTM auto-tagging for this campaign. null = follow the brand's setting.
                utm_campaign:
                  type:
                  - string
                  - 'null'
                  maxLength: 100
                  description: utm_campaign value. null = a slug of the campaign name.
                utm_content:
                  type:
                  - string
                  - 'null'
                  enum:
                  - position
                  - text
                  - null
                  description: 'Per-link utm_content: `position` (link-1, link-2, ...) or `text` (a slug
                    of the link text). null = none.'
                base_revision:
                  type: integer
                  minimum: 1
                  description: The revision being edited; a stale one is a 409.
      responses:
        '200':
          description: The campaign
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/cancel:
    post:
      tags:
      - Campaigns
      operationId: campaignsCancel
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: cancel
      summary: Stop a running or paused campaign, or unschedule one
      description: 'Messages already sent cannot be recalled; an unscheduled campaign becomes a draft again.


        Requires the `campaigns:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: '{id, status}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/duplicate:
    post:
      tags:
      - Campaigns
      operationId: campaignsDuplicate
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: duplicate
      summary: Copy a campaign into a new draft
      description: 'Copies the content choice (template and layout), sender, brand, topic, segment, tracking
        and speed settings and the warm-up opt-in. The copy is named `Copy of <name>`, starts as a draft
        at revision 1, and carries no runs, sends, schedule or test history.


        Requires the `campaigns:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '201':
          description: The new draft
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/pause:
    post:
      tags:
      - Campaigns
      operationId: campaignsPause
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: pause
      summary: Pause a running campaign
      description: 'Takes effect within one slice of the worker.


        Requires the `campaigns:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: '{id, status}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/preflight:
    get:
      tags:
      - Campaigns
      operationId: campaignsPreflight
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: preflight
      summary: Checks before sending
      description: 'Blocking: sender domain not verified for marketing, content errors, empty audience,
        no credits, invalid sender or reply-to. Warnings: credits shorter than the audience, no test in
        the last 24 hours, recipients the brand''s frequency caps would skip, and the in-house inbox check
        (inbox_spam_warn, and inbox_spam_fail when the spam score is 5.0 or more; a warning only, the app
        asks the author to acknowledge it). The inbox report (spam score and rules, sender authentication,
        per-client rendering checks) is returned as `inbox`. Answers 200 with ok and problems[]; audience
        is an upper bound. frequency {enabled, would_skip, rules[]} is present when a cap applies; would_skip
        is an estimate.


        Requires the `campaigns:read` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: '{ok, problems[], audience, findings[], inbox?}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/report:
    get:
      tags:
      - Campaigns
      operationId: campaignsReport
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: report
      summary: 'Results: messages, delivered, bounced (hard/soft), spam reports, unsubscribes by route,
        skipped by reason, engagement'
      description: "Built from the campaign's sends and their delivery events in Postgres, so delivery numbers\
        \ lag provider\ncallbacks; it works without the analytics service. For the per-provider breakdown\
        \ and the first-48-hours\ntimeline use the analytics service's `campaign_id` filters (`/api/analytics/provider-comparison`,\n\
        `/api/analytics/campaign-timeline`); `since` is where to start that window.\n\n- `bounced` is distinct\
        \ sends that bounced. `bounces` splits them into `hard`, `soft` and `undetermined`\n  (the provider\
        \ gave no type, or one that is neither); a send with both kinds counts as hard. The three add up\n\
        \  to `bounced`.\n- `unsubscribes.by_route`: `one_click` (the mail client's List-Unsubscribe-Post\
        \ request), `link` (the footer\n  link, confirmed on the page), `preference_center`, `provider`\
        \ (an unsubscribe event the email provider\n  reported) and `complaint` (a spam report). `unsubscribes.total`\
        \ and `unsubscribed` are every route except\n  `complaint`. A person who uses two routes (or whose\
        \ provider reports the same unsubscribe the mail client\n  already sent) is counted once per route,\
        \ so the total can slightly exceed the number of people.\n- `skipped_by_reason`: recipients not\
        \ sent to at send time, by the eligibility code recorded.\n- `engagement` splits first-party opens\
        \ and clicks into human, mpp (Apple Mail Privacy Protection), bot\n  (scanners) and unclassified\
        \ (a provider's own tracking), each as {total, unique}; read the human numbers.\n  `links` lists\
        \ the most-clicked destinations by human clickers. `tracking` says whether opens and clicks are\n\
        \  switched on for the campaign.\n- `variants` (A/B tests): the phase, the decision and, per variant,\
        \ `test` (the test cohort: messages sent,\n  human clickers and human click rate, which is what\
        \ the winner was chosen on) and `all` (everything the\n  variant sent, including the remainder sent\
        \ to the winner); null for a campaign that never ran as a test.\n- `non_engagers` counts contacts\
        \ the campaign reached with no human open or click ({count, proxy_only};\n  proxy_only are those\
        \ whose only sign of life is an Apple proxy open): the audience Resend to non-engagers\n  would\
        \ use.\n\nRequires the `campaigns:read` scope and acts as the viewer role."
      security:
      - apiKey: []
      x-mp-scope: campaigns:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The report
          content:
            application/json:
              schema:
                type: object
                properties:
                  campaign_id:
                    type: string
                  since:
                    type: string
                    format: date-time
                  sends:
                    type: object
                    properties:
                      total:
                        type: integer
                      by_status:
                        type: object
                        additionalProperties:
                          type: integer
                  events:
                    type: object
                    additionalProperties:
                      type: integer
                    description: Distinct sends with an event of each type
                  tracking:
                    type: object
                    properties:
                      opens:
                        type: boolean
                      clicks:
                        type: boolean
                      brand_enabled:
                        type: boolean
                  engagement:
                    type: object
                  recipients:
                    type: object
                    additionalProperties:
                      type: integer
                  delivered:
                    type: integer
                  bounced:
                    type: integer
                  bounces:
                    type: object
                    properties:
                      hard:
                        type: integer
                      soft:
                        type: integer
                      undetermined:
                        type: integer
                  complaints:
                    type: integer
                  unsubscribed:
                    type: integer
                  unsubscribes:
                    type: object
                    properties:
                      total:
                        type: integer
                      by_route:
                        type: object
                        properties:
                          one_click:
                            type: integer
                          link:
                            type: integer
                          preference_center:
                            type: integer
                          provider:
                            type: integer
                          complaint:
                            type: integer
                  suppressed:
                    type: integer
                  skipped_by_reason:
                    type: object
                    additionalProperties:
                      type: integer
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/resume:
    post:
      tags:
      - Campaigns
      operationId: campaignsResume
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: resume
      summary: Resume a paused campaign
      description: 'Continues with the recipients not yet sent to. A campaign the spam-rate circuit breaker
        paused (`pause_reason` complaint_rate or bounce_rate) requires a non-empty `reason` (400 without
        it); the reason and the acting user are recorded on the run and in the audit log, and the run continues
        at 25% of its configured rate for the rest of the send.


        Requires the `campaigns:send` scope and acts as the marketer role. Requires an `Idempotency-Key`
        header.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:send
      x-mp-role: marketer
      x-mp-rate-class: start
      x-mp-idempotency: required
      x-mp-charges-credits: true
      x-mp-credit-cost: 1 email credit per recipient message still to send, as for start. The messages already
        sent are not charged again.
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  maxLength: 500
                  description: Why it is safe to resume. Required after an automatic pause.
      responses:
        '200':
          description: '{id, status}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/start:
    post:
      tags:
      - Campaigns
      operationId: campaignsStart
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: start
      summary: Send now, or schedule with scheduled_at
      description: 'Runs the pre-flight again and refuses (400, details.problems) if anything blocks. Snapshots
        the audience and begins sending. With a scheduled_at more than a minute away the campaign is scheduled
        and everything is checked again at that time. A campaign set to send in each recipient''s timezone
        takes scheduled_local instead (see there); it is scheduled for the first moment any zone reaches
        that time. When the workspace requires approval an unapproved campaign is refused with 409 (constraint
        campaign:approval_required).


        Requires the `campaigns:send` scope and acts as the marketer role. Requires an `Idempotency-Key`
        header.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:send
      x-mp-role: marketer
      x-mp-rate-class: start
      x-mp-idempotency: required
      x-mp-charges-credits: true
      x-mp-credit-cost: 1 email credit per recipient message, taken as each message is queued and refunded
        if it cannot be queued. Refused with no_credits when the balance is zero; the run pauses (credits_exhausted)
        if credits run out.
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                scheduled_at:
                  type: string
                  format: date-time
                scheduled_local:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$
                  example: 2026-12-01T09:00
                  description: 'For a campaign set to send in each recipient''s timezone (required for it,
                    refused with scheduled_at): the local date and time, with no zone. Each recipient is
                    sent it in their own timezone, over the 26 hours from UTC+14 to UTC-12; a zone whose
                    time has already passed is sent at once. A wall time skipped by a clock change is sent
                    just after the gap; one that happens twice is sent the first time.'
      responses:
        '200':
          description: '{id, status, scheduled_at, preflight}: the pre-flight result the start passed, with
            its warnings (credits_short, no_recent_test)'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          description: 'daily_recipient_cap: an API key has reached its daily recipient cap (details: cap,
            used, requested, remaining, resets_at). Only a start made through the public API can be refused
            for this.'
          content:
            application/json:
              schema:
                type: object
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/campaigns/{id}/test-send:
    post:
      tags:
      - Campaigns
      operationId: campaignsTestSend
      x-speakeasy-group: campaigns
      x-speakeasy-name-override: testSend
      summary: Send the newest saved content as a test
      description: 'Marked as a test, uses one email credit per address, and records that the campaign was
        tested (a pre-flight warning clears for 24 hours).


        Requires the `campaigns:send` scope and acts as the marketer role. Requires an `Idempotency-Key`
        header.'
      security:
      - apiKey: []
      x-mp-scope: campaigns:send
      x-mp-role: marketer
      x-mp-rate-class: start
      x-mp-idempotency: required
      x-mp-charges-credits: true
      x-mp-credit-cost: 1 email credit per test recipient.
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - recipients
              properties:
                recipients:
                  type: array
                  items:
                    type: string
                variant_id:
                  type: string
                  description: Send one A/B variant's own email (its subject and template) instead of the
                    campaign's
      responses:
        '200':
          description: '{results[]}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/consent-statements:
    get:
      tags:
      - Consent statements
      operationId: consentStatementsList
      x-speakeasy-group: consentStatements
      x-speakeasy-name-override: list
      summary: List statements
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Statements, newest first
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Consent statements
      operationId: consentStatementsCreate
      x-speakeasy-group: consentStatements
      x-speakeasy-name-override: create
      summary: Create a statement or its next version (marketer+); runs the CASL lint (warnings never block)
      description: Requires the `audience:admin` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              - text
              - produces_basis
              - grants
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                statement_id:
                  type: string
                  description: Add a version or locale to an existing statement
                version:
                  type: integer
                  minimum: 1
                locale:
                  type: string
                text:
                  type: string
                produces_basis:
                  type: string
                  enum:
                  - express
                  - implied_purchase
                  - implied_contract
                  - implied_inquiry
                  - implied_publication
                  - implied_disclosed
                  - pecr_soft_opt_in
                grants:
                  type: array
                  items:
                    type: object
                    required:
                    - topic_id
                    - channels
                    properties:
                      topic_id:
                        type: string
                      channels:
                        type: array
                        items:
                          type: string
      responses:
        '201':
          description: Created, with lint findings
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/consent-statements/{id}:
    get:
      tags:
      - Consent statements
      operationId: consentStatementsGet
      x-speakeasy-group: consentStatements
      x-speakeasy-name-override: get
      summary: Every version and locale of one statement
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: Versions, newest first
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/tags:
    get:
      tags:
      - Contacts
      operationId: contactTagsList
      x-speakeasy-group: contactTags
      x-speakeasy-name-override: list
      summary: Tags in use with how many contacts carry each (any member)
      description: Requires the `contacts:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: data[] of {tag, contacts}
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/{id}/consent/evidence.pdf:
    get:
      tags:
      - Contacts
      operationId: contactActivityConsentEvidencePdf
      x-speakeasy-group: contactActivity
      x-speakeasy-name-override: consentEvidencePdf
      summary: 'Consent evidence as a PDF report: every event with tier, IP, browser, page and the wording
        shown, plus each sealed event''s canonical text and hashes'
      description: Requires the `contacts:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The PDF report, as an attachment named consent-evidence-{id}.pdf
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/{id}/export:
    get:
      tags:
      - Contacts
      operationId: contactActivityExport
      x-speakeasy-group: contactActivity
      x-speakeasy-name-override: export
      summary: Subject-access export as a JSON download (owner/admin); audited
      description: Requires the `contacts:read` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: admin
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: Contact, consent and evidence
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/{id}/sends:
    get:
      tags:
      - Contacts
      operationId: contactActivitySends
      x-speakeasy-group: contactActivity
      x-speakeasy-name-override: sends
      summary: Recent sends to a contact (by id or address) with delivery events; no message content
      description: Requires the `contacts:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: data[] of sends with events[]
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/{id}/suppression:
    get:
      tags:
      - Contacts
      operationId: contactActivitySuppression
      x-speakeasy-group: contactActivity
      x-speakeasy-name-override: suppression
      summary: Whether the contact's address is suppressed in this workspace (marketer+); the address key
        is never returned
      description: Requires the `contacts:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: '{suppressed, entries[{id, reason, brand_id, created_at, expires_at}]}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: The Send API is not configured or not reachable
  /v1/contacts/{id}/tags:
    post:
      tags:
      - Contacts
      operationId: contactTagsAdd
      x-speakeasy-group: contactTags
      x-speakeasy-name-override: add
      summary: Add tags to a contact
      description: 'Tags are stored trimmed and lower-case. At most 20 per call and 50 per contact; a tag
        cannot contain a comma, semicolon or vertical bar (the CSV import splits on them).


        Requires the `contacts:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: contacts:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - tags
              properties:
                tags:
                  type: array
                  items:
                    type: string
                    maxLength: 64
                  minItems: 1
                  maxItems: 20
      responses:
        '200':
          description: '{tags, added}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The contact was erased
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Contacts
      operationId: contactTagsRemove
      x-speakeasy-group: contactTags
      x-speakeasy-name-override: remove
      summary: Remove tags from a contact
      description: Requires the `contacts:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - tags
              properties:
                tags:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          description: '{tags, removed}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/contacts/{id}/timeline:
    get:
      tags:
      - Contacts
      operationId: contactActivityTimeline
      x-speakeasy-group: contactActivity
      x-speakeasy-name-override: timeline
      summary: Consent events for a contact, newest first, without network evidence
      description: Requires the `contacts:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: contacts:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 200
      responses:
        '200':
          description: data[]
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/layouts:
    get:
      tags:
      - Content
      operationId: contentLayoutsList
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: list
      summary: A brand's layouts, the generated default first (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: data[]
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Content
      operationId: contentLayoutsCreate
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: create
      summary: Create a layout
      description: 'The compliance footer is never part of a layout''s HTML; it can be restyled within readable
        limits but not removed.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              - name
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                html:
                  type:
                  - string
                  - 'null'
                  description: Own layout HTML with one {{{body}}} slot; null = generated structure
                style:
                  type: object
                  description: background, content_background, text, link, font (sans|serif|mono), width
                    (480-720), footer{background,text,link,font_size 11-16,align}
                is_default:
                  type: boolean
      responses:
        '200':
          description: The layout (201)
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: A layout with that name exists for the brand
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/layouts/validate:
    post:
      tags:
      - Content
      operationId: contentLayoutsValidate
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: validate
      summary: Check a layout without saving (any member)
      description: Requires the `content:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                html:
                  type:
                  - string
                  - 'null'
                  description: Own layout HTML with one {{{body}}} slot; null = generated structure
                style:
                  type: object
                  description: background, content_background, text, link, font (sans|serif|mono), width
                    (480-720), footer{background,text,link,font_size 11-16,align}
                is_default:
                  type: boolean
      responses:
        '200':
          description: '{valid, problems[]}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/layouts/{id}:
    get:
      tags:
      - Content
      operationId: contentLayoutsGet
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: get
      summary: One layout, with its effective HTML (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: brand_id
        in: query
        schema:
          $ref: '#/components/schemas/Id'
        description: Required for the generated layout (id `default`)
      responses:
        '200':
          description: The layout
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
      - Content
      operationId: contentLayoutsUpdate
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: update
      summary: Change a layout (marketer+); the brand cannot change
      description: Requires the `content:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - name
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                html:
                  type:
                  - string
                  - 'null'
                  description: Own layout HTML with one {{{body}}} slot; null = generated structure
                style:
                  type: object
                  description: background, content_background, text, link, font (sans|serif|mono), width
                    (480-720), footer{background,text,link,font_size 11-16,align}
                is_default:
                  type: boolean
      responses:
        '200':
          description: The layout
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/layouts/{id}/archive:
    post:
      tags:
      - Content
      operationId: contentLayoutsArchive
      x-speakeasy-group: contentLayouts
      x-speakeasy-name-override: archive
      summary: Archive a layout
      description: Requires the `content:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: '{id, status}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/preflight:
    post:
      tags:
      - Content
      operationId: contentPreflight
      x-speakeasy-group: content
      x-speakeasy-name-override: preflight
      summary: Pre-flight checks on content (any member)
      description: 'Always 200: findings are the product. ok is false when any finding is an error.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                topic_id:
                  $ref: '#/components/schemas/Id'
                  description: Topic the email is sent under; the footer names it
                layout_id:
                  type: string
                  description: A layout id, or `default` for the generated one; omitted = the brand's default
                contact_id:
                  $ref: '#/components/schemas/Id'
                  description: Render for this contact (marketer+)
                campaign_name:
                  type: string
                content:
                  $ref: '#/components/schemas/CampaignContent'
                template_id:
                  $ref: '#/components/schemas/Id'
                  description: Use a saved campaign template instead of `content`
                version:
                  type: integer
                  description: 'With template_id: a specific version; default the latest'
      responses:
        '200':
          description: '{ok, findings[{code, severity, message}], size_bytes, inbox{spam{score, verdict
            pass|warn|fail, rules[{code, weight, message, snippet}]}, auth{domain, known, spf, dkim, dmarc,
            ready, notes[]}, clients{clients[{client, label, status, issues[{code, severity, message, snippet}]}]}}}.
            inbox is advice from in-house heuristics and never affects ok.'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/preview:
    post:
      tags:
      - Content
      operationId: contentPreview
      x-speakeasy-group: content
      x-speakeasy-name-override: preview
      summary: Render content exactly as it would be sent (any member; marketer+ with contact_id)
      description: 'Nothing is stored. Links are inert. MJML is compiled first; an invalid document is a
        400 with the compiler''s problems. Content may include partials with {{> name}} and show blocks
        per recipient with {{#showif segment="…"}}, tag="…" or attr="…" equals/not_equals/in/is_set, {{else}},
        {{/showif}}. With contact_id the dynamic blocks are decided for that contact; without it the sample
        contact belongs to no segment and has no tags, so else branches show.


        Requires the `content:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: content:write
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                topic_id:
                  $ref: '#/components/schemas/Id'
                  description: Topic the email is sent under; the footer names it
                layout_id:
                  type: string
                  description: A layout id, or `default` for the generated one; omitted = the brand's default
                contact_id:
                  $ref: '#/components/schemas/Id'
                  description: Render for this contact (marketer+)
                campaign_name:
                  type: string
                campaign_id:
                  $ref: '#/components/schemas/Id'
                  description: Show the links with this saved campaign's UTM tags (its own settings, else
                    its brand's).
                utm:
                  type: object
                  description: UTM settings from an unsaved form; overrides the saved ones. Present means
                    tagging is on unless `enabled` is false.
                  properties:
                    enabled:
                      type: boolean
                    source:
                      type: string
                    campaign:
                      type: string
                    content:
                      type: string
                      enum:
                      - position
                      - text
                content:
                  $ref: '#/components/schemas/CampaignContent'
                template_id:
                  $ref: '#/components/schemas/Id'
                  description: Use a saved campaign template instead of `content`
                version:
                  type: integer
                  description: 'With template_id: a specific version; default the latest'
                partial_drafts:
                  type: boolean
                  description: Use each included partial's latest draft instead of its published version,
                    to preview work in progress. Campaigns never do.
      responses:
        '200':
          description: subject, preheader, html, text, size_bytes, undefined_variables[], partials[] (the
            partial versions included), dynamic_blocks[] (which branch of each {{#showif}} this contact,
            or the sample contact, sees)
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/content/variables:
    get:
      tags:
      - Content
      operationId: contentVariables
      x-speakeasy-group: content
      x-speakeasy-name-override: variables
      summary: Merge variables an author can use (any member)
      description: Requires the `content:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: content:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: variables[]
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/forms:
    get:
      tags:
      - Signup forms
      operationId: formsList
      x-speakeasy-group: forms
      x-speakeasy-name-override: list
      summary: List signup forms (any member)
      description: Requires the `forms:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: forms:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        schema:
          $ref: '#/components/schemas/Id'
      - name: status
        in: query
        schema:
          type: string
          enum:
          - draft
          - active
          - archived
      responses:
        '200':
          description: data[] of forms, each with hosted_url
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Signup forms
      operationId: formsCreate
      x-speakeasy-group: forms
      x-speakeasy-name-override: create
      summary: Create a signup form
      description: 'A form is the public face of one registered consent statement. The statement must be
        express, belong to the brand and grant every listed topic by email. The wording shown on the page
        and recorded as evidence is the statement''s registered text, never text typed into the form. Hosted
        at /s/{slug} on the public pages host. A form that is active cannot list a topic that requires double
        opt-in (not supported yet). The slug is generated from the name unless given, and is unique across
        the platform.


        Requires the `forms:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: forms:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              - name
              - statement_id
              - topic_ids
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                  maxLength: 100
                slug:
                  type: string
                  description: 3-63 characters of a-z, 0-9 and hyphen; immutable once the form leaves draft
                status:
                  type: string
                  enum:
                  - draft
                  - active
                  default: draft
                statement_id:
                  $ref: '#/components/schemas/Id'
                statement_version:
                  type: integer
                  minimum: 1
                  description: Default the newest version in the locale
                statement_locale:
                  type: string
                  default: en
                topic_ids:
                  type: array
                  items:
                    $ref: '#/components/schemas/Id'
                  minItems: 1
                  maxItems: 10
                fields:
                  type: object
                  additionalProperties:
                    type: string
                  description: 'Extra inputs on the form: first_name and last_name, each `off`, `optional`
                    or `required`'
                title:
                  type:
                  - string
                  - 'null'
                  maxLength: 200
                intro:
                  type:
                  - string
                  - 'null'
                  maxLength: 2000
                button_label:
                  type:
                  - string
                  - 'null'
                  maxLength: 60
                success_message:
                  type:
                  - string
                  - 'null'
                  maxLength: 1000
                redirect_url:
                  type:
                  - string
                  - 'null'
                  description: https URL to send the person to after signing up
                allowed_origins:
                  type: array
                  items:
                    type: string
                  maxItems: 20
                  description: Sites allowed to embed the form or post to it from a browser (https origins)
                waitlist:
                  type: boolean
                  default: false
                  description: 'Waitlist mode (CMP-3.12.5): each signup is also given a place in order,
                    and the person gets one email saying they are on the list. Consent is recorded as for
                    any form. With double opt-in required the place is taken when the address is confirmed,
                    not at signup.'
                waitlist_show_position:
                  type: boolean
                  default: false
                  description: Put the person's number in that email. Needs waitlist. Off by default because
                    a number tells every signup how long the list is. The signup page never shows a position.
      responses:
        '201':
          description: The form, with hosted_url, embed (iframe, html, script) and warnings[]
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Name or slug already in use
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/forms/{id}:
    get:
      tags:
      - Signup forms
      operationId: formsGet
      x-speakeasy-group: forms
      x-speakeasy-name-override: get
      summary: One form with embed code and warnings (any member)
      description: 'warnings[] may include double_opt_in_recommended and form_out_of_date (a topic was archived
        or the statement changed after the form was saved).


        Requires the `forms:read` scope and acts as the viewer role.'
      security:
      - apiKey: []
      x-mp-scope: forms:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The form
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Signup forms
      operationId: formsUpdate
      x-speakeasy-group: forms
      x-speakeasy-name-override: update
      summary: Change a form
      description: 'Same fields as create except brand_id. Pointing at another statement or locale takes
        its newest version unless one is named. Forms are archived rather than deleted. Audited.


        Requires the `forms:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: forms:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                slug:
                  type: string
                  description: Only while the form is a draft
                status:
                  type: string
                  enum:
                  - draft
                  - active
                  - archived
                statement_id:
                  $ref: '#/components/schemas/Id'
                statement_version:
                  type: integer
                statement_locale:
                  type: string
                topic_ids:
                  type: array
                  items:
                    $ref: '#/components/schemas/Id'
                fields:
                  type: object
                  additionalProperties:
                    type: string
                title:
                  type:
                  - string
                  - 'null'
                intro:
                  type:
                  - string
                  - 'null'
                button_label:
                  type:
                  - string
                  - 'null'
                success_message:
                  type:
                  - string
                  - 'null'
                redirect_url:
                  type:
                  - string
                  - 'null'
                allowed_origins:
                  type: array
                  items:
                    type: string
                waitlist:
                  type: boolean
                  description: 'Waitlist mode (CMP-3.12.5): each signup is also given a place in order,
                    and the person gets one email saying they are on the list. Consent is recorded as for
                    any form. With double opt-in required the place is taken when the address is confirmed,
                    not at signup.'
                waitlist_show_position:
                  type: boolean
                  description: Put the person's number in that email. Needs waitlist. Off by default because
                    a number tells every signup how long the list is. The signup page never shows a position.
      responses:
        '200':
          description: The updated form
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Name or slug already in use
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports:
    get:
      tags:
      - Imports
      operationId: importsList
      x-speakeasy-group: imports
      x-speakeasy-name-override: list
      summary: Recent imports
      description: Requires the `imports:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: imports[]
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Imports
      operationId: importsUpload
      x-speakeasy-group: imports
      x-speakeasy-name-override: upload
      summary: Upload a CSV to import (marketer+); the body is the file
      description: 'Content-Type text/csv, UTF-8 with a header row, at most 10 MB, 100,000 rows and 200
        columns. Nothing is added to the audience by an upload. The file is deleted when the import ends,
        is cancelled, or goes unused for 24 hours.


        Requires the `imports:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: imports:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: filename
        in: query
        schema:
          type: string
          maxLength: 255
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          text/csv:
            schema:
              type: string
      responses:
        '201':
          description: The import, status draft, with headers and the first rows
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/declaration:
    get:
      tags:
      - Imports
      operationId: importsDeclaration
      x-speakeasy-group: imports
      x-speakeasy-name-override: declaration
      summary: The exact declaration a person agrees to when confirming an import
      description: Requires the `imports:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: '{text}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}:
    get:
      tags:
      - Imports
      operationId: importsGet
      x-speakeasy-group: imports
      x-speakeasy-name-override: get
      summary: 'One import: status, configuration, progress and report'
      description: Requires the `imports:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The import
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}/cancel:
    post:
      tags:
      - Imports
      operationId: importsCancel
      x-speakeasy-group: imports
      x-speakeasy-name-override: cancel
      summary: Cancel an import that has not ended (marketer+); rows already applied stay
      description: Requires the `imports:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: Cancelled
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Already ended
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}/commit:
    post:
      tags:
      - Imports
      operationId: importsCommit
      x-speakeasy-group: imports
      x-speakeasy-name-override: commit
      summary: Attest and start the import
      description: 'Refused unless a dry run finished for the saved configuration. Records the declaration
        text, the file''s SHA-256 and the collection details as an append-only attestation, which every
        imported subscription cites. Audited at warning severity. People who unsubscribed or are suppressed
        are never subscribed.


        Requires the `imports:write` scope and acts as the marketer role. Requires an `Idempotency-Key`
        header.'
      security:
      - apiKey: []
      x-mp-scope: imports:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: required
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - declaration_accepted
              properties:
                declaration_accepted:
                  type: boolean
      responses:
        '202':
          description: Queued
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: No current dry run, or already started
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}/config:
    put:
      tags:
      - Imports
      operationId: importsConfigure
      x-speakeasy-group: imports
      x-speakeasy-name-override: configure
      summary: Set the column mapping and consent options (marketer+); saved only if valid
      description: 'Always 200. valid=false lists every problem at once with the field it belongs to. Saving
        discards any earlier dry run. Allowed while the import is a draft or a finished dry run. Bases that
        can be imported: express, implied_purchase, implied_contract, implied_inquiry (not pecr_soft_opt_in,
        implied_publication or implied_disclosed). Topics that require double opt-in are refused.


        Requires the `imports:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: imports:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - mapping
              - options
              properties:
                mapping:
                  type: object
                  required:
                  - email
                  description: 'Field to column header. Also first_name, last_name, locale, country, timezone,
                    external_id, tags, consent_date, basis_date, and attributes {key: header}.'
                options:
                  type: object
                  required:
                  - existing
                  - topic_ids
                  - basis
                  - statement_id
                  - statement_version
                  - collection_method
                  - collection_from
                  properties:
                    existing:
                      type: string
                      enum:
                      - update
                      - skip
                    topic_ids:
                      type: array
                      items:
                        type: string
                      minItems: 1
                      maxItems: 10
                    basis:
                      type: string
                    statement_id:
                      type: string
                    statement_version:
                      type: integer
                    collection_method:
                      type: string
                      maxLength: 1000
                    original_platform:
                      type: string
                      maxLength: 200
                    collection_from:
                      type: string
                      format: date
                    collection_to:
                      type: string
                      format: date
      responses:
        '200':
          description: '{valid, problems[{field, message}], import?}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The import can no longer be configured
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}/dry-run:
    post:
      tags:
      - Imports
      operationId: importsDryRun
      x-speakeasy-group: imports
      x-speakeasy-name-override: dryRun
      summary: 'Queue a dry run (marketer+): the whole file is processed and rolled back; the report says
        what an import would do'
      description: Requires the `imports:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '202':
          description: Queued
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Not configured, wrong state, or the file is gone
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/imports/{id}/issues:
    get:
      tags:
      - Imports
      operationId: importsIssues
      x-speakeasy-group: imports
      x-speakeasy-name-override: issues
      summary: Rows that did not simply import, by line (marketer+); format=csv downloads up to 20,000 of
        them
      description: Requires the `imports:read` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: imports:read
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: run
        in: query
        schema:
          type: string
          enum:
          - dry_run
          - import
      - name: after
        in: query
        schema:
          type: integer
      - name: format
        in: query
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: issues[] with total and next_after, or text/csv
          content:
            application/json:
              schema:
                type: object
            text/csv:
              schema:
                type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments:
    get:
      tags:
      - Segments
      operationId: segmentsList
      x-speakeasy-group: segments
      x-speakeasy-name-override: list
      summary: List segments with their cached counts
      description: Requires the `segments:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: status
        in: query
        schema:
          type: string
          enum:
          - active
          - archived
          - all
      - name: type
        in: query
        schema:
          type: string
          enum:
          - dynamic
          - static
          - all
      responses:
        '200':
          description: Segments
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Segments
      operationId: segmentsCreate
      x-speakeasy-group: segments
      x-speakeasy-name-override: create
      summary: Create a segment (marketer+); dynamic needs rules, static has members
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - name
              - type
              properties:
                name:
                  type: string
                  maxLength: 120
                  description: Unique among active segments, case-insensitively
                description:
                  type:
                  - string
                  - 'null'
                type:
                  type: string
                  enum:
                  - dynamic
                  - static
                rules:
                  type: object
                  description: 'Rule tree: an object with exactly one key. all/any (arrays of rules), not
                    (one rule), attribute {name, op, value}, tag {op: has|has_any|has_all, value}, topic
                    {id, state: subscribed|unsubscribed|pending|none, channel?}, consent {basis?, topic_id?,
                    min_tier?, expires_within_days?} (basis may be left out when expires_within_days is
                    set: implied consent that lapses within that many days, the re-permission list), created_at
                    {op, value}, field {name: country|locale|email_domain, op, value}. Limits: depth 6,
                    100 nodes. engagement {event: opened|clicked|not_engaged, days?, campaign_id?, proxy_opens?:
                    unknown|ignore}: human opens and clicks only (Apple Mail Privacy Protection proxy opens
                    and scanner clicks never count); not_engaged needs days, or a campaign_id. With days
                    it means the contact was sent at least one tracked campaign email in the last N days
                    (a send that went out, from a campaign with open or click tracking on, of a brand with
                    tracking on) and has no human open or click in those days; a contact who was never mailed
                    does not match. With a campaign_id it means received that campaign and did neither.
                    By default a contact whose only sign of life is a proxy open is neither opened nor not_engaged,
                    proxy_opens ignore treats the proxy open as nothing. Invalid rules return 400 with details.problems[]
                    ({path, code, message}).'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/preview:
    post:
      tags:
      - Segments
      operationId: segmentsPreview
      x-speakeasy-group: segments
      x-speakeasy-name-override: preview
      summary: Count (and, for marketer+, a sample of 20) for unsaved rules, a saved segment, or everyone;
        optionally only a topic's subscribers
      description: 'The count is an upper bound: suppressions and per-send eligibility are applied again
        at send time. A topic filter is applied first, so a segment can only narrow a topic''s audience.


        Requires the `segments:read` scope and acts as the viewer role.'
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                rules:
                  type: object
                segment_id:
                  $ref: '#/components/schemas/Id'
                topic_id:
                  $ref: '#/components/schemas/Id'
                channel:
                  $ref: '#/components/schemas/Channel'
                sample:
                  type: boolean
                  description: Ignored for viewers
      responses:
        '200':
          description: '{count, upper_bound, sample?}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/schema:
    get:
      tags:
      - Segments
      operationId: segmentsSchema
      x-speakeasy-group: segments
      x-speakeasy-name-override: schema
      summary: 'What the rule builder can offer: attribute definitions and the 200 most-used tags'
      description: Requires the `segments:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: '{attributes[{key,type,enum_values}], tags[{tag,contacts}]}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/validate:
    post:
      tags:
      - Segments
      operationId: segmentsValidate
      x-speakeasy-group: segments
      x-speakeasy-name-override: validate
      summary: Check rules without saving (marketer+); 200 either way, problems[] says what is wrong
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - rules
              properties:
                rules:
                  type: object
                  description: 'Rule tree: an object with exactly one key. all/any (arrays of rules), not
                    (one rule), attribute {name, op, value}, tag {op: has|has_any|has_all, value}, topic
                    {id, state: subscribed|unsubscribed|pending|none, channel?}, consent {basis?, topic_id?,
                    min_tier?, expires_within_days?} (basis may be left out when expires_within_days is
                    set: implied consent that lapses within that many days, the re-permission list), created_at
                    {op, value}, field {name: country|locale|email_domain, op, value}. Limits: depth 6,
                    100 nodes. engagement {event: opened|clicked|not_engaged, days?, campaign_id?, proxy_opens?:
                    unknown|ignore}: human opens and clicks only (Apple Mail Privacy Protection proxy opens
                    and scanner clicks never count); not_engaged needs days, or a campaign_id. With days
                    it means the contact was sent at least one tracked campaign email in the last N days
                    (a send that went out, from a campaign with open or click tracking on, of a brand with
                    tracking on) and has no human open or click in those days; a contact who was never mailed
                    does not match. With a campaign_id it means received that campaign and did neither.
                    By default a contact whose only sign of life is a proxy open is neither opened nor not_engaged,
                    proxy_opens ignore treats the proxy open as nothing. Invalid rules return 400 with details.problems[]
                    ({path, code, message}).'
      responses:
        '200':
          description: '{valid, problems[]}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/{id}:
    get:
      tags:
      - Segments
      operationId: segmentsGet
      x-speakeasy-group: segments
      x-speakeasy-name-override: get
      summary: Segment detail
      description: Requires the `segments:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The segment
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Segments
      operationId: segmentsUpdate
      x-speakeasy-group: segments
      x-speakeasy-name-override: update
      summary: Rename, change rules (dynamic), archive or restore (marketer+); changing rules clears the
        cached count
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type:
                  - string
                  - 'null'
                status:
                  type: string
                  enum:
                  - active
                  - archived
                rules:
                  type: object
      responses:
        '200':
          description: The segment
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Segments
      operationId: segmentsDelete
      x-speakeasy-group: segments
      x-speakeasy-name-override: delete
      summary: Archive a segment (marketer+); never deleted, a sent campaign keeps pointing at it
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '204':
          description: Archived (idempotent)
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/{id}/count:
    get:
      tags:
      - Segments
      operationId: segmentsCount
      x-speakeasy-group: segments
      x-speakeasy-name-override: count
      summary: Live member count, cached on the segment for up to 60 seconds (never cached with topic_id)
      description: Requires the `segments:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: topic_id
        in: query
        schema:
          type: string
      - name: channel
        in: query
        schema:
          type: string
      - name: refresh
        in: query
        schema:
          type: boolean
      responses:
        '200':
          description: '{count, counted_at, cached, upper_bound}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/{id}/members:
    get:
      tags:
      - Segments
      operationId: segmentsListMembers
      x-speakeasy-group: segments
      x-speakeasy-name-override: listMembers
      summary: Members of a static segment
      description: Requires the `segments:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: segments:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 200
      - name: cursor
        in: query
        schema:
          type: string
      responses:
        '200':
          description: 'A page: data[] and next_cursor'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Segments
      operationId: segmentsAddMembers
      x-speakeasy-group: segments
      x-speakeasy-name-override: addMembers
      summary: Add contacts to a static segment by id, address and/or CSV text
      description: 'Erased and unknown contacts are not added and are counted in not_found; unparseable
        addresses are listed in invalid_sample.


        Requires the `segments:write` scope and acts as the marketer role.'
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contact_ids:
                  type: array
                  items:
                    type: string
                emails:
                  type: array
                  items:
                    type: string
                csv:
                  type: string
                  description: First column of each line; an 'email' header line is skipped
      responses:
        '200':
          description: '{added, already_members, not_found, not_found_sample, invalid_emails, invalid_sample}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Segments
      operationId: segmentsRemoveMembers
      x-speakeasy-group: segments
      x-speakeasy-name-override: removeMembers
      summary: Remove contacts from a static segment
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contact_ids:
                  type: array
                  items:
                    type: string
                emails:
                  type: array
                  items:
                    type: string
                csv:
                  type: string
      responses:
        '200':
          description: '{removed}'
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/segments/{id}/sample:
    get:
      tags:
      - Segments
      operationId: segmentsSample
      x-speakeasy-group: segments
      x-speakeasy-name-override: sample
      summary: Twenty matching contacts
      description: Requires the `segments:write` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: segments:write
      x-mp-role: marketer
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - name: topic_id
        in: query
        schema:
          type: string
      - name: channel
        in: query
        schema:
          type: string
      responses:
        '200':
          description: '{count, data[], upper_bound}'
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/topics:
    get:
      tags:
      - Topics
      operationId: topicsList
      x-speakeasy-group: topics
      x-speakeasy-name-override: list
      summary: List topics
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: brand_id
        in: query
        schema:
          type: string
      - name: status
        in: query
        schema:
          type: string
          enum:
          - active
          - archived
          - all
      responses:
        '200':
          description: Topics
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Topics
      operationId: topicsCreate
      x-speakeasy-group: topics
      x-speakeasy-name-override: create
      summary: Create a topic
      description: Requires the `audience:admin` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - brand_id
              - name
              properties:
                brand_id:
                  $ref: '#/components/schemas/Id'
                name:
                  type: string
                description:
                  type:
                  - string
                  - 'null'
                default_state:
                  type: string
                  enum:
                  - opt_in
                  - opt_out
                channels:
                  type: array
                  items:
                    $ref: '#/components/schemas/Channel'
                double_opt_in:
                  type: string
                  enum:
                  - false
                  - optional
                  - required
                min_evidence_tier:
                  type: string
                  enum:
                  - A
                  - B
                  - C
                visibility:
                  type: string
                  enum:
                  - public
                  - private
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/topics/{id}:
    get:
      tags:
      - Topics
      operationId: topicsGet
      x-speakeasy-group: topics
      x-speakeasy-name-override: get
      summary: Topic detail
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: The topic
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Topics
      operationId: topicsUpdate
      x-speakeasy-group: topics
      x-speakeasy-name-override: update
      summary: Update a topic (marketer+); changes to who may be mailed are audited at warning severity
      description: Requires the `audience:admin` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type:
                  - string
                  - 'null'
                default_state:
                  type: string
                  enum:
                  - opt_in
                  - opt_out
                channels:
                  type: array
                  items:
                    $ref: '#/components/schemas/Channel'
                double_opt_in:
                  type: string
                  enum:
                  - false
                  - optional
                  - required
                min_evidence_tier:
                  type: string
                  enum:
                  - A
                  - B
                  - C
                visibility:
                  type: string
                  enum:
                  - public
                  - private
                status:
                  type: string
                  enum:
                  - active
                  - archived
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
      - Topics
      operationId: topicsArchive
      x-speakeasy-group: topics
      x-speakeasy-name-override: archive
      summary: Archive a topic
      description: Requires the `audience:admin` scope and acts as the marketer role.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: marketer
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Id'
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '204':
          description: Archived
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/workspace-settings:
    get:
      tags:
      - Workspace settings
      operationId: workspaceSettingsGet
      x-speakeasy-group: workspaceSettings
      x-speakeasy-name-override: get
      summary: Suppression mode, transactional-on-complaint, unsubscribe scope, daily recipient cap and
        credits.low threshold and campaign approval (defaults when never set)
      description: Requires the `audience:read` scope and acts as the viewer role.
      security:
      - apiKey: []
      x-mp-scope: audience:read
      x-mp-role: member
      x-mp-rate-class: read
      x-mp-idempotency: none
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      responses:
        '200':
          description: Settings
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
    patch:
      tags:
      - Workspace settings
      operationId: workspaceSettingsUpdate
      x-speakeasy-group: workspaceSettings
      x-speakeasy-name-override: update
      summary: Change settings (owner/admin); audited with before and after
      description: Requires the `audience:admin` scope and acts as the workspace admin role. The key must
        have been created by a workspace owner or admin.
      security:
      - apiKey: []
      x-mp-scope: audience:admin
      x-mp-role: admin
      x-mp-rate-class: write
      x-mp-idempotency: optional
      x-mp-charges-credits: false
      x-mp-credit-cost: '0'
      x-mp-gateway: true
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                suppression_mode:
                  type:
                  - string
                  - 'null'
                  enum:
                  - false
                  - shadow
                  - enforce
                  - null
                  description: null follows the platform default
                block_transactional_on_complaint:
                  type: boolean
                unsubscribe_scope:
                  type: string
                  enum:
                  - brand
                  - workspace
                daily_recipient_cap:
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 10000000
                  description: Recipients one API key may start campaigns and test sends to per UTC day;
                    null uses the platform default (10,000). Owner or admin only; a key cannot change it
                    (API-6.4). The response also carries daily_recipient_cap_default.
                credits_low_threshold:
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  maximum: 100000000
                  description: 'The balance, per credit channel, at or below which the credits.low webhook
                    event fires (once, when a debit crosses it downward). null uses the default: 10% of
                    the channel''s monthly quota or 100 credits, whichever is higher, never more than the
                    quota. A key with audience:admin may change it.'
                campaigns_require_approval:
                  type: boolean
                  description: When true a campaign must be submitted, approved by an owner or admin who
                    is not one of its authors, and only then can be started or scheduled. Enforced by the
                    send engine.
      responses:
        '200':
          description: Updated settings
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/Unprocessable'
        '429':
          $ref: '#/components/responses/RateLimited'
  # <<< generated:paths
# Events MessagePipe posts to a workspace-wide webhook endpoint (API-5.5). An endpoint is created in the
# dashboard and subscribes to event types; each delivery is signed (`X-MP-Signature`) and carries
# `X-MP-Event-Type` and `X-MP-Event-Id`. Delivery is at least once: deduplicate on `id`. Each event is
# written once per occurrence, in the same transaction as the change it describes. Payloads carry
# identifiers and counts, never an email address.
webhooks:
  campaign.paused:
    post:
      tags: [Campaigns]
      summary: A running campaign was paused
      description: >
        Sent once each time a run is paused: by a person or key (`manual`) or because credits ran out
        (`credits_exhausted`). `complaint_rate` or `bounce_rate` when the spam-rate breaker paused it
        (a person must resume it, with a reason). A run that is resumed and paused again sends a second event. `pending` messages are not sent until the
        campaign is resumed.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/WebhookEnvelope"
                - type: object
                  properties:
                    type: { const: campaign.paused }
                    data:
                      type: object
                      required: [campaign_id, run_id, reason, recipients, pending]
                      properties:
                        campaign_id: { type: string }
                        run_id: { type: string }
                        name: { type: string }
                        reason: { type: string, enum: [manual, credits_exhausted, bounce_rate, complaint_rate] }
                        recipients: { type: integer, description: "Recipients in the run." }
                        pending: { type: integer, description: "Recipients not yet sent." }
      responses:
        "200": { description: Acknowledged. Any 2xx counts as delivered. }
  campaign.completed:
    post:
      tags: [Campaigns]
      summary: A campaign finished sending
      description: Sent once per run when every recipient has been handled. `by_status` counts recipients by outcome (`queued`, `suppressed`, `skipped`, `failed`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/WebhookEnvelope"
                - type: object
                  properties:
                    type: { const: campaign.completed }
                    data:
                      type: object
                      required: [campaign_id, run_id, recipients, by_status]
                      properties:
                        campaign_id: { type: string }
                        run_id: { type: string }
                        name: { type: string }
                        recipients: { type: integer }
                        by_status: { type: object, additionalProperties: { type: integer } }
      responses:
        "200": { description: Acknowledged. }
  credits.low:
    post:
      tags: [Credits]
      summary: A credit balance fell to its low-balance threshold
      description: >
        Sent when a debit takes a channel's total balance (monthly allowance plus top-up) from above the
        threshold to at or below it, not on every debit after that. The threshold is the workspace's
        `credits_low_threshold` setting, or by default 10% of the channel's monthly quota or 100
        credits, whichever is higher, but never more than the quota. A refund or top-up that lifts the
        balance back over the line re-arms it.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/WebhookEnvelope"
                - type: object
                  properties:
                    type: { const: credits.low }
                    data:
                      type: object
                      required: [channel, balance, threshold]
                      properties:
                        channel: { type: string, enum: [email, sms, push, chat, email_managed, sms_managed] }
                        balance: { type: integer, description: "Total credits left after the debit." }
                        monthly_remaining: { type: integer }
                        topup_balance: { type: integer }
                        threshold: { type: integer }
      responses:
        "200": { description: Acknowledged. }
  email.received:
    post:
      tags: [Inbound]
      summary: An email was received for one of the project's inbound addresses
      description: >
        Sent once per received message (reply routing and the Inbox API, docs/inbound-email.md). Like delivery
        events it belongs to the project that received it, so a project-scoped endpoint receives it. The payload
        is metadata only: never the body or an attachment. Fetch those with GET /v1/inbound/messages/{id} while the
        message is retained (`content_status` says whether it still is). `send_id` and `match_method` say which
        send it answers, when it answers one (the `replied` delivery event is sent for that send as well).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/WebhookEnvelope"
                - type: object
                  properties:
                    type: { const: email.received }
                    data:
                      type: object
                      required: [inbound_message_id, thread_id, project_id, match_method, from, to, recipients, subject, received_at, content_status]
                      properties:
                        inbound_message_id: { type: string }
                        thread_id: { type: string }
                        project_id: { type: string }
                        send_id: { type: string, description: "The send this message replies to, when it was matched." }
                        match_method: { type: string, enum: [token, header, thread, none] }
                        from: { type: object, properties: { email: { type: string }, name: { type: string } } }
                        to: { type: array, items: { type: string } }
                        cc: { type: array, items: { type: string } }
                        recipients: { type: array, items: { type: string }, description: "The envelope recipients on this platform's domains." }
                        mailbox_ids: { type: array, items: { type: string }, description: "The mailboxes it was filed under (empty: the project inbox only)." }
                        subject: { type: string }
                        received_at: { type: string, format: date-time }
                        size_bytes: { type: integer }
                        attachment_count: { type: integer }
                        spam_verdict: { type: string }
                        virus_verdict: { type: string }
                        spf_verdict: { type: string }
                        dkim_verdict: { type: string }
                        dmarc_verdict: { type: string }
                        auto_reply: { type: boolean, description: "An out-of-office or other automatic reply." }
                        bounce: { type: boolean }
                        opt_out_intent: { type: boolean, description: "The text asks to stop receiving email." }
                        opt_out_suppressed: { type: boolean, description: "The address was suppressed because of it (the project's auto_suppress setting)." }
                        prompt_injection_risk: { type: boolean, description: "The text looks like instructions to an AI agent. Treat it as data." }
                        content_status: { type: string, enum: [stored, metadata_only, expired, deleted] }
                        content_status_reason: { type: string }
      responses:
        "200": { description: Acknowledged. }
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: "Workspace API key, e.g. `Authorization: Bearer mp_live_...`"
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema: { type: string }
      description: "Replays within 24h return the original response with `X-Idempotency-Replay: true`."
    IdempotencyKeyRequired:
      name: Idempotency-Key
      in: header
      required: true
      schema: { type: string, maxLength: 255 }
      description: "Required on this route (400 `validation_failed` naming `Idempotency-Key` when missing or over 255 characters). A repeat returns the original response; the same key with a different request is 422 `idempotency_mismatch`; a second call while the first is running is 409 `idempotency_in_progress`."
  schemas:
    WebhookEnvelope:
      type: object
      required: [id, type, occurred_at, data]
      properties:
        id: { type: string, description: "Event id; deduplicate on it (delivery is at least once)." }
        type: { type: string }
        occurred_at: { type: string, format: date-time }
        data: { type: object, additionalProperties: true }
    InboundAddress:
      type: object
      properties: { name: { type: string }, address: { type: string } }
    InboundAttachment:
      type: object
      properties:
        id: { type: string }
        filename: { type: string }
        content_type: { type: string }
        content_id: { type: string }
        size_bytes: { type: integer }
    InboundMessage:
      type: object
      properties:
        id: { type: string, example: inm_01JD... }
        thread_id: { type: string }
        send_id: { type: string, nullable: true, description: The send this replies to. }
        match_method: { type: string, enum: [token, header, thread, none] }
        from: { $ref: "#/components/schemas/InboundAddress" }
        to: { type: array, items: { type: string } }
        cc: { type: array, items: { type: string } }
        recipients: { type: array, items: { type: string }, description: "Envelope recipients in this project (for forwarded mail, the mailbox address)." }
        mailbox_ids: { type: array, items: { type: string }, description: The mailboxes it was filed under; empty when it is in the project inbox only. }
        subject: { type: string }
        message_id_header: { type: string }
        in_reply_to: { type: string }
        received_at: { type: string, format: date-time }
        size_bytes: { type: integer }
        spam_verdict: { type: string }
        virus_verdict: { type: string }
        spf_verdict: { type: string }
        dkim_verdict: { type: string }
        dmarc_verdict: { type: string }
        auto_reply: { type: boolean }
        bounce: { type: boolean }
        opt_out_intent: { type: boolean, description: The reply's new text is only an opt-out phrase. }
        opt_out_suppressed: { type: boolean, description: The sender was suppressed (project opt-out mode auto_suppress). }
        prompt_injection_risk: { type: boolean, description: Heuristic flag for text written to steer an LLM. Not a guarantee. }
        content_status: { type: string, enum: [stored, metadata_only, expired, deleted] }
        content_status_reason: { type: string, nullable: true, description: "virus | too_large | dmarc_fail | inbound_credits_exhausted | content_unavailable | unparseable" }
        content_expires_at: { type: string, format: date-time }
        read: { type: boolean }
        archived: { type: boolean }
        text: { type: string }
        html: { type: string }
        reply_text: { type: string }
        attachments: { type: array, items: { $ref: "#/components/schemas/InboundAttachment" } }
    InboundMessageList:
      type: object
      properties:
        data: { type: array, items: { $ref: "#/components/schemas/InboundMessage" } }
        next_cursor: { type: string, nullable: true }
    InboundThread:
      type: object
      properties:
        id: { type: string }
        external_address: { type: string }
        subject: { type: string }
        origin_send_id: { type: string, nullable: true }
        mailbox_id: { type: string, nullable: true, description: The mailbox the conversation belongs to (replies are sent from it). }
        message_count: { type: integer }
        last_message_at: { type: string, format: date-time }
        created_at: { type: string, format: date-time }
        messages: { type: array, items: { $ref: "#/components/schemas/InboundMessage" } }
        reply_send_ids: { type: array, items: { type: string } }
    InboundMailbox:
      type: object
      properties:
        id: { type: string, example: ibx_01JD... }
        address: { type: string, format: email }
        display_name: { type: string }
        reply_from: { type: boolean, description: Replies in this mailbox's threads are sent from it unless the request names `from`. }
        domain_id: { type: string }
        domain_kind: { type: string, enum: [custom, hosted] }
        domain_status: { type: string, enum: [pending, active, failed] }
        receive_mode: { type: string, enum: [direct, forwarding], description: "direct: the domain's MX points at MessagePipe. forwarding: the customer's mail system forwards the mailbox." }
        sendable: { type: boolean, description: "The project may send from this address (an active custom domain its sender policy allows). Replies in the mailbox's threads use it only then." }
        created_at: { type: string, format: date-time }
    InboundThreadList:
      type: object
      properties:
        data: { type: array, items: { $ref: "#/components/schemas/InboundThread" } }
        next_cursor: { type: string, nullable: true }
    CreditBalanceList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            type: object
            required: [channel, monthly_remaining, topup_balance, total]
            properties:
              channel: { type: string, enum: [email, sms, push, chat, email_managed, sms_managed], description: "The credit bucket. The first four are the plain channels; `email_managed` and `sms_managed` are billed for sends through MessagePipe's managed providers." }
              monthly_remaining: { type: integer }
              topup_balance: { type: integer }
              total: { type: integer }
    CreditLedgerList:
      type: object
      required: [data, next_before]
      properties:
        data:
          type: array
          items:
            type: object
            required: [id, channel, type, amount, balance_after, created_at]
            properties:
              id: { type: string }
              channel: { type: string, description: "The credit bucket: email, sms, push, chat, email_managed or sms_managed." }
              type: { type: string }
              amount: { type: integer }
              balance_after: { type: integer }
              reason_code: { type: [string, "null"] }
              reference_id: { type: [string, "null"] }
              created_at: { type: string, format: date-time }
        next_before: { type: [string, "null"], format: date-time }
    Health:
      type: object
      properties: { status: { type: string, example: ok } }
    EmailSend:
      type: object
      required: [to]
      properties:
        to: { type: string, format: email }
        from:
          type: object
          description: >
            Sender identity, honoured on template and inline sends alike (it overrides a
            template's own sender). Optional — when omitted, the template's sender or the
            project's default sender is used; an inline send with neither is rejected with
            400. Must be an object (a bare string is rejected). The address must be on one
            of the project's sender domains (the default sender's domain plus the project's
            `sender_domains`); any other is refused with 403 `sender_not_allowed`, never
            replaced by the default. A project with neither configured accepts any `from`.
            `email` must be one bare address (no list, display name or angle brackets).
          required: [email]
          properties:
            email: { type: string, format: email }
            name: { type: string, description: Display name. Control characters are rejected. }
        subject: { type: string, description: Inline sends only. A template send takes its subject from the template. }
        html: { type: string }
        track_replies:
          type: boolean
          description: >
            Give the send a tracked Reply-To (r-<token>@<your receiving domain>) so a reply comes back
            through the Inbox API matched to this send (email.received webhook, `replied` delivery event).
            Overrides `reply_to`. Absent = the project's default (inbound settings). Needs an active
            receiving domain; without one the send goes out untracked. Works with managed and own-key providers.
        reply_to:
          type: string
          format: email
          description: >
            Reply-To address, honoured on template and inline sends alike; the template
            needn't reference it. Overrides the template's and the project's default.
            Rejected if it contains control characters.
        headers:
          type: object
          maxProperties: 20
          additionalProperties: { type: string }
          example:
            List-Unsubscribe: "<https://example.com/unsubscribe?t=abc>, <mailto:unsubscribe@example.com>"
            List-Unsubscribe-Post: List-Unsubscribe=One-Click
          description: >
            Custom email headers, delivered unchanged by every email provider, including
            after failover; a provider that can't carry them is skipped, and the send fails
            if none can. Use for `List-Unsubscribe` / `List-Unsubscribe-Post` (RFC 2369 /
            RFC 8058) and `X-` headers. 400 `validation_failed` (with `details.field` =
            `headers.<Name>`) for: a value that is empty or holds CR, LF, another control
            character or non-ASCII (`header:value`); a name that isn't printable ASCII, has
            a space or colon, or is over 64 characters (`header:name`); a platform-owned
            header: From, To, Cc, Bcc, Subject, Date, Message-ID, Reply-To, Sender,
            Return-Path, DKIM-Signature, Received, MIME-Version, Content-Type,
            Content-Transfer-Encoding, Content-Disposition, Authentication-Results,
            Received-SPF, Resent-*, ARC-*, or a provider control header (X-SES-*,
            X-Mailgun-*, X-SG-*, X-SMTPAPI) (`header:reserved`); a repeated name, case-insensitively (`header:duplicate`);
            a line over 998 characters (`header:max_length`).
        metadata:
          $ref: "#/components/schemas/Metadata"
        attachments:
          type: array
          maxItems: 20
          description: >
            Files to attach. The combined decoded size of all attachments may not exceed
            10 MB; the request body itself is capped at 16 MB, which the base64 encoding
            of the attachments counts against. Attachments apply to template sends too.
          items:
            type: object
            required: [filename, content]
            properties:
              filename:
                type: string
                maxLength: 255
                description: Leaf name only — path separators and control characters are rejected.
                example: invoice-1234.pdf
              content_type:
                type: string
                description: Defaults to application/octet-stream.
                example: application/pdf
              content:
                type: string
                format: byte
                description: Standard base64-encoded file contents.
        template: { type: string, description: Template id or name (alternative to subject+html) }
        template_version: { type: integer }
        scheduled_for: { type: string, format: date-time, nullable: true }
        idempotency_key: { type: string }
        category:
          type: string
          enum: [transactional, marketing]
          default: transactional
          description: >
            `marketing` sends are only delivered to contacts with valid consent for the given
            brand and topic, carry platform-managed `List-Unsubscribe` / `List-Unsubscribe-Post`
            (RFC 8058 one-click) headers, and require `brand` and `topic`. Supplying those
            headers yourself on a marketing send is a 400 (`header:platform_managed`). Marketing
            is email-only. Transactional sends are never blocked by an unsubscribe.
        brand: { type: string, description: "Brand id (`brd_...`) or slug in this project. Required when `category` is `marketing`; rejected otherwise." }
        topic: { type: string, description: "Topic id (`top_...`). Required when `category` is `marketing`; rejected otherwise." }
    Metadata:
      type: object
      maxProperties: 20
      additionalProperties: { type: string, maxLength: 512 }
      example: { order_id: "1234" }
      description: >
        Your own string key/value pairs (at most 20 keys, keys up to 64 bytes, values up
        to 512 bytes). Stored with the send and returned unchanged as `data.metadata` in
        every webhook event for it. Never sent to the recipient.
    TextSend:
      type: object
      required: [to]
      description: >
        Body for SMS (`/v1/sms/send`) and chat (`/v1/chat/send`) sends. Provide
        `template`, `body`, or (WhatsApp only) a `whatsapp` template.
      properties:
        to: { type: string }
        body: { type: string }
        template: { type: string }
        template_version: { type: integer }
        whatsapp:
          $ref: "#/components/schemas/WhatsAppTemplate"
        metadata:
          $ref: "#/components/schemas/Metadata"
        scheduled_for: { type: string, format: date-time, nullable: true }
        idempotency_key: { type: string }
    WhatsAppTemplate:
      type: object
      description: >
        Send a pre-approved WhatsApp (Meta) template — required to message a user
        outside the 24h session window. The template must already be approved in
        your WhatsApp Business account; MessagePipe only references it by name.
      required: [template]
      properties:
        template: { type: string, description: The approved template name. }
        language: { type: string, description: "BCP-47 language code, e.g. en_US (default en_US)." }
        variables:
          type: array
          items: { type: string }
          description: Ordered body-parameter values substituted into the template's {{1}}, {{2}}, ...
    PushSend:
      type: object
      required: [to]
      properties:
        to:
          type: object
          description: >
            Provide a raw `device_token`, or a `user_id` that has a device
            registered via POST /v1/push/devices. A user_id send is one send
            (one credit) delivered to all of that user's registered devices;
            400 if the user has none.
          properties:
            device_token: { type: string }
            user_id: { type: string }
            platform: { type: string }
        title: { type: string }
        body: { type: string }
        template: { type: string }
        template_version: { type: integer }
        metadata:
          $ref: "#/components/schemas/Metadata"
        scheduled_for: { type: string, format: date-time, nullable: true }
        idempotency_key: { type: string }
    DeviceRegistration:
      type: object
      required: [user_id, token]
      properties:
        user_id: { type: string, description: Your identifier for the end user. }
        token: { type: string, description: The FCM/APNs device token. }
        platform: { type: string, description: "Optional, e.g. ios / android." }
    DeviceRegistered:
      type: object
      properties:
        id: { type: string, example: dev_06F9... }
        user_id: { type: string }
        platform: { type: string }
        status: { type: string, example: registered }
    BulkRequest:
      type: object
      required: [messages]
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1000
          items: { type: object, description: A single send object for the matching channel }
        global_metadata:
          type: object
          additionalProperties: true
          description: Accepted but not applied to the messages. Set `metadata` on each message instead.
    SendAccepted:
      type: object
      properties:
        id: { type: string, example: msg_06F9..., description: "The message id. Webhook events for this send carry it as `data.message_id`." }
        status: { type: string, example: queued }
        channel: { type: string, enum: [email, sms, chat, push] }
        template_id: { type: string, nullable: true }
        template_version: { type: integer, nullable: true }
        queued_at: { type: string, format: date-time }
        scheduled_for: { type: string, format: date-time, nullable: true }
        suppression:
          type: object
          description: Present when `status` is `suppressed`.
          properties:
            code:
              type: string
              enum: [suppressed_hard_bounce, suppressed_soft_bounce, suppressed_complaint, suppressed_unsubscribed,
                     suppressed_manual, suppressed_global, no_contact, no_consent, consent_pending,
                     consent_expired, evidence_below_minimum]
            since: { type: string, format: date-time, nullable: true }
        _links: { type: object, properties: { self: { type: string } } }
    BulkResult:
      type: object
      properties:
        accepted: { type: integer }
        rejected: { type: integer }
        suppressed: { type: integer, description: Messages recorded as suppressed (omitted when zero). }
        results:
          type: array
          items:
            type: object
            properties:
              index: { type: integer }
              id: { type: string }
              status: { type: string }
              suppression: { type: object, description: "Present when status is `suppressed`; same shape as on a single send.", properties: { code: { type: string }, since: { type: string, format: date-time, nullable: true } } }
              error: { $ref: "#/components/schemas/Error" }
    SendDetail:
      type: object
      properties:
        id: { type: string }
        workspace_id: { type: string }
        project_id: { type: string }
        channel: { type: string }
        recipient: { type: string }
        status: { type: string }
        template_id: { type: string, nullable: true }
        template_version: { type: integer, nullable: true }
        provider: { type: string, nullable: true }
        attempt_count: { type: integer }
        queued_at: { type: string, format: date-time }
        sent_at: { type: string, format: date-time, nullable: true }
        delivered_at: { type: string, format: date-time, nullable: true }
        failed_at: { type: string, format: date-time, nullable: true }
        failure_code:
          type: string
          nullable: true
          description: Machine-readable cause of failure (e.g. provider_terminal, no_providers), or null unless the send failed.
        failure_reason:
          type: string
          nullable: true
          description: Human-readable failure detail from the provider or dispatcher, or null unless the send failed.
        events:
          type: array
          items:
            type: object
            properties:
              type: { type: string }
              occurred_at: { type: string, format: date-time }
              provider: { type: string, nullable: true }
              metadata:
                type: object
                additionalProperties: true
                description: Event-specific detail (for failed events, includes failure_code and reason).
    SendList:
      type: object
      properties:
        data: { type: array, items: { $ref: "#/components/schemas/SendDetail" } }
        _pagination:
          type: object
          properties:
            next_cursor: { type: string, nullable: true }
            has_more: { type: boolean }
    Template:
      type: object
      properties:
        id: { type: string }
        name: { type: string }
        channel: { type: string, enum: [email, sms, chat, push] }
        sub_type: { type: string, nullable: true }
        state: { type: string }
        current_version: { type: integer }
        variables_schema: { type: array, items: { $ref: "#/components/schemas/VariableSchema" } }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
    VariableSchema:
      type: object
      properties:
        name: { type: string }
        required: { type: boolean }
        sample_value: { type: string }
        description: { type: string }
    TemplateList:
      type: object
      properties:
        data: { type: array, items: { $ref: "#/components/schemas/Template" } }
    ContactInput:
      type: object
      description: At least one of email, phone, external_id.
      additionalProperties: false
      properties:
        email: { type: string, format: email }
        phone: { type: string, description: "E.164, e.g. +15551234567" }
        external_id: { type: string, maxLength: 255 }
        first_name: { type: string, nullable: true, maxLength: 200 }
        last_name: { type: string, nullable: true, maxLength: 200 }
        locale: { type: string, nullable: true, example: fr-CA }
        timezone: { type: string, nullable: true, example: Europe/Paris }
        country: { type: string, nullable: true, example: CA, description: ISO 3166-1 alpha-2, upper case }
        attributes: { $ref: "#/components/schemas/Attributes" }
        consent:
          allOf: [ { $ref: "#/components/schemas/ConsentWrite" } ]
          description: >
            Optional. Records the person's consent in the same transaction as the contact, with exactly
            the shape and rules of `POST /v1/contacts/{id}/consent` (requires the `consent:write` scope
            as well). Either both land or neither: if the consent evidence is rejected the contact is
            not created and the error is the consent error (422). The response is the contact plus a
            `consent` object holding the consent result. Use this from a form you built yourself.
    ContactPatch:
      type: object
      additionalProperties: false
      properties:
        first_name: { type: string, nullable: true }
        last_name: { type: string, nullable: true }
        locale: { type: string, nullable: true }
        timezone: { type: string, nullable: true }
        country: { type: string, nullable: true }
        attributes: { $ref: "#/components/schemas/Attributes" }
    Attributes:
      type: object
      maxProperties: 50
      description: Keys match ^[a-z][a-z0-9_]{0,62}$. Values are string (max 1000 chars), number, boolean, list of strings, or null to remove.
      additionalProperties: true
    Contact:
      type: object
      properties:
        id: { type: string, example: con_01H }
        email: { type: string, nullable: true }
        phone: { type: string, nullable: true }
        external_id: { type: string, nullable: true }
        first_name: { type: string, nullable: true }
        last_name: { type: string, nullable: true }
        locale: { type: string, nullable: true }
        timezone: { type: string, nullable: true }
        country: { type: string, nullable: true }
        attributes: { type: object, additionalProperties: true }
        status: { type: string, enum: [active, erased] }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
        erased_at: { type: string, format: date-time, nullable: true }
        consent: { type: array, items: { $ref: "#/components/schemas/ConsentRecord" } }
    ConsentRecord:
      type: object
      properties:
        brand_id: { type: string }
        topic_id: { type: string }
        channel: { type: string, enum: [email, sms, chat, push] }
        state: { type: string, enum: [pending, subscribed, unsubscribed, expired] }
        basis: { type: string, nullable: true }
        evidence_tier: { type: string, enum: [A, B, C], nullable: true }
        implied_expires_at: { type: string, format: date-time, nullable: true }
        updated_at: { type: string, format: date-time }
    ConsentWrite:
      type: object
      required: [brand, grants]
      additionalProperties: false
      properties:
        brand: { type: string, description: Brand id or slug within this API key's project. }
        grants:
          type: array
          maxItems: 50
          items:
            type: object
            required: [topic, channel, state]
            properties:
              topic: { type: string }
              channel: { type: string, enum: [email, sms, chat, push] }
              state: { type: string, enum: [subscribed, unsubscribed] }
        statement:
          type: object
          required: [id, version]
          properties:
            id: { type: string }
            version: { type: integer, minimum: 1 }
            locale: { type: string, description: Defaults to the brand's default locale. }
        basis: { type: string, enum: [express, implied_purchase, implied_contract, implied_inquiry, implied_publication, implied_disclosed, pecr_soft_opt_in] }
        method: { type: string, enum: [checkbox_unticked, typed_address, confirm_click, toggle, keyword_reply, verbal, api_withdrawal] }
        captured_at: { type: string, format: date-time, description: When the person consented. More than 30 days old needs backfill=true. }
        channel_context: { type: string, enum: [web, app, server, pos, phone] }
        channel_context_reason: { type: string, description: Required for server, pos and phone. }
        ip: { type: string, description: Required for web and app. }
        user_agent: { type: string, description: Required for web and app. }
        page_url: { type: string }
        external_ref: { type: string }
        artifact_hash: { type: string }
        relevance_note: { type: string }
        no_unsolicited_statement: { type: boolean }
        basis_event_at: { type: string, format: date-time, nullable: true, description: Purchase, contract end or inquiry date for implied bases. }
        backfill: { type: boolean, description: Declares the consent was captured long ago; the record earns tier C. }
    ConsentWriteResult:
      type: object
      properties:
        contact_id: { type: string }
        brand_id: { type: string }
        results:
          type: array
          items:
            type: object
            properties:
              topic: { type: string }
              channel: { type: string }
              state: { type: string, enum: [pending, subscribed, unsubscribed] }
              evidence_tier: { type: string, enum: [A, B, C] }
              implied_expires_at: { type: string, format: date-time }
              event_id: { type: string }
              no_op: { type: boolean }
        warnings:
          type: array
          items:
            type: object
            properties:
              code: { type: string, enum: [address_suppressed, evidence_below_topic_minimum] }
              channel: { type: string }
              topic: { type: string }
              reasons: { type: array, items: { type: string } }
    ConsentState:
      type: object
      properties:
        contact_id: { type: string }
        records: { type: array, items: { $ref: "#/components/schemas/ConsentRecord" } }
        events: { type: array, items: { type: object, additionalProperties: true } }
    EraseResult:
      type: object
      properties:
        id: { type: string }
        status: { type: string, enum: [erased] }
        erased_at: { type: string, format: date-time }
        events_pseudonymised: { type: integer }
        suppressions_added: { type: integer }
    SuppressionInput:
      type: object
      required: [address, reason]
      additionalProperties: false
      properties:
        address: { type: string }
        channel: { type: string, enum: [email, sms, chat, push], default: email }
        reason: { type: string, enum: [manual, unsubscribed] }
        brand: { type: string, description: Brand id or slug; only with reason unsubscribed. }
        note: { type: string, maxLength: 500 }
    Suppression:
      type: object
      properties:
        id: { type: string }
        channel: { type: string }
        reason: { type: string, enum: [hard_bounce, soft_bounce_repeated, complaint, unsubscribed, manual, global_blocklist] }
        source: { type: string, enum: [manual, import, bounce, complaint, unsubscribe, global], description: How the row was created }
        brand_id: { type: string, nullable: true }
        address_key_prefix: { type: string }
        source_send_id: { type: string, nullable: true }
        note: { type: string, nullable: true }
        created_by: { type: string }
        created_at: { type: string, format: date-time }
        expires_at: { type: string, format: date-time, nullable: true }
        removed_at: { type: string, format: date-time, nullable: true }
        removed_reason: { type: string, nullable: true }
    SuppressionList:
      type: object
      properties:
        data: { type: array, items: { $ref: "#/components/schemas/Suppression" } }
        next_cursor: { type: string }
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code: { type: string }
            message: { type: string }
            details: { type: object, nullable: true, additionalProperties: true }
            request_id: { type: string }
            documentation_url: { type: string }
    # >>> generated:schemas (scripts/openapi_gateway.py; do not edit by hand)
    CampaignContent:
      type: object
      required:
      - mode
      - source
      properties:
        mode:
          type: string
          enum:
          - markdown
          - html
          - mjml
        source:
          type: string
          description: Markdown, HTML or MJML as written; at most 1 MB (MJML 256 KB)
        subject:
          type: string
          maxLength: 998
        preheader:
          type: string
          maxLength: 300
        text:
          type: string
          description: Optional hand-written plain-text part; generated from the HTML when empty
        blocks:
          type: object
          description: 'The block editor''s document (CMP-3.7.4(c)). MJML content only. When it is present
            the server builds `source` from it with the editor''s own generator and ignores the MJML sent
            with it, so the stored and sent email is always the one the document describes. It has no footer
            block: the platform adds the compliance footer (why the person receives this, the postal address,
            unsubscribe and preferences links) to every campaign, so a `footer` block is refused (400, `blocks:footer_not_allowed`).
            Every image block needs alt text (400 otherwise). Never composed or sent; omit it to detach a
            template to raw MJML.'
          additionalProperties: true
    Channel:
      type: string
      enum:
      - email
      - sms
      - chat
      - push
    Id:
      type: string
      pattern: ^[a-z]+_[A-Z0-9]+$
      examples:
      - wks_8C4E2A1F
      - usr_06F4Y9CP1GQB39AA
    # <<< generated:schemas
  responses:
    BadRequest: { description: "validation_failed / invalid_json / template_not_found", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    Unauthorized: { description: Missing or invalid API key, content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    Forbidden: { description: "insufficient_scope; forbidden (workspace suspended); or, on email sends, sender_not_allowed (`from` is off the project's sender domains)", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    NotFound: { description: not_found, content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    UnprocessableSMS: { description: "sms_destination_not_supported: managed SMS has no price for the destination country (or is not on sale), nothing was charged (details.country, details.message_type, details.reason = country_not_priced | unknown_country | managed_sms_unavailable)", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    CreditsExhausted: { description: "No credits remaining in the bucket the send is billed from (the plain channel, or the managed one for a send through a MessagePipe managed provider). A managed SMS costs segments x the destination's credit weight: when some credits remain but fewer than that, the message says how many were needed and details carries credits_required and credits_available", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    RateLimited: { description: Rate limit exceeded (see Retry-After), content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    Conflict: { description: "identity_conflict; recent_recipient_withdrawal; idempotency_in_progress", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    Unprocessable: { description: "consent_evidence_incomplete (details.missing) / consent_evidence_invalid (details.reason) / idempotency_mismatch", content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
