{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arena-predictions-com/json-schema/arena-predictions-com-key-rotate-response-schema.json",
  "title": "KeyRotateResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arena-predictions-com-api-keys-api-openapi.yml#/components/schemas/KeyRotateResponse",
  "type": "object",
  "required": [
    "key",
    "token",
    "warning",
    "replaced"
  ],
  "properties": {
    "key": {
      "$ref": "#/$defs/KeyView"
    },
    "token": {
      "type": "string",
      "description": "The new plaintext key. Shown once; only its hash is stored."
    },
    "warning": {
      "type": "string"
    },
    "replaced": {
      "$ref": "#/$defs/KeyView"
    }
  },
  "$defs": {
    "KeyView": {
      "type": "object",
      "required": [
        "id",
        "label",
        "tokenPrefix",
        "scopes",
        "status",
        "createdAt",
        "lastUsedAt",
        "expiresAt",
        "revokedAt",
        "createdVia",
        "rotatedFrom",
        "rotatedAt",
        "requestsThisMonth"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "label": {
          "type": "string",
          "maxLength": 64
        },
        "tokenPrefix": {
          "type": "string",
          "description": "First 16 characters of the token, for matching a row to a key. Never the token."
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "records:read",
              "portfolio:read",
              "markets:read",
              "trade:write",
              "trade:write:kalshi",
              "trade:write:poly-intl",
              "trade:write:prophetx"
            ]
          }
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "rotating",
            "revoked",
            "expired"
          ],
          "description": "rotating: replaced by a rotation and still inside its grace period (it works until expiresAt)."
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "lastUsedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Updated at most once an hour."
        },
        "expiresAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "revokedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "createdVia": {
          "type": "string",
          "enum": [
            "web",
            "cli"
          ],
          "description": "web: Settings. cli: arena keys."
        },
        "rotatedFrom": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "The key this one replaced by rotation."
        },
        "rotatedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When this key was rotated."
        },
        "requestsThisMonth": {
          "type": "integer",
          "minimum": 0,
          "description": "Keyed requests counted against this key this month (UTC)."
        }
      }
    }
  }
}