{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/terminal49/json-schema/terminal49-email-submission-schema.json",
  "title": "Email Submission",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/terminal49-email-submissions-api-openapi.yml#/components/schemas/email_submission",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "type": "string",
      "enum": [
        "email_submission"
      ]
    },
    "attributes": {
      "type": "object",
      "properties": {
        "subject": {
          "type": "string",
          "description": "Email subject line."
        },
        "body": {
          "type": [
            "string",
            "null"
          ],
          "description": "Email body content captured from the inbound message."
        },
        "from": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Sender email addresses."
        },
        "to": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Primary recipient email addresses."
        },
        "cc": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "CC recipient email addresses."
        },
        "sent_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Timestamp from the inbound email header."
        },
        "message_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Message-ID header value."
        },
        "in_reply_to": {
          "type": [
            "string",
            "null"
          ],
          "description": "In-Reply-To header value."
        },
        "references": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "References header values."
        },
        "content_type": {
          "type": [
            "string",
            "null"
          ],
          "description": "Top-level MIME content type of the inbound email."
        },
        "documents_count": {
          "type": "integer",
          "description": "Number of non-discarded documents created from this email."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the email submission record was created."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the email submission record was last updated."
        }
      }
    },
    "relationships": {
      "type": "object",
      "properties": {
        "account": {
          "type": "object",
          "properties": {
            "data": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "account"
                  ]
                }
              }
            }
          }
        },
        "user": {
          "type": "object",
          "properties": {
            "data": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "user"
                  ]
                }
              }
            }
          }
        },
        "documents": {
          "type": "object",
          "properties": {
            "data": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "document"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "links": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string"
        }
      }
    }
  },
  "required": [
    "id",
    "type"
  ]
}