Creates a user through the backend management API. The SDK sends this request as multipart/form-data, which lets you provide the core user fields and optionally upload a profile_image in the same call.
Usage
The following example shows a basic usage of the backend client from @wacht/nextjs/server.
function createUser( request: CreateUserRequest,): Promise<User>
CreateUserRequest
›
first_name?: string | undefined;
User first name. This is required when first names are enabled and required by the deployment auth settings.
›
last_name?: string | undefined;
User last name. This is required when last names are enabled and required by the deployment auth settings.
›
email_address?: string | undefined;
Primary email address to create with the user. When present, the backend creates it as the primary email and marks it verified immediately.
›
phone_number?: string | undefined;
Primary phone number to create with the user. When present, the backend creates it as the primary phone number and marks it verified immediately.
›
username?: string | undefined;
Optional username for the new user. Depending on deployment auth settings, this may be required.
›
password?: string | undefined;
Optional password for the new user. Depending on deployment auth settings, this may be required and validated against the configured password rules.
›
skip_password_check?: boolean | undefined;
When `true`, bypasses the normal password validation check during creation.
›
profile_image?: File | Blob | undefined;
Optional profile image uploaded with the create request. When present, the backend uploads it after the user record is created and stores the resulting profile image URL.
Return value
›
id?: string | undefined;
Stable user identifier.
›
created_at?: string | undefined;
Creation timestamp.
›
updated_at?: string | undefined;
Last update timestamp.
›
first_name?: string | undefined;
User first name.
›
last_name?: string | undefined;
User last name.
›
username?: string | undefined;
Optional username.
›
profile_picture_url?: string | undefined;
Resolved profile picture URL. This is empty when no profile image was uploaded.
›
primary_email_address?: string | undefined;
Primary email address string when one was created with the user.
›
primary_phone_number?: string | undefined;
Primary phone number string when one was created with the user.
What the backend does
The backend creates the core user record first, then creates the primary email and primary phone records when you provide them.
If you include profile_image, the backend uploads it after the user exists and then updates the user profile image URL.
Validation depends on deployment settings
Whether fields like email_address, phone_number, username, or password are actually required depends on the deployment auth settings the backend reads at request time.
If password validation is enabled, the backend enforces the configured password rules unless you explicitly pass skip_password_check: true.