invite - JS SDK Admin Reference

This documentation provides a reference to the sdk.admin.invite set of methods used to send requests to Medusa's Admin API routes.

accept#

This method accepts an invite. It requires sending a previous request to the Auth.register.

This method sends a request to the [Accept Invite] (https://docs.medusajs.com/api/admin#invites_postinvitesaccept) API route.

Example#

Code
1await sdk.auth.register("user", "emailpass", {2  email: "user@gmail.com",3  password: "supersecret"4})5
6// all subsequent requests will use the token in the header7const { user } = await sdk.admin.invite.accept(8  {9    email: "user@gmail.com",10    first_name: "John",11    last_name: "Smith",12    invite_token: "12345..."13  },14)

Parameters#

inputAdminAcceptInvite & object
The details of the user to create.
querySelectParamsOptional
Configure the fields to retrieve in the user.
headersClientHeadersOptional
Headers to pass in the request

Returns#

The user's details.

create#

This method creates an invite. It sends a request to the Create Invite API route.

Example#

Code
1sdk.admin.invite.create({2  email: "user@gmail.com",3})4.then(({ invite }) => {5  console.log(invite)6})

Parameters#

The invite's details.
querySelectParamsOptional
Configure the fields to retrieve in the invite.
headersClientHeadersOptional
Headers to pass in the request

Returns#

PromisePromise<AdminInviteResponse>
The invite's details.

retrieve#

This method retrieves an invite by its ID. It sends a request to the Get Invite API route.

Example#

To retrieve an invite its ID:

Code
1sdk.admin.invite.retrieve("invite_123")2.then(({ invite }) => {3  console.log(invite)4})

To specify the fields and relations to retrieve:

Code
1sdk.admin.invite.retrieve("invite_123", {2  fields: "id,email"3})4.then(({ invite }) => {5  console.log(invite)6})

Learn more about the fields property in the API reference.

Parameters#

idstring
The invite's ID.
querySelectParamsOptional
Configure the fields to retrieve in the invite.
headersClientHeadersOptional
Headers to pass in the request

Returns#

PromisePromise<AdminInviteResponse>
The invite's details.

list#

This method retrieves a paginated list of invites. It sends a request to the List Invites API route.

Example#

To retrieve the list of invites:

Code
1sdk.admin.invite.list()2.then(({ invites, count, limit, offset }) => {3  console.log(invites)4})

To configure the pagination, pass the limit and offset query parameters.

For example, to retrieve only 10 items and skip 10 items:

Code
1sdk.admin.invite.list({2  limit: 10,3  offset: 104})5.then(({ invites, count, limit, offset }) => {6  console.log(invites)7})

Using the fields query parameter, you can specify the fields and relations to retrieve in each invite:

Code
1sdk.admin.invite.list({2  fields: "id,email"3})4.then(({ invites, count, limit, offset }) => {5  console.log(invites)6})

Learn more about the fields property in the API reference.

Parameters#

queryParamsFindParamsOptional
Filters and pagination configurations.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<AdminInviteListResponse>
The paginated list of invites.

resend#

This method refreshes the token of an invite. It sends a request to the Refresh Invite Token API route.

Example#

Code
1sdk.admin.invite.resend("invite_123")2.then(({ invite }) => {3  console.log(invite)4})

Parameters#

idstring
The invite's ID.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<AdminInviteResponse>
The invite's details.

delete#

This method deletes an invite. It sends a request to the Delete Invite API route.

Example#

Code
1sdk.admin.invite.delete("invite_123")2.then(({ deleted }) => {3  console.log(deleted)4})

Parameters#

idstring
The invite's ID.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

The deletion's details.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break