Unkey · Schema

V2KeysAddRolesRequestBody

API KeysRate LimitingAuthenticationDeveloper PlatformAccess ControlIdentityAnalytics

Properties

Name Type Description
keyId string Specifies which key receives the additional roles using the database identifier returned from `createKey`. Do not confuse this with the actual API key string that users include in requests. Added role
roles array Assigns additional roles to the key through direct assignment to existing workspace roles. Operations are idempotent - adding existing roles has no effect and causes no errors. All roles must already
View JSON Schema on GitHub

JSON Schema

unkey-v2keysaddrolesrequestbody-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/V2KeysAddRolesRequestBody",
  "title": "V2KeysAddRolesRequestBody",
  "type": "object",
  "required": [
    "keyId",
    "roles"
  ],
  "properties": {
    "keyId": {
      "type": "string",
      "minLength": 3,
      "maxLength": 255,
      "pattern": "^[a-zA-Z0-9_]+$",
      "description": "Specifies which key receives the additional roles using the database identifier returned from `createKey`.\nDo not confuse this with the actual API key string that users include in requests.\nAdded roles supplement existing roles and permissions without replacing them.\nRole assignments take effect immediately but may take up to 30 seconds to propagate across all regions.\n",
      "example": "key_2cGKbMxRyIzhCxo1Idjz8q"
    },
    "roles": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "description": "Assigns additional roles to the key through direct assignment to existing workspace roles.\nOperations are idempotent - adding existing roles has no effect and causes no errors.\n\nAll roles must already exist in the workspace - roles cannot be created automatically.\nInvalid roles cause the entire operation to fail atomically, ensuring consistent state.\n",
      "items": {
        "type": "string",
        "minLength": 3,
        "maxLength": 255,
        "pattern": "^[a-zA-Z][a-zA-Z0-9._-]*$",
        "description": "Specify the role by name."
      }
    }
  },
  "additionalProperties": false
}