{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/buckybuild-com/json-schema/buckybuild-com-credential-self-schema.json",
  "title": "CredentialSelf",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/buckybuild-com-openapi.json#/components/schemas/CredentialSelf",
  "type": "object",
  "properties": {
    "credential": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "api_key",
            "session"
          ]
        },
        "keyId": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "keyPrefix": {
          "type": [
            "string",
            "null"
          ]
        },
        "environment": {
          "type": [
            "string",
            "null"
          ]
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "expiresAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "lastUsedAt": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "kind",
        "keyId",
        "name",
        "keyPrefix",
        "environment",
        "scopes",
        "expiresAt",
        "lastUsedAt"
      ],
      "additionalProperties": false
    },
    "capabilities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "GET",
              "POST"
            ]
          },
          "path": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          },
          "allowed": {
            "type": "boolean"
          },
          "billing": {
            "type": "string",
            "enum": [
              "free",
              "priced"
            ]
          },
          "rateLimit": {
            "type": "object",
            "properties": {
              "policy": {
                "type": "string"
              },
              "limit": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "windowSeconds": {
                "type": "number"
              }
            },
            "required": [
              "policy",
              "limit",
              "windowSeconds"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "method",
          "path",
          "scope",
          "allowed",
          "billing",
          "rateLimit"
        ],
        "additionalProperties": false
      }
    },
    "unsupported": {
      "type": "object",
      "properties": {
        "reason": {
          "type": "string"
        },
        "alternative": {
          "type": "string"
        }
      },
      "required": [
        "reason",
        "alternative"
      ],
      "additionalProperties": false
    },
    "billing": {
      "type": "object",
      "properties": {
        "currency": {
          "type": "string",
          "const": "USD"
        },
        "spendBound": {
          "type": "string",
          "const": "prepaid_balance"
        },
        "perKeySpendCap": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "capMicroUsd": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "period": {
                  "type": "string",
                  "enum": [
                    "day",
                    "month"
                  ]
                },
                "spentMicroUsd": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "resetsAt": {
                  "type": "string"
                }
              },
              "required": [
                "capMicroUsd",
                "period",
                "spentMicroUsd",
                "resetsAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "siteCheck": {
          "type": "object",
          "properties": {
            "priceMicroUsd": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "charged": {
              "type": "string"
            },
            "notCharged": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "dedupeWindow": {
              "type": "string"
            },
            "idempotencyKeyHeader": {
              "type": "string"
            },
            "receipt": {
              "type": "string"
            }
          },
          "required": [
            "priceMicroUsd",
            "charged",
            "notCharged",
            "dedupeWindow",
            "idempotencyKeyHeader",
            "receipt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "currency",
        "spendBound",
        "perKeySpendCap",
        "siteCheck"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "credential",
    "capabilities",
    "unsupported",
    "billing"
  ],
  "additionalProperties": false
}