{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xcathletes.org/contract/schemas/checkin.json",
  "title": "checkin",
  "description": "GET /v1/checkins, GET /v1/checkins/{id}: one daily check-in, unique per person per local calendar date (ENT-07). Response schema, PRIN-04 open.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "id",
    "person_id",
    "date",
    "feeling",
    "time_in_bed_hours",
    "note",
    "external_ref",
    "origin_team_id",
    "origin_person_id",
    "version",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "A pre-existing platform id (a legacy check-in predating the /v1/ contract) or a new PRIN-05 128-bit hex id may both appear here; format is not otherwise constrained."
    },
    "person_id": {
      "type": "string",
      "description": "A pre-existing platform id (a legacy person predating the /v1/ contract) or a new PRIN-05 128-bit hex id may both appear here; format is not otherwise constrained."
    },
    "date": {
      "type": "string",
      "format": "date"
    },
    "feeling": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "poor",
        "ok",
        "good",
        "great",
        null
      ],
      "description": "The one-tap feeling scale. An unrecognized value falls back to null (treat as unreported)."
    },
    "time_in_bed_hours": {
      "type": [
        "number",
        "null"
      ],
      "enum": [
        5.5,
        6,
        6.5,
        7,
        7.5,
        8,
        8.5,
        9,
        9.5,
        10,
        null
      ],
      "description": "Half-hour picks. An unrecognized value falls back to null (treat as unreported)."
    },
    "note": {
      "type": [
        "string",
        "null"
      ]
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "origin_team_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "A pre-existing platform id (a legacy team predating the /v1/ contract) or a new PRIN-05 128-bit hex id may both appear here; format is not otherwise constrained."
    },
    "origin_person_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "A pre-existing platform id (a legacy person predating the /v1/ contract) or a new PRIN-05 128-bit hex id may both appear here; format is not otherwise constrained."
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "createRequest": {
      "title": "checkin create request",
      "description": "POST /v1/checkins (ENT-07, requires the checkins grant scope). Request schema, PRIN-04 strict: additionalProperties forbidden; at least one of feeling, time_in_bed_hours, or note is required.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "person_id",
        "date"
      ],
      "anyOf": [
        {
          "required": [
            "feeling"
          ]
        },
        {
          "required": [
            "time_in_bed_hours"
          ]
        },
        {
          "required": [
            "note"
          ]
        }
      ],
      "properties": {
        "person_id": {
          "type": "string",
          "description": "A pre-existing platform id (a legacy person predating the /v1/ contract) or a new PRIN-05 128-bit hex id may both appear here; format is not otherwise constrained."
        },
        "date": {
          "type": "string",
          "format": "date"
        },
        "feeling": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "poor",
            "ok",
            "good",
            "great",
            null
          ],
          "description": "The one-tap feeling scale. An unrecognized value falls back to null (treat as unreported)."
        },
        "time_in_bed_hours": {
          "type": [
            "number",
            "null"
          ],
          "enum": [
            5.5,
            6,
            6.5,
            7,
            7.5,
            8,
            8.5,
            9,
            9.5,
            10,
            null
          ],
          "description": "Half-hour picks. An unrecognized value falls back to null (treat as unreported)."
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 4000
        },
        "external_ref": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200
        }
      }
    }
  }
}
