@doist/todoist-sdk 10.2.0 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,148 @@
1
+ import { ENDPOINT_PAYMENTS_CANCEL_PLAN, ENDPOINT_PAYMENTS_REACTIVATE_PLAN, ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO, ENDPOINT_PRICES, ENDPOINT_PRICING, ENDPOINT_PRO_BILLING_PORTAL, ENDPOINT_PRO_PLAN_DETAILS, ENDPOINT_PRO_TRIAL, ENDPOINT_PRO_UPGRADE, ENDPOINT_WORKSPACE_BILLING_PORTAL, ENDPOINT_WORKSPACE_TRIAL, ENDPOINT_WORKSPACE_UPGRADE, } from '../consts/endpoints.js';
2
+ import { request } from '../transport/http-client.js';
3
+ import { validatePricing, validatePrices, validateProPlanDetails, validateSubscriptionInfo, } from '../utils/validators.js';
4
+ import { BaseClient } from './base-client.js';
5
+ /**
6
+ * Internal sub-client handling all billing-domain endpoints.
7
+ *
8
+ * Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
9
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
10
+ */
11
+ export class BillingClient extends BaseClient {
12
+ async getSubscriptionInfo() {
13
+ const response = await request({
14
+ httpMethod: 'POST',
15
+ baseUri: this.syncApiBase,
16
+ relativePath: ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO,
17
+ apiToken: this.authToken,
18
+ customFetch: this.customFetch,
19
+ });
20
+ return validateSubscriptionInfo(response.data);
21
+ }
22
+ async cancelPlan(args, requestId) {
23
+ const response = await request({
24
+ httpMethod: 'POST',
25
+ baseUri: this.syncApiBase,
26
+ relativePath: ENDPOINT_PAYMENTS_CANCEL_PLAN,
27
+ apiToken: this.authToken,
28
+ customFetch: this.customFetch,
29
+ payload: args,
30
+ requestId: requestId,
31
+ });
32
+ return response.data;
33
+ }
34
+ async reactivatePlan(requestId) {
35
+ const response = await request({
36
+ httpMethod: 'POST',
37
+ baseUri: this.syncApiBase,
38
+ relativePath: ENDPOINT_PAYMENTS_REACTIVATE_PLAN,
39
+ apiToken: this.authToken,
40
+ customFetch: this.customFetch,
41
+ requestId: requestId,
42
+ });
43
+ return validateSubscriptionInfo(response.data);
44
+ }
45
+ async upgradeToPro(args, requestId) {
46
+ const response = await request({
47
+ httpMethod: 'POST',
48
+ baseUri: this.syncApiBase,
49
+ relativePath: ENDPOINT_PRO_UPGRADE,
50
+ apiToken: this.authToken,
51
+ customFetch: this.customFetch,
52
+ payload: args,
53
+ requestId: requestId,
54
+ });
55
+ return response.data;
56
+ }
57
+ async startProTrial(args, requestId) {
58
+ const response = await request({
59
+ httpMethod: 'POST',
60
+ baseUri: this.syncApiBase,
61
+ relativePath: ENDPOINT_PRO_TRIAL,
62
+ apiToken: this.authToken,
63
+ customFetch: this.customFetch,
64
+ payload: args,
65
+ requestId: requestId,
66
+ });
67
+ return response.data;
68
+ }
69
+ async createProBillingPortalSession(args, requestId) {
70
+ const response = await request({
71
+ httpMethod: 'POST',
72
+ baseUri: this.syncApiBase,
73
+ relativePath: ENDPOINT_PRO_BILLING_PORTAL,
74
+ apiToken: this.authToken,
75
+ customFetch: this.customFetch,
76
+ payload: args,
77
+ requestId: requestId,
78
+ });
79
+ return response.data;
80
+ }
81
+ async getProPlanDetails() {
82
+ const response = await request({
83
+ httpMethod: 'GET',
84
+ baseUri: this.syncApiBase,
85
+ relativePath: ENDPOINT_PRO_PLAN_DETAILS,
86
+ apiToken: this.authToken,
87
+ customFetch: this.customFetch,
88
+ });
89
+ return validateProPlanDetails(response.data);
90
+ }
91
+ async upgradeWorkspace(args, requestId) {
92
+ const response = await request({
93
+ httpMethod: 'POST',
94
+ baseUri: this.syncApiBase,
95
+ relativePath: ENDPOINT_WORKSPACE_UPGRADE,
96
+ apiToken: this.authToken,
97
+ customFetch: this.customFetch,
98
+ payload: args,
99
+ requestId: requestId,
100
+ });
101
+ return response.data;
102
+ }
103
+ async startWorkspaceTrial(args, requestId) {
104
+ const response = await request({
105
+ httpMethod: 'POST',
106
+ baseUri: this.syncApiBase,
107
+ relativePath: ENDPOINT_WORKSPACE_TRIAL,
108
+ apiToken: this.authToken,
109
+ customFetch: this.customFetch,
110
+ payload: args,
111
+ requestId: requestId,
112
+ });
113
+ return response.data;
114
+ }
115
+ async createWorkspaceBillingPortalSession(args, requestId) {
116
+ const response = await request({
117
+ httpMethod: 'POST',
118
+ baseUri: this.syncApiBase,
119
+ relativePath: ENDPOINT_WORKSPACE_BILLING_PORTAL,
120
+ apiToken: this.authToken,
121
+ customFetch: this.customFetch,
122
+ payload: args,
123
+ requestId: requestId,
124
+ });
125
+ return response.data;
126
+ }
127
+ async getPrices() {
128
+ const response = await request({
129
+ httpMethod: 'GET',
130
+ baseUri: this.syncApiBase,
131
+ relativePath: ENDPOINT_PRICES,
132
+ apiToken: this.authToken,
133
+ customFetch: this.customFetch,
134
+ });
135
+ return validatePrices(response.data);
136
+ }
137
+ async getPricing(args) {
138
+ const response = await request({
139
+ httpMethod: 'GET',
140
+ baseUri: this.syncApiBase,
141
+ relativePath: ENDPOINT_PRICING,
142
+ apiToken: this.authToken,
143
+ customFetch: this.customFetch,
144
+ payload: args,
145
+ });
146
+ return validatePricing(response.data);
147
+ }
148
+ }
@@ -84,6 +84,19 @@ export const ENDPOINT_WORKSPACE_JOIN = 'workspaces/join';
84
84
  export const ENDPOINT_WORKSPACE_LOGO = 'workspaces/logo';
85
85
  export const ENDPOINT_WORKSPACE_PLAN_DETAILS = 'workspaces/plan_details';
86
86
  export const ENDPOINT_WORKSPACE_USERS = 'workspaces/users';
87
+ // Billing endpoints
88
+ export const ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = 'payments/get_subscription_info';
89
+ export const ENDPOINT_PAYMENTS_CANCEL_PLAN = 'payments/cancel_plan_with_redirect_to_stripe';
90
+ export const ENDPOINT_PAYMENTS_REACTIVATE_PLAN = 'payments/reactivate_plan';
91
+ export const ENDPOINT_PRO_UPGRADE = 'pro/upgrade';
92
+ export const ENDPOINT_PRO_TRIAL = 'pro/trial';
93
+ export const ENDPOINT_PRO_BILLING_PORTAL = 'pro/billing_portal';
94
+ export const ENDPOINT_PRO_PLAN_DETAILS = 'pro/plan_details';
95
+ export const ENDPOINT_WORKSPACE_UPGRADE = 'workspaces/upgrade';
96
+ export const ENDPOINT_WORKSPACE_TRIAL = 'workspaces/trial';
97
+ export const ENDPOINT_WORKSPACE_BILLING_PORTAL = 'workspaces/billing_portal';
98
+ export const ENDPOINT_PRICES = 'prices';
99
+ export const ENDPOINT_PRICING = 'pricing';
87
100
  // Workspace invitation actions (require invite_code parameter)
88
101
  export function getWorkspaceInvitationAcceptEndpoint(inviteCode) {
89
102
  return `workspaces/invitations/${inviteCode}/accept`;
@@ -1,6 +1,7 @@
1
1
  import { ActivityClient } from './clients/activity-client.js';
2
2
  import { AppClient } from './clients/app-client.js';
3
3
  import { BackupClient } from './clients/backup-client.js';
4
+ import { BillingClient } from './clients/billing-client.js';
4
5
  import { CommentClient } from './clients/comment-client.js';
5
6
  import { EmailClient } from './clients/email-client.js';
6
7
  import { FolderClient } from './clients/folder-client.js';
@@ -60,6 +61,7 @@ export class TodoistApi {
60
61
  this.productivityClient = new ProductivityClient(clientDeps);
61
62
  this.workspaceClient = new WorkspaceClient(clientDeps);
62
63
  this.goalsClient = new GoalsClient(clientDeps);
64
+ this.billingClient = new BillingClient(clientDeps);
63
65
  this.appClient = new AppClient(clientDeps);
64
66
  this.uiExtensionClient = new UiExtensionClient(clientDeps);
65
67
  }
@@ -1040,6 +1042,143 @@ export class TodoistApi {
1040
1042
  async unlinkTaskFromGoal(args, requestId) {
1041
1043
  return this.goalsClient.unlinkTaskFromGoal(args, requestId);
1042
1044
  }
1045
+ // ── Billing ──
1046
+ /**
1047
+ * Retrieves the current user's subscription state.
1048
+ *
1049
+ * Requires the `billing:read` scope.
1050
+ *
1051
+ * @returns A promise that resolves to the user's subscription info.
1052
+ */
1053
+ async getSubscriptionInfo() {
1054
+ return this.billingClient.getSubscriptionInfo();
1055
+ }
1056
+ /**
1057
+ * Starts a hosted cancellation flow for the current user's plan.
1058
+ *
1059
+ * Requires the `billing:read_write` scope.
1060
+ *
1061
+ * @param args - Optional cancellation reason details and return URL.
1062
+ * @param requestId - Optional custom identifier for the request.
1063
+ * @returns A promise that resolves to the billing portal redirect URL.
1064
+ */
1065
+ async cancelPlan(args, requestId) {
1066
+ return this.billingClient.cancelPlan(args, requestId);
1067
+ }
1068
+ /**
1069
+ * Reactivates a previously canceled subscription.
1070
+ *
1071
+ * Requires the `billing:read_write` scope.
1072
+ *
1073
+ * @param requestId - Optional custom identifier for the request.
1074
+ * @returns A promise that resolves to the fresh subscription info after reactivation.
1075
+ */
1076
+ async reactivatePlan(requestId) {
1077
+ return this.billingClient.reactivatePlan(requestId);
1078
+ }
1079
+ /**
1080
+ * Creates a Stripe checkout session to upgrade the current user to Pro.
1081
+ *
1082
+ * Requires the `billing:read_write` scope.
1083
+ *
1084
+ * @param args - Currency, billing cycle, redirect URLs, and optional promotion/trial details.
1085
+ * @param requestId - Optional custom identifier for the request.
1086
+ * @returns A promise that resolves to the checkout session URL.
1087
+ */
1088
+ async upgradeToPro(args, requestId) {
1089
+ return this.billingClient.upgradeToPro(args, requestId);
1090
+ }
1091
+ /**
1092
+ * Creates a Stripe checkout session to start a Pro trial.
1093
+ *
1094
+ * Requires the `billing:read_write` scope.
1095
+ *
1096
+ * @param args - Currency, billing cycle, and redirect URLs.
1097
+ * @param requestId - Optional custom identifier for the request.
1098
+ * @returns A promise that resolves to the checkout session URL.
1099
+ */
1100
+ async startProTrial(args, requestId) {
1101
+ return this.billingClient.startProTrial(args, requestId);
1102
+ }
1103
+ /**
1104
+ * Creates a one-time Stripe billing portal session for the current user's Pro plan.
1105
+ *
1106
+ * Requires the `billing:read_write` scope.
1107
+ *
1108
+ * @param args - Return URL and optional flow type / promotion code.
1109
+ * @param requestId - Optional custom identifier for the request.
1110
+ * @returns A promise that resolves to the billing portal URL.
1111
+ */
1112
+ async createProBillingPortalSession(args, requestId) {
1113
+ return this.billingClient.createProBillingPortalSession(args, requestId);
1114
+ }
1115
+ /**
1116
+ * Retrieves the current user's Pro plan and billing details.
1117
+ *
1118
+ * Requires the `billing:read` scope.
1119
+ *
1120
+ * @returns A promise that resolves to the Pro plan details.
1121
+ */
1122
+ async getProPlanDetails() {
1123
+ return this.billingClient.getProPlanDetails();
1124
+ }
1125
+ /**
1126
+ * Creates a Stripe checkout session to upgrade a workspace.
1127
+ *
1128
+ * Requires the `billing:read_write` scope.
1129
+ *
1130
+ * @param args - Workspace ID, currency, billing cycle, redirect URLs, and optional promotion details.
1131
+ * @param requestId - Optional custom identifier for the request.
1132
+ * @returns A promise that resolves to the checkout session URL.
1133
+ */
1134
+ async upgradeWorkspace(args, requestId) {
1135
+ return this.billingClient.upgradeWorkspace(args, requestId);
1136
+ }
1137
+ /**
1138
+ * Creates a Stripe checkout session to start a workspace trial.
1139
+ *
1140
+ * Requires the `billing:read_write` scope.
1141
+ *
1142
+ * @param args - Workspace ID, currency, billing cycle, and redirect URLs.
1143
+ * @param requestId - Optional custom identifier for the request.
1144
+ * @returns A promise that resolves to the checkout session URL.
1145
+ */
1146
+ async startWorkspaceTrial(args, requestId) {
1147
+ return this.billingClient.startWorkspaceTrial(args, requestId);
1148
+ }
1149
+ /**
1150
+ * Creates a one-time Stripe billing portal session for a workspace.
1151
+ *
1152
+ * Requires the `billing:read_write` scope.
1153
+ *
1154
+ * @param args - Workspace ID, return URL, and optional flow type.
1155
+ * @param requestId - Optional custom identifier for the request.
1156
+ * @returns A promise that resolves to the billing portal URL.
1157
+ */
1158
+ async createWorkspaceBillingPortalSession(args, requestId) {
1159
+ return this.billingClient.createWorkspaceBillingPortalSession(args, requestId);
1160
+ }
1161
+ /**
1162
+ * Retrieves available Pro and Teams prices.
1163
+ *
1164
+ * Requires the `billing:read` scope.
1165
+ *
1166
+ * @returns A promise that resolves to the available prices.
1167
+ */
1168
+ async getPrices() {
1169
+ return this.billingClient.getPrices();
1170
+ }
1171
+ /**
1172
+ * Retrieves pricing information.
1173
+ *
1174
+ * Requires the `billing:read` scope.
1175
+ *
1176
+ * @param args - Optional flag to request formatted pricing.
1177
+ * @returns A promise that resolves to current and legacy pricing keyed by version.
1178
+ */
1179
+ async getPricing(args) {
1180
+ return this.billingClient.getPricing(args);
1181
+ }
1043
1182
  // ── Backups ──
1044
1183
  /**
1045
1184
  * Retrieves a list of available backups.
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ import { z } from 'zod';
2
+ import { WORKSPACE_PLAN_STATUSES } from '../workspaces/types.js';
3
+ /** Available subscription statuses. */
4
+ export const BILLING_SUBSCRIPTION_STATUSES = [
5
+ 'none',
6
+ 'autorenew',
7
+ 'canceled',
8
+ 'expired',
9
+ 'trial',
10
+ 'trial_canceled',
11
+ ];
12
+ /** Available plan tiers. */
13
+ export const BILLING_PLANS = ['free', 'pro', 'pro_gifted', 'pro_legacy'];
14
+ /** Ways an active subscription can be purchased. */
15
+ export const BILLING_ACTIVATION_METHODS = [
16
+ 'stripe',
17
+ 'appstore',
18
+ 'playstore',
19
+ 'teams',
20
+ 'manual',
21
+ ];
22
+ /** Available billing cycles. */
23
+ export const BILLING_CYCLES = ['monthly', 'yearly'];
24
+ /** Available tax behaviors for a price. */
25
+ export const TAX_BEHAVIORS = ['exclusive', 'inclusive', 'unspecified'];
26
+ export const BillingPlanPriceSchema = z.object({
27
+ amount: z.string(),
28
+ rawAmount: z.number(),
29
+ currency: z.string(),
30
+ billingCycle: z.enum(BILLING_CYCLES).nullable(),
31
+ taxBehavior: z.enum(TAX_BEHAVIORS),
32
+ });
33
+ export const SubscriptionInfoSchema = z.object({
34
+ status: z.enum(BILLING_SUBSCRIPTION_STATUSES),
35
+ plan: z.enum(BILLING_PLANS),
36
+ expirationDate: z.string().nullable(),
37
+ activationMethod: z.enum(BILLING_ACTIVATION_METHODS),
38
+ planPrice: BillingPlanPriceSchema.nullable(),
39
+ billingPortalUrl: z.string().nullable(),
40
+ billingPortalSwitchToAnnualUrl: z.string().nullable(),
41
+ hasBillingPortal: z.boolean(),
42
+ hasBillingPortalSwitchToAnnual: z.boolean(),
43
+ invoiceCreditBalance: z.record(z.string(), z.number().int()).nullable(),
44
+ hasSwitchLegacyToCurrent: z.boolean(),
45
+ });
46
+ export const FormattedPriceSchema = z.object({
47
+ currency: z.string(),
48
+ unitAmount: z.number().int(),
49
+ taxBehavior: z.enum(TAX_BEHAVIORS),
50
+ });
51
+ export const PriceListingSchema = z.object({
52
+ billingCycle: z.enum(BILLING_CYCLES),
53
+ prices: z.array(FormattedPriceSchema),
54
+ });
55
+ export const ProPlanDetailsSchema = z.object({
56
+ currentPlanStatus: z.enum(WORKSPACE_PLAN_STATUSES),
57
+ downgradeAt: z.string().nullable(),
58
+ priceList: z.array(PriceListingSchema),
59
+ });
60
+ export const PricesResponseSchema = z.object({
61
+ pro: z.array(PriceListingSchema),
62
+ teams: z.array(PriceListingSchema),
63
+ });
64
+ /**
65
+ * Monthly and yearly amounts for a single currency. Each amount is a number in
66
+ * the currency's smallest unit, or a localized formatted string when the
67
+ * `pricing` endpoint is called with `formatted: true`.
68
+ */
69
+ export const PricingTermsSchema = z.object({
70
+ monthly: z.union([z.number(), z.string()]),
71
+ yearly: z.union([z.number(), z.string()]),
72
+ });
73
+ /**
74
+ * A pricing version entry: plan name (`pro` / `biz`) → currency code →
75
+ * {@link PricingTerms}.
76
+ */
77
+ export const PricingVersionSchema = z.record(z.string(), z.record(z.string(), PricingTermsSchema));
78
+ /**
79
+ * Response of the `pricing` endpoint: fixed version-pointer string fields plus
80
+ * dynamic version keys (`v1`, `v2`, …), each a {@link PricingVersion}.
81
+ */
82
+ export const PricingResponseSchema = z
83
+ .object({
84
+ latestPro: z.string(),
85
+ latestBiz: z.string(),
86
+ sessionPro: z.string(),
87
+ sessionBiz: z.string(),
88
+ })
89
+ .catchall(PricingVersionSchema);
@@ -10,6 +10,7 @@ export * from './activity/index.js';
10
10
  export * from './workspaces/index.js';
11
11
  export * from './folders/index.js';
12
12
  export * from './goals/index.js';
13
+ export * from './billing/index.js';
13
14
  export * from './insights/index.js';
14
15
  export * from './backups/index.js';
15
16
  export * from './id-mappings/index.js';
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ActivityEventSchema } from '../types/activity/types.js';
3
3
  import { AppSchema, AppWithUserCountSchema, AppSecretsSchema, AppVerificationTokenSchema, AppTestTokenSchema, AppDistributionTokenSchema, AppByDistributionTokenSchema, AppWebhookSchema, AppInstallationSchema, UserAuthorizationSchema, } from '../types/apps/types.js';
4
4
  import { BackupSchema } from '../types/backups/types.js';
5
+ import { SubscriptionInfoSchema, ProPlanDetailsSchema, PricesResponseSchema, PricingResponseSchema, } from '../types/billing/types.js';
5
6
  import { AttachmentSchema, CommentSchema } from '../types/comments/types.js';
6
7
  import { GoalSchema } from '../types/goals/types.js';
7
8
  import { IdMappingSchema, MovedIdSchema } from '../types/id-mappings/types.js';
@@ -65,6 +66,11 @@ export const { validate: validateCollaborator, validateArray: validateCollaborat
65
66
  export const { validate: validateCollaboratorState, validateArray: validateCollaboratorStateArray, } = createValidator(CollaboratorStateSchema);
66
67
  export const { validate: validateFolder, validateArray: validateFolderArray } = createValidator(FolderSchema);
67
68
  export const { validate: validateGoal, validateArray: validateGoalArray } = createValidator(GoalSchema);
69
+ // Billing validators
70
+ export const { validate: validateSubscriptionInfo } = createValidator(SubscriptionInfoSchema);
71
+ export const { validate: validateProPlanDetails } = createValidator(ProPlanDetailsSchema);
72
+ export const { validate: validatePrices } = createValidator(PricesResponseSchema);
73
+ export const { validate: validatePricing } = createValidator(PricingResponseSchema);
68
74
  export const { validate: validateNote, validateArray: validateNoteArray } = createValidator(NoteSchema);
69
75
  export const { validate: validateTooltips } = createValidator(TooltipsSchema);
70
76
  export const { validate: validateWorkspaceFilter, validateArray: validateWorkspaceFilterArray } = createValidator(WorkspaceFilterSchema);
@@ -7,7 +7,7 @@ export type AuthOptions = {
7
7
  customFetch?: CustomFetch;
8
8
  };
9
9
  /** Available OAuth2 permission scopes. */
10
- export declare const PERMISSIONS: readonly ["task:add", "data:read", "data:read_write", "data:delete", "project:delete", "backups:read", "dev:app_console"];
10
+ export declare const PERMISSIONS: readonly ["task:add", "data:read", "data:read_write", "data:delete", "project:delete", "backups:read", "billing:read", "billing:read_write", "dev:app_console"];
11
11
  /**
12
12
  * Permission scope that can be requested during OAuth2 authorization.
13
13
  * @see {@link https://developer.todoist.com/api/v1/#tag/Authorization}
@@ -0,0 +1,22 @@
1
+ import type { BillingPortalUrlResponse, CancelPlanArgs, CheckoutSessionResponse, GetPricingArgs, PricesResponse, PricingResponse, ProBillingPortalArgs, ProPlanDetails, StartProTrialArgs, StartWorkspaceTrialArgs, SubscriptionInfo, UpgradeToProArgs, UpgradeWorkspaceArgs, WorkspaceBillingPortalArgs } from '../types/billing/index.js';
2
+ import { BaseClient } from './base-client.js';
3
+ /**
4
+ * Internal sub-client handling all billing-domain endpoints.
5
+ *
6
+ * Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
7
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
8
+ */
9
+ export declare class BillingClient extends BaseClient {
10
+ getSubscriptionInfo(): Promise<SubscriptionInfo>;
11
+ cancelPlan(args?: CancelPlanArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
12
+ reactivatePlan(requestId?: string): Promise<SubscriptionInfo>;
13
+ upgradeToPro(args: UpgradeToProArgs, requestId?: string): Promise<CheckoutSessionResponse>;
14
+ startProTrial(args: StartProTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
15
+ createProBillingPortalSession(args: ProBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
16
+ getProPlanDetails(): Promise<ProPlanDetails>;
17
+ upgradeWorkspace(args: UpgradeWorkspaceArgs, requestId?: string): Promise<CheckoutSessionResponse>;
18
+ startWorkspaceTrial(args: StartWorkspaceTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
19
+ createWorkspaceBillingPortalSession(args: WorkspaceBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
20
+ getPrices(): Promise<PricesResponse>;
21
+ getPricing(args?: GetPricingArgs): Promise<PricingResponse>;
22
+ }
@@ -72,6 +72,18 @@ export declare const ENDPOINT_WORKSPACE_JOIN = "workspaces/join";
72
72
  export declare const ENDPOINT_WORKSPACE_LOGO = "workspaces/logo";
73
73
  export declare const ENDPOINT_WORKSPACE_PLAN_DETAILS = "workspaces/plan_details";
74
74
  export declare const ENDPOINT_WORKSPACE_USERS = "workspaces/users";
75
+ export declare const ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = "payments/get_subscription_info";
76
+ export declare const ENDPOINT_PAYMENTS_CANCEL_PLAN = "payments/cancel_plan_with_redirect_to_stripe";
77
+ export declare const ENDPOINT_PAYMENTS_REACTIVATE_PLAN = "payments/reactivate_plan";
78
+ export declare const ENDPOINT_PRO_UPGRADE = "pro/upgrade";
79
+ export declare const ENDPOINT_PRO_TRIAL = "pro/trial";
80
+ export declare const ENDPOINT_PRO_BILLING_PORTAL = "pro/billing_portal";
81
+ export declare const ENDPOINT_PRO_PLAN_DETAILS = "pro/plan_details";
82
+ export declare const ENDPOINT_WORKSPACE_UPGRADE = "workspaces/upgrade";
83
+ export declare const ENDPOINT_WORKSPACE_TRIAL = "workspaces/trial";
84
+ export declare const ENDPOINT_WORKSPACE_BILLING_PORTAL = "workspaces/billing_portal";
85
+ export declare const ENDPOINT_PRICES = "prices";
86
+ export declare const ENDPOINT_PRICING = "pricing";
75
87
  export declare function getWorkspaceInvitationAcceptEndpoint(inviteCode: string): string;
76
88
  export declare function getWorkspaceInvitationRejectEndpoint(inviteCode: string): string;
77
89
  export declare function getProjectInsightsActivityStatsEndpoint(projectId: string): string;
@@ -2,6 +2,7 @@ import type { Reminder } from './types/index.js';
2
2
  import { GetActivityLogsArgs, GetActivityLogsResponse } from './types/activity/index.js';
3
3
  import type { AddAppArgs, App, AppByDistributionToken, AppDistributionToken, AppInstallation, AppSecrets, AppTestToken, AppVerificationToken, AppWebhook, AppWithUserCount, InstallAppArgs, RevokeUserAuthorizationArgs, UpdateAppArgs, UpdateAppInstallationArgs, UpdateAppWebhookArgs, UploadAppIconArgs, UserAuthorization } from './types/apps/index.js';
4
4
  import { Backup, GetBackupsArgs, DownloadBackupArgs } from './types/backups/index.js';
5
+ import type { BillingPortalUrlResponse, CancelPlanArgs, CheckoutSessionResponse, GetPricingArgs, PricesResponse, PricingResponse, ProBillingPortalArgs, ProPlanDetails, StartProTrialArgs, StartWorkspaceTrialArgs, SubscriptionInfo, UpgradeToProArgs, UpgradeWorkspaceArgs, WorkspaceBillingPortalArgs } from './types/billing/index.js';
5
6
  import { Attachment, Comment, AddCommentArgs, UpdateCommentArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetCommentsResponse } from './types/comments/index.js';
6
7
  import { GetOrCreateEmailArgs, GetOrCreateEmailResponse, DisableEmailArgs } from './types/emails/index.js';
7
8
  import { GetFoldersArgs, GetFoldersResponse, AddFolderArgs, UpdateFolderArgs } from './types/folders/index.js';
@@ -77,6 +78,7 @@ export declare class TodoistApi {
77
78
  private readonly productivityClient;
78
79
  private readonly workspaceClient;
79
80
  private readonly goalsClient;
81
+ private readonly billingClient;
80
82
  private readonly appClient;
81
83
  private readonly uiExtensionClient;
82
84
  constructor(
@@ -867,6 +869,118 @@ export declare class TodoistApi {
867
869
  * @returns A promise that resolves to `true` if successful.
868
870
  */
869
871
  unlinkTaskFromGoal(args: TaskLinkingArgs, requestId?: string): Promise<boolean>;
872
+ /**
873
+ * Retrieves the current user's subscription state.
874
+ *
875
+ * Requires the `billing:read` scope.
876
+ *
877
+ * @returns A promise that resolves to the user's subscription info.
878
+ */
879
+ getSubscriptionInfo(): Promise<SubscriptionInfo>;
880
+ /**
881
+ * Starts a hosted cancellation flow for the current user's plan.
882
+ *
883
+ * Requires the `billing:read_write` scope.
884
+ *
885
+ * @param args - Optional cancellation reason details and return URL.
886
+ * @param requestId - Optional custom identifier for the request.
887
+ * @returns A promise that resolves to the billing portal redirect URL.
888
+ */
889
+ cancelPlan(args?: CancelPlanArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
890
+ /**
891
+ * Reactivates a previously canceled subscription.
892
+ *
893
+ * Requires the `billing:read_write` scope.
894
+ *
895
+ * @param requestId - Optional custom identifier for the request.
896
+ * @returns A promise that resolves to the fresh subscription info after reactivation.
897
+ */
898
+ reactivatePlan(requestId?: string): Promise<SubscriptionInfo>;
899
+ /**
900
+ * Creates a Stripe checkout session to upgrade the current user to Pro.
901
+ *
902
+ * Requires the `billing:read_write` scope.
903
+ *
904
+ * @param args - Currency, billing cycle, redirect URLs, and optional promotion/trial details.
905
+ * @param requestId - Optional custom identifier for the request.
906
+ * @returns A promise that resolves to the checkout session URL.
907
+ */
908
+ upgradeToPro(args: UpgradeToProArgs, requestId?: string): Promise<CheckoutSessionResponse>;
909
+ /**
910
+ * Creates a Stripe checkout session to start a Pro trial.
911
+ *
912
+ * Requires the `billing:read_write` scope.
913
+ *
914
+ * @param args - Currency, billing cycle, and redirect URLs.
915
+ * @param requestId - Optional custom identifier for the request.
916
+ * @returns A promise that resolves to the checkout session URL.
917
+ */
918
+ startProTrial(args: StartProTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
919
+ /**
920
+ * Creates a one-time Stripe billing portal session for the current user's Pro plan.
921
+ *
922
+ * Requires the `billing:read_write` scope.
923
+ *
924
+ * @param args - Return URL and optional flow type / promotion code.
925
+ * @param requestId - Optional custom identifier for the request.
926
+ * @returns A promise that resolves to the billing portal URL.
927
+ */
928
+ createProBillingPortalSession(args: ProBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
929
+ /**
930
+ * Retrieves the current user's Pro plan and billing details.
931
+ *
932
+ * Requires the `billing:read` scope.
933
+ *
934
+ * @returns A promise that resolves to the Pro plan details.
935
+ */
936
+ getProPlanDetails(): Promise<ProPlanDetails>;
937
+ /**
938
+ * Creates a Stripe checkout session to upgrade a workspace.
939
+ *
940
+ * Requires the `billing:read_write` scope.
941
+ *
942
+ * @param args - Workspace ID, currency, billing cycle, redirect URLs, and optional promotion details.
943
+ * @param requestId - Optional custom identifier for the request.
944
+ * @returns A promise that resolves to the checkout session URL.
945
+ */
946
+ upgradeWorkspace(args: UpgradeWorkspaceArgs, requestId?: string): Promise<CheckoutSessionResponse>;
947
+ /**
948
+ * Creates a Stripe checkout session to start a workspace trial.
949
+ *
950
+ * Requires the `billing:read_write` scope.
951
+ *
952
+ * @param args - Workspace ID, currency, billing cycle, and redirect URLs.
953
+ * @param requestId - Optional custom identifier for the request.
954
+ * @returns A promise that resolves to the checkout session URL.
955
+ */
956
+ startWorkspaceTrial(args: StartWorkspaceTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
957
+ /**
958
+ * Creates a one-time Stripe billing portal session for a workspace.
959
+ *
960
+ * Requires the `billing:read_write` scope.
961
+ *
962
+ * @param args - Workspace ID, return URL, and optional flow type.
963
+ * @param requestId - Optional custom identifier for the request.
964
+ * @returns A promise that resolves to the billing portal URL.
965
+ */
966
+ createWorkspaceBillingPortalSession(args: WorkspaceBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
967
+ /**
968
+ * Retrieves available Pro and Teams prices.
969
+ *
970
+ * Requires the `billing:read` scope.
971
+ *
972
+ * @returns A promise that resolves to the available prices.
973
+ */
974
+ getPrices(): Promise<PricesResponse>;
975
+ /**
976
+ * Retrieves pricing information.
977
+ *
978
+ * Requires the `billing:read` scope.
979
+ *
980
+ * @param args - Optional flag to request formatted pricing.
981
+ * @returns A promise that resolves to current and legacy pricing keyed by version.
982
+ */
983
+ getPricing(args?: GetPricingArgs): Promise<PricingResponse>;
870
984
  /**
871
985
  * Retrieves a list of available backups.
872
986
  *
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';