---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminInvitesResource
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# AdminInvitesResource

This class is used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites). All its method
are available in the JS Client under the `medusa.admin.invites` property.

All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).

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](https://docs.medusajs.com/modules/users/admin/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

```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.invites
  .accept({
    token,
    user: {
      first_name: "Brigitte",
      last_name: "Collier",
      password: "supersecret",
    },
  })
  .then(() => {
    // successful
  })
  .catch(() => {
    // an error occurred
  })
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "payload",
    "type": "[`AdminPostInvitesInviteAcceptReq`](../internal/classes/internal.AdminPostInvitesInviteAcceptReq.mdx)",
    "description": "The user accepting the invite.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "token",
        "type": "`string`",
        "description": "The token of the invite to accept. This is a unique token generated when the invite was created or resent.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "user",
        "type": "[`AdminPostInvitesInviteAcceptUserReq`](../internal/classes/internal.AdminPostInvitesInviteAcceptUserReq.mdx)",
        "description": "The details of the user to create.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "first_name",
            "type": "`string`",
            "description": "The invite's first name.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "last_name",
            "type": "`string`",
            "description": "The invite's last name.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "password",
            "type": "`string`",
            "description": "The invite's password",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../internal/types/internal.ResponsePromise.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves when the invite is accepted successfully.",
    "expandable": false,
    "children": []
  }
]} />

___

### create

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

```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.invites
  .create({
    user: "user@example.com",
    role: "admin",
  })
  .then(() => {
    // successful
  })
  .catch(() => {
    // an error occurred
  })
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "payload",
    "type": "[`AdminPostInvitesPayload`](../internal/types/internal.AdminPostInvitesPayload.mdx)",
    "description": "The invite to be created.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "user",
        "type": "`string`",
        "description": "The email associated with the invite. Once the invite is accepted, the email will be associated with the created user.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "role",
        "type": "[`InviteUserRolesEnum`](../internal/types/internal.InviteUserRolesEnum.mdx)",
        "description": "",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../internal/types/internal.ResponsePromise.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves when the invite is created successfully.",
    "expandable": false,
    "children": []
  }
]} />

___

### delete

Delete an invite. Only invites that weren't accepted can be deleted.

#### 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.invites.delete(inviteId).then(({ id, object, deleted }) => {
  console.log(id)
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "The invite's ID.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../internal/types/internal.ResponsePromise.mdx)<[`DeleteResponse`](../internal/interfaces/internal.DeleteResponse.mdx)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the deletion operation's details.",
    "expandable": false,
    "children": [
      {
        "name": "deleted",
        "type": "`boolean`",
        "description": "Whether the item was deleted successfully.",
        "optional": false,
        "defaultValue": "true",
        "expandable": false,
        "children": []
      },
      {
        "name": "id",
        "type": "`string`",
        "description": "The ID of the deleted item.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "object",
        "type": "`string`",
        "description": "The type of the deleted item.",
        "optional": false,
        "defaultValue": "product-collection",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />

___

### list

Retrieve a list of invites.

#### 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.invites.list().then(({ invites }) => {
  console.log(invites.length)
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../internal/types/internal.ResponsePromise.mdx)<[`AdminListInvitesRes`](../internal/types/internal.AdminListInvitesRes.mdx)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the list of invites.",
    "expandable": false,
    "children": [
      {
        "name": "AdminListInvitesRes",
        "type": "`object`",
        "description": "The list of invites.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "invites",
            "type": "[`Invite`](../internal/classes/internal.Invite.mdx)[]",
            "description": "An array of invites",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "accepted",
                "type": "`boolean`",
                "description": "Whether the invite was accepted or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "expires_at",
                "type": "`Date`",
                "description": "The date the invite expires at.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The invite's ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "metadata",
                "type": "Record<`string`, `unknown`\\>",
                "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 change the privileges of the user.",
                "optional": false,
                "defaultValue": "member",
                "expandable": false,
                "children": []
              },
              {
                "name": "token",
                "type": "`string`",
                "description": "The token used to accept the invite.",
                "optional": false,
                "defaultValue": "",
                "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": []
              },
              {
                "name": "user_email",
                "type": "`string`",
                "description": "The email of the user being invited.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### resend

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

```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.invites
  .resend(inviteId)
  .then(() => {
    // successful
  })
  .catch(() => {
    // an error occurred
  })
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "The invite's ID.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../internal/types/internal.ResponsePromise.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves when the invite is resent successfully.",
    "expandable": false,
    "children": []
  }
]} />
