Skip to content

Commit c19f936

Browse files
authored
chore(backend): Get user's subscription via BillingApi (#6667)
1 parent e1d89ac commit c19f936

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.changeset/wild-rice-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
Get user's subscription via BillingApi.

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AbstractAPI } from './AbstractApi';
99

1010
const basePath = '/commerce';
1111
const organizationBasePath = '/organizations';
12+
const userBasePath = '/users';
1213

1314
type GetOrganizationListParams = ClerkPaginationRequest<{
1415
payerType: 'org' | 'user';
@@ -59,4 +60,16 @@ export class BillingAPI extends AbstractAPI {
5960
path: joinPaths(organizationBasePath, organizationId, 'billing', 'subscription'),
6061
});
6162
}
63+
64+
/**
65+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
66+
* It is advised to pin the SDK version to avoid breaking changes.
67+
*/
68+
public async getUserBillingSubscription(userId: string) {
69+
this.requireId(userId);
70+
return this.request<CommerceSubscription>({
71+
method: 'GET',
72+
path: joinPaths(userBasePath, userId, 'billing', 'subscription'),
73+
});
74+
}
6275
}

0 commit comments

Comments
 (0)