{
  "$id": "https://intentschema.org/intents/communication/email/draft/update/v1.json",
  "fqdn": "org.intentschema.communication.email.draft.update.v1",
  "title": "Update email draft",
  "description": "Replace the contents of an existing draft. The full `object` is sent (not a patch).",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target",
      "object"
    ],
    "properties": {
      "target": {
        "allOf": [
          {
            "$ref": "https://intentschema.org/common/target/v1.json"
          },
          {
            "required": [
              "external_id"
            ]
          }
        ]
      },
      "object": {
        "type": "object",
        "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>)."
            }
          },
          "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"
            }
          },
          "inReplyTo": {
            "type": "string"
          }
        }
      },
      "idempotency_key": {
        "type": "string"
      }
    }
  },
  "result": {
    "type": "object",
    "properties": {
      "external_id": {
        "type": "string"
      },
      "updated_at": {
        "type": "string",
        "format": "date-time"
      }
    }
  },
  "examples": [
    {
      "name": "update draft body",
      "value": {
        "target": {
          "system": "gmail",
          "external_id": "draft_abc"
        },
        "object": {
          "to": [
            "jane@example.com"
          ],
          "subject": "Re: Checking in",
          "textBody": "Updated reply text."
        }
      }
    }
  ]
}
