{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usewrit-app/json-schema/usewrit-app-api-key-schema.json",
  "title": "ApiKey",
  "description": "One `wlk_` key record. The sha256 `key_hash` is NEVER serialized; the plaintext key exists only in the create response.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usewrit-app-keys-api-openapi.yml#/components/schemas/ApiKey",
  "type": "object",
  "required": [
    "id",
    "name",
    "prefix",
    "scopes",
    "enabled",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "name": {
      "type": "string"
    },
    "prefix": {
      "type": "string",
      "description": "`wlk_` + first 6 chars of the raw key (display only)."
    },
    "scopes": {
      "type": "string",
      "description": "CSV of scopes: `read|run|admin`."
    },
    "enabled": {
      "type": "integer",
      "description": "0/1 integer flag."
    },
    "last_used_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "created_at": {
      "type": "string"
    },
    "revoked_at": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}