{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getcaute.com/card-format/1/item.schema.json",
  "title": "items/<id>/item.json",
  "description": "One saved thing that isn't a note: what it is, where it came from, and the text read from it.",
  "$defs": {
    "datetime": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}[ T]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?([+-]\\d{2}:\\d{2}|Z)$",
      "description": "A date and time with its offset (RFC 3339), written with a space between date and time: 2026-10-14 03:04:05.123456+00:00. Fractional seconds are left out when they are zero."
    },
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    }
  },
  "type": "object",
  "required": [
    "id",
    "kind",
    "title",
    "source",
    "url",
    "filename",
    "captured_at",
    "space",
    "mime_type",
    "byte_size",
    "status",
    "superseded_by",
    "summary",
    "text",
    "reading_state"
  ],
  "additionalProperties": false,
  "properties": {
    "id": {
      "$ref": "#/$defs/uuid"
    },
    "kind": {
      "type": "string",
      "description": "web_page, document, image, audio, video, email, text, agent_conversation or archive; read unknown values as other."
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "source": {
      "type": "string",
      "description": "How it was caught: ios_share, extension, email, mcp, api, web_upload, folder_watch, import or feed; read unknown values as other."
    },
    "url": {
      "anyOf": [
        {
          "type": "string",
          "description": "The address it was saved from, after redirects, for a web page or a file saved by its address."
        },
        {
          "type": "null"
        }
      ]
    },
    "filename": {
      "anyOf": [
        {
          "type": "string",
          "description": "The file's name as it was caught."
        },
        {
          "type": "null"
        }
      ]
    },
    "captured_at": {
      "$ref": "#/$defs/datetime"
    },
    "space": {
      "type": "string",
      "description": "The name of the space it is in."
    },
    "mime_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "byte_size": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "description": "captured, processing, searchable, failed or quarantined; read unknown values as other."
    },
    "superseded_by": {
      "anyOf": [
        {
          "$ref": "#/$defs/uuid",
          "description": "When a newer version replaced this one, the newer one's id."
        },
        {
          "type": "null"
        }
      ]
    },
    "summary": {
      "anyOf": [
        {
          "type": "string",
          "description": "The summary Caute wrote, when there is one."
        },
        {
          "type": "null"
        }
      ]
    },
    "text": {
      "anyOf": [
        {
          "type": "string",
          "description": "The text read from the original (or the person's correction of it), as blocks separated by blank lines."
        },
        {
          "type": "null"
        }
      ]
    },
    "reading_state": {
      "anyOf": [
        {
          "type": "string",
          "description": "The person's reading queue: later, archived or none; null when it was never in the queue."
        },
        {
          "type": "null"
        }
      ]
    },
    "properties": {
      "type": "object",
      "description": "Its confirmed properties (ADR 0127), by name: lower-case letters, digits and underscores. A value is text, a number, a date (2026-10-15), a web address, or a list of text. Added in format 1 without changing the number; an older export has no such field.",
      "propertyNames": {
        "pattern": "^[a-z0-9_]{1,40}$"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Its confirmed tags that the person who made the export can see, by path (projects/atlas), as tags.json lists them. Added in format 1 without changing the number; an older export has no such field."
    },
    "capture": {
      "type": "object",
      "description": "The record of its catch (ADR 0170): a fingerprint of the original's bytes as caught, and when and how. `caute verify` checks original.<ext> against `sha256`. Absent for a thing with no original, and from an export made before records were kept. Added in format 1 without changing the number.",
      "required": [
        "sha256",
        "byte_size",
        "via",
        "source",
        "caught_at",
        "requested_url",
        "arrived_url",
        "http_status",
        "recorded_later",
        "recorded_at"
      ],
      "additionalProperties": false,
      "properties": {
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the original's bytes, in lower-case hex."
        },
        "byte_size": {
          "type": "integer"
        },
        "via": {
          "type": "string",
          "description": "sent, fetched, uploaded, attachment, archive or copied; read unknown values as other."
        },
        "source": {
          "type": "string",
          "description": "The capture surface, as `source`."
        },
        "caught_at": {
          "$ref": "#/$defs/datetime",
          "description": "When it was really caught; `captured_at` may be earlier for an import."
        },
        "requested_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "arrived_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "http_status": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "recorded_later": {
          "type": "boolean",
          "description": "Recorded after the catch, for things caught before records were kept: the fingerprint is of the copy as it was on `recorded_at`."
        },
        "recorded_at": {
          "$ref": "#/$defs/datetime"
        }
      }
    }
  }
}
