fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

fix(backend): Inconsistent create params for Invite & Org Invite - #6750

Merged
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params
Sep 10, 2025
Merged

fix(backend): Inconsistent create params for Invite & Org Invite#6750
tmilewski merged 1 commit into
mainfrom
tm/user-3259-update-invite-org-invite-create-params

Conversation

@tmilewski

@tmilewskitmilewski commented Sep 10, 2025

Copy link
Copy Markdown
Member

Description

Updates inconsistent create params for Invites & Organization Invites (including bulk).

Fixes USER-3259

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Invitation creation now supports selecting a template (invitation or waitlist), optional expiration, notify recipient, ignore existing users, redirect URL, and public metadata.
    • Organization invitations now support optional expiration, inviter user ID, private and public metadata, and redirect URL; bulk invitations accept the same options.
  • Chores

    • Prepared a patch release entry aligning invitation creation parameters with the backend API.

@tmilewskitmilewski self-assigned this Sep 10, 2025
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f2fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
NameType
@clerk/backendPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Sep 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentSep 10, 2025 4:43pm

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset for a patch release and updates backend SDK invitation-related type definitions to align with the backend API. Invitation creation gains a required templateSlug and optional fields; organization invitation types add optional expiresInDays, inviterUserId, and privateMetadata. No runtime logic or endpoints change.

Changes

Cohort / File(s)Summary
Release metadata
\.changeset/all-hats-float.md
Adds changeset declaring a patch for @clerk/backend to align invitation create params with backend API.
Invitation API types
packages/backend/src/api/endpoints/InvitationApi.ts
Adds TemplateSlug type ('invitation' | 'waitlist_invitation'). Updates CreateParams: adds required templateSlug and optional expiresInDays, ignoreExisting, notify, publicMetadata, redirectUrl. Endpoint functions unchanged; only parameter type shape updated.
Organization API invitation types
packages/backend/src/api/endpoints/OrganizationApi.ts
Updates CreateOrganizationInvitationParams and bulk variant to include optional expiresInDays, inviterUserId, privateMetadata; preserves publicMetadata and redirectUrl (order adjusted). No runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor Dev as Developer Code
participant SDK as Backend SDK (Invitations)
participant BAPI as Backend API
Note over Dev,SDK: Create Invitation (aligned params)
Dev->>SDK: createInvitation({ emailAddress, templateSlug, expiresInDays?, notify?, redirectUrl?, publicMetadata?, ignoreExisting? })
SDK->>BAPI: POST /invitations with payload
BAPI-->>SDK: 201 Created (invitation)
SDK-->>Dev: Invitation object
rect rgba(230,245,255,0.4)
Note right of SDK: Organization Invitations (single/bulk)
Dev->>SDK: createOrganizationInvitation({ emailAddress, role, expiresInDays?, inviterUserId?, privateMetadata?, publicMetadata?, redirectUrl? })
SDK->>BAPI: POST /organizations/:id/invitations
BAPI-->>SDK: 201 Created
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningIn addition to the requested InvitationApi updates, this PR also modifies OrganizationApi invitation types by adding fields like inviterUserId and privateMetadata, which fall outside the scope of USER-3259’s focus on the general invitations endpoint.Please isolate the OrganizationApi invitation parameter changes in a separate pull request or update the linked issue to explicitly include organization invitation consistency requirements.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe current title succinctly describes that this PR fixes inconsistencies in the create parameters for both invitation and organization invitation endpoints, clearly conveying the primary change without extraneous detail.
Linked Issues Check✅ PassedThe PR adds the backend-supported expiresInDays and required templateSlug fields to the InvitationApi CreateParams type, thereby aligning the JS SDK with the BAPI as specified in USER-3259 and fulfilling the linked issue’s primary objective.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit taps keys with delighted feet,
“Template slugs aligned—now that’s neat!”
Expiry days hop into place,
Private bits tucked with gentle grace.
SDK and backend now rhyme in time—
Invitations sent, rhythm sublime.
Thump-thump! Ship the patch—prime.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/user-3259-update-invite-org-invite-create-params

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6750

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6750

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6750

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6750

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6750

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6750

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6750

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6750

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6750

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6750

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6750

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6750

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6750

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6750

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6750

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6750

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6750

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6750

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6750

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6750

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6750

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6750

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6750

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6750

commit: 22f2fcf

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@tmilewskitmilewski changed the title fix: Inconsistent create params for Invite & Org Invitefix(backend): Inconsistent create params for Invite & Org InviteSep 10, 2025
@tmilewski
tmilewski enabled auto-merge (squash) September 10, 2025 16:51

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.changeset/all-hats-float.md (1)

5-6: Changeset likely understates a breaking type change

templateSlug appears to be newly required in InvitationAPI CreateParams (see InvitationApi.ts). If so, this is a breaking change for TS consumers and should not be a patch. Either keep it optional (preferred for patch) or bump to a minor with a clear migration note.

Apply one of:

-Align create params for Invitation and OrganizationInvitation with backend API+Align create params for Invitation and OrganizationInvitation with backend API.++Note: `templateSlug` remains optional in the SDK for backward compatibility; the backend default is used when omitted.

or reclassify the release as minor if keeping templateSlug required.

packages/backend/src/api/endpoints/InvitationApi.ts (1)

1-8: Missing import for UserPublicMetadata

UserPublicMetadata is referenced but not imported; TS will error if it’s not globally available.

-import type { ClerkPaginationRequest } from '@clerk/types';+import type { ClerkPaginationRequest, UserPublicMetadata } from '@clerk/types';
packages/backend/src/api/endpoints/OrganizationApi.ts (1)

1-1: Import missing metadata types used below

OrganizationInvitationPrivateMetadata / OrganizationInvitationPublicMetadata are referenced but not imported.

-import type { ClerkPaginationRequest, OrganizationEnrollmentMode } from '@clerk/types';+import type {+ ClerkPaginationRequest,+ OrganizationEnrollmentMode,+ OrganizationInvitationPrivateMetadata,+ OrganizationInvitationPublicMetadata,+} from '@clerk/types';
🧹 Nitpick comments (4)
packages/backend/src/api/endpoints/InvitationApi.ts (2)

11-12: Export param types for DX and to satisfy package guidelines

These types shape a public API surface; exporting them helps consumers and aligns with “packages should export TypeScript types”.

-type TemplateSlug = 'invitation' | 'waitlist_invitation';+export type TemplateSlug = 'invitation' | 'waitlist_invitation';

Optionally also:

- type CreateParams = { ... }+ export type CreateInvitationParams = CreateParams;

13-21: Add concise JSDoc for newly exposed fields

Public API additions should be documented (notify defaults, redirect behavior, TTL semantics).

 type CreateParams = {
- emailAddress: string;- expiresInDays?: number;+ /** Recipient email for the invitation. */+ emailAddress: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;
ignoreExisting?: boolean;
- notify?: boolean;- publicMetadata?: UserPublicMetadata;- redirectUrl?: string;- templateSlug?: TemplateSlug;+ /** Whether to trigger email notification. Defaults to true on backend unless specified. */+ notify?: boolean;+ /** Public metadata to attach to the invited user. */+ publicMetadata?: UserPublicMetadata;+ /** URL to redirect the user after accepting the invitation. */+ redirectUrl?: string;+ /** Invitation email template to use. */+ templateSlug?: TemplateSlug;
};
packages/backend/src/api/endpoints/OrganizationApi.ts (2)

165-174: Document new invitation fields and export the params type

Add JSDoc for the new fields and export the type for consumers.

-type CreateOrganizationInvitationParams = {+export type CreateOrganizationInvitationParams = {
organizationId: string;
emailAddress: string;
role: OrganizationMembershipRole;
- expiresInDays?: number;- inviterUserId?: string;- privateMetadata?: OrganizationInvitationPrivateMetadata;- publicMetadata?: OrganizationInvitationPublicMetadata;- redirectUrl?: string;+ /** Invitation validity in days. If omitted, backend default applies. */+ expiresInDays?: number;+ /** Explicit inviter user id. If omitted, the caller is used. */+ inviterUserId?: string;+ /** Private metadata attached to the invitation. */+ privateMetadata?: OrganizationInvitationPrivateMetadata;+ /** Public metadata attached to the invitation. */+ publicMetadata?: OrganizationInvitationPublicMetadata;+ /** Redirect URL after invitation acceptance. */+ redirectUrl?: string;
};

379-388: Add JSDoc to bulk endpoint and clarify accepted shapes

Clarify whether the endpoint accepts an array of items or an object with emailAddresses. This avoids ambiguity between backends and @clerk/types.

Proposed JSDoc:

 public async createOrganizationInvitationBulk(
organizationId: string,
params: CreateOrganizationInvitationBulkItem[],
) {
+ /**+ * Creates multiple invitations for the given organization.+ * Accepts an array of invitation item objects. If the backend also accepts+ * `{ emailAddresses: string[]; role: ... }`, document and accept that shape too+ * (with runtime normalization) to ease migration.+ */

If both shapes are allowed by BAPI, consider overloading the signature and normalizing at runtime.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 773d71c and 22f2fcf.

📒 Files selected for processing (3)
  • .changeset/all-hats-float.md (1 hunks)
  • packages/backend/src/api/endpoints/InvitationApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/OrganizationApi.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/all-hats-float.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/endpoints/InvitationApi.ts
  • packages/backend/src/api/endpoints/OrganizationApi.ts
🧬 Code graph analysis (1)
packages/backend/src/api/endpoints/OrganizationApi.ts (1)
packages/types/src/clerk.ts (1)
  • CreateBulkOrganizationInvitationParams (2145-2148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/backend/src/api/endpoints/InvitationApi.ts (1)

59-65: BodyParams are automatically snake_cased by the shared request util (via snakecase-keys); enable deepSnakecaseBodyParamKeys: true only if you need nested-object key transforms.

packages/backend/src/api/endpoints/OrganizationApi.ts (1)

165-185: No manual mapping needed: The request builder uses snakecaseKeys for all bodyParams, so expiresInDays, inviterUserId, metadata and redirectUrl are automatically serialized to the expected snake_case keys.

Comment threadpackages/backend/src/api/endpoints/InvitationApi.ts
Comment threadpackages/backend/src/api/endpoints/OrganizationApi.ts
@tmilewski
tmilewski merged commit b598581 into mainSep 10, 2025
41 of 43 checks passed
@tmilewski
tmilewski deleted the tm/user-3259-update-invite-org-invite-create-params branch September 10, 2025 16:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tmilewski@wobsoriano@clerk-cookie