{
  "$id": "https://intentschema.org/intents/communication/email/message/send/v1.json",
  "fqdn": "org.intentschema.communication.email.message.send.v1",
  "title": "Send email message",
  "description": "Composes and sends an email message to one or more recipients.",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target",
      "object"
    ],
    "properties": {
      "target": {
        "$ref": "https://intentschema.org/common/target/v1.json"
      },
      "object": {
        "type": "object",
        "required": [
          "to",
          "subject"
        ],
        "properties": {
          "from": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "description": "RFC 5321 mailbox. Plain address (jane@example.com) or with display name (\"Jane Doe\" <jane@example.com>)."
            }
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "description": "RFC 5321 mailbox. Plain address (jane@example.com) or with display name (\"Jane Doe\" <jane@example.com>)."
            },
            "minItems": 1
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "description": "RFC 5321 mailbox. Plain address (jane@example.com) or with display name (\"Jane Doe\" <jane@example.com>)."
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email",
              "description": "RFC 5321 mailbox. Plain address (jane@example.com) or with display name (\"Jane Doe\" <jane@example.com>)."
            }
          },
          "subject": {
            "type": "string"
          },
          "textBody": {
            "type": "string"
          },
          "htmlBody": {
            "type": "string"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "https://intentschema.org/common/blob-ref/v1.json"
            }
          }
        }
      },
      "idempotency_key": {
        "type": "string"
      }
    }
  },
  "result": {
    "type": "object",
    "required": [
      "external_id",
      "sent_at"
    ],
    "properties": {
      "external_id": {
        "type": "string",
        "description": "Provider message id."
      },
      "thread_id": {
        "type": "string"
      },
      "sent_at": {
        "type": "string",
        "format": "date-time"
      }
    }
  },
  "examples": [
    {
      "name": "basic send to one recipient",
      "value": {
        "target": {
          "system": "gmail"
        },
        "object": {
          "to": [
            "jane@example.com"
          ],
          "subject": "Checking in",
          "textBody": "Thursday still works for me."
        }
      }
    },
    {
      "name": "send with cc and an attachment",
      "value": {
        "target": {
          "system": "gmail"
        },
        "object": {
          "to": [
            "\"Ops\" <ops@example.com>"
          ],
          "cc": [
            "cto@example.com"
          ],
          "subject": "Q3 review",
          "textBody": "Attached is the draft.",
          "attachments": [
            {
              "url": "https://files.example.com/q3.pdf",
              "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "filename": "q3.pdf",
              "mime_type": "application/pdf",
              "size": 1048576
            }
          ]
        },
        "idempotency_key": "01HN9X7K8J2Q3R4S5T6U7V8W9X"
      }
    }
  ]
}
