{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/benjipays-com/json-schema/benjipays-com-list-emails-response-schema.json",
  "title": "ListEmailsResponse",
  "description": "Paginated email list response",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/benjipays-com-emails-api-openapi.yml#/components/schemas/ListEmailsResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EmailSummary"
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "total": {
          "type": "number",
          "description": "Total matching emails across all pages"
        },
        "limit": {
          "type": "number"
        },
        "offset": {
          "type": "number"
        },
        "hasMore": {
          "type": "boolean"
        },
        "nextOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "prevOffset": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "total",
        "limit",
        "offset",
        "hasMore",
        "nextOffset",
        "prevOffset"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "data",
    "pagination"
  ],
  "additionalProperties": false,
  "$defs": {
    "EmailReminderRule": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "displayName": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Friendly reminder rule name, resolved from email-reminder settings"
            }
          },
          "required": [
            "displayName"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Reminder rule descriptor for reminder emails; null for non-reminder emails"
    },
    "EmailSummary": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Email identifier (Mongo `_id`)"
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Email type (e.g. invoice, receipt, emailreminder)"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Delivery status (sent, queued, error)"
        },
        "subject": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "from": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "to": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cc": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "bcc": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sentDate": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 UTC timestamp the email was created/sent"
        },
        "opened": {
          "type": "boolean"
        },
        "lastOpened": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 UTC timestamp of the last non-bot open"
        },
        "bounced": {
          "type": "boolean"
        },
        "delivered": {
          "type": "boolean"
        },
        "customerId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Accounting customer ID"
        },
        "invoiceIds": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Associated accounting invoice IDs"
        },
        "sentBy": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Display name of the user who sent the email"
        },
        "reminderRule": {
          "$ref": "#/$defs/EmailReminderRule"
        },
        "hasAttachments": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "type",
        "status",
        "subject",
        "from",
        "to",
        "cc",
        "bcc",
        "sentDate",
        "opened",
        "lastOpened",
        "bounced",
        "delivered",
        "customerId",
        "invoiceIds",
        "sentBy",
        "reminderRule",
        "hasAttachments"
      ],
      "additionalProperties": false,
      "description": "A sent email (summary)"
    }
  }
}