Skip to content

feat(backend): Add agent tokens endpoints#7783

Open
tmilewski wants to merge 5 commits intomainfrom
tom/user-4622-implement-utt-backend-sdk-endpoints
Open

feat(backend): Add agent tokens endpoints#7783
tmilewski wants to merge 5 commits intomainfrom
tom/user-4622-implement-utt-backend-sdk-endpoints

Conversation

@tmilewski
Copy link
Member

@tmilewski tmilewski commented Feb 5, 2026

Description

Adds support for the Agent Tokens API endpoint to the backend SDK. This allows developers to create agent tokens that can be used to impersonate users during testing or other automated flows.

Usage

import { createBackendApiClient } from '@clerk/backend';

const client = createBackendApiClient({ secretKey: 'sk_test_...' });

// Create an agent token
const agentToken = await client.agentTokens.create({
  userId: 'user_xxx',
  sessionMaxDurationInSeconds: 1800, // optional
});

// Access token properties
console.log(agentToken.token);
console.log(agentToken.url);
console.log(agentToken.status); // 'pending' | 'accepted' | 'revoked'

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
    • Added experimental Agent Tokens API to create agent tokens for automated user impersonation flows. Supports session duration and redirect URL options.
    • Agent token responses now include token value, status (pending|accepted|revoked), associated user, URL, and timestamps (created/updated).

@tmilewski tmilewski self-assigned this Feb 5, 2026
@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: f76dbf1

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/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify 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
Copy link

vercel bot commented Feb 5, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Feb 6, 2026 10:26pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: f76dbf1

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds Agent Tokens support to the backend SDK: a new AgentTokenAPI endpoint with a create method that POSTs to /agent_tokens, a new AgentToken resource model with fields (id, userId, token, status, url, createdAt, updatedAt), JSON schema (AgentTokenJSON) and ObjectType.AgentToken, deserialization handling for AgentToken, and re-exports to the public API surface. Includes a changeset marking a minor version bump for the backend package.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(backend): Add agent tokens endpoints' accurately and concisely describes the main change—introducing the Agent Tokens API endpoint to the backend SDK.
Linked Issues check ✅ Passed The pull request implements the Agent Tokens API endpoint to enable creating agent tokens for impersonating users, which aligns with the requirements in USER-4622.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Agent Tokens API endpoint; the additional commit to re-add the testing-token export is a supporting fix for the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

coderabbitai[bot]

This comment was marked as resolved.

@tmilewski tmilewski changed the title feat(backend): Add test session tokens endpoints feat(backend): Add agent tokens endpoints Feb 6, 2026
coderabbitai[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant