{
  "openapi": "3.1.0",
  "info": {
    "title": "PostalForm Projects Public API",
    "version": "2026-05-06",
    "contact": {
      "name": "PostalForm",
      "url": "https://projects.postalform.com",
      "email": "support@postalform.com"
    },
    "description": "Public PostalForm Projects API for customer SDKs. Includes document uploads, quotes, mail orders, credits, API keys, and signed customer webhooks."
  },
  "servers": [
    {
      "url": "https://projects.postalform.com"
    }
  ],
  "paths": {
    "/api/v1/documents/upload-intent": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Create a PDF upload intent.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "content_type": {
                    "type": "string",
                    "const": "application/pdf"
                  },
                  "byte_size": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 26214400,
                    "description": "PDF size in bytes. Projects currently limits uploads to 25 MiB while preparation runs inside the Worker memory budget."
                  },
                  "page_count": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Optional known PDF page count. Used for quote validation and pricing if supplied."
                  },
                  "upload_origin": {
                    "type": "string",
                    "format": "uri",
                    "description": "Optional exact browser origin restriction for this individual upload, for example https://app.example.com. When omitted, browser PUTs are allowed from any origin unless the workspace has an upload-origin allowlist. Workspace and per-upload restrictions both apply when configured. Configured origins require HTTPS except HTTP localhost/loopback for development; paths and wildcards are not supported. No cookies or API-key headers are granted by CORS. Your server creates and completes the intent with its API key; the browser uploads only the PDF bytes. The URL expires after 15 minutes and cannot overwrite a completed document."
                  }
                },
                "required": [
                  "content_type",
                  "byte_size"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload instructions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadIntent"
                }
              }
            }
          }
        },
        "operationId": "createUploadIntent"
      }
    },
    "/api/v1/documents/{document_id}/complete": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Mark an uploaded document complete after the object is present.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DocumentId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "page_count": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Optional PDF page count if it was not supplied during upload-intent creation."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validated document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "document_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "validated"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "completeDocumentUpload"
      }
    },
    "/api/v1/letters/quotes": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Quote a mailpiece.",
        "description": "Quote a letter from document size, country codes, mail class, and proof-mail settings. Country codes default to US when omitted. PostalForm automatically selects an eligible fulfillment path; API clients choose mailpiece options, not the underlying production network.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          }
        },
        "operationId": "createLetterQuote"
      }
    },
    "/api/v1/letters": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.submit_without_approval"
          ]
        },
        "summary": "Send a PDF as a letter in one call, or create a letter from a quote.",
        "description": "One call: send the PDF with the order, as a JSON `file_url` or a multipart `file` part, plus the recipient, sender and mail options. PostalForm stores the PDF, counts its pages, quotes it for the recipient's and sender's countries and creates the order; the response adds `document_id`, `quote_id` and `page_count`. Sending a file also requires `drafts.create`, which standard keys include. Alternatively send `quote_id` from `POST /api/v1/letters/quotes`; the mail options are then fixed by the quote. An Idempotency-Key is required. A retry with the same key returns the original order with `idempotent_replay=true` and does not store the PDF again, even after a signed `file_url` has expired. PDFs are limited to 25 MiB. A `file_url` must be a public HTTPS URL. Up to five redirects are followed, and the download must finish within 30 seconds. Multipart requests need a Content-Length header. They take `recipient`, `sender` and `metadata` as JSON parts or as bracketed fields such as `recipient[name]`. `to` and `from` are accepted as aliases for `recipient` and `sender`. To try it without a PDF, mail the sample letter at https://projects.postalform.com/samples/letter.pdf.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLetterRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "description": "Multipart form for sending a PDF as a letter in one call. Text parts carry the mail options, and booleans are true or false. recipient, sender and metadata are JSON parts or bracketed fields such as recipient[name].",
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "file": {
                        "type": "string",
                        "format": "binary",
                        "description": "The PDF to mail, at most 25 MiB."
                      },
                      "target_delivery_date": {
                        "type": "string",
                        "format": "date",
                        "description": "Optional YYYY-MM-DD arrival target for a U.S. letter, as in the JSON body."
                      },
                      "recipient": {
                        "$ref": "#/components/schemas/MailingAddress"
                      },
                      "sender": {
                        "$ref": "#/components/schemas/MailingAddress"
                      },
                      "metadata": {
                        "type": "object",
                        "description": "Optional caller metadata stored on the order and surfaced in reads/webhook payloads.",
                        "additionalProperties": true
                      }
                    },
                    "required": [
                      "file",
                      "recipient",
                      "sender"
                    ]
                  },
                  {
                    "$ref": "#/components/schemas/LetterMailOptions"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "201": {
            "description": "Created order. Optional target_delivery_date reserves credits and schedules fulfillment for a U.S. arrival target.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, for example a missing file, a missing or incomplete sender (sender_required or invalid_sender_address with missing_fields), conflicting fields, an unusable file_url, or a file that is not a readable PDF."
          },
          "411": {
            "description": "A multipart request without a Content-Length header."
          },
          "413": {
            "description": "The PDF exceeds 25 MiB. The body includes `max_bytes`."
          },
          "422": {
            "description": "The file_url could not be downloaded, or the mail options or addresses cannot be mailed as requested."
          }
        },
        "operationId": "createLetter"
      }
    },
    "/api/v1/letters/{order_id}": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Retrieve a mail order, timeline, tracking fields, and customer webhook events.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Order detail.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Letter"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "timeline": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MailOrderEvent"
                          }
                        },
                        "webhook_events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "operationId": "getLetter"
      }
    },
    "/api/v1/letters/{order_id}/document.pdf": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Preview or download the PDF for a letter order.",
        "description": "Streams the prepared PDF when available, otherwise the original uploaded PDF while preparation is pending. Documents follow the workspace document retention window.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "current",
                "original",
                "prepared"
              ],
              "default": "current"
            },
            "description": "current returns the prepared PDF when available and otherwise the original upload."
          },
          {
            "name": "disposition",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "inline",
                "attachment"
              ],
              "default": "inline"
            },
            "description": "Use attachment to download instead of previewing inline."
          }
        ],
        "responses": {
          "200": {
            "description": "PDF bytes.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "operationId": "getLetterDocument"
      }
    },
    "/api/v1/letters/{order_id}/cancel": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.cancel",
            "mailings.content.read"
          ],
          "live": [
            "mailings.cancel",
            "mailings.content.read"
          ]
        },
        "summary": "Cancel a scheduled letter before release and return reserved credits.",
        "description": "Only available while status is scheduled. Repeated cancellation is idempotent. Orders already released for fulfillment return 409.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Canceled order with funds_status released.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "409": {
            "description": "The order is no longer scheduled or already has a submission."
          }
        },
        "operationId": "cancelScheduledLetter"
      }
    },
    "/api/v1/letters/{order_id}/simulate-delivery": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "mailings.content.read"
          ],
          "live": [
            "mailings.submit_test",
            "mailings.content.read"
          ]
        },
        "summary": "Run a test letter to delivered and send its webhooks.",
        "description": "Test mode only. Test letters are never printed, so on their own they stop before delivery. This moves a test letter through accepted, in_transit and delivered, the status path a live letter takes, and creates the matching signed customer webhook events: postalform.letter.accepted, postalform.letter.in_transit and postalform.letter.delivered. Statuses the letter already reached are skipped, so a letter that was already accepted only gets the in_transit and delivered events. Deliveries to your webhook endpoints start when the request completes, so the response can list events before their delivery attempts. Calling it again on a delivered letter returns the letter unchanged and creates no new events; no Idempotency-Key is needed. Live API keys get 403 test_mode_only. Scheduled, failed, canceled and returned letters get 409 order_not_simulatable. A letter that PostalForm is preparing at that moment gets 409 order_processing; retry after the Retry-After header's seconds.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "The delivered letter with its timeline and webhook events, as GET /api/v1/letters/{order_id} returns it.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Letter"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "timeline": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MailOrderEvent"
                          }
                        },
                        "webhook_events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A live API key (test_mode_only), or a key without mailings.submit_test (permission_denied)."
          },
          "404": {
            "description": "No test letter with this ID in the key's workspace."
          },
          "409": {
            "description": "The letter is scheduled, failed, canceled or returned (order_not_simulatable), or is being prepared right now (order_processing, with a Retry-After header)."
          }
        },
        "operationId": "simulateLetterDelivery"
      }
    },
    "/api/v1/letters/{order_id}/return-receipt.pdf": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Download a stored USPS electronic return receipt.",
        "description": "Returns the signed USPS proof-of-delivery PDF after it has been acquired for an order using automatic ERR delivery. The PDF contains USPS delivery details and the recipient signature image or approved hand-stamp supplied by USPS. The order response exposes availability and the retention deadline.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "USPS electronic return receipt PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "The receipt has not been acquired or is not available for this order."
          },
          "410": {
            "description": "The stored receipt has passed its retention deadline."
          }
        },
        "operationId": "getLetterReturnReceipt"
      }
    },
    "/api/v1/return-receipts/export.zip": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Export stored electronic return receipts in bulk.",
        "description": "Downloads up to 500 available receipt PDFs plus a CSV manifest in one ZIP archive. Use the optional date range to partition larger exports.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Include orders created at or after this ISO 8601 date-time."
          },
          {
            "name": "created_before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Include orders created before this ISO 8601 date-time."
          }
        ],
        "responses": {
          "200": {
            "description": "ZIP archive containing manifest.csv and the available receipt PDFs.",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid date range."
          },
          "413": {
            "description": "Export exceeds the 500-receipt or 25 MiB limit; narrow the date range."
          }
        },
        "operationId": "exportReturnReceipts"
      }
    },
    "/api/v1/postcards/prepare": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Prepare a postcard from an image, note and mailing addresses.",
        "description": "PostalForm composes and stores the print artwork internally and returns a quote and front-and-back layout preview. No PDF upload is needed. Preparation does not create an order or reserve credits. This helper currently supports US-to-US postcards; postage and barcode in the preview are illustrative. Confirm the returned quote through POST /postcards using the same mailing addresses.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreparePostcardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Prepared postcard, quoted price and base64 PDF layout preview.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparedPostcard"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 12 MiB."
          },
          "422": {
            "description": "Invalid artwork, message or mailing address."
          },
          "429": {
            "description": "Workspace preparation rate limit exceeded."
          }
        },
        "operationId": "preparePostcard"
      }
    },
    "/api/v1/postcards/{order_id}/cancel": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.cancel",
            "mailings.content.read"
          ],
          "live": [
            "mailings.cancel",
            "mailings.content.read"
          ]
        },
        "summary": "Cancel a scheduled postcard before release and return reserved credits.",
        "description": "Only available while status is scheduled. Repeated cancellation is idempotent. Orders already released for fulfillment return 409.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Canceled order with funds_status released.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "409": {
            "description": "The order is no longer scheduled or already has a submission."
          }
        },
        "operationId": "cancelScheduledPostcard"
      }
    },
    "/api/v1/postcards/{order_id}/simulate-delivery": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "mailings.content.read"
          ],
          "live": [
            "mailings.submit_test",
            "mailings.content.read"
          ]
        },
        "summary": "Run a test postcard to delivered and send its webhooks.",
        "description": "Test mode only, and the same as POST /api/v1/letters/{order_id}/simulate-delivery for a postcard. It moves a test postcard through accepted, in_transit and delivered and creates the postalform.postcard.accepted, postalform.postcard.in_transit and postalform.postcard.delivered webhook events, skipping statuses the postcard already reached. Repeating it on a delivered postcard creates no new events. Live API keys get 403 test_mode_only; scheduled, failed, canceled and returned postcards get 409 order_not_simulatable; a postcard being prepared right now gets 409 order_processing with a Retry-After header.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "The delivered postcard with its timeline and webhook events, as GET /api/v1/postcards/{order_id} returns it.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Letter"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "timeline": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MailOrderEvent"
                          }
                        },
                        "webhook_events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A live API key (test_mode_only), or a key without mailings.submit_test (permission_denied)."
          },
          "404": {
            "description": "No test postcard with this ID in the key's workspace."
          },
          "409": {
            "description": "The postcard is scheduled, failed, canceled or returned (order_not_simulatable), or is being prepared right now (order_processing, with a Retry-After header)."
          }
        },
        "operationId": "simulatePostcardDelivery"
      }
    },
    "/api/v1/postcards/render": {
      "post": {
        "operationId": "renderPostcardArtwork",
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Render postcard artwork from images and a note without sending mail.",
        "description": "Returns a two-page bleed PDF. Cover image and message are required; the optional back image is masked behind a readable message panel and a blank mailing area. No order or credit reservation is created. PNG/JPEG data URLs only, at most 4 MiB and 4 million pixels per image; 12 MiB request limit; 30 renders per minute per workspace. Unsupported text or overflow returns 422.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderPostcardArtworkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Printable cover and note artwork; provide recipient and sender separately when creating an order.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 12 MiB."
          },
          "422": {
            "description": "Invalid image, unsupported text, or text that does not fit."
          },
          "429": {
            "description": "Workspace rendering rate limit exceeded."
          }
        }
      }
    },
    "/api/v1/postcards/quotes": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Quote a postcard mailpiece.",
        "description": "Postcards require a fully composed two-page PDF and a postcard_size of 4x6, 6x9, or 11x6. Postcards are first-class, color, double-sided mailpieces and do not support certified or registered mail.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePostcardQuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Postcard quote.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          }
        },
        "operationId": "createPostcardQuote"
      }
    },
    "/api/v1/postcards": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.submit_without_approval"
          ]
        },
        "summary": "Create a test or live postcard order from a postcard quote.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLetterRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "201": {
            "description": "Created postcard order. Optional target_delivery_date reserves credits and schedules fulfillment for a U.S. arrival target.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          }
        },
        "operationId": "createPostcard"
      }
    },
    "/api/v1/postcards/{order_id}": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Retrieve a postcard order, timeline, tracking fields, and customer webhook events.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Postcard order detail.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Letter"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "timeline": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MailOrderEvent"
                          }
                        },
                        "webhook_events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "operationId": "getPostcard"
      }
    },
    "/api/v1/postcards/{order_id}/preview.pdf": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "View a postcard order with its mailing details in place.",
        "description": "Returns a front-and-back layout preview for US-to-US postcards. Postage and barcode are illustrative. This preview is separate from the address-free print artwork and follows document retention and workspace access controls.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "PDF layout preview.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Preview unavailable or order not found."
          }
        },
        "operationId": "getPostcardPreview"
      }
    },
    "/api/v1/postcards/{order_id}/document.pdf": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Preview or download the PDF for a postcard order.",
        "description": "Streams the prepared postcard PDF when available, otherwise the original uploaded PDF while preparation is pending. Documents follow the workspace document retention window.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "current",
                "original",
                "prepared"
              ],
              "default": "current"
            },
            "description": "current returns the prepared PDF when available and otherwise the original upload."
          },
          {
            "name": "disposition",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "inline",
                "attachment"
              ],
              "default": "inline"
            },
            "description": "Use attachment to download instead of previewing inline."
          }
        ],
        "responses": {
          "200": {
            "description": "PDF bytes.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "operationId": "getPostcardDocument"
      }
    },
    "/api/v1/templates": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "List active mail templates.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Active templates in the workspace, sorted by name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MailTemplate"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listTemplates"
      },
      "post": {
        "x-workspace-permissions": {
          "test": [
            "drafts.create"
          ],
          "live": [
            "drafts.create"
          ]
        },
        "summary": "Create a reusable mail template.",
        "description": "A template stores message text with `{{field}}` placeholders plus how every send from it is mailed, either handwritten (a 4x6 card or 7x10 letter in a sealed, stamped envelope) or printed (First Class, Priority, Express, or Certified Mail). `{{first_name}}`, `{{last_name}}`, `{{full_name}}`, and `{{company}}` are filled from the recipient address; any other field is supplied in `variables` when sending. Add a fallback with `{{field|Fallback}}`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MailTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created template.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailTemplate"
                }
              }
            }
          }
        },
        "operationId": "createTemplate"
      }
    },
    "/api/v1/templates/{template_id}": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Retrieve a mail template.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          }
        ],
        "responses": {
          "200": {
            "description": "Template.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailTemplate"
                }
              }
            }
          }
        },
        "operationId": "getTemplate"
      },
      "patch": {
        "x-workspace-permissions": {
          "test": [
            "drafts.edit",
            "mailings.content.read"
          ],
          "live": [
            "drafts.edit",
            "mailings.content.read"
          ]
        },
        "summary": "Update a mail template.",
        "description": "Fields you send replace the stored values; omitted fields are kept. Orders already sent keep the text they were sent with.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MailTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated template.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailTemplate"
                }
              }
            }
          }
        },
        "operationId": "updateTemplate"
      },
      "delete": {
        "x-workspace-permissions": {
          "test": [
            "drafts.discard",
            "mailings.content.read"
          ],
          "live": [
            "drafts.discard",
            "mailings.content.read"
          ]
        },
        "summary": "Archive a mail template.",
        "description": "Archived templates can't be sent or edited. Orders already sent from them are unchanged.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          }
        ],
        "responses": {
          "200": {
            "description": "Archived template.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailTemplate"
                }
              }
            }
          }
        },
        "operationId": "archiveTemplate"
      }
    },
    "/api/v1/templates/{template_id}/send": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "drafts.create"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.submit_without_approval",
            "drafts.create"
          ]
        },
        "summary": "Send one mailpiece from a template.",
        "description": "Fills the template for the recipient, then creates a handwritten or printed order according to the template's delivery settings and reserves credits. Requires an Idempotency-Key; repeating a key returns the original order without sending again. Returns 400 naming any `{{field}}` that has no value.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailSendOrder"
                }
              }
            }
          },
          "201": {
            "description": "Created order.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailSendOrder"
                }
              }
            }
          }
        },
        "operationId": "sendTemplate"
      }
    },
    "/api/v1/handwritten": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "drafts.create"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.submit_without_approval",
            "drafts.create"
          ]
        },
        "summary": "Send a handwritten card or letter.",
        "description": "Writes the message in a handwriting style and mails it in a sealed envelope with a first-class stamp to a U.S. address. The message may use English letters, numbers, accented Latin letters, and common punctuation; 4x6 cards fit 400 characters and 7x10 letters fit 1,000. Requires an Idempotency-Key.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHandwrittenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailSendOrder"
                }
              }
            }
          },
          "201": {
            "description": "Created handwritten order.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailSendOrder"
                }
              }
            }
          }
        },
        "operationId": "createHandwritten"
      }
    },
    "/api/v1/handwritten/{order_id}": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Retrieve a handwritten order, its message, timeline, and customer webhook events.",
        "description": "Handwritten mail reports accepted, in_transit once handed to the carrier, and failed or canceled when it can't be mailed. It has no carrier tracking number.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Handwritten order detail.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/MailSendOrder"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "timeline": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MailOrderEvent"
                          }
                        },
                        "webhook_events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "operationId": "getHandwritten"
      }
    },
    "/api/v1/handwritten/{order_id}/document.pdf": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Download the proof PDF for a handwritten order.",
        "description": "A two-page proof showing the message and the envelope. The mailed piece is written in a handwriting style rather than typeset.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/OrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Proof PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "operationId": "getHandwrittenDocument"
      }
    },
    "/api/v1/webhook-endpoints": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "List customer webhook endpoints for the workspace.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listWebhookEndpoints"
      },
      "post": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "Configure a customer webhook endpoint for status events.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^https://",
                    "description": "HTTPS endpoint that receives signed PostalForm status webhooks."
                  },
                  "signing_secret": {
                    "type": "string",
                    "description": "Optional. Generated if omitted."
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointSecretResponse"
                }
              }
            }
          }
        },
        "operationId": "createWebhookEndpoint"
      }
    },
    "/api/v1/webhook-endpoints/{endpoint_id}": {
      "delete": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "Disable a customer webhook endpoint.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "endpoint_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disabled endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          }
        },
        "operationId": "disableWebhookEndpoint"
      }
    },
    "/api/v1/webhook-endpoints/{endpoint_id}/rotate-secret": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "Rotate a customer webhook endpoint signing secret.",
        "description": "Returns the new signing secret once. Store it securely; list endpoints does not expose secrets.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "endpoint_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rotated endpoint signing secret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointSecretResponse"
                }
              }
            }
          }
        },
        "operationId": "rotateWebhookEndpointSecret"
      }
    },
    "/api/v1/webhook-events": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "List customer webhook events for the workspace.",
        "description": "Customer webhook events are fulfillment status-change events only. Event names use `postalform.{letter|postcard|handwritten}.{status}` and are emitted for `accepted`, `in_transit`, `delivered`, `returned`, `failed`, and `canceled`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Events.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listWebhookEvents"
      }
    },
    "/api/v1/webhook-events/{event_id}/replay": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ],
          "live": [
            "integrations.webhooks.manage",
            "mailings.content.read"
          ]
        },
        "summary": "Queue a customer webhook event for replay.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/EventId"
          }
        ],
        "responses": {
          "200": {
            "description": "Replay queued."
          }
        },
        "operationId": "replayWebhookEvent"
      }
    },
    "/api/v1/credits/balance": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "billing.read"
          ],
          "live": [
            "billing.read"
          ]
        },
        "summary": "Get prepaid credit balance.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditBalance"
                }
              }
            }
          }
        },
        "operationId": "getCreditBalance"
      }
    },
    "/api/v1/credits/payment-methods": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "billing.read"
          ],
          "live": [
            "billing.read"
          ]
        },
        "summary": "List saved live billing payment methods.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Saved payment methods for live auto-refill.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BillingPaymentMethod"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listPaymentMethods"
      }
    },
    "/api/v1/credits/payment-methods/setup-session": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "billing.payment_methods.manage"
          ],
          "live": [
            "billing.payment_methods.manage"
          ]
        },
        "summary": "Create a Checkout setup session for live credit auto-refill.",
        "description": "Requires a live API key. The returned Checkout URL lets the customer save a payment method for future off-session auto-refill charges.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Checkout setup session URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethodSetupSession"
                }
              }
            }
          }
        },
        "operationId": "createPaymentMethodSetupSession"
      }
    },
    "/api/v1/credits/auto-refill": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "billing.read"
          ],
          "live": [
            "billing.read"
          ]
        },
        "summary": "Get credit auto-refill threshold policies.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Auto-refill policies for test and live credit balances.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditAutoRefillPolicies"
                }
              }
            }
          }
        },
        "operationId": "getCreditAutoRefillPolicies"
      },
      "post": {
        "x-workspace-permissions": {
          "test": [
            "billing.auto_refill.manage"
          ],
          "live": [
            "billing.auto_refill.manage"
          ]
        },
        "summary": "Configure the credit auto-refill threshold for the authenticated key mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreditAutoRefillRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated auto-refill policy.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CreditAutoRefillPolicy"
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "configureCreditAutoRefill"
      }
    },
    "/api/v1/credits/ledger": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "billing.read"
          ],
          "live": [
            "billing.read"
          ]
        },
        "summary": "List prepaid credit ledger entries.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Ledger entries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CreditLedgerEntry"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listCreditLedger"
      }
    },
    "/api/v1/api-keys": {
      "get": {
        "x-workspace-permissions": {
          "test": [
            "integrations.api_keys.manage"
          ],
          "live": [
            "integrations.api_keys.manage"
          ]
        },
        "summary": "List API key prefixes and status.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "API keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "listApiKeys"
      }
    },
    "/api/v1/api-keys/rotate": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "integrations.api_keys.manage"
          ],
          "live": [
            "integrations.api_keys.manage"
          ]
        },
        "summary": "Rotate a test or live API key.",
        "description": "A test-mode key can rotate only test keys; rotating live keys requires a live key. The new key never has permissions the calling key lacks.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "$ref": "#/components/schemas/Mode"
                  }
                },
                "required": [
                  "mode"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New API key secret. Returned once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyRotation"
                }
              }
            }
          },
          "403": {
            "description": "mode_mismatch when a test key asks to rotate live keys, or live_mode_disabled."
          }
        },
        "operationId": "rotateApiKey"
      }
    },
    "/api/v1/credits/checkout-session": {
      "post": {
        "x-workspace-permissions": {
          "test": [
            "billing.topup"
          ],
          "live": [
            "billing.topup"
          ]
        },
        "summary": "Create a prepaid credit top-up checkout session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount_cents": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stripe Checkout URL in configured environments, or a local checkout stub URL for local development.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditCheckoutSession"
                }
              }
            }
          }
        },
        "operationId": "createCreditCheckoutSession"
      }
    },
    "/api/v1/drafts": {
      "get": {
        "summary": "List mailing drafts within the credential mode.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "listMailingDrafts",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "drafts"
                  ],
                  "properties": {
                    "drafts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MailingDraft"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      },
      "post": {
        "summary": "Save a mailing draft without spending or sending.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "createMailingDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.create",
            "mailings.content.read"
          ],
          "live": [
            "drafts.create",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMailingDraftRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}": {
      "get": {
        "summary": "Read a mailing draft and its immutable revisions.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "getMailingDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      },
      "patch": {
        "summary": "Save a new draft revision and invalidate approval.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "reviseMailingDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.edit",
            "mailings.content.read"
          ],
          "live": [
            "drafts.edit",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SaveMailingDraftRequest"
                  },
                  {
                    "type": "object",
                    "required": [
                      "revision"
                    ],
                    "properties": {
                      "revision": {
                        "type": "integer",
                        "minimum": 1
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}/request-approval": {
      "post": {
        "summary": "Request independent expenditure approval.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "requestMailingApproval",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.request_approval",
            "mailings.content.read"
          ],
          "live": [
            "drafts.request_approval",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}/withdraw": {
      "post": {
        "summary": "Withdraw an unused approval request.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "withdrawMailingApproval",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.request_approval",
            "mailings.content.read"
          ],
          "live": [
            "drafts.request_approval",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}/discard": {
      "post": {
        "summary": "Discard an unreleased draft without erasing its history.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "discardMailingDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.discard",
            "mailings.content.read"
          ],
          "live": [
            "drafts.discard",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}/refresh": {
      "post": {
        "summary": "Refresh pricing and create a new unapproved revision.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "refreshMailingDraftPrice",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.edit",
            "mailings.content.read"
          ],
          "live": [
            "drafts.edit",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/drafts/{draft_id}/release": {
      "post": {
        "summary": "Release the approved revision once; retries return the same order.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "releaseMailingDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "mailings.content.read"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "order",
                    "created"
                  ],
                  "properties": {
                    "order": {
                      "$ref": "#/components/schemas/Letter"
                    },
                    "created": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "order",
                    "created"
                  ],
                  "properties": {
                    "order": {
                      "$ref": "#/components/schemas/Letter"
                    },
                    "created": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, reassignment_required, approval_pending, changes_requested, or handwritten_unavailable; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/approvals": {
      "get": {
        "summary": "Read an expense-only summary without documents, addresses, metadata, or tracking.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "listMailingApprovals",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "approvals.read"
          ],
          "live": [
            "approvals.read"
          ]
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "drafts"
                  ],
                  "properties": {
                    "drafts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MailingApprovalSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/approvals/{draft_id}": {
      "get": {
        "summary": "Read an expense-only summary without documents, addresses, metadata, or tracking.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "getMailingApproval",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "approvals.read"
          ],
          "live": [
            "approvals.read"
          ]
        },
        "parameters": [
          {
            "name": "draft_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingApprovalSummary"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/templates/{template_id}/drafts": {
      "post": {
        "summary": "Prepare a rendered mailing draft without spending or sending.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "createTemplateDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.create",
            "mailings.content.read"
          ],
          "live": [
            "drafts.create",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTemplateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/handwritten/drafts": {
      "post": {
        "summary": "Prepare a rendered mailing draft without spending or sending.",
        "description": "Authenticated workspace and credential mode apply. Approval decisions require a signed-in human in the dashboard; API keys cannot approve. Draft preparation and approval never reserve credits, charge or enqueue mail.",
        "operationId": "createHandwrittenDraft",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-workspace-permissions": {
          "test": [
            "drafts.create",
            "mailings.content.read"
          ],
          "live": [
            "drafts.create",
            "mailings.content.read"
          ]
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHandwrittenRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "draft"
                  ],
                  "properties": {
                    "draft": {
                      "$ref": "#/components/schemas/MailingDraft"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "permission_denied or approval_required; no mailing or payment action."
          },
          "409": {
            "description": "revision_conflict, revision_changed, draft_closed, idempotency_conflict, or reassignment_required; refresh and review the current draft."
          }
        }
      }
    },
    "/api/v1/brochures/catalog": {
      "get": {
        "operationId": "getBrochureCatalog",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Get the square roll-fold brochure specification.",
        "description": "Brochures are bundles shipped to US delivery addresses. Printing requires an approved proof, operator preflight, current quotes, prepaid credit and an enabled production interface.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Brochure specification and pricing basis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brochures": {
      "get": {
        "operationId": "listBrochureDrafts",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "List brochure drafts in this workspace and API-key mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Drafts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BrochureDraft"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createBrochureDraft",
        "x-workspace-permissions": {
          "test": [
            "drafts.create",
            "mailings.content.read"
          ],
          "live": [
            "drafts.create",
            "mailings.content.read"
          ]
        },
        "summary": "Save an unpaid brochure draft without printing, charging or sending email.",
        "description": "Requires drafts.create and mailings.content.read. Delivery addresses may be omitted while preparing a draft. Use the existing document upload API for two flat PDF sides, then attach document_id.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BrochureDraftInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved draft, or the current draft on an identical retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureDraft"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brochures/{brochure_id}": {
      "parameters": [
        {
          "in": "path",
          "name": "brochure_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getBrochureDraft",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Get a brochure draft and its remaining preparation steps.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Brochure draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureDraft"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateBrochureDraft",
        "x-workspace-permissions": {
          "test": [
            "drafts.edit",
            "mailings.content.read"
          ],
          "live": [
            "drafts.edit",
            "mailings.content.read"
          ]
        },
        "summary": "Replace brochure draft fields and invalidate its prices and proof status.",
        "description": "Requires drafts.edit and mailings.content.read. Include the current revision; stale revisions return 409.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/BrochureDraftInput"
                  },
                  {
                    "type": "object",
                    "required": [
                      "revision"
                    ],
                    "properties": {
                      "revision": {
                        "type": "integer",
                        "minimum": 1
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureDraft"
                }
              }
            }
          },
          "409": {
            "description": "Draft revision changed; reload before saving."
          }
        }
      }
    },
    "/api/v1/brochures/{brochure_id}/quote": {
      "parameters": [
        {
          "in": "path",
          "name": "brochure_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "quoteBrochureDraft",
        "x-workspace-permissions": {
          "test": [
            "drafts.edit",
            "mailings.content.read"
          ],
          "live": [
            "drafts.edit",
            "mailings.content.read"
          ]
        },
        "summary": "Quote printing, folding, tracked shipping and tax for every delivery.",
        "description": "Requires all US delivery addresses and drafts.edit plus mailings.content.read. Does not create a print order or charge payment. Grayscale artwork uses the full-color SKU. Quote expiration is returned per shipment.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "revision"
                ],
                "properties": {
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft with current retail delivery quotes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureDraft"
                }
              }
            }
          },
          "409": {
            "description": "Draft revision changed."
          },
          "502": {
            "description": "Provider pricing is unavailable; no print order or charge was created."
          }
        }
      }
    },
    "/api/v1/brochures/{brochure_id}/readiness": {
      "parameters": [
        {
          "in": "path",
          "name": "brochure_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getBrochureReadiness",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Check missing addresses, quotes and artwork review.",
        "description": "Checks current permission, proof, preflight, quotes, prepaid credit and production configuration. Checking readiness cannot print or reserve funds.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Readiness and preparation blockers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "can_submit": {
                      "type": "boolean"
                    },
                    "price_cents": {
                      "type": "integer"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "order_id": {
                      "type": "string"
                    },
                    "blockers": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brochures/{brochure_id}/orders": {
      "parameters": [
        {
          "in": "path",
          "name": "brochure_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "releaseBrochureOrder",
        "x-workspace-permissions": {
          "test": [
            "mailings.submit_test",
            "mailings.content.read"
          ],
          "live": [
            "mailings.submit_live",
            "mailings.content.read"
          ]
        },
        "summary": "Reserve prepaid credit and queue an approved brochure for printing.",
        "description": "Requires a current human proof approval and operator preflight. Live orders require an enabled production interface and prepaid billing. Uses fresh delivery quotes without exceeding the approved price. Idempotent retries return the same order. Test orders simulate acceptance and shipping without contacting the provider.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "revision",
                  "maximum_price_cents",
                  "confirm"
                ],
                "properties": {
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "maximum_price_cents": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "confirm": {
                    "type": "string",
                    "enum": [
                      "SEND_BROCHURES"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Queued order or identical retry. Credit is captured per accepted delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureOrder"
                }
              }
            }
          },
          "400": {
            "description": "Preparation, production configuration or prepaid credit is incomplete."
          },
          "403": {
            "description": "Submission permission denied."
          },
          "409": {
            "description": "Revision, price authorization or idempotency conflict."
          }
        }
      }
    },
    "/api/v1/brochure-orders": {
      "get": {
        "operationId": "listBrochureOrders",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "List brochure orders in this workspace and mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Brochure orders.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BrochureOrder"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brochure-orders/{order_id}": {
      "parameters": [
        {
          "in": "path",
          "name": "order_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getBrochureOrder",
        "x-workspace-permissions": {
          "test": [
            "mailings.content.read"
          ],
          "live": [
            "mailings.content.read"
          ]
        },
        "summary": "Read brochure delivery, funds and tracking status.",
        "description": "Shipped means the printer reports shipment completion; it does not certify carrier delivery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Brochure order.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureOrder"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brochure-orders/{order_id}/cancel": {
      "parameters": [
        {
          "in": "path",
          "name": "order_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "cancelBrochureOrder",
        "x-workspace-permissions": {
          "test": [
            "mailings.cancel",
            "mailings.content.read"
          ],
          "live": [
            "mailings.cancel",
            "mailings.content.read"
          ]
        },
        "summary": "Cancel a brochure order before any delivery begins printing.",
        "description": "Releases reserved credit only while every delivery remains queued. Started or uncertain orders require support reconciliation; this endpoint does not request provider cancellation or assume a refund.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled order with credit released.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrochureOrder"
                }
              }
            }
          },
          "400": {
            "description": "Printing has already started or acceptance is uncertain."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Workspace API key with enforced permissions. Each operation documents test/live requirements in x-workspace-permissions. Standard keys include direct sending. The exact historical letters:write plus letters:read pair retains broad access; individual legacy labels do not grant billing or key management. Denied actions return 403 permission_denied, or approval_required when live direct-send permission is missing. Key rotation preserves restrictions and cannot exceed the caller's permissions. Approved-draft release and restricted human team roles are not yet exposed."
      }
    },
    "schemas": {
      "UploadIntent": {
        "type": "object",
        "properties": {
          "document_id": {
            "type": "string"
          },
          "upload_url": {
            "type": "string",
            "format": "uri"
          },
          "upload_method": {
            "type": "string",
            "enum": [
              "PUT"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateQuoteRequest": {
        "type": "object",
        "description": "Letter quote request. API clients choose mailpiece options; PostalForm handles fulfillment automatically.",
        "properties": {
          "document_id": {
            "type": "string"
          },
          "page_count": {
            "type": "integer",
            "minimum": 1,
            "description": "Optional explicit PDF page count. Used for deterministic pricing when present."
          },
          "mail_class": {
            "type": "string",
            "default": "usps_first_class",
            "description": "Standard/USPS First Class by default. Accepts standard/usps_first_class, priority/usps_priority, and express/usps_express. Priority/Express cannot be combined with certified or registered proof mail."
          },
          "color": {
            "type": "boolean",
            "default": false
          },
          "double_sided": {
            "type": "boolean",
            "default": true
          },
          "standalone_address_page": {
            "type": "boolean",
            "description": "Keep the address page on its own sheet with a blank reverse for double-sided letters, preserving the document page pairing. Omit to inherit the workspace setting (off by default); explicit true or false overrides it. Single-sided letters are unchanged. The resolved choice is fixed on the quote, and added pages or sheets are included in pricing and provider limits."
          },
          "certified": {
            "type": "boolean",
            "default": false,
            "description": "Proof-mail add-on for letters only. Eligible U.S. standard letters request USPS Certified Mail. Eligible Canada standard letters request Canada Post Registered Mail. Eligible Belgium, Switzerland, Spain, and France standard letters request the available registered-mail option for that destination."
          },
          "certified_return_receipt": {
            "type": "boolean",
            "default": false,
            "description": "Return receipt for eligible U.S. Certified Mail letters. Defaults to the electronic format when true."
          },
          "return_receipt_format": {
            "type": "string",
            "enum": [
              "electronic",
              "physical"
            ],
            "default": "electronic",
            "description": "Electronic selects the USPS signed proof-of-delivery PDF. Physical selects the mailed PS Form 3811 green card. Requires certified_return_receipt=true."
          },
          "restricted_delivery": {
            "type": "boolean",
            "default": false,
            "description": "Requests USPS Restricted Delivery for addressee-only delivery. Requires certified_return_receipt=true and uses the provider-managed restricted-delivery service."
          },
          "err_delivery": {
            "type": "string",
            "enum": [
              "manual",
              "email"
            ],
            "default": "manual",
            "description": "Manual leaves receipt retrieval to the customer through the USPS tracking link. Email makes PostalForm acquire, retain, and email the electronic receipt when available."
          },
          "err_email": {
            "type": "string",
            "format": "email",
            "maxLength": 256,
            "description": "Optional destination when err_delivery=email. If omitted, PostalForm uses the Projects account email. Not valid for a physical PS Form 3811."
          },
          "signature_required": {
            "type": "boolean",
            "default": false,
            "description": "Signature confirmation for eligible U.S. Priority and Express letters."
          },
          "destination_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "US",
            "description": "ISO 3166-1 alpha-2 destination country code used for quote validation and pricing. Defaults to US. First-party Projects destinations are US, CA, AT, BE, CH, DE, ES, FR, GB, IN, LU, and NL."
          },
          "origin_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "US",
            "description": "ISO 3166-1 alpha-2 sender/origin country code used for quote validation and pricing. Defaults to US."
          }
        },
        "required": [
          "document_id"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "standalone_address_page": {
            "type": "boolean",
            "description": "Resolved standalone address page setting saved on this quote. Always false for postcards."
          },
          "quote_id": {
            "type": "string"
          },
          "mailpiece_type": {
            "type": "string",
            "enum": [
              "letter",
              "postcard"
            ]
          },
          "postcard_size": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "4x6",
              "6x9",
              "11x6",
              null
            ]
          },
          "price_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string",
            "enum": [
              "usd"
            ]
          },
          "pricing_version": {
            "type": "string"
          },
          "certified_return_receipt": {
            "type": "boolean"
          },
          "return_receipt_format": {
            "type": "string",
            "enum": [
              "electronic",
              "physical"
            ]
          },
          "restricted_delivery": {
            "type": "boolean"
          },
          "err_delivery": {
            "type": "string",
            "enum": [
              "manual",
              "email"
            ]
          },
          "err_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email"
          },
          "signature_required": {
            "type": "boolean"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateLetterRequest": {
        "description": "Send the PDF at file_url with its mail options, or create the order from quote_id. Requires Idempotency-Key header. sender is the return address printed on the mailpiece and needs a name or company, line1, city and postal_code, plus state in the U.S. and Canada; without one the order is rejected with 400 sender_required or invalid_sender_address.",
        "allOf": [
          {
            "type": "object",
            "properties": {
              "file_url": {
                "type": "string",
                "format": "uri",
                "description": "Public HTTPS URL of the PDF to mail, instead of quote_id. PostalForm downloads it once, counts its pages and quotes it with the mail options in this request."
              },
              "quote_id": {
                "type": "string",
                "description": "Quote from POST /api/v1/letters/quotes, instead of file_url. The quote fixes the mail options."
              },
              "target_delivery_date": {
                "type": "string",
                "format": "date",
                "description": "Optional YYYY-MM-DD arrival target for U.S. letters and postcards, at most 180 days ahead. PostalForm works backward from the conservative end-to-end estimate, including production, mailing speed, cutoffs and holidays. Arrival is estimated and may be early or late. A too-soon date returns 422 with earliest_delivery_date; unsupported destinations also return 422. The order reserves credits immediately and remains scheduled until scheduled_release_at. Cancel before release to return reserved credits. Omit to start normal fulfillment immediately. Use the same date on idempotent retries."
              },
              "recipient": {
                "$ref": "#/components/schemas/MailingAddress"
              },
              "sender": {
                "$ref": "#/components/schemas/MailingAddress"
              },
              "metadata": {
                "type": "object",
                "description": "Optional caller metadata stored on the order and surfaced in reads/webhook payloads.",
                "additionalProperties": true
              }
            },
            "required": [
              "recipient",
              "sender"
            ]
          },
          {
            "$ref": "#/components/schemas/LetterMailOptions"
          }
        ]
      },
      "MailingAddress": {
        "type": "object",
        "description": "Flexible mailing address object. Pass countryCode, country_code, country, address_country, or addressCountry for international destinations; country defaults to US when omitted.",
        "additionalProperties": true,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Name is preserved. The selected mailing route may require a lower limit of 40 or 45 characters. Validation errors identify the applicable limit. Overlong names are rejected before credits are reserved and are never silently shortened."
          },
          "company": {
            "type": "string"
          },
          "line1": {
            "type": "string",
            "description": "Also accepts street1, address_line1, or addressLine1."
          },
          "line2": {
            "type": "string",
            "description": "Also accepts street2, address_line2, or addressLine2."
          },
          "city": {
            "type": "string",
            "description": "Also accepts address_city or addressCity."
          },
          "state": {
            "type": "string",
            "description": "Also accepts province, provinceOrState, address_state, or addressState."
          },
          "postal_code": {
            "type": "string",
            "description": "Also accepts postalCode, postalOrZip, zip, address_zip, or addressZip."
          },
          "countryCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "US",
            "description": "ISO 3166-1 alpha-2 country code. Defaults to US when omitted."
          }
        }
      },
      "LetterMailOptions": {
        "type": "object",
        "description": "Mail options for a letter sent with its PDF. They match POST /api/v1/letters/quotes, but the countries come from the addresses.",
        "properties": {
          "mail_class": {
            "type": "string",
            "default": "usps_first_class",
            "description": "Standard/USPS First Class by default. Accepts standard/usps_first_class, priority/usps_priority, and express/usps_express. Priority/Express cannot be combined with certified or registered proof mail."
          },
          "color": {
            "type": "boolean",
            "default": false
          },
          "double_sided": {
            "type": "boolean",
            "default": true
          },
          "standalone_address_page": {
            "type": "boolean",
            "description": "Keep the address page on its own sheet for double-sided letters. Omit to inherit the workspace setting."
          },
          "certified": {
            "type": "boolean",
            "default": false,
            "description": "Proof-mail add-on, as in POST /api/v1/letters/quotes. U.S. letters request USPS Certified Mail."
          },
          "certified_return_receipt": {
            "type": "boolean",
            "default": false,
            "description": "Return receipt for eligible U.S. Certified Mail letters."
          },
          "return_receipt_format": {
            "type": "string",
            "enum": [
              "electronic",
              "physical"
            ],
            "default": "electronic",
            "description": "Requires certified_return_receipt=true."
          },
          "restricted_delivery": {
            "type": "boolean",
            "default": false,
            "description": "USPS Restricted Delivery. Requires certified_return_receipt=true."
          },
          "err_delivery": {
            "type": "string",
            "enum": [
              "manual",
              "email"
            ],
            "default": "manual",
            "description": "Email makes PostalForm acquire, retain, and email the electronic receipt when available."
          },
          "err_email": {
            "type": "string",
            "format": "email",
            "maxLength": 256,
            "description": "Optional destination when err_delivery=email. Defaults to the Projects account email."
          },
          "signature_required": {
            "type": "boolean",
            "default": false,
            "description": "Signature confirmation for eligible U.S. Priority and Express letters."
          },
          "page_count": {
            "type": "integer",
            "minimum": 1,
            "description": "Optional expected page count. The request is rejected if the PDF has a different number of pages."
          },
          "destination_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "description": "Optional. Must match the recipient's country, which sets the destination."
          },
          "origin_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "description": "Optional. Must match the sender's country, which sets the origin."
          }
        }
      },
      "Letter": {
        "type": "object",
        "properties": {
          "target_delivery_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "scheduled_release_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Planned start of fulfillment. A scheduled order is released by the periodic worker, normally within 15 minutes. This is not a guaranteed delivery time."
          },
          "estimated_delivery_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "estimated_delivery_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "preview_url": {
            "type": "string",
            "description": "Authenticated PDF layout preview for a postcard order, including mailing details. Available for US-to-US postcards."
          },
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "letter",
              "postcard",
              "handwritten"
            ]
          },
          "mailpiece_type": {
            "type": "string",
            "enum": [
              "letter",
              "postcard",
              "handwritten"
            ]
          },
          "postcard_size": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "4x6",
              "6x9",
              "11x6",
              null
            ]
          },
          "status": {
            "$ref": "#/components/schemas/MailOrderStatus"
          },
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "price_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "funds_status": {
            "type": "string"
          },
          "billing_rail": {
            "type": "string"
          },
          "tracking_number": {
            "type": "string",
            "nullable": true,
            "description": "Carrier tracking number when available."
          },
          "tracking_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Direct USPS tracking URL when a tracking number is available. Manual ERR customers can use it to request their receipt from USPS."
          },
          "tracking_status": {
            "type": "string",
            "nullable": true,
            "description": "Normalized tracking status when available."
          },
          "return_receipt_format": {
            "type": "string",
            "enum": [
              "electronic",
              "physical"
            ]
          },
          "restricted_delivery": {
            "type": "boolean"
          },
          "err_delivery": {
            "type": "string",
            "enum": [
              "manual",
              "email"
            ]
          },
          "err_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email"
          },
          "err_status": {
            "type": "string",
            "enum": [
              "manual",
              "pending",
              "sent",
              "failed",
              "expired"
            ]
          },
          "err_delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "err_retention_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last instant at which an acquired receipt remains retrievable. PostalForm's default ERR retention is three years."
          },
          "return_receipt_available": {
            "type": "boolean",
            "description": "Whether a stored electronic receipt can currently be downloaded."
          },
          "return_receipt_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Relative authenticated download URL when return_receipt_available is true."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "idempotent_replay": {
            "type": "boolean"
          },
          "document_id": {
            "type": "string",
            "description": "Stored PDF, returned when the PDF was sent with the order."
          },
          "quote_id": {
            "type": "string",
            "description": "Quote PostalForm created for the PDF, returned when the PDF was sent with the order."
          },
          "page_count": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Pages counted in the PDF, returned when the PDF was sent with the order."
          }
        }
      },
      "MailOrderEvent": {
        "type": "object",
        "description": "Customer-facing order timeline event. Internal fulfillment identifiers are not exposed.",
        "properties": {
          "id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "status_before": {
            "type": "string"
          },
          "status_after": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "orderId": {
            "type": "string"
          },
          "eventType": {
            "$ref": "#/components/schemas/CustomerWebhookEventType"
          },
          "payload": {
            "$ref": "#/components/schemas/CustomerWebhookPayload"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "deliveries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDeliveryAttempt"
            }
          }
        }
      },
      "PreparePostcardRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "front_image",
          "message",
          "recipient",
          "sender"
        ],
        "properties": {
          "postcard_size": {
            "type": "string",
            "enum": [
              "4x6",
              "6x9",
              "11x6"
            ],
            "default": "4x6"
          },
          "front_image": {
            "type": "string",
            "maxLength": 5592460,
            "description": "PNG/JPEG base64 data URL for the cover; at most 4 MiB decoded and 4 million pixels."
          },
          "back_image": {
            "type": "string",
            "maxLength": 5592460,
            "description": "Optional PNG/JPEG data URL for message-side decoration. The message panel and mailing area are covered with opaque white."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "Latin text and common punctuation. The renderer rejects layout overflow even below this input limit."
          },
          "signature": {
            "type": "string",
            "maxLength": 120
          },
          "front_text": {
            "type": "string",
            "maxLength": 120
          },
          "front_text_color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "default": "#392b22"
          },
          "recipient": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          }
        }
      },
      "PreparedPostcard": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Quote"
          },
          {
            "type": "object",
            "required": [
              "document_id",
              "recipient",
              "sender",
              "preview_pdf_base64",
              "preview_kind"
            ],
            "properties": {
              "document_id": {
                "type": "string",
                "description": "Print artwork stored internally by PostalForm."
              },
              "recipient": {
                "$ref": "#/components/schemas/MailingAddress"
              },
              "sender": {
                "$ref": "#/components/schemas/MailingAddress"
              },
              "preview_kind": {
                "type": "string",
                "enum": [
                  "layout"
                ]
              },
              "preview_pdf_base64": {
                "type": "string",
                "format": "byte",
                "description": "Base64-encoded two-page PDF showing the cover and note with mailing details. Postage and barcode are illustrative; display this for review and confirm using quote_id."
              }
            }
          }
        ]
      },
      "RenderPostcardArtworkRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "front_image",
          "message"
        ],
        "properties": {
          "postcard_size": {
            "type": "string",
            "enum": [
              "4x6",
              "6x9",
              "11x6"
            ],
            "default": "4x6"
          },
          "front_image": {
            "type": "string",
            "maxLength": 5592460,
            "description": "PNG/JPEG base64 data URL for the cover; at most 4 MiB decoded and 4 million pixels."
          },
          "back_image": {
            "type": "string",
            "maxLength": 5592460,
            "description": "Optional PNG/JPEG data URL for message-side decoration. The message panel and mailing area are covered with opaque white."
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "Latin text and common punctuation. The renderer rejects layout overflow even below this input limit."
          },
          "signature": {
            "type": "string",
            "maxLength": 120
          },
          "front_text": {
            "type": "string",
            "maxLength": 120
          },
          "front_text_color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "default": "#392b22"
          }
        }
      },
      "CreatePostcardQuoteRequest": {
        "type": "object",
        "description": "Postcard quote request. Postcards force first-class color double-sided mail and cannot use certified or registered mail.",
        "properties": {
          "document_id": {
            "type": "string"
          },
          "page_count": {
            "type": "integer",
            "minimum": 1,
            "description": "Optional explicit PDF page count. Postcard source PDFs should be fully composed."
          },
          "postcard_size": {
            "type": "string",
            "enum": [
              "4x6",
              "6x9",
              "11x6"
            ]
          },
          "destination_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "US",
            "description": "ISO 3166-1 alpha-2 destination country code used for quote validation and pricing. Defaults to US."
          },
          "origin_country_code": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "US",
            "description": "ISO 3166-1 alpha-2 sender/origin country code used for quote validation and pricing. Defaults to US."
          }
        },
        "required": [
          "document_id",
          "postcard_size"
        ]
      },
      "MailTemplate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "template"
            ]
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "body": {
            "type": "string"
          },
          "merge_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every placeholder in the body."
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Placeholders that must be supplied in `variables` when sending (recipient fields are filled automatically)."
          },
          "delivery": {
            "type": "object",
            "properties": {
              "method": {
                "type": "string",
                "enum": [
                  "handwritten",
                  "printed"
                ]
              },
              "format": {
                "$ref": "#/components/schemas/HandwrittenFormat"
              },
              "max_characters": {
                "type": "integer"
              },
              "mail_class": {
                "type": "string",
                "enum": [
                  "standard",
                  "priority",
                  "express"
                ]
              },
              "certified": {
                "type": "boolean"
              },
              "certified_return_receipt": {
                "type": "boolean"
              }
            }
          },
          "price_cents": {
            "type": "integer",
            "description": "Per-piece price for handwritten templates. Printed letters are priced per page when sent."
          },
          "currency": {
            "type": "string"
          },
          "sender": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MailingAddress"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MailTemplateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string"
          },
          "body": {
            "type": "string",
            "description": "Message text with `{{field}}` or `{{field|Fallback}}` placeholders."
          },
          "delivery_method": {
            "type": "string",
            "enum": [
              "handwritten",
              "printed"
            ]
          },
          "handwritten_format": {
            "$ref": "#/components/schemas/HandwrittenFormat"
          },
          "mail_class": {
            "type": "string",
            "enum": [
              "standard",
              "priority",
              "express"
            ],
            "default": "standard",
            "description": "Printed letters only. Certified Mail requires `standard`."
          },
          "certified": {
            "type": "boolean",
            "default": false,
            "description": "Printed letters only."
          },
          "certified_return_receipt": {
            "type": "boolean",
            "default": false,
            "description": "Printed Certified Mail only."
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          }
        },
        "required": [
          "name",
          "body",
          "delivery_method"
        ]
      },
      "SendTemplateRequest": {
        "type": "object",
        "properties": {
          "recipient": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Values for the template's placeholders, for example {\"amount\": \"$180\"}."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Optional caller metadata stored on the order. `template_id` is added automatically."
          }
        },
        "required": [
          "recipient"
        ]
      },
      "MailSendOrder": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Letter"
          },
          {
            "type": "object",
            "properties": {
              "template_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "handwritten_format": {
                "$ref": "#/components/schemas/HandwrittenFormat"
              },
              "message": {
                "type": "string",
                "description": "Handwritten orders only. The final text after placeholders were filled."
              },
              "document_url": {
                "type": "string",
                "description": "Path to the order's PDF (the proof for handwritten orders)."
              }
            }
          }
        ]
      },
      "CreateHandwrittenRequest": {
        "type": "object",
        "properties": {
          "format": {
            "$ref": "#/components/schemas/HandwrittenFormat"
          },
          "message": {
            "type": "string"
          },
          "recipient": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "format",
          "message",
          "recipient",
          "sender"
        ]
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEndpointSecretResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "signing_secret": {
            "type": "string",
            "description": "Returned only when the endpoint is created or its signing secret is rotated."
          }
        }
      },
      "CreditBalance": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "billing_rail": {
            "type": "string",
            "enum": [
              "mock_test_credits",
              "prepaid_credits",
              "future_projects_spt",
              "future_metronome_streaming",
              "future_mpp_tempo",
              "manual_invoice"
            ]
          },
          "available_cents": {
            "type": "integer"
          },
          "reserved_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "test": {
            "$ref": "#/components/schemas/CreditBalanceSnapshot"
          },
          "live": {
            "$ref": "#/components/schemas/CreditBalanceSnapshot"
          },
          "auto_refill": {
            "$ref": "#/components/schemas/CreditAutoRefillPolicies"
          }
        }
      },
      "BillingPaymentMethod": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "stripe"
            ]
          },
          "type": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "last4": {
            "type": "string"
          },
          "exp_month": {
            "type": "integer"
          },
          "exp_year": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaymentMethodSetupSession": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "stripe_checkout",
              "local_checkout_stub"
            ]
          },
          "checkout_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "CreditAutoRefillPolicies": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "test": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/CreditAutoRefillPolicy"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "live": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/CreditAutoRefillPolicy"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "test": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CreditAutoRefillPolicy"
              },
              {
                "type": "null"
              }
            ]
          },
          "live": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CreditAutoRefillPolicy"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "CreditAutoRefillRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "threshold_cents": {
            "type": "integer",
            "minimum": 100,
            "maximum": 100000
          },
          "refill_amount_cents": {
            "type": "integer",
            "minimum": 100,
            "maximum": 100000
          }
        },
        "required": [
          "threshold_cents",
          "refill_amount_cents"
        ]
      },
      "CreditAutoRefillPolicy": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace_id": {
            "type": "string"
          },
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "billing_rail": {
            "type": "string",
            "enum": [
              "mock_test_credits",
              "prepaid_credits"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "threshold_cents": {
            "type": "integer"
          },
          "refill_amount_cents": {
            "type": "integer"
          },
          "provider": {
            "type": "string",
            "enum": [
              "test_grant",
              "stripe_checkout",
              "local_checkout_stub"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled",
              "payment_action_required",
              "payment_pending",
              "payment_failed"
            ]
          },
          "last_triggered_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreditLedgerEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace_id": {
            "type": "string"
          },
          "credit_account_id": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "billing_rail": {
            "type": "string",
            "enum": [
              "mock_test_credits",
              "prepaid_credits",
              "future_projects_spt",
              "future_metronome_streaming",
              "future_mpp_tempo",
              "manual_invoice"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "test_grant",
              "topup",
              "reserve",
              "capture",
              "release",
              "refund",
              "adjustment"
            ]
          },
          "amount_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "external_reference": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "prefix": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled",
              "revoked"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Mode": {
        "type": "string",
        "enum": [
          "test",
          "live"
        ]
      },
      "ApiKeyRotation": {
        "type": "object",
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "api_key": {
            "type": "string",
            "description": "Full API key secret. Returned once."
          },
          "api_key_prefix": {
            "type": "string"
          }
        }
      },
      "CreditCheckoutSession": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "PostalForm top-up ID."
          },
          "mode": {
            "type": "string",
            "enum": [
              "stripe_checkout",
              "local_checkout_stub"
            ]
          },
          "checkout_url": {
            "type": "string",
            "format": "uri"
          },
          "amount_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          }
        }
      },
      "MailingDraft": {
        "type": "object",
        "required": [
          "id",
          "workspaceId",
          "mode",
          "createdByActorId",
          "state",
          "revision",
          "revisions",
          "decisions",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "createdByActorId": {
            "type": "string"
          },
          "responsibleActorId": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "pending_approval",
              "approved",
              "changes_requested",
              "discarded",
              "released"
            ]
          },
          "revision": {
            "type": "integer"
          },
          "revisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailingDraftRevision"
            }
          },
          "decisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailingApprovalDecision"
            }
          },
          "orderId": {
            "type": "string"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SaveMailingDraftRequest": {
        "type": "object",
        "required": [
          "quote_id",
          "recipient",
          "sender"
        ],
        "properties": {
          "quote_id": {
            "type": "string"
          },
          "recipient": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "DraftRevisionRequest": {
        "type": "object",
        "required": [
          "revision"
        ],
        "additionalProperties": false,
        "properties": {
          "revision": {
            "type": "integer",
            "minimum": 1,
            "description": "The current revision the caller reviewed. Release accepts no replacement mailing fields."
          }
        }
      },
      "MailingApprovalSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "workspaceId",
          "mode",
          "state",
          "revision",
          "priceCents",
          "currency",
          "submitter",
          "approvalValid",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "state": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "priceCents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "submitter": {
            "type": "string",
            "description": "Workspace staff identity or integration label, never a recipient."
          },
          "approvalValid": {
            "type": "boolean"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BrochureDraft": {
        "type": "object",
        "required": [
          "id",
          "workspace_id",
          "mode",
          "status",
          "revision",
          "title",
          "shipments",
          "total_quantity",
          "blockers"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace_id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "released"
            ]
          },
          "released_order_id": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "product": {
            "type": "string"
          },
          "artwork": {
            "type": "object",
            "additionalProperties": true
          },
          "shipments": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "total_quantity": {
            "type": "integer"
          },
          "estimate": {
            "type": "object",
            "additionalProperties": true
          },
          "blockers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BrochureDraftInput": {
        "type": "object",
        "required": [
          "title",
          "shipments"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "document_id": {
            "type": "string",
            "description": "A validated two-page flat PDF uploaded in the same workspace and mode."
          },
          "artwork_treatment": {
            "type": "string",
            "enum": [
              "grayscale",
              "color"
            ],
            "default": "grayscale"
          },
          "shipments": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "quantity"
              ],
              "properties": {
                "label": {
                  "type": "string",
                  "maxLength": 100
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 10,
                  "maximum": 10000
                },
                "address": {
                  "type": "object",
                  "required": [
                    "firstname",
                    "lastname",
                    "street1",
                    "city",
                    "state",
                    "zip",
                    "country",
                    "email",
                    "phone"
                  ],
                  "properties": {
                    "firstname": {
                      "type": "string"
                    },
                    "lastname": {
                      "type": "string"
                    },
                    "company": {
                      "type": "string"
                    },
                    "street1": {
                      "type": "string"
                    },
                    "street2": {
                      "type": "string"
                    },
                    "city": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 2
                    },
                    "zip": {
                      "type": "string"
                    },
                    "country": {
                      "const": "US"
                    },
                    "email": {
                      "type": "string",
                      "format": "email"
                    },
                    "phone": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "BrochureOrder": {
        "type": "object",
        "required": [
          "id",
          "workspace_id",
          "brochure_id",
          "mode",
          "status",
          "title",
          "price_cents",
          "currency",
          "shipments"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace_id": {
            "type": "string"
          },
          "brochure_id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "submitting",
              "submitted",
              "shipped",
              "delivered",
              "failed",
              "needs_review",
              "cancelled",
              "partial"
            ]
          },
          "title": {
            "type": "string"
          },
          "price_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "shipments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer"
                },
                "address": {
                  "type": "object",
                  "additionalProperties": true
                },
                "status": {
                  "type": "string"
                },
                "funds_status": {
                  "type": "string",
                  "enum": [
                    "reserved",
                    "captured",
                    "released",
                    "refunded"
                  ]
                },
                "tracking": {
                  "type": "object",
                  "additionalProperties": true
                },
                "error": {
                  "type": "string"
                }
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MailOrderStatus": {
        "type": "string",
        "enum": [
          "scheduled",
          "queued",
          "document_preparing",
          "document_prepared",
          "submitted",
          "accepted",
          "in_transit",
          "delivered",
          "returned",
          "submission_pending",
          "failed",
          "canceled"
        ],
        "description": "Order timeline status. `submission_pending` means the fulfillment submit job entered a physical-mail safety window where PostalForm cannot blindly retry without risking duplicate mail; it requires reconciliation if it remains the current order status."
      },
      "CustomerWebhookEventType": {
        "type": "string",
        "description": "Customer webhook event names emitted for fulfillment status changes. Replace `letter` with `postcard` for postcard mailpieces or `handwritten` for handwritten cards and letters.",
        "enum": [
          "postalform.letter.scheduled",
          "postalform.letter.queued",
          "postalform.postcard.scheduled",
          "postalform.postcard.queued",
          "postalform.letter.accepted",
          "postalform.letter.in_transit",
          "postalform.letter.delivered",
          "postalform.letter.returned",
          "postalform.letter.failed",
          "postalform.letter.canceled",
          "postalform.postcard.accepted",
          "postalform.postcard.in_transit",
          "postalform.postcard.delivered",
          "postalform.postcard.returned",
          "postalform.postcard.failed",
          "postalform.postcard.canceled",
          "postalform.handwritten.accepted",
          "postalform.handwritten.in_transit",
          "postalform.handwritten.delivered",
          "postalform.handwritten.failed",
          "postalform.handwritten.canceled"
        ],
        "x-enumDescriptions": {
          "postalform.letter.scheduled": "Letter scheduled for future release. Credits are reserved and artwork is retained until fulfillment begins or the order is canceled.",
          "postalform.letter.queued": "Scheduled letter released into ordinary preparation and fulfillment.",
          "postalform.postcard.scheduled": "Postcard scheduled for future release. Credits are reserved and artwork is retained until fulfillment begins or the order is canceled.",
          "postalform.postcard.queued": "Scheduled postcard released into ordinary preparation and fulfillment.",
          "postalform.letter.accepted": "Letter accepted for production or mailing after the order leaves PostalForm's preparation queue.",
          "postalform.letter.in_transit": "Letter entered the mail stream. The payload may include or update `mailpiece.tracking_number` when tracking is available.",
          "postalform.letter.delivered": "Letter reported delivered by the carrier or delivery network.",
          "postalform.letter.returned": "Letter returned or otherwise marked undeliverable.",
          "postalform.letter.failed": "Letter could not be produced or mailed. Inspect the order timeline and retry with a corrected request when appropriate.",
          "postalform.letter.canceled": "Letter canceled before delivery completion.",
          "postalform.postcard.accepted": "Postcard accepted for production or mailing after the order leaves PostalForm's preparation queue.",
          "postalform.postcard.in_transit": "Postcard entered the mail stream. The payload may include or update `mailpiece.tracking_number` when tracking is available.",
          "postalform.postcard.delivered": "Postcard reported delivered by the carrier or delivery network.",
          "postalform.postcard.returned": "Postcard returned or otherwise marked undeliverable.",
          "postalform.postcard.failed": "Postcard could not be produced or mailed. Inspect the order timeline and retry with a corrected request when appropriate.",
          "postalform.postcard.canceled": "Postcard canceled before delivery completion.",
          "postalform.handwritten.accepted": "Handwritten card or letter accepted for writing.",
          "postalform.handwritten.in_transit": "Handwritten card or letter was sealed, stamped, and handed to the carrier. Handwritten mail has no carrier tracking, so this is usually the last status.",
          "postalform.handwritten.delivered": "Handwritten card or letter reported delivered.",
          "postalform.handwritten.failed": "Handwritten card or letter could not be written or mailed, for example because of an invalid address.",
          "postalform.handwritten.canceled": "Handwritten card or letter canceled before it was mailed."
        }
      },
      "CustomerWebhookPayload": {
        "type": "object",
        "description": "JSON body POSTed to customer webhook endpoints.",
        "properties": {
          "id": {
            "type": "string",
            "example": "evt_123"
          },
          "type": {
            "$ref": "#/components/schemas/CustomerWebhookEventType"
          },
          "data": {
            "type": "object",
            "properties": {
              "object": {
                "$ref": "#/components/schemas/Letter"
              }
            }
          },
          "mailpiece": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "nullable": true
              },
              "tracking_number": {
                "type": "string",
                "nullable": true
              },
              "tracking_status": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "WebhookDeliveryAttempt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "webhookEventId": {
            "type": "string"
          },
          "endpointId": {
            "type": "string"
          },
          "attemptNumber": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded",
              "failed"
            ]
          },
          "httpStatus": {
            "type": "integer"
          },
          "responseBodySnippet": {
            "type": "string"
          },
          "attemptedAt": {
            "type": "string",
            "format": "date-time"
          },
          "nextRetryAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HandwrittenFormat": {
        "type": "string",
        "enum": [
          "card_4x6",
          "letter_7x10"
        ],
        "description": "`card_4x6` is a 4x6 card and `letter_7x10` is a 7x10 letter. Both are written in a handwriting style and mailed in a sealed envelope with a first-class stamp."
      },
      "CreditBalanceSnapshot": {
        "type": "object",
        "properties": {
          "available_cents": {
            "type": "integer"
          },
          "reserved_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "MailingDraftRevision": {
        "type": "object",
        "required": [
          "number",
          "manifestHash",
          "quote",
          "documentSha256",
          "documentKey",
          "recipient",
          "sender",
          "metadata",
          "contributorActorIds",
          "createdAt"
        ],
        "properties": {
          "number": {
            "type": "integer"
          },
          "manifestHash": {
            "type": "string"
          },
          "quote": {
            "type": "object",
            "additionalProperties": true,
            "description": "Frozen resolved quote, including priceCents, currency, documentId, service and printing dimensions."
          },
          "documentSha256": {
            "type": "string"
          },
          "documentKey": {
            "type": "string",
            "description": "Private storage reference, not a public URL."
          },
          "recipient": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "sender": {
            "$ref": "#/components/schemas/MailingAddress"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "contributorActorIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MailingApprovalDecision": {
        "type": "object",
        "required": [
          "id",
          "revision",
          "manifestHash",
          "actorId",
          "decision",
          "expiresAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "manifestHash": {
            "type": "string"
          },
          "actorId": {
            "type": "string"
          },
          "decision": {
            "type": "string",
            "enum": [
              "approved",
              "rejected",
              "revoked"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "parameters": {
      "DocumentId": {
        "name": "document_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "OrderId": {
        "name": "order_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "TemplateId": {
        "name": "template_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "EventId": {
        "name": "event_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  }
}