{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usewrit-app/json-schema/usewrit-app-api-key-list-schema.json",
  "title": "ApiKeyList",
  "description": "`{data, count}` list envelope.",
  "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/ApiKeyList",
  "type": "object",
  "required": [
    "data",
    "count"
  ],
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ApiKey"
      }
    },
    "count": {
      "type": "integer"
    }
  },
  "$defs": {
    "ApiKey": {
      "type": "object",
      "description": "One `wlk_` key record. The sha256 `key_hash` is NEVER serialized; the plaintext key exists only in the create response.",
      "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"
          ]
        }
      }
    }
  }
}