Skip to content

Commit 9ee0531

Browse files
authored
feat(backend): Adds createSession to the Backend API client (#5592)
1 parent 950ffed commit 9ee0531

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

.changeset/rich-jobs-serve.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
Adds the ability to create an active session to the Backend API client.
6+
7+
```ts
8+
import { createClerkClient } from '@clerk/backend';
9+
10+
const clerkClient = createClerkClient(...);
11+
await clerkClient.sessions.createSession({
12+
userId: 'user_xxxxxx',
13+
});
14+
```

packages/backend/src/api/endpoints/SessionApi.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ type RefreshTokenParams = {
2525
format?: 'token' | 'cookie';
2626
};
2727

28+
type CreateSessionParams = {
29+
userId: string;
30+
};
31+
2832
export class SessionAPI extends AbstractAPI {
2933
public async getSessionList(params: SessionListParams = {}) {
3034
return this.request<PaginatedResourceResponse<Session[]>>({
@@ -42,6 +46,14 @@ export class SessionAPI extends AbstractAPI {
4246
});
4347
}
4448

49+
public async createSession(params: CreateSessionParams) {
50+
return this.request<Session>({
51+
method: 'POST',
52+
path: basePath,
53+
bodyParams: params,
54+
});
55+
}
56+
4557
public async revokeSession(sessionId: string) {
4658
this.requireId(sessionId);
4759
return this.request<Session>({

0 commit comments

Comments
 (0)