diff --git a/.changeset/nasty-insects-follow.md b/.changeset/nasty-insects-follow.md new file mode 100644 index 00000000000..4d2fb25d129 --- /dev/null +++ b/.changeset/nasty-insects-follow.md @@ -0,0 +1,5 @@ +--- +'@clerk/backend': patch +--- + +feat: add `orderBy` argument to `getInvitationList` to control sorting (supports leading '+' for ascending and '-' for descending) diff --git a/packages/backend/src/api/endpoints/InvitationApi.ts b/packages/backend/src/api/endpoints/InvitationApi.ts index f869234ec99..d852737e848 100644 --- a/packages/backend/src/api/endpoints/InvitationApi.ts +++ b/packages/backend/src/api/endpoints/InvitationApi.ts @@ -5,6 +5,7 @@ import type { PaginatedResourceResponse } from '../resources/Deserializer'; import type { InvitationStatus } from '../resources/Enums'; import type { Invitation } from '../resources/Invitation'; import { AbstractAPI } from './AbstractApi'; +import type { WithSign } from './util-types'; const basePath = '/invitations'; @@ -23,6 +24,26 @@ type CreateParams = { type CreateBulkParams = Array; type GetInvitationListParams = ClerkPaginationRequest<{ + /** + * Orders the returned invitations by a specific field and direction. + * + * Use a leading '-' for descending order, or no sign/'+' for ascending. + * + * Supported fields: + * - 'created_at' — when the invitation was created + * - 'email_address' — recipient email address + * - 'expires_at' — when the invitation expires + * + * @example + * ```ts + * // Newest first + * await clerkClient.invitations.getInvitationList({ orderBy: '-created_at' }); + * + * // Alphabetical by email + * await clerkClient.invitations.getInvitationList({ orderBy: 'email_address' }); + * ``` + */ + orderBy?: WithSign<'created_at' | 'email_address' | 'expires_at'>; /** * Filters invitations based on their status. *