const { result, error } = await unkey.permissions.createRole({
  name: "dns.records.manager",
  description:
    "dns.records.manager can read and write dns records for our domains",
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "result": {
      "roleId": "role_45TTRKT5Yh28M6Qj"
    }
}
const { result, error } = await unkey.permissions.createRole({
  name: "dns.records.manager",
  description:
    "dns.records.manager can read and write dns records for our domains",
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "result": {
      "roleId": "role_45TTRKT5Yh28M6Qj"
    }
}

To use this function, your root key must have the rbac.*.create_role

Request

name
string
required

The unique name of your role.

Required string length: 3 - 256

Example: "dns.records.manager"

description
string

Explain what this role does. This is just for your team, your users will not see this.

Required string length: 3 - 256

Example:"dns.records.manager can read and write dns records for our domains."

Response

roleId
string
required

The id of the role. This is used internally

Example: "role_123"