Skip to content

feat(backend): support organization-scoped sign-in tokens#9192

Merged
swolfand merged 1 commit into
mainfrom
sam/mobile-591-sign-in-token-org
Jul 17, 2026
Merged

feat(backend): support organization-scoped sign-in tokens#9192
swolfand merged 1 commit into
mainfrom
sam/mobile-591-sign-in-token-org

Conversation

@swolfand

@swolfand swolfand commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an optional orgId field to CreateSignInTokensParams
  • serialize the value as org_id in the Backend API request
  • add Node and edge-runtime coverage for the request body
  • add a minor changeset for @clerk/backend

Context

Supports the organization-scoped sign-in token API introduced in clerk/clerk_go#20464.

Related SDK and docs work:

Manual verification

The organization-scoped sign-in token flow was exercised against the local backend branch.

Organization-scoped sign-in token created with orgId

Validation

  • pnpm turbo build --filter=@clerk/backend
  • pnpm turbo test --filter=@clerk/backend
  • pnpm --filter @clerk/backend lint
  • pnpm --filter @clerk/backend format:check

Summary by CodeRabbit

  • New Features
    • Sign-in tokens can now optionally activate a specified organization when redeemed, provided the organization is enabled and the user is a member.
  • Documentation
    • Added guidance for using the optional organization parameter when creating sign-in tokens.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9389ae4

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

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

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

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 17, 2026 6:34pm
swingset Ready Ready Preview, Comment Jul 17, 2026 6:34pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

createSignInToken() now accepts an optional orgId, forwards it in the sign-in token request, and documents the change as a minor backend release. A new MSW-backed test verifies the request payload and response mapping.

Changes

Sign-in token organization activation

Layer / File(s) Summary
Organization-aware token creation
packages/backend/src/api/endpoints/SignInTokenApi.ts, packages/backend/src/api/__tests__/SignInTokenApi.test.ts, .changeset/tidy-tokens-activate.md
The token creation parameters add optional orgId, the API test verifies it in the request body and checks the returned token ID, and the Changeset records the minor release.
Estimated code review effort: 2 (Simple) ~10 minutes

Poem

A rabbit packed a token bright,
With orgId tucked in tight.
The request hopped through tests with cheer,
Its token ID came hopping near.
Minor notes now bloom in sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: backend sign-in tokens now support an optional organization scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9192

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9192

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9192

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9192

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9192

@clerk/upgrade

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

@clerk/vue

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

commit: 9389ae4

@swolfand
swolfand marked this pull request as ready for review July 17, 2026 19:57
@macroscopeapp

macroscopeapp Bot commented Jul 17, 2026

Copy link
Copy Markdown

Approvability

Verdict: Approved

Adds an optional orgId parameter to an existing API method. This is a backwards-compatible, additive change where the SDK simply passes the parameter to the backend API. The test validates correct serialization.

You can customize Macroscope's approvability policy. Learn more.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
packages/backend/src/api/__tests__/SignInTokenApi.test.ts (1)

13-45: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover the optional-field and error-path cases.

This test only covers the happy path with orgId present. Add cases verifying that omitted orgId is not serialized and that backend errors are propagated correctly. As per coding guidelines, new functionality must include edge-case and error-handling coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/backend/src/api/__tests__/SignInTokenApi.test.ts` around lines 13 -
45, Extend the sign-in token tests around
apiClient.signInTokens.createSignInToken to verify that omitting orgId excludes
org_id from the request payload, and add an error-path case where the mocked
backend failure is propagated to the caller. Preserve the existing
organization-ID happy-path assertion.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/backend/src/api/__tests__/SignInTokenApi.test.ts`:
- Around line 13-45: Extend the sign-in token tests around
apiClient.signInTokens.createSignInToken to verify that omitting orgId excludes
org_id from the request payload, and add an error-path case where the mocked
backend failure is propagated to the caller. Preserve the existing
organization-ID happy-path assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: aef2e311-82f7-484a-9e93-4f3d2c30dfe0

📥 Commits

Reviewing files that changed from the base of the PR and between 118492e and 9389ae4.

📒 Files selected for processing (3)
  • .changeset/tidy-tokens-activate.md
  • packages/backend/src/api/__tests__/SignInTokenApi.test.ts
  • packages/backend/src/api/endpoints/SignInTokenApi.ts

@github-actions

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-17T20:00:42.677Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 9389ae4.

@wobsoriano wobsoriano 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.

looks legit 👍🏼

@swolfand
swolfand merged commit 26530ce into main Jul 17, 2026
93 checks passed
@swolfand
swolfand deleted the sam/mobile-591-sign-in-token-org branch July 17, 2026 20:08
Sign up for free to 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.

2 participants