-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Lennart <[email protected]>
- Loading branch information
1 parent
ea9c9a4
commit c503100
Showing
4 changed files
with
20 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
--- | ||
title: getOrganizationInvitationList() | ||
description: Use Clerk's Backend SDK to retrieve a list of organization invitations that have not yet been accepted. | ||
description: Retrieves a list of organization invitations that have not yet been accepted. | ||
--- | ||
|
||
# `getOrganizationInvitationList()` | ||
|
||
Retrieves a list of organization invitations that have not yet been accepted. | ||
|
||
```tsx | ||
function getOrganizationInvitationList: (params: GetOrganizationInvitationListParams) => Promise<PaginatedResourceResponse<OrganizationInvitation[]>>; | ||
const organizationId = 'my-organization-id'; | ||
|
||
const invitations = await clerkClient.organizations.getOrganizationInvitationList({ organizationId }); | ||
``` | ||
|
||
## `GetOrganizationInvitationListParams` | ||
|
@@ -20,91 +22,46 @@ function getOrganizationInvitationList: (params: GetOrganizationInvitationListPa | |
| `limit?` | `number` | The number of results to return. Must be an integer greater than zero and less than 500. | | ||
| `offset?` | `number` | The number of results to skip. | | ||
|
||
## `getOrganizationInvitationList()` examples | ||
|
||
### `getOrganizationInvitationList({ organizationId})` | ||
|
||
In this example, you can see that the returned [`PaginatedResourceResponse`](/docs/references/backend/types/paginated-resource-response) includes `data`, which is an array of [`OrganizationInvitation`](/docs/references/javascript/organization-invitation) objects, and `totalCount`, which indicates the total number of organization invitations in the system for the specified organization. | ||
|
||
```tsx | ||
const organizationId = 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh'; | ||
|
||
const response = await clerkClient.organizations.getOrganizationInvitationList({ organizationId }); | ||
|
||
console.log(response); | ||
/* | ||
{ | ||
data: [ | ||
_OrganizationInvitation { | ||
id: 'orginv_2b6b8BKxYmCdSNYtEBdk2aQSlyY', | ||
emailAddress: '[email protected]', | ||
role: 'org:member', | ||
organizationId: 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh', | ||
createdAt: 1705538313485, | ||
updatedAt: 1705538313485, | ||
status: 'pending', | ||
publicMetadata: {}, | ||
privateMetadata: {} | ||
}, | ||
_OrganizationInvitation { | ||
id: 'orginv_2b6SO8VwBMDn2IMYn0xqiaSxVpN', | ||
emailAddress: '[email protected]', | ||
role: 'org:member', | ||
organizationId: 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh', | ||
createdAt: 1705534000014, | ||
updatedAt: 1705534817946, | ||
status: 'revoked', | ||
publicMetadata: {}, | ||
privateMetadata: {} | ||
} | ||
], | ||
totalCount: 2 | ||
} | ||
*/ | ||
``` | ||
## Examples | ||
|
||
### `getOrganizationInvitationList({ organizationId, status })` | ||
### `getOrganizationInvitationList({ status })` | ||
|
||
Retrieves organization invitation list that is filtered by the status of the invitation. | ||
|
||
```tsx | ||
const organizationId = 'org_123'; | ||
const organizationId = 'my-organization-id'; | ||
|
||
const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({ | ||
const invitations = await clerkClient.organizations.getOrganizationInvitationList({ | ||
organizationId, | ||
// returns a list of invitations that have not yet been accepted | ||
status: [ 'pending' ], | ||
}); | ||
``` | ||
|
||
### `getOrganizationInvitationList({ organizationId, limit })` | ||
### `getOrganizationInvitationList({ limit })` | ||
|
||
Retrieves organization invitation list that is filtered by the number of results. | ||
|
||
```tsx | ||
const organizationId = 'org_123'; | ||
const organizationId = 'my-organization-id'; | ||
|
||
const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({ | ||
const invitations = await clerkClient.organizations.getOrganizationInvitationList({ | ||
organizationId, | ||
// returns the first 10 results | ||
limit: 10, | ||
}); | ||
``` | ||
|
||
### `getOrganizationInvitationList({ organizationId, offset })` | ||
### `getOrganizationInvitationList({ offset })` | ||
|
||
Retrieves organization invitation list that is filtered by the number of results to skip. | ||
|
||
```tsx | ||
const organizationId = 'my-organization-id'; | ||
|
||
const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({ | ||
const invitations = await clerkClient.organizations.getOrganizationInvitationList({ | ||
organizationId, | ||
// skips the first 10 results | ||
offset: 10, | ||
}); | ||
``` | ||
|
||
## Backend API (BAPI) endpoint | ||
|
||
This method in the SDK is a wrapper around the BAPI endpoint `GET/organizations/{organization_id}/invitations`. See the [BAPI reference](https://clerk.com/docs/reference/backend-api/tag/Organization-Invitations#operation/ListOrganizationInvitations) for more details. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters