AdminUsersResource
This class is used to send requests to Admin User API Routes. All its method
are available in the JS Client under the medusa.admin.users
property.
All methods in this class require authentication.
A store can have more than one user, each having the same privileges. Admins can manage users, their passwords, and more.
Related Guide: How to manage users.
Methods
sendResetPasswordToken
Generate a password token for an admin user with a given email. This also triggers the user.password_reset
event. So, if you have a Notification Service installed
that can handle this event, a notification, such as an email, will be sent to the user. The token is triggered as part of the user.password_reset
event's payload.
That token must be used later to reset the password using the resetPassword method.
Example
Parameters
The user's reset details.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<void>RequiredresetPassword
Reset the password of an admin user using their reset password token. You must generate a reset password token first for the user using the sendResetPasswordToken method, then use that token to reset the password in this method.
Example
Parameters
The reset details.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminUserRes>RequiredResolves to the user's details.
ResponsePromise
ResponsePromise<AdminUserRes>Requiredretrieve
Retrieve an admin user's details.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminUserRes>RequiredResolves to the user's details.
ResponsePromise
ResponsePromise<AdminUserRes>Requiredcreate
Create an admin user. The user has the same privileges as all admin users, and will be able to authenticate and perform admin functionalities right after creation.
Example
Parameters
payload
AdminCreateUserPayloadRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminUserRes>RequiredResolves to the user's details.
ResponsePromise
ResponsePromise<AdminUserRes>Requiredupdate
Update an admin user's details.
Example
Parameters
id
stringRequiredpayload
AdminUpdateUserPayloadRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminUserRes>RequiredResolves to the user's details.
ResponsePromise
ResponsePromise<AdminUserRes>Requireddelete
Delete a user. Once deleted, the user will not be able to authenticate or perform admin functionalities.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>Requiredlist
Retrieve all admin users.
Example
To list users:
By default, only the first 20
users are returned. You can control pagination by specifying the limit
and offset
properties:
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
query
AdminGetUsersParams
query
AdminGetUsersParamsReturns
ResponsePromise
ResponsePromise<AdminUsersListRes>RequiredResolves to the list of users.
ResponsePromise
ResponsePromise<AdminUsersListRes>Required