{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/teamyou-com/json-schema/teamyou-com-agent-document-schema.json",
  "title": "AgentDocument",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/teamyou-com-openapi.json#/components/schemas/AgentDocument",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "ownerType": {
      "type": "string",
      "enum": [
        "user"
      ]
    },
    "ownerId": {
      "type": "string"
    },
    "createdByAgentId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Agent that CREATED the document. Set on insert and never changed — not by an overwrite from another agent, not by delete/restore."
    },
    "lastModifiedByAgentId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Agent that last changed content or title. Unchanged by an unchanged (no-op) write and by delete/restore."
    },
    "title": {
      "type": "string"
    },
    "path": {
      "type": "string"
    },
    "storageBackend": {
      "type": "string",
      "enum": [
        "db"
      ]
    },
    "contentType": {
      "type": "string",
      "description": "IANA media type of the stored document. Always \"text/markdown\" today; binary types arrive with the object-storage tail. Response-only — the write endpoint does not accept it."
    },
    "content": {
      "type": [
        "string",
        "null"
      ]
    },
    "storageKey": {
      "type": [
        "string",
        "null"
      ]
    },
    "contentHash": {
      "type": [
        "string",
        "null"
      ]
    },
    "byteSize": {
      "type": [
        "integer",
        "null"
      ]
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Structured metadata PARSED from the document's leading YAML front matter, refreshed on every write. Read-only and derived — there is no field to set it with, deliberately: the front-matter block in content is the single source, so a pull returns exactly the bytes that were pushed and there is no second channel to disagree with them. Write a block to attach metadata; remove the block and this goes back to null on the next write. null means the document has no front matter, or has a block that did not parse (unterminated, invalid YAML, or not a mapping) — the two are not distinguished. The body is stored untouched either way. Conventional keys, not enforced and not the only ones allowed: status, type, and tags (an array). Filter on any of them with the where parameter on GET /agent-drive and POST /search/documents."
    },
    "archivedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Non-null when the document has been deleted (recoverable). Archived documents are absent from the default list and from GET /agent-drive/{id}."
    },
    "visibility": {
      "type": "string",
      "enum": [
        "private",
        "public",
        "authenticated"
      ],
      "description": "Who can open the document at its /agent-drive/{id} URL. READ-ONLY here: private is the default, and changing it is a separate, separately-scoped request — PUT /agent-drive/{id}/visibility with the share scope, or the owner in the web app. The write path neither accepts nor honours this field, so publishing is never a side effect of saving content."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "ownerType",
    "ownerId",
    "title",
    "path",
    "storageBackend",
    "contentType",
    "visibility",
    "createdAt",
    "updatedAt"
  ]
}