Overview
Thecreate-member function creates a new member in your BoxApp system. It handles both authentication account creation and profile setup in a single operation. If a user with the provided email already exists in the authentication system, the function updates their profile instead of creating a duplicate account.
Endpoint
This is a Supabase Edge Function that requires service role authentication.
Request Body
The member’s email address. Used for authentication and communication.
Initial password for the member’s account. The member will be required to change this on first login.
The member’s first name.
The member’s last name.
The role identifier that determines the member’s permissions within the system.
The unique identifier for the CrossFit box this member belongs to.
Response
Behavior
The function performs the following operations:- Checks for existing user: Searches the authentication system for a user with the provided email
- Creates or reuses auth account:
- If the user doesn’t exist, creates a new authentication account with
email_confirm: true - If the user exists, uses the existing account ID
- If the user doesn’t exist, creates a new authentication account with
- Validates box ownership: Ensures the user isn’t already registered with a different box
- Creates or updates profile:
- Sets
force_password_change: trueto require password change on first login - Sets
status: 'active'to enable the member immediately
- Sets
Example Request
Example Response
Error Response
If an error occurs, you’ll receive a response with status 400:Common Use Cases
- Onboarding new members: Create accounts for members joining your box
- Bulk member import: Add multiple members programmatically
- Admin user creation: Set up new members with specific roles
Members created through this function will have
force_password_change set to true, requiring them to change their password upon first login for security.