{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sendmypaper-com/json-schema/sendmypaper-com-create-letter-schema.json",
  "title": "CreateLetter",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sendmypaper-com-openapi.json#/components/schemas/CreateLetter",
  "type": "object",
  "required": [
    "from",
    "content"
  ],
  "properties": {
    "to": {
      "$ref": "#/$defs/Address",
      "description": "Recipient address Use `recipients` instead to send to several people."
    },
    "from": {
      "$ref": "#/$defs/SenderAddress"
    },
    "content": {
      "type": "object",
      "required": [],
      "properties": {
        "body": {
          "type": "string",
          "maxLength": 9000,
          "description": "Plain text; blank lines separate paragraphs"
        },
        "font": {
          "type": "string",
          "enum": [
            "serif",
            "sans"
          ],
          "default": "serif"
        },
        "image_url": {
          "type": "string",
          "format": "uri",
          "description": "Optional https URL of a JPG or PNG printed under the date. A letter with a photo prints in color and costs $1.00 more."
        },
        "pdf_url": {
          "type": "string",
          "format": "uri",
          "description": "Mail your own PDF (public https link, up to 6 pages) instead of body. Pages are fitted to 8.5x11; an address page is added in front."
        },
        "color": {
          "type": "boolean",
          "description": "PDF letters: print in color (+$1.00)."
        }
      }
    },
    "customer_email": {
      "type": "string",
      "format": "email"
    },
    "idempotency_key": {
      "type": "string",
      "description": " With `recipients`, a retry with the same key returns the same batch."
    },
    "certified": {
      "type": "string",
      "enum": [
        "none",
        "certified",
        "certified_return_receipt"
      ],
      "default": "none",
      "description": "USPS Certified Mail. `certified` ($14.99): tracking number and proof of mailing and delivery. `certified_return_receipt` ($19.99): adds the recipient's signature. `none` ($4.99): regular First-Class."
    },
    "express": {
      "type": "boolean",
      "default": false,
      "description": "USPS Priority Mail (2-3 days, tracked); not with certified."
    },
    "recipients": {
      "type": "array",
      "minItems": 2,
      "maxItems": 25,
      "items": {
        "$ref": "#/$defs/Address"
      },
      "description": "Send the same postcard or letter to several people: 2–25 addresses, used instead of `to`. Each recipient becomes its own order (own review, tracking and refund), grouped into a batch that is paid with one checkout link. The response is a Batch, not an Order."
    }
  },
  "oneOf": [
    {
      "required": [
        "to"
      ]
    },
    {
      "required": [
        "recipients"
      ]
    }
  ],
  "$defs": {
    "Address": {
      "type": "object",
      "required": [
        "name",
        "line1",
        "city",
        "state",
        "zip"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 60
        },
        "company": {
          "type": "string",
          "maxLength": 60
        },
        "line1": {
          "type": "string",
          "maxLength": 64,
          "description": "Street address"
        },
        "line2": {
          "type": "string",
          "maxLength": 64,
          "description": "Apartment, suite, unit"
        },
        "city": {
          "type": "string",
          "maxLength": 40
        },
        "state": {
          "type": "string",
          "description": "Two-letter US state or territory code"
        },
        "zip": {
          "type": "string",
          "pattern": "^\\d{5}(-\\d{4})?$"
        }
      },
      "description": "A US address (recipients are always in the US, including territories and APO/FPO/DPO)."
    },
    "SenderAddress": {
      "type": "object",
      "required": [
        "name",
        "line1",
        "city"
      ],
      "description": "Return address. It may be outside the US: set `country`. For a US address (no `country`, or `US`), `state` and `zip` are required and follow the US rules; elsewhere `state` is the region and `zip` the postcode, both optional.",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 60
        },
        "company": {
          "type": "string",
          "maxLength": 60
        },
        "line1": {
          "type": "string",
          "maxLength": 64,
          "description": "Street address"
        },
        "line2": {
          "type": "string",
          "maxLength": 64,
          "description": "Apartment, suite, unit"
        },
        "city": {
          "type": "string",
          "maxLength": 40,
          "description": "City or town"
        },
        "state": {
          "type": "string",
          "maxLength": 40,
          "description": "US: two-letter state or territory code (required). Elsewhere: region, county or province, if any"
        },
        "zip": {
          "type": "string",
          "maxLength": 12,
          "description": "US: 5-digit ZIP or ZIP+4 (required). Elsewhere: postcode"
        },
        "country": {
          "type": "string",
          "pattern": "^[A-Za-z]{2}$",
          "default": "US",
          "description": "Two-letter ISO 3166-1 country code of the return address, e.g. GB. Defaults to US. US territories use US with their state code."
        }
      }
    }
  }
}