{
  "openapi": "3.1.0",
  "info": {
    "title": "KasaPost Transactional Email API",
    "version": "0.1.0",
    "description": "Early-access API for sending transactional email through a KasaPost-authenticated domain."
  },
  "servers": [
    {
      "url": "https://mail.kasapost.com/api/v2"
    }
  ],
  "paths": {
    "/kasapost/send/": {
      "post": {
        "summary": "Send a transactional email",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted for delivery"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "502": {
            "description": "SMTP backend failed"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "SendRequest": {
        "type": "object",
        "required": ["to", "subject"],
        "properties": {
          "from": {
            "type": "string",
            "description": "Formatted sender, such as KasaPost <hello@kasapost.com>."
          },
          "from_email": {
            "type": "string",
            "format": "email"
          },
          "from_name": {
            "type": "string",
            "maxLength": 120
          },
          "to": {
            "type": "array",
            "items": {"type": "string", "format": "email"}
          },
          "cc": {
            "type": "array",
            "items": {"type": "string", "format": "email"}
          },
          "bcc": {
            "type": "array",
            "items": {"type": "string", "format": "email"}
          },
          "reply_to": {
            "type": "array",
            "items": {"type": "string", "format": "email"}
          },
          "subject": {
            "type": "string",
            "maxLength": 255
          },
          "text": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "headers": {
            "type": "object",
            "additionalProperties": {"type": "string"}
          }
        },
        "anyOf": [
          {"required": ["text"]},
          {"required": ["html"]}
        ]
      }
    }
  }
}
