Unkey · Schema

V2KeysUpdateCreditsRequestBody

API KeysRate LimitingAuthenticationDeveloper PlatformAccess ControlIdentityAnalytics

Properties

Name Type Description
keyId string The ID of the key to update (begins with `key_`). This is the database reference ID for the key, not the actual API key string that users authenticate with. This ID uniquely identifies which key's cre
value integernull The credit value to use with the specified operation. The meaning depends on the operation: for 'set', this becomes the new remaining credits value; for 'increment', this amount is added to current cr
operation string Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and
View JSON Schema on GitHub

JSON Schema

unkey-v2keysupdatecreditsrequestbody-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/V2KeysUpdateCreditsRequestBody",
  "title": "V2KeysUpdateCreditsRequestBody",
  "type": "object",
  "required": [
    "keyId",
    "operation"
  ],
  "properties": {
    "keyId": {
      "type": "string",
      "description": "The ID of the key to update (begins with `key_`). This is the database reference ID for the key, not the actual API key string that users authenticate with. This ID uniquely identifies which key's credits will be updated.",
      "example": "key_2cGKbMxRyIzhCxo1Idjz8q",
      "minLength": 3
    },
    "value": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "minimum": 0,
      "maximum": 9223372036854776000,
      "description": "The credit value to use with the specified operation. The meaning depends on the operation: for 'set', this becomes the new remaining credits value; for 'increment', this amount is added to current credits; for 'decrement', this amount is subtracted from current credits.\n\nSet to null when using 'set' operation to make the key unlimited (removes usage restrictions entirely). When decrementing, if the result would be negative, remaining credits are automatically set to zero. Credits are consumed during successful key verification, and when credits reach zero, verification fails with `code=USAGE_EXCEEDED`.\n\nRequired when using 'increment' or 'decrement' operations. Optional for 'set' operation (null creates unlimited usage).\n",
      "example": 1000
    },
    "operation": {
      "type": "string",
      "enum": [
        "set",
        "increment",
        "decrement"
      ],
      "x-speakeasy-unknown-values": "allow",
      "description": "Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and 'decrement' to reduce credits for refunds or policy violations.\n",
      "example": "set"
    }
  },
  "additionalProperties": false
}