--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminUsersResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminUsersResource This class is used to send requests to [Admin User API Routes](https://docs.medusajs.com/api/admin#users). All its method are available in the JS Client under the `medusa.admin.users` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). 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](https://docs.medusajs.com/modules/users/admin/manage-users). ## Methods ### create 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 ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users .create({ email: "user@example.com", password: "supersecret", }) .then(({ user }) => { console.log(user.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UserRoles](../internal/enums/internal.internal.UserRoles.mdx)", "description": "The user's role. These roles don't provide any different privileges.", "optional": false, "defaultValue": "member", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### delete Delete a user. Once deleted, the user will not be able to authenticate or perform admin functionalities. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users.delete(userId).then(({ id, object, deleted }) => { console.log(id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### list Retrieve all admin users. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users.list().then(({ users }) => { console.log(users.length) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UserRoles](../internal/enums/internal.internal.UserRoles.mdx)", "description": "The user's role. These roles don't provide any different privileges.", "optional": false, "defaultValue": "member", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### resetPassword 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](AdminUsersResource.mdx#sendresetpasswordtoken) method, then use that token to reset the password in this method. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users .resetPassword({ token: "supersecrettoken", password: "supersecret", }) .then(({ user }) => { console.log(user.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UserRoles](../internal/enums/internal.internal.UserRoles.mdx)", "description": "The user's role. These roles don't provide any different privileges.", "optional": false, "defaultValue": "member", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve an admin user's details. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users.retrieve(userId).then(({ user }) => { console.log(user.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UserRoles](../internal/enums/internal.internal.UserRoles.mdx)", "description": "The user's role. These roles don't provide any different privileges.", "optional": false, "defaultValue": "member", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### 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](AdminUsersResource.mdx#resetpassword) method. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users .sendResetPasswordToken({ email: "user@example.com", }) .then(() => { // successful }) .catch(() => { // error occurred }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### update Update an admin user's details. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.users .update(userId, { first_name: "Marcellus", }) .then(({ user }) => { console.log(user.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs with additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UpdateUserRoles](../internal/types/internal.UpdateUserRoles.mdx)", "description": "", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "role", "type": "[UserRoles](../internal/enums/internal.internal.UserRoles.mdx)", "description": "The user's role. These roles don't provide any different privileges.", "optional": false, "defaultValue": "member", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />