createRole
const url = 'https://example.com/api/v1/roles';const options = { method: 'POST', headers: {'X-CSRF-Token': 'example', 'Content-Type': 'application/json'}, body: '{"name":"example","description":"example","capabilities":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/roles \ --header 'Content-Type: application/json' \ --header 'X-CSRF-Token: example' \ --data '{ "name": "example", "description": "example", "capabilities": [ "example" ] }'Create a custom role. Requires the roles.manage capability and the admin scope. A caller other than the Owner may include only capabilities they hold, and never users.manage or roles.manage. Cookie-authenticated unsafe requests require X-CSRF-Token.
Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Examplegenerated
{ "name": "example", "description": "example", "capabilities": [ "example" ]}Responses
Section titled “ Responses ”Role created
object
object
Role key. The built-in roles are owner, administrator, editor, contributor, and viewer. Custom role keys start with “custom.”. Decide authorization from the capabilities the server reports, not from the role key.
Active accounts on the role.
Whether the caller may change or delete the role.
Whether the caller may place accounts on the role.
Example
{ "data": { "key": "owner" }}Invalid request body
Dashboard authentication required
Insufficient role or capability outside the caller’s authority
Role name already in use
Name, description, or capability set invalid