{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dynamicdocumentapi-com/json-schema/dynamicdocumentapi-com-email-send-schema.json",
  "title": "EmailSend",
  "description": "One email of a render and rule. Only `to` shows addresses; cc and bcc are counts.",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dynamicdocumentapi-com-openapi.yml#/components/schemas/EmailSend",
  "properties": {
    "attachments": {
      "items": {
        "$ref": "#/$defs/EmailSendAttachment"
      },
      "type": "array"
    },
    "attempts": {
      "type": "integer"
    },
    "batch_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "bcc_count": {
      "type": "integer"
    },
    "cc_count": {
      "type": "integer"
    },
    "connection_id": {
      "type": "string"
    },
    "created_at": {
      "format": "date-time",
      "type": "string"
    },
    "delivery": {
      "$ref": "#/$defs/EmailDeliveryCounts"
    },
    "error": {
      "anyOf": [
        {
          "$ref": "#/$defs/EmailSendError"
        },
        {
          "type": "null"
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "mode": {
      "description": "`live`; for test renders the connection's `test_mode` (`sandbox`, `redirect`, `skip`); `redirect` for a rule test.",
      "enum": [
        "live",
        "sandbox",
        "redirect",
        "skip"
      ],
      "type": "string"
    },
    "object": {
      "enum": [
        "email_send"
      ],
      "type": "string"
    },
    "provider": {
      "enum": [
        "brevo",
        "smtp",
        "postmark",
        "resend",
        "ses",
        "graph"
      ],
      "type": "string"
    },
    "provider_message_id": {
      "anyOf": [
        {
          "description": "The provider's id of the message; for SMTP the `Message-ID` we set. Microsoft 365 (`graph`) returns none.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "render_id": {
      "type": "string"
    },
    "resend_of": {
      "anyOf": [
        {
          "description": "The send this one repeats (`ems_…`).",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "rule_id": {
      "type": "string"
    },
    "sandbox": {
      "description": "Sent with Brevo's sandbox header: nothing is delivered.",
      "type": "boolean"
    },
    "sent_at": {
      "anyOf": [
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "skip_reason": {
      "anyOf": [
        {
          "enum": [
            "condition_false",
            "test_mode"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "description": "`unknown`: the provider may have delivered it (e.g. a timeout after sending); it is never retried automatically: check the provider's logs (the message carries `X-Dda-Send-Id`) before resending.",
      "enum": [
        "pending",
        "sending",
        "retrying",
        "sent",
        "sandboxed",
        "skipped",
        "failed",
        "unknown",
        "canceled"
      ],
      "type": "string"
    },
    "subject": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "template_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "test": {
      "type": "boolean"
    },
    "to": {
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "object",
    "render_id",
    "batch_id",
    "template_id",
    "rule_id",
    "connection_id",
    "status",
    "skip_reason",
    "mode",
    "test",
    "sandbox",
    "to",
    "cc_count",
    "bcc_count",
    "subject",
    "attachments",
    "provider",
    "provider_message_id",
    "attempts",
    "error",
    "delivery",
    "resend_of",
    "created_at",
    "sent_at"
  ],
  "type": "object",
  "$defs": {
    "EmailDeliveryCounts": {
      "description": "The recipients' delivery events, by kind: only Brevo reports them, so other providers' sends show zeros. `bounced` counts soft and hard bounces.",
      "properties": {
        "blocked": {
          "minimum": 0,
          "type": "integer"
        },
        "bounced": {
          "minimum": 0,
          "type": "integer"
        },
        "complained": {
          "minimum": 0,
          "type": "integer"
        },
        "deferred": {
          "minimum": 0,
          "type": "integer"
        },
        "delivered": {
          "minimum": 0,
          "type": "integer"
        },
        "invalid": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "delivered",
        "deferred",
        "bounced",
        "blocked",
        "complained",
        "invalid"
      ],
      "type": "object"
    },
    "EmailSendAttachment": {
      "properties": {
        "bytes": {
          "type": "integer"
        },
        "file_id": {
          "type": "string"
        },
        "filename": {
          "type": "string"
        },
        "mode": {
          "description": "`linked`: a download link valid until the file's retention ends, at most 7 days.",
          "enum": [
            "attached",
            "linked"
          ],
          "type": "string"
        }
      },
      "required": [
        "file_id",
        "filename",
        "bytes",
        "mode"
      ],
      "type": "object"
    },
    "EmailSendError": {
      "additionalProperties": true,
      "description": "Why a send failed or waits: never message bodies or addresses.",
      "properties": {
        "code": {
          "description": "`email_template_error`, `email_too_large`, `email_recipient_missing`, `email_address_invalid`, `email_too_many_recipients`, `email_attachment_too_large`, `email_attachment_type_not_allowed`, `email_needs_hosted_file`, `email_provider_rejected`, `email_provider_auth_failed`, `email_provider_unavailable`, `email_ip_not_authorized`, `email_rate_limited`, `email_outcome_unknown`, `email_daily_cap_reached`, `email_disabled`, `email_credentials_removed`, `email_send_expired`, `internal_error`",
          "type": "string"
        },
        "column": {
          "type": "integer"
        },
        "field": {
          "description": "`email_template_error`, `email_too_large`: the rule field, e.g. `subject`.",
          "type": "string"
        },
        "line": {
          "description": "`email_template_error`: where in the field.",
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "provider_code": {
          "anyOf": [
            {
              "description": "The provider's own error code.",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "provider_status": {
          "anyOf": [
            {
              "description": "The provider's HTTP or SMTP status.",
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    }
  }
}