Skip to main content
Version: 2.0.0

Create

Create a new user with specified user information.

Parameters

ctx - The context of the request.
userCreate - A struct that contains the information about the user that should be created. The payload is defined below.

userCreate Payload

key - A unique id by which Permit will identify the user for permission checks.

You will later pass this ID to the permit.check() API. You can use anything for this ID; 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).

Email - optional - The email of the user. If synced, will be unique inside the environment.
FirstName - optional - First name of the user.
LastName - optional - Last name of the user.
Attributes - optional - Arbitraty user attributes that will be used to enforce attribute-based access control policies.

user := models.NewUserCreate("user-key")
user.SetEmail("john@doe.com")
user.SetFirstName("John")
user.SetLastName("Doe")
user.SetAttributes(map[string]interface{}{
"age": "26",
})

Implementation

newUser, err := Permit.Api.Users.Create(ctx, *user)