medusa user
Create an admin user or invitation for your Medusa application.Usage
Description
Themedusa user command creates a new admin user or generates an invitation token for your Medusa application. This is useful for:
- Creating the first admin user for a new installation
- Adding additional admin users
- Generating invitation links for new administrators
- Creates a user record in the database
- Registers authentication credentials with the email/password provider
- Assigns roles (including super admin role if RBAC is enabled)
- Links the authentication identity to the user
Options
-e, --email <email>
The email address for the user.
- Type:
string - Required: Yes (prompted if not provided)
-p, --password <password>
The password for the user.
- Type:
string - Required: Yes for user creation (prompted if not provided)
- Not used when
--inviteflag is set
-i, --id <id>
Optional user ID to assign.
- Type:
string - Default: Auto-generated
--invite
Create an invitation instead of a user directly.
- Type:
boolean - Default:
false
- An invitation is created instead of a user
- No password is required
- An invite token is returned
- The user can complete registration via the admin dashboard
Interactive Mode
If you run the command without options, you’ll be prompted for the required information:Examples
Create a User
Create a new admin user with email and password:Create a User Interactively
Run without arguments to be prompted:Create an Invitation
Generate an invitation token instead of creating a user directly:Create User with Custom ID
Specify a custom user ID:Role Assignment
With RBAC Enabled
When Role-Based Access Control (RBAC) is enabled:- The command automatically assigns the super admin role
- Super admin role ID:
role_super_admin - You’ll see: “Assigning super admin role to user.”
Without RBAC
When RBAC is not enabled:- No role assignment occurs
- The user is created without specific role limitations
Workflow Integration
The command uses Medusa workflows internally:- User Creation:
create-users-workflow - Invitation Creation:
create-invite-step
Authentication Provider
The command uses theemailpass authentication provider to register user credentials. This provider:
- Stores email/password authentication
- Hashes passwords securely
- Links auth identities to user records
Common Use Cases
First-Time Setup
Create your first admin user after installing Medusa:Invite New Admin
Generate an invitation link for a new team member:Scripted User Creation
Create users non-interactively in deployment scripts:Error Handling
Common errors and their solutions:Email Already Exists
Invalid Email Format
Authentication Provider Error
- The database is accessible
- The auth module is properly configured
- No conflicting authentication records exist
Security Considerations
Password Security
When creating users:- Use strong passwords with mixed character types
- Avoid passing passwords as command-line arguments in production (they appear in shell history)
- Use environment variables or interactive prompts instead
Secure Password Input
Super Admin Access
Users created with this command receive super admin privileges. Only create users for trusted administrators.Advanced Usage
Programmatic User Creation
For more complex user creation scenarios, you can use Medusa workflows directly in your code:See Also
- API Authentication - Learn about authentication in Medusa
- Admin Dashboard - Admin dashboard overview
- Auth Providers - Configure authentication providers