{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/terminal49/json-schema/terminal49-document-schema.json",
  "title": "Document",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/terminal49-openapi.json#/components/schemas/document",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "type": "string",
      "enum": [
        "document"
      ]
    },
    "attributes": {
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique identifier for the document.",
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "description": "Display name of the document.",
          "type": "string"
        },
        "document_type": {
          "description": "System-classified document type.",
          "type": "string"
        },
        "document_type_manual": {
          "description": "Document type set manually by a user, when available.",
          "type": [
            "string",
            "null"
          ]
        },
        "classification_notes": {
          "description": "Additional notes captured during document classification.",
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "description": "How the document was created in Terminal49.",
          "type": "string",
          "enum": [
            "upload",
            "api",
            "email",
            "split_document"
          ]
        },
        "file_name": {
          "description": "Original file name of the uploaded or generated document.",
          "type": "string"
        },
        "file_content_type": {
          "description": "MIME type of the document file.",
          "type": [
            "string",
            "null"
          ]
        },
        "file_size_bytes": {
          "description": "File size in bytes.",
          "type": [
            "integer",
            "null"
          ]
        },
        "created_at": {
          "description": "Timestamp when the document was created.",
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "description": "Timestamp when the document was last updated.",
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "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"
                  ]
                }
              }
            }
          }
        },
        "email_submission": {
          "type": "object",
          "properties": {
            "data": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "email_submission"
                  ]
                }
              }
            }
          }
        },
        "last_document_representation": {
          "type": "object",
          "properties": {
            "data": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "document_representation"
                  ]
                }
              }
            }
          }
        },
        "shipments": {
          "type": "object",
          "properties": {
            "data": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "shipment"
                    ]
                  }
                }
              }
            }
          }
        },
        "cargos": {
          "type": "object",
          "properties": {
            "data": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "container"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "links": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string"
        },
        "download": {
          "type": "string"
        }
      }
    }
  },
  "required": [
    "id",
    "type"
  ]
}