{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/thread-page/json-schema/thread-page-note-schema.json",
  "title": "Note",
  "x-generated": "2026-11-07",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/thread-page-openapi.json#/components/schemas/Note",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "thread_id": {
      "type": "string",
      "format": "uuid"
    },
    "thread": {
      "$ref": "#/$defs/ThreadRef"
    },
    "revision": {
      "type": "integer"
    },
    "content_revision": {
      "type": "integer",
      "description": "Moves with every change to the text; compare it to tell newer text from older."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "pinned": {
      "type": "boolean"
    },
    "done": {
      "type": "boolean"
    },
    "trashed": {
      "type": "boolean"
    },
    "origin": {
      "$ref": "#/$defs/EventOriginEnum"
    },
    "last_change_origin": {
      "allOf": [
        {
          "$ref": "#/$defs/EventOriginEnum"
        }
      ],
      "description": "Who made the latest change to the text, in the same terms as origin.\n\n* `human` - human\n* `service` - service\n* `agent` - agent\n* `participant` - participant"
    },
    "added_via": {
      "oneOf": [
        {
          "$ref": "#/$defs/AddedVia"
        },
        {
          "type": "null"
        }
      ]
    },
    "changed_via": {
      "oneOf": [
        {
          "$ref": "#/$defs/AddedVia"
        },
        {
          "type": "null"
        }
      ],
      "description": "The connection whose change is the note's latest content change; null when a person changed it last or nobody changed it since it was added."
    },
    "editable": {
      "type": "boolean",
      "description": "Whether this connection may change this note now: its level, Read and add's own notes, shared places and request notes."
    },
    "text": {
      "type": "string",
      "description": "Plain text of the whole note."
    },
    "markdown": {
      "type": "string",
      "description": "The whole note as Markdown, as events and requests carry it; an image or a note reference becomes a link to the note."
    },
    "document": {
      "type": "object",
      "additionalProperties": {},
      "description": "RichDocument v4 (format work-threads.richtext)."
    },
    "images": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/NoteImage"
      },
      "description": "The images the document holds, in its order; an image whose bytes have not reached the server yet is left out."
    },
    "files": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/NoteFileSummary"
      },
      "description": "The other files the document holds, in its order (getNoteFile): those of its file blocks, and a file an image block holds that is no image (such as a TIFF); one whose bytes have not reached the server yet, or that was deleted, is left out."
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "context_receipt": {
      "type": [
        "string",
        "null"
      ],
      "description": "Send it with PUT /notes/{note_id}/content or a version restore; null when this connection may not change the note."
    }
  },
  "required": [
    "added_via",
    "changed_via",
    "content_revision",
    "context_receipt",
    "created_at",
    "document",
    "done",
    "editable",
    "files",
    "id",
    "images",
    "last_change_origin",
    "markdown",
    "origin",
    "pinned",
    "revision",
    "text",
    "thread",
    "thread_id",
    "trashed",
    "updated_at",
    "url"
  ],
  "$defs": {
    "AddedVia": {
      "type": "object",
      "properties": {
        "connection_id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "connection_id",
        "name"
      ]
    },
    "EventOriginEnum": {
      "enum": [
        "human",
        "service",
        "agent",
        "participant"
      ],
      "type": "string",
      "description": "* `human` - human\n* `service` - service\n* `agent` - agent\n* `participant` - participant"
    },
    "FileKindEnum": {
      "enum": [
        "image",
        "video",
        "audio",
        "pdf",
        "text",
        "document",
        "archive",
        "other"
      ],
      "type": "string",
      "description": "* `image` - image\n* `video` - video\n* `audio` - audio\n* `pdf` - pdf\n* `text` - text\n* `document` - document\n* `archive` - archive\n* `other` - other"
    },
    "NoteFileSummary": {
      "type": "object",
      "description": "A file a note holds that is no image (images are in `images`).",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string",
          "description": "The name it goes by, with the extension of what it is."
        },
        "media_type": {
          "type": "string",
          "description": "Found in the bytes."
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "kind": {
          "$ref": "#/$defs/FileKindEnum"
        }
      },
      "required": [
        "bytes",
        "id",
        "kind",
        "media_type",
        "name"
      ]
    },
    "NoteImage": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "A preview up to 1600 px, without metadata (getNoteImage); read it with this connection's token."
        }
      },
      "required": [
        "id",
        "url"
      ]
    },
    "ThreadRef": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "title": {
          "type": "string",
          "description": "The thread's name as the app shows it: its own, or for a thread still called New thread, the first line of words of its first note, without the @name it was sent to."
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "id",
        "title",
        "url"
      ]
    }
  }
}