AdminInvitesResource
This class is used to send requests to Admin Invite API Routes. All its method
are available in the JS Client under the medusa.admin.invites
property.
All methods in this class require user authentication.
An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.
Related Guide: How to manage invites.
Methods
accept
Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities.
The user will have the email associated with the invite, and the password provided in the payload
parameter.
Example
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.invites.accept({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret"
}
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
Parameters
The user accepting the invite.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromiseRequiredcreate
Create an invite. This will generate a token associated with the invite and trigger an invite.created
event. If you have a Notification Provider installed that handles this
event, a notification should be sent to the email associated with the invite to allow them to accept the invite.
Example
Parameters
payload
AdminPostInvitesPayloadRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromiseRequireddelete
Delete an invite. Only invites that weren't accepted can be deleted.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>Requiredlist
Retrieve a list of invites.
Example
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminListInvitesRes>RequiredResolves to the list of invites.
ResponsePromise
ResponsePromise<AdminListInvitesRes>Requiredresend
Resend an invite. This renews the expiry date by seven days and generates a new token for the invite. It also triggers the invite.created
event,
so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the
invite to allow them to accept the invite.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromiseRequired