keys

Set key permissions

Replace all permissions on a key with the specified set in a single atomic operation.

Use this to synchronize with external systems, reset permissions to a known state, or apply standardized permission templates. Permissions granted through roles remain unchanged.

Important: Changes take effect immediately with up to 30-second edge propagation.

Required Permissions

Your root key must have one of the following permissions:

  • api.*.update_key (to update keys in any API)
  • api.<api_id>.update_key (to update keys in a specific API)

Side Effects

Invalidates the key cache for immediate effect, and makes permission changes available for verification within 30 seconds across all regions.

post/v2/keys.setPermissions

Request body

keyIdstring required

Specifies which key receives the additional permissions using the database identifier returned from keys.createKey. Do not confuse this with the actual API key string that users include in requests.

permissionsstring[] required

The permissions to set for this key.

This is a complete replacement operation - it overwrites all existing direct permissions with this new set.

Key behaviors:

  • Providing an empty array removes all direct permissions from the key
  • This only affects direct permissions - permissions granted through roles are not affected
  • All existing direct permissions not included in this list will be removed

Any permissions that do not exist will be auto created if the root key has permissions, otherwise this operation will fail with a 403 error.

Example request

{
  "keyId": "key_2cGKbMxRyIzhCxo1Idjz8q"
}

Response

Permissions set successfully. Returns all permissions currently assigned to the key.

Example response

{
  "meta": {
    "requestId": "req_123"
  },
  "data": [
    {
      "id": "perm_1234567890abcdef",
      "name": "users.read",
      "slug": "users-read",
      "description": "Allows reading user profile information and account details"
    }
  ]
}

Changes

Changed in 5 of the 90 revisions of this API.16

  • 59efaed65ec411See the full diff
    • the permissions/items/ request property's maxLength was set to 128

      request-property-max-length-set

    • the permissions/items/ request property's minLength was decreased from 3 to 1

      request-property-min-length-decreased

    • the endpoint scheme security dashboard was removed from the API

      api-security-removed

    • the endpoint scheme security rootKey was removed from the API

      api-security-removed

    This revision also has 5 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

    • the endpoint scheme security dashboard was added to the API

      api-security-added

    This revision also has 1 change that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

    • added the non-success response with the status 429

      response-non-success-status-added

    • api operation id setPermissions removed and replaced with keys.setPermissions

      api-operation-id-removed