Skip to main content
Version: 2.0.0

Create

Creates a new role.

Parameters

ctx - The context of the request.
roleCreate - An object that contains the information about the new role. The payload is defined below.

Payload

Key - A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role.

You will later pass this Key to the permit.check() API. You can use anything for this Key - the user email, a UUID or anything else as long as it's unique on your end. The user key must be url-friendly (slugified).

Name - optional - The name of the role. Description - optional - Description string explaining what this role represents, or what permissions are granted to it.
Permissions - optional - List of action keys that define what actions this resource role is permitted to do.
Extends - optional - List of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list.

roleCreate := models.NewRoleCreate("role-key", "role-name")
roleCreate.SetPermissions([]string{"resource-key:read", "resource-key:write"})

Implementation

role, err := Permit.Api.Roles.Create(ctx, *roleCreate)