Skip to main content
Version: 2.0.0


Creates a new resource.


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


Key - A URL-friendly name of the resource (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the resource.
Name - The name of the resource.
Urn - optional - The URN(Uniform Resource Name) of the resource.
Description - optional - An optional longer description of what this resource respresents in your system.
Actions - A actions definition block, typically contained within a resource type definition block. The actions represents the ways you can interact with a protected resource.
Attributes - optional - Attributes that each resource of this type defines, and can be used in your ABAC policies.
Roles - optional - Roles defined on this resource. The key is the role name, and the value contains the role properties such as granted permissions, base roles, etc.
Relations - optional - Relations to other resources. The key is the relation name, and the value is the destination resource.

    action := models.NewActionBlockEditable()
resourceCreate := models.NewResourceCreate("resource-key", "resource-name", map[string]models.ActionBlockEditable{"edit": *action})


    resource, err := Permit.Api.Resources.Create(ctx, *resourceCreate)