Postfleet Drafts API

Human-in-the-loop drafts and approvals.

GitHub OpenAPI

Operations 6

POST /api/v1/drafts Create a draft #
GET /api/v1/drafts List open drafts in a mailbox #
GET /api/v1/drafts/{id} Get a draft #
PATCH /api/v1/drafts/{id} Edit a draft's envelope #
DELETE /api/v1/drafts/{id} Discard a draft #
POST /api/v1/drafts/{id}/send Send a draft #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/postfleet-ai:postfleet-ai-drafts-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

postfleet-ai-drafts-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Postfleet Drafts API
  version: 1.0.0
  description: Hand-authored OpenAPI description of the Postfleet `/api/v1/**` REST surface. Every path, method, status code, request field, and error `code` is transcribed from the shipped route handlers under `src/app/api/v1/`; a drift test asserts this file stays in sync with the code. All endpoints authenticate with a bearer `pf_` API key. This spec documents shipped behavior only — see the `/docs` pages for narrative guides and current limitations.
servers:
- url: /
  description: Same-origin (relative). Prefix every path with your deployment origin, e.g. https://your-app.example.com
security:
- bearerAuth: []
tags:
- name: Drafts
  description: Human-in-the-loop drafts and approvals.
paths:
  /api/v1/drafts:
    post:
      operationId: createDraft
      tags:
      - Drafts
      summary: Create a draft
      description: 'Creates a voluntary draft in status `draft`. Requires `can_send`. The draft is not forced into the approval queue at creation time even on a `require_approval` mailbox — forcing happens at send time. `to` is one address or an array of up to 10 unless `reply_to_message_id` is supplied. `html` is rejected. Note: draft creation has no `client_id` idempotency yet — a retried create can duplicate a draft.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendRequest'
      responses:
        '201':
          description: Draft created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  status:
                    type: string
                    const: draft
                required:
                - id
                - status
                additionalProperties: false
        '400':
          description: Validation error (missing `mailbox_id`/`text`, bad `client_id`, `to` not a single address or more than 10 addresses, missing `to` when not replying, `html` on a draft).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Key cannot send, or is scoped to a different mailbox (`code:key_scope`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyScopeError'
        '404':
          description: Mailbox not found, or (when replying) the original message was not found / not visible to a mailbox-bound key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listDrafts
      tags:
      - Drafts
      summary: List open drafts in a mailbox
      description: Lists non-tombstoned, non-terminal drafts for a mailbox. Requires `can_read`.
      parameters:
      - name: mailbox_id
        in: query
        required: true
        schema:
          type: string
        description: A mailbox-bound key may only list its own mailbox.
      responses:
        '200':
          description: Drafts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  drafts:
                    type: array
                    items:
                      $ref: '#/components/schemas/Draft'
                required:
                - drafts
                additionalProperties: false
        '400':
          description: '`mailbox_id` query param required.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Key cannot read drafts, or is scoped to a different mailbox (`code:key_scope`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyScopeError'
  /api/v1/drafts/{id}:
    get:
      operationId: getDraft
      tags:
      - Drafts
      summary: Get a draft
      description: Returns a draft's public shape. Requires `can_read`. Missing, cross-account, cross-mailbox (for a bound key), and tombstoned (sent/rejected/deleted) drafts all collapse to a byte-identical `404` (anti-enumeration).
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Draft.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Draft'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Key cannot read drafts (`code:key_scope`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyScopeError'
        '404':
          $ref: '#/components/responses/DraftNotFound'
    patch:
      operationId: updateDraft
      tags:
      - Drafts
      summary: Edit a draft's envelope
      description: 'Merges `to`/`subject`/`text` over the stored draft and re-validates every recipient. `to` may be one address or an array of up to 10. Requires `can_send`. The reply context is immutable: supplying `reply_to_message_id` is rejected `400`. `html` is rejected.'
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDraftRequest'
      responses:
        '200':
          description: Updated draft.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Draft'
        '400':
          description: '`reply_to_message_id` cannot be changed, or the merged `to` is not a single address.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Key cannot send (`code:key_scope`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyScopeError'
        '404':
          $ref: '#/components/responses/DraftNotFound'
        '409':
          description: Draft is no longer editable (already sending or terminal).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalConflictError'
              example:
                code: approval_conflict
                error: draft is no longer editable
    delete:
      operationId: deleteDraft
      tags:
      - Drafts
      summary: Discard a draft
      description: Soft-deletes a non-terminal draft. Requires `can_send`. Returns `204` on success; `409` if the draft is already sending/sent/rejected.
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Draft discarded (no content).
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Key cannot send (`code:key_scope`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyScopeError'
        '404':
          $ref: '#/components/responses/DraftNotFound'
        '409':
          description: Draft can no longer be deleted (already sending or terminal).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalConflictError'
              example:
                code: approval_conflict
                error: draft can no longer be deleted
  /api/v1/drafts/{id}/send:
    post:
      operationId: sendDraft
      tags:
      - Drafts
      summary: Send a draft
      description: 'Sends an agent''s own draft. Requires `can_send`. The mailbox''s current `require_approval` decides the outcome: when enabled the draft is promoted to `pending_approval` (`202`); when disabled it is delivered through the shared send pipeline (`201`). A draft already queued for a human idempotently returns `202`.'
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '201':
          description: Draft sent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftSendResult'
        '202':
          description: Mailbox requires approval — the draft was queued for a human (or was already queued).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PendingApproval'
        '400':
          description: Permanent provider rejection during delivery (`{retryable:false}`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: Monthly send quota exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MonthlySendLimitError'
              example:
                code: monthly_send_limit
                error: monthly send quota exhausted
        '403':
          description: Key cannot send (`code:key_scope`), recipient blocked by a send list (`code:send_blocked_by_list`), account sending is held (`code:sending_held` or `code:account_send_held`; owner review required), or a custom-domain entitlement rejection.
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/KeyScopeError'
                - $ref: '#/components/schemas/SendBlockedByListError'
                - $ref: '#/components/schemas/SendingHeldError'
                - $ref: '#/components/schemas/AccountSendHeldError'
                - $ref: '#/components/schemas/Error'
        '404':
          $ref: '#/components/responses/DraftNotFound'
        '409':
          description: Draft can no longer be sent (concurrent send/delete/edit moved it out of a sendable state).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalConflictError'
              example:
                code: approval_conflict
                error: draft can no longer be sent
        '422':
          description: Recipient is suppressed, or the draft has no recipient.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Free-account daily send or distinct-recipient limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendRateLimitError'
        '502':
          description: Transient delivery failure (`{retryable:true}`) or an ambiguous provider outcome (`code:delivery_outcome_unknown`); the draft stays in `sending` for reconciliation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeliveryError'
        '503':
          description: Screening or quota cleanup is unavailable; known-undelivered drafts return to their original queue. Cleanup is retried by cron.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendingSafetyUnavailableError'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
      required:
      - error
      additionalProperties: false
    DraftSendResult:
      type: object
      properties:
        id:
          type: string
          description: Stored message id.
        draft_id:
          type: string
          description: The now-tombstoned source draft.
        thread_id:
          type: string
        provider_message_id:
          type: string
      required:
      - id
      - draft_id
      - thread_id
      - provider_message_id
      additionalProperties: false
    SendingSafetyUnavailableError:
      type: object
      properties:
        code:
          type: string
          enum:
          - sending_safety_unavailable
          - sending_cleanup_pending
        error:
          type: string
        retryable:
          type: boolean
          const: true
      required:
      - code
      - error
      - retryable
      additionalProperties: false
    SendRateLimitError:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          enum:
          - recipient_limit
          - daily_send_limit
      required:
      - error
      - code
      additionalProperties: false
    KeyScopeError:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          const: key_scope
      required:
      - error
      - code
      additionalProperties: false
    SendBlockedByListError:
      type: object
      properties:
        code:
          type: string
          const: send_blocked_by_list
        reason:
          type: string
          enum:
          - block_match
          - no_allow_match
        scope:
          type: string
          enum:
          - account
          - mailbox
        list_entry_id:
          description: The matched block entry (present only on `block_match`).
          type: string
      required:
      - code
      - reason
      - scope
      additionalProperties: false
    PendingApproval:
      type: object
      properties:
        draft_id:
          type: string
        status:
          type: string
          const: pending_approval
      required:
      - draft_id
      - status
      additionalProperties: false
    Draft:
      type: object
      properties:
        id:
          type: string
        mailbox_id:
          type: string
        status:
          type: string
          enum:
          - draft
          - pending_approval
          - sending
          - sent
          - rejected
        to:
          anyOf:
          - type: string
          - type: 'null'
        subject:
          type: string
        text:
          type: string
        reply_to_message_id:
          anyOf:
          - type: string
          - type: 'null'
        requires_human:
          type: boolean
        thread_id:
          type: string
        created_at:
          type: string
        updated_at:
          type: string
        attachments:
          description: Metadata only — file bytes are not returned.
          type: array
          items:
            type: object
            properties:
              filename:
                type: string
              content_type:
                type: string
              size_bytes:
                type: integer
                minimum: 0
                maximum: 9007199254740991
              url:
                description: Present when the draft stored a URL-backed attachment. Bytes are never returned.
                type: string
            required:
            - filename
            - content_type
            - size_bytes
            additionalProperties: false
      required:
      - id
      - mailbox_id
      - status
      - subject
      - text
      - requires_human
      - thread_id
      - created_at
      - updated_at
      additionalProperties: false
    SendingHeldError:
      type: object
      properties:
        code:
          type: string
          const: sending_held
        error:
          type: string
        reason:
          type: string
          enum:
          - burst_limit
          - hourly_limit
          - spam_complaint
          - hard_bounces
          - owner_pause
          - bounce_rate
          - manual_review
          - legacy_hold
          - suspicious_content
        hold_id:
          type: string
          format: uuid
          pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        retryable:
          type: boolean
          const: false
      required:
      - code
      - error
      - reason
      - hold_id
      - retryable
      additionalProperties: false
    UpdateDraftRequest:
      type: object
      properties:
        to:
          description: Replacement recipient or recipients, one address or an array of up to 10.
          anyOf:
          - type: string
          - minItems: 1
            maxItems: 10
            type: array
            items:
              type: string
              minLength: 1
        subject:
          type: string
        text:
          type: string
        attachments:
          description: Replace the draft attachments. Omit to keep the stored files; pass [] to clear them. URL-backed files are stored as the URL and fetched when the draft is sent.
          maxItems: 20
          type: array
          items:
            anyOf:
            - type: object
              properties:
                filename:
                  description: Basename only — no path separators. Derived from the URL path, or `attachment`, when omitted.
                  type: string
                  minLength: 1
                  maxLength: 255
                  pattern: ^[^/\0\\]+$
                content:
                  type: string
                  minLength: 1
                  description: File bytes, standard base64.
                content_type:
                  description: MIME type. Defaults to application/octet-stream, or the URL response Content-Type.
                  type: string
                  maxLength: 127
                  pattern: ^[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*$
              required:
              - content
              additionalProperties: false
            - type: object
              properties:
                filename:
                  description: Basename only — no path separators. Derived from the URL path, or `attachment`, when omitted.
                  type: string
                  minLength: 1
                  maxLength: 255
                  pattern: ^[^/\0\\]+$
                url:
                  type: string
                  minLength: 1
                  maxLength: 2048
                  description: HTTPS URL fetched at send time. Not forwarded to the provider.
                content_type:
                  description: MIME type. Defaults to application/octet-stream, or the URL response Content-Type.
                  type: string
                  maxLength: 127
                  pattern: ^[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*$
              required:
              - url
              additionalProperties: false
      additionalProperties: false
      description: Omitted fields keep the stored value. `reply_to_message_id` is immutable and rejected if supplied.
    MonthlySendLimitError:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          const: monthly_send_limit
      required:
      - error
      - code
      additionalProperties: false
    ApprovalConflictError:
      type: object
      properties:
        code:
          type: string
          const: approval_conflict
        error:
          type: string
      required:
      - code
      - error
      additionalProperties: false
    SendRequest:
      type: object
      properties:
        mailbox_id:
          type: string
          minLength: 1
          description: Mailbox to send from. A mailbox-bound key must match this.
        text:
          type: string
          minLength: 1
          description: Plain-text body. Required even when html is set.
        html:
          description: Optional HTML body sent with the text part. Not accepted on drafts or on mailboxes that require approval.
          type: string
          maxLength: 100000
        to:
          description: One address, or an array of up to 10. A string must be exactly one address (commas are rejected). Required unless replying.
          anyOf:
          - type: string
          - minItems: 1
            maxItems: 10
            type: array
            items:
              type: string
              minLength: 1
        subject:
          type: string
        reply_to_message_id:
          description: Reply in-thread to an existing message; resolves `to`/`subject`/thread from the original.
          type: string
        client_id:
          description: Idempotency key for duplicate protection. Must not start with `draft:` (reserved).
          type: string
          minLength: 1
          maxLength: 256
          pattern: ^(?!draft:)
        attachments:
          description: Optional files to attach. Each item is exactly one of base64 `content` or an HTTPS `url` (fetched at send time). Filename and content_type are optional. At most 20 files; 6 MB total inline, 30 MB total URL-backed. Bytes are not echoed on draft reads.
          maxItems: 20
          type: array
          items:
            anyOf:
            - type: object
              properties:
                filename:
                  description: Basename only — no path separators. Derived from the URL path, or `attachment`, when omitted.
                  type: string
                  minLength: 1
                  maxLength: 255
                  pattern: ^[^/\0\\]+$
                content:
                  type: string
                  minLength: 1
                  description: File bytes, standard base64.
                content_type:
                  description: MIME type. Defaults to application/octet-stream, or the URL response Content-Type.
                  type: string
                  maxLength: 127
                  pattern: ^[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*$
              required:
              - content
              additionalProperties: false
            - type: object
              properties:
                filename:
                  description: Basename only — no path separators. Derived from the URL path, or `attachment`, when omitted.
                  type: string
                  minLength: 1
                  maxLength: 255
                  pattern: ^[^/\0\\]+$
                url:
                  type: string
                  minLength: 1
                  maxLength: 2048
                  description: HTTPS URL fetched at send time. Not forwarded to the provider.
                content_type:
                  description: MIME type. Defaults to application/octet-stream, or the URL response Content-Type.
                  type: string
                  maxLength: 127
                  pattern: ^[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&^_.+-]*$
              required:
              - url
              additionalProperties: false
      required:
      - mailbox_id
      - text
      additionalProperties: false
    AccountSendHeldError:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          const: account_send_held
      required:
      - error
      - code
      additionalProperties: false
    DeliveryError:
      type: object
      properties:
        error:
          type: string
        retryable:
          type: boolean
        code:
          description: Present only on an ambiguous provider outcome.
          type: string
          const: delivery_outcome_unknown
      required:
      - error
      - retryable
      additionalProperties: false
  responses:
    DraftNotFound:
      description: Draft not found (missing, cross-account, cross-mailbox for a bound key, or tombstoned). Byte-identical for every case (anti-enumeration).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: draft not found
    Unauthorized:
      description: Missing or invalid bearer token, or a key whose scope is not permitted for this endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'A Postfleet API key, e.g. `Authorization: Bearer pf_...`. Keys carry a scope (`api`/`mcp`/`bootstrap`), optional mailbox binding, and `can_read`/`can_send` capabilities.'