{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
    },
    "create_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "kind": {
      "type": "string"
    },
    "schema": {
      "type": "string",
      "pattern": "^[a-z_]+@[1-9]\\d*\\.\\d+$"
    },
    "revision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "revision_op": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
    },
    "account": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "deleted_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        {
          "type": "null"
        }
      ]
    },
    "origin": {
      "type": "object",
      "properties": {
        "connection": {
          "type": "string",
          "pattern": "^cnx_"
        },
        "app": {
          "type": "string"
        }
      },
      "required": ["connection", "app"],
      "additionalProperties": false
    },
    "home": {
      "type": "string"
    },
    "upstream": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "source": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "artifact": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "extraction_version": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "edited": {
              "type": "boolean"
            }
          },
          "required": ["source", "artifact", "extraction_version", "edited"],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "edits": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "part": {
                "type": "string"
              },
              "field": {
                "type": "string"
              },
              "path": {
                "minItems": 1,
                "maxItems": 2,
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": ["part", "field"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "part": {
                "type": "string"
              },
              "list": {
                "type": "string"
              }
            },
            "required": ["part", "list"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "part": {
                "type": "string"
              }
            },
            "required": ["part"],
            "additionalProperties": false
          }
        ]
      },
      "atomic": true
    },
    "review": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "from_version": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "candidate_version": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "latest_seen_version": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "acknowledged_version": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": ["from_version", "candidate_version"],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "external_ids": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ns": {
            "type": "string",
            "pattern": "^(?:cnx:cnx_|fmt:)"
          },
          "value": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": ["ns", "value"],
        "additionalProperties": false
      },
      "atomic": true
    },
    "provenance": {
      "type": "object",
      "properties": {
        "creator": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "handle": {
              "type": "string"
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          },
          "additionalProperties": false
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "attribution": {
          "type": "string"
        },
        "captured_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        "parser": {
          "type": "string"
        },
        "acquired_via": {
          "type": "string",
          "enum": ["sent", "created", "imported", "downloaded", "recovered"]
        }
      },
      "additionalProperties": false
    },
    "relations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rel": {
            "type": "string"
          },
          "target": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "position": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": ["rel", "target"],
        "additionalProperties": false
      },
      "atomic": true
    },
    "flags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          }
        },
        "required": ["code"],
        "additionalProperties": false
      },
      "atomic": true
    },
    "gaps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "part": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
          },
          "field": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": ["missing", "inferred", "warning"]
          },
          "note": {
            "type": "string"
          }
        },
        "required": ["part", "code"],
        "additionalProperties": false
      },
      "atomic": true
    },
    "body": {
      "$ref": "#/$defs/__schema0"
    },
    "state": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "$ref": "#/$defs/__schema0"
      }
    }
  },
  "required": [
    "id",
    "create_id",
    "kind",
    "schema",
    "revision",
    "revision_op",
    "account",
    "created_at",
    "updated_at",
    "deleted_at",
    "origin",
    "home",
    "upstream",
    "review",
    "external_ids",
    "provenance",
    "relations",
    "flags",
    "gaps",
    "body",
    "state"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "$id": "https://sendtopigeon.com/schemas/record@1.schema.json",
  "title": "Pigeon Open Data: record@1",
  "$comment": "Apache-2.0. Structural schema; use Zod/parseRecord for semantic invariants. This published schema URL is immutable.",
  "examples": [
    {
      "id": "0194ab00-0000-7000-8000-000000000001",
      "create_id": "0194ab00-0000-7000-8000-000000000001",
      "kind": "workout",
      "schema": "workout@1.0",
      "revision": 1,
      "revision_op": "0194ab00-0000-7000-8000-000000000001",
      "account": "0194ab00-0000-7000-8000-000000000001",
      "created_at": "2026-01-01T00:00:00Z",
      "updated_at": "2026-01-01T00:00:00Z",
      "deleted_at": "2026-01-01T00:00:00Z",
      "origin": {
        "connection": "cnx_0194ab00-0000-7000-8000-000000000001",
        "app": "demo"
      },
      "home": "demo",
      "upstream": {
        "source": "0194ab00-0000-7000-8000-000000000001",
        "artifact": "0194ab00-0000-7000-8000-000000000001",
        "extraction_version": 1,
        "edited": false
      },
      "review": {
        "from_version": 1,
        "candidate_version": 1
      },
      "external_ids": [],
      "provenance": {},
      "relations": [],
      "flags": [],
      "gaps": [],
      "body": {
        "title": "demo",
        "equipment": [],
        "target_muscles": [],
        "contraindications": [],
        "blocks": []
      },
      "state": {}
    }
  ]
}
