Docs

getInvitationList()

Retrieves a list of non-revoked invitations for your application, sorted by descending creation date.

function getInvitationList(
  params: GetInvitationListParams,
): Promise<PaginatedResourceResponse<Invitation[]>>
  • Name
    status?
    Type
    accepted | pending | revoked
    Description

    Filter by invitation status.

  • Name
    limit?
    Type
    number
    Description

    The number of results to return. Must be an integer greater than zero and less than 501. Can be used for paginating the results together with offset. Defaults to 10.

  • Name
    offset?
    Type
    number
    Description

    Skip the first offset results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit. Defaults to 0.

Examples

Basic

In the following example, you can see that the returned PaginatedResourceResponse includes data, which is an array of Invitation objects, and totalCount, which indicates the total number of invitations in the system.

const response = await clerkClient.invitations.getInvitationList()

console.log(response)
/*
[
  data: [
    _Invitation {
      id: 'inv_123',
      emailAddress: 'invite@example.com',
      publicMetadata: [Object],
      createdAt: 1705531674576,
      updatedAt: 1705531674576,
      status: 'pending',
      revoked: undefined
    }
  ],
  totalCount: 1
]
*/

Filter by invitation status

Retrieves list of invitations that have been revoked.

// get all revoked invitations
const response = await clerkClient.invitations.getInvitationList({ status: 'revoked' })

console.log(response)
/*
{
  data: [
    _Invitation {
      id: 'inv_123',
      emailAddress: 'invite@example.com',
      publicMetadata: [Object],
      createdAt: 1705531674576,
      updatedAt: 1705531674576,
      status: 'pending',
      revoked: undefined
    }
  ],
  totalCount: 1
}
*/

Limit the number of results

Retrieves list of invitations that have been revoked that is filtered by the number of results.

const { data, totalCount } = await clerkClient.invitations.getInvitationList({
  status: 'revoked',
  // returns the first 10 results
  limit: 10,
})

Skip results

Retrieves list of invitations that have been revoked that is filtered by the number of results to skip.

const { data, totalCount } = await clerkClient.invitations.getInvitationList({
  status: 'revoked',
  // skips the first 10 results
  offset: 10,
})

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint GET/invitations. See the BAPI reference for more details.

Feedback

What did you think of this content?

Last updated on