diff --git a/.changeset/rich-jobs-serve.md b/.changeset/rich-jobs-serve.md new file mode 100644 index 00000000000..ab816f7b287 --- /dev/null +++ b/.changeset/rich-jobs-serve.md @@ -0,0 +1,14 @@ +--- +'@clerk/backend': minor +--- + +Adds the ability to create an active session to the Backend API client. + +```ts + import { createClerkClient } from '@clerk/backend'; + + const clerkClient = createClerkClient(...); + await clerkClient.sessions.createSession({ + userId: 'user_xxxxxx', + }); +``` \ No newline at end of file diff --git a/packages/backend/src/api/endpoints/SessionApi.ts b/packages/backend/src/api/endpoints/SessionApi.ts index 4022e12512c..339a19b851f 100644 --- a/packages/backend/src/api/endpoints/SessionApi.ts +++ b/packages/backend/src/api/endpoints/SessionApi.ts @@ -25,6 +25,10 @@ type RefreshTokenParams = { format?: 'token' | 'cookie'; }; +type CreateSessionParams = { + userId: string; +}; + export class SessionAPI extends AbstractAPI { public async getSessionList(params: SessionListParams = {}) { return this.request>({ @@ -42,6 +46,14 @@ export class SessionAPI extends AbstractAPI { }); } + public async createSession(params: CreateSessionParams) { + return this.request({ + method: 'POST', + path: basePath, + bodyParams: params, + }); + } + public async revokeSession(sessionId: string) { this.requireId(sessionId); return this.request({