{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beel-es/json-schema/beel-es-email-delivery-list-response-schema.json",
  "title": "EmailDeliveryListResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beel-es-accountemails-api-openapi.yml#/components/schemas/EmailDeliveryListResponse",
  "type": "object",
  "required": [
    "success",
    "data"
  ],
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "type": "object",
      "required": [
        "emails"
      ],
      "properties": {
        "emails": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EmailDeliveryResponse"
          }
        },
        "pagination": {
          "$ref": "#/$defs/Pagination"
        }
      }
    },
    "meta": {
      "$ref": "#/$defs/ResponseMeta"
    }
  },
  "$defs": {
    "EmailDeliveryResponse": {
      "type": "object",
      "description": "Email sent by the system on behalf of the user (history).",
      "required": [
        "id",
        "email_type",
        "recipients",
        "status"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "email_type": {
          "type": "string",
          "description": "Email type (EmailType name or template). e.g. INVOICE_EMITTED"
        },
        "recipients": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Recipient addresses (To)"
        },
        "cc": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Carbon-copy addresses (CC)"
        },
        "subject": {
          "type": "string"
        },
        "related_entity_type": {
          "type": [
            "string",
            "null"
          ],
          "description": "Type of the SINGLE related entity (e.g. INVOICE for an invoice,\nUSER, SUBSCRIPTION). `null` for batch emails (BULK_INVOICES): their\nrelation is the invoices in `related_invoices`, not a single entity.\n"
        },
        "related_entity_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "Id of the single related entity. `null` for batch emails."
        },
        "status": {
          "$ref": "#/$defs/EmailDeliveryStatus"
        },
        "sent_at": {
          "type": "string",
          "format": "date-time",
          "description": "Time the email was sent"
        }
      }
    },
    "EmailDeliveryStatus": {
      "type": "string",
      "enum": [
        "QUEUED",
        "REJECTED",
        "SENT",
        "FAILED",
        "DELIVERED",
        "BOUNCED",
        "OPENED"
      ],
      "description": "Status of an email.\n\nThe history records every email the system decided to send, not only the ones that\nwent out: an email stopped by policy is listed as REJECTED rather than omitted.\n\n- QUEUED: authorised and recorded, not dispatched yet\n- REJECTED: stopped by policy and never sent (terminal, not retried). In test\n  environments invoices may only be emailed to the account owner's own address\n  (`+tag` aliases included), so a message addressed elsewhere lands here\n- SENT: successfully sent to the provider\n- FAILED: sending failed\n- DELIVERED / BOUNCED / OPENED: reported by the provider's webhooks\n"
    },
    "Pagination": {
      "type": "object",
      "required": [
        "current_page",
        "total_pages",
        "total_items",
        "items_per_page"
      ],
      "properties": {
        "current_page": {
          "type": "integer"
        },
        "total_pages": {
          "type": "integer",
          "description": "How many pages the query has. An empty collection has **one** page — the\nfirst one, empty — so the smallest value a canonical route returns is `1`.\n\nThe deprecated flat aliases (`/v1/invoices`, `/v1/customers`, …) answer `0`\nfor that same empty collection, and `has_next`/`has_previous` follow suit.\nThey were left as they were on purpose: a client that reads `total_pages == 0`\nas \"no results\" would break if it changed under it. Do not compare the two\nfamilies of routes field by field; read `total_items` if what you want to know\nis whether anything came back.\n"
        },
        "total_items": {
          "type": "integer"
        },
        "items_per_page": {
          "type": "integer"
        },
        "has_next": {
          "type": "boolean"
        },
        "has_previous": {
          "type": "boolean"
        }
      }
    },
    "ResponseMeta": {
      "type": "object",
      "properties": {
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "request_id": {
          "type": "string"
        }
      }
    }
  }
}