POST
/
v1
/
keys.addRoles
curl --request POST \
  --url https://api.unkey.dev/v1/keys.addRoles \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "keyId": "<string>",
  "roles": [
    {
      "id": "role_123"
    },
    {
      "name": "dns.record.create"
    },
    {
      "name": "dns.record.delete",
      "create": true
    }
  ]
}'
[
  {
    "id": "role_123",
    "name": "dns.record.create"
  }
]

Adds roles to a key. Existing roles are not removed.

To use this endpoint, your root key must have the rbac.*.add_role_to_key and potentially the rbac.*.create_role permissions.

Changelog

DateChanges
Jul 08 2024Introduced endpoint

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
keyId
string
required

The id of the key.

Minimum length: 1
roles
object[]
required

The roles you want to set for this key. This overwrites all existing roles. Setting roles requires the rbac.*.add_role_to_key permission.

Response

200
application/json
All currently connected roles
id
string
required

The id of the role. This is used internally

name
string
required

The name of the role