{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openteesheet.com/schemas/door-grant.schema.json",
  "title": "OpenTeeSheet door grant (open format v1)",
  "description": "One door credential issued for one booking on one lock (keypad code, card, mobile key or remote unlock). The secret (the code itself) is never exported: a grant says which lock, which window and whether it is live.",
  "type": "object",
  "properties": {
    "object": {
      "const": "door_grant"
    },
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "booking_id": {
      "type": "string",
      "format": "uuid"
    },
    "venue_id": {
      "type": "string",
      "format": "uuid"
    },
    "method": {
      "type": "string",
      "enum": [
        "keypad",
        "card",
        "mobile",
        "remote"
      ]
    },
    "provider": {
      "type": "string",
      "minLength": 1,
      "description": "Lock provider key, e.g. igloohome, remotelock, kisi, seam, custom"
    },
    "lock_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "external_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The credential's id at the lock vendor"
    },
    "window_start": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "window_end": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "revoked",
        "failed"
      ]
    },
    "created_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "revoked_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "object",
    "id",
    "booking_id",
    "venue_id",
    "method",
    "provider",
    "status"
  ],
  "additionalProperties": false
}
