{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sendmypaper-com/json-schema/sendmypaper-com-create-postcard-schema.json",
  "title": "CreatePostcard",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sendmypaper-com-openapi.json#/components/schemas/CreatePostcard",
  "type": "object",
  "required": [
    "from",
    "content"
  ],
  "properties": {
    "size": {
      "type": "string",
      "enum": [
        "4x6",
        "6x9",
        "6x11"
      ],
      "default": "4x6"
    },
    "to": {
      "$ref": "#/$defs/Address",
      "description": "Recipient address Use `recipients` instead to send to several people."
    },
    "from": {
      "$ref": "#/$defs/SenderAddress",
      "description": "Return address, printed on the card. Required."
    },
    "content": {
      "type": "object",
      "required": [
        "message"
      ],
      "description": "Provide front_image_url or front_headline.",
      "properties": {
        "front_image_url": {
          "type": "string",
          "format": "uri",
          "description": "https URL of a JPG or PNG for the front"
        },
        "front_headline": {
          "type": "string",
          "maxLength": 60,
          "description": "Big text for a text-only front"
        },
        "front_theme": {
          "type": "string",
          "enum": [
            "ink",
            "sky",
            "sunset",
            "forest",
            "rose",
            "sand",
            "night",
            "mint"
          ],
          "default": "ink"
        },
        "message": {
          "type": "string",
          "maxLength": 600,
          "description": "Message on the back"
        },
        "layout": {
          "type": "string",
          "enum": [
            "headline",
            "photo",
            "photo_caption",
            "collage"
          ],
          "description": "Front layout; inferred when omitted."
        },
        "caption": {
          "type": "string",
          "maxLength": 80,
          "description": "photo_caption: text over the bottom of the photo."
        },
        "front_images": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "minItems": 2,
          "maxItems": 4,
          "description": "collage: 2-4 https photo URLs."
        },
        "headline_font": {
          "type": "string",
          "enum": [
            "serif",
            "sans",
            "script"
          ],
          "default": "serif"
        },
        "message_font": {
          "type": "string",
          "enum": [
            "handwriting",
            "serif",
            "sans"
          ],
          "default": "handwriting"
        }
      }
    },
    "customer_email": {
      "type": "string",
      "format": "email"
    },
    "idempotency_key": {
      "type": "string",
      "description": "Alternative to the Idempotency-Key header With `recipients`, a retry with the same key returns the same batch."
    },
    "express": {
      "type": "boolean",
      "default": false,
      "description": "USPS Priority Mail (2-3 days, tracked) for an extra charge."
    },
    "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."
        }
      }
    }
  }
}