{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/Message",
  "title": "Message",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/send0-dev-openapi.json#/components/schemas/Message",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "const": "message"
    },
    "id": {
      "type": "string"
    },
    "inbox_id": {
      "type": "string"
    },
    "thread_id": {
      "type": "string"
    },
    "direction": {
      "type": "string",
      "enum": [
        "in",
        "out"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "received",
        "queued",
        "sent",
        "delivered",
        "bounced",
        "complained",
        "failed"
      ]
    },
    "expired": {
      "type": "boolean",
      "description": "true once the inbox's retention period has passed: text, html, extracted_text, extracted and attachments are gone (null or empty) and the raw message can't be downloaded. Addresses, subject, status and timestamps remain until the message is deleted, 35 days after it was created."
    },
    "rfc_message_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "in_reply_to": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "references": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "from": {
      "anyOf": [
        {
          "$ref": "#/$defs/Mailbox"
        },
        {
          "type": "null"
        }
      ]
    },
    "to": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      }
    },
    "cc": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      }
    },
    "reply_to": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      }
    },
    "subject": {
      "type": "string"
    },
    "text": {
      "type": [
        "string",
        "null"
      ]
    },
    "html": {
      "description": "Only on single-message reads and threads with include_html=true",
      "type": [
        "string",
        "null"
      ]
    },
    "extracted_text": {
      "description": "New text only: quoted history, forwards and signatures removed",
      "type": [
        "string",
        "null"
      ]
    },
    "extracted": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "otp": {
              "description": "Most likely one-time code",
              "type": [
                "string",
                "null"
              ]
            },
            "links": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "action_link": {
              "description": "Most likely verify / sign-in / reset link",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "otp",
            "links",
            "action_link"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "auth": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "spf": {
              "type": "string"
            },
            "dkim": {
              "type": "string"
            },
            "dmarc": {
              "type": "string"
            }
          },
          "required": [
            "spf",
            "dkim",
            "dmarc"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "safety": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "prompt_injection": {
              "type": "string",
              "enum": [
                "none",
                "suspected",
                "likely"
              ]
            },
            "reasons": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": [
            "prompt_injection",
            "reasons"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "tag": {
      "description": "Plus-address tag, e.g. task42 for bot+task42@",
      "type": [
        "string",
        "null"
      ]
    },
    "attachments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Attachment"
      }
    },
    "size": {
      "type": "integer"
    },
    "sent_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "received_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "object",
    "id",
    "inbox_id",
    "thread_id",
    "direction",
    "status",
    "expired",
    "rfc_message_id",
    "in_reply_to",
    "references",
    "from",
    "to",
    "cc",
    "reply_to",
    "subject",
    "text",
    "extracted_text",
    "extracted",
    "auth",
    "safety",
    "tag",
    "attachments",
    "size",
    "sent_at",
    "received_at",
    "created_at"
  ],
  "additionalProperties": false,
  "$defs": {
    "Attachment": {
      "$id": "#/components/schemas/Attachment",
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "filename": {
          "type": [
            "string",
            "null"
          ]
        },
        "content_type": {
          "type": "string"
        },
        "size": {
          "type": "integer"
        },
        "inline": {
          "type": "boolean"
        },
        "content_id": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "filename",
        "content_type",
        "size",
        "inline",
        "content_id"
      ],
      "additionalProperties": false
    },
    "Mailbox": {
      "$id": "#/components/schemas/Mailbox",
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "email"
      ],
      "additionalProperties": false
    }
  }
}