@gpt-platform/client 0.4.1 → 0.4.3

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.
package/dist/index.mjs CHANGED
@@ -901,6 +901,34 @@ var ConflictError = class extends GptCoreError {
901
901
  super(message, { statusCode: 409, code: "conflict_error", ...options });
902
902
  }
903
903
  };
904
+ var PaymentRequiredError = class extends GptCoreError {
905
+ constructor(message = "Payment required", options) {
906
+ super(message, {
907
+ statusCode: 402,
908
+ code: "payment_required",
909
+ ...options
910
+ });
911
+ }
912
+ };
913
+ var CardDeclinedError = class extends GptCoreError {
914
+ constructor(message = "Card declined", declineCode, options) {
915
+ super(message, {
916
+ statusCode: 402,
917
+ code: "card_declined",
918
+ ...options
919
+ });
920
+ this.declineCode = declineCode;
921
+ }
922
+ };
923
+ var SubscriptionConflictError = class extends GptCoreError {
924
+ constructor(message = "Subscription conflict", options) {
925
+ super(message, {
926
+ statusCode: 409,
927
+ code: "subscription_conflict",
928
+ ...options
929
+ });
930
+ }
931
+ };
904
932
  function handleApiError(error) {
905
933
  if (typeof error !== "object" || error === null) {
906
934
  throw new NetworkError(
@@ -909,7 +937,7 @@ function handleApiError(error) {
909
937
  }
910
938
  const err = error;
911
939
  const response = err.response || err;
912
- const statusCode = response.status || err.status || err.statusCode;
940
+ let statusCode = response.status || err.status || err.statusCode;
913
941
  const headers = response.headers || err.headers;
914
942
  const requestId = (headers && typeof headers === "object" && "get" in headers ? headers.get("x-request-id") : headers?.["x-request-id"]) || void 0;
915
943
  const body = response.body || response.data || err.body || err.data || err;
@@ -923,6 +951,10 @@ function handleApiError(error) {
923
951
  field: err2.source?.pointer?.split("/").pop(),
924
952
  message: err2.detail || err2.title || "Unknown error"
925
953
  }));
954
+ if (!statusCode && firstError?.status) {
955
+ const parsed = parseInt(firstError.status, 10);
956
+ if (!isNaN(parsed)) statusCode = parsed;
957
+ }
926
958
  } else if (typeof body === "object" && body !== null && "message" in body && typeof body.message === "string") {
927
959
  message = body.message;
928
960
  } else if (typeof body === "string") {
@@ -969,8 +1001,21 @@ function handleApiError(error) {
969
1001
  throw new AuthorizationError(message, errorOptions);
970
1002
  case 404:
971
1003
  throw new NotFoundError(message, errorOptions);
972
- case 409:
1004
+ case 402: {
1005
+ const bodyCode = typeof body === "object" && body !== null && "code" in body ? body.code : void 0;
1006
+ const declineCode = typeof body === "object" && body !== null && "decline_code" in body ? body.decline_code : void 0;
1007
+ if (bodyCode === "card_declined") {
1008
+ throw new CardDeclinedError(message, declineCode, errorOptions);
1009
+ }
1010
+ throw new PaymentRequiredError(message, errorOptions);
1011
+ }
1012
+ case 409: {
1013
+ const bodyCode409 = typeof body === "object" && body !== null && "code" in body ? body.code : void 0;
1014
+ if (bodyCode409 === "subscription_conflict") {
1015
+ throw new SubscriptionConflictError(message, errorOptions);
1016
+ }
973
1017
  throw new ConflictError(message, errorOptions);
1018
+ }
974
1019
  case 400:
975
1020
  case 422:
976
1021
  throw new ValidationError(message, errors, errorOptions);
@@ -1224,7 +1269,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1224
1269
  }
1225
1270
 
1226
1271
  // src/version.ts
1227
- var SDK_VERSION = "0.4.1";
1272
+ var SDK_VERSION = "0.4.3";
1228
1273
  var DEFAULT_API_VERSION = "2026-02-27";
1229
1274
 
1230
1275
  // src/base-client.ts
@@ -1690,6 +1735,15 @@ var postEmailOutboundEmails = (options) => (options.client ?? client).post({
1690
1735
  ...options.headers
1691
1736
  }
1692
1737
  });
1738
+ var patchWalletCredits = (options) => (options.client ?? client).patch({
1739
+ security: [{ scheme: "bearer", type: "http" }],
1740
+ url: "/wallet/credits",
1741
+ ...options,
1742
+ headers: {
1743
+ "Content-Type": "application/vnd.api+json",
1744
+ ...options.headers
1745
+ }
1746
+ });
1693
1747
  var getCrmCustomEntitiesWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1694
1748
  security: [{ scheme: "bearer", type: "http" }],
1695
1749
  url: "/crm/custom-entities/workspace/{workspace_id}",
@@ -1728,6 +1782,11 @@ var patchApiKeysByIdRotate = (options) => (options.client ?? client).patch({
1728
1782
  ...options.headers
1729
1783
  }
1730
1784
  });
1785
+ var getApplicationsCurrent = (options) => (options.client ?? client).get({
1786
+ security: [{ scheme: "bearer", type: "http" }],
1787
+ url: "/applications/current",
1788
+ ...options
1789
+ });
1731
1790
  var patchWorkspaceMembershipsByWorkspaceIdByUserIdProfile = (options) => (options.client ?? client).patch({
1732
1791
  security: [{ scheme: "bearer", type: "http" }],
1733
1792
  url: "/workspace-memberships/{workspace_id}/{user_id}/profile",
@@ -1737,6 +1796,15 @@ var patchWorkspaceMembershipsByWorkspaceIdByUserIdProfile = (options) => (option
1737
1796
  ...options.headers
1738
1797
  }
1739
1798
  });
1799
+ var postInvitationsAcceptByToken = (options) => (options.client ?? client).post({
1800
+ security: [{ scheme: "bearer", type: "http" }],
1801
+ url: "/invitations/accept-by-token",
1802
+ ...options,
1803
+ headers: {
1804
+ "Content-Type": "application/vnd.api+json",
1805
+ ...options.headers
1806
+ }
1807
+ });
1740
1808
  var getWorkspaces = (options) => (options.client ?? client).get({
1741
1809
  security: [{ scheme: "bearer", type: "http" }],
1742
1810
  url: "/workspaces",
@@ -1775,6 +1843,11 @@ var getAgentsByIdStats = (options) => (options.client ?? client).get({
1775
1843
  url: "/agents/{id}/stats",
1776
1844
  ...options
1777
1845
  });
1846
+ var getSchedulingEventsByParticipant = (options) => (options.client ?? client).get({
1847
+ security: [{ scheme: "bearer", type: "http" }],
1848
+ url: "/scheduling/events/by_participant",
1849
+ ...options
1850
+ });
1778
1851
  var getEmailTrackingEventsById = (options) => (options.client ?? client).get({
1779
1852
  security: [{ scheme: "bearer", type: "http" }],
1780
1853
  url: "/email/tracking-events/{id}",
@@ -1828,15 +1901,6 @@ var patchCrmDealsById = (options) => (options.client ?? client).patch({
1828
1901
  ...options.headers
1829
1902
  }
1830
1903
  });
1831
- var postUsersAuthResetPasswordRequest = (options) => (options.client ?? client).post({
1832
- security: [{ scheme: "bearer", type: "http" }],
1833
- url: "/users/auth/reset-password/request",
1834
- ...options,
1835
- headers: {
1836
- "Content-Type": "application/vnd.api+json",
1837
- ...options.headers
1838
- }
1839
- });
1840
1904
  var getSupportTagsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1841
1905
  security: [{ scheme: "bearer", type: "http" }],
1842
1906
  url: "/support/tags/workspace/{workspace_id}",
@@ -1968,6 +2032,11 @@ var getAgentsByIdTrainingExamples = (options) => (options.client ?? client).get(
1968
2032
  url: "/agents/{id}/training-examples",
1969
2033
  ...options
1970
2034
  });
2035
+ var getInvitationsConsumeByToken = (options) => (options.client ?? client).get({
2036
+ security: [{ scheme: "bearer", type: "http" }],
2037
+ url: "/invitations/consume/{token}",
2038
+ ...options
2039
+ });
1971
2040
  var postEmailMarketingCampaignsByIdOptimizeSendTimes = (options) => (options.client ?? client).post({
1972
2041
  security: [{ scheme: "bearer", type: "http" }],
1973
2042
  url: "/email-marketing/campaigns/{id}/optimize-send-times",
@@ -2034,6 +2103,15 @@ var patchRetentionPoliciesById = (options) => (options.client ?? client).patch({
2034
2103
  ...options.headers
2035
2104
  }
2036
2105
  });
2106
+ var patchInvitationsByIdRevoke = (options) => (options.client ?? client).patch({
2107
+ security: [{ scheme: "bearer", type: "http" }],
2108
+ url: "/invitations/{id}/revoke",
2109
+ ...options,
2110
+ headers: {
2111
+ "Content-Type": "application/vnd.api+json",
2112
+ ...options.headers
2113
+ }
2114
+ });
2037
2115
  var getCatalogTaxonomiesApplicationByApplicationId = (options) => (options.client ?? client).get({
2038
2116
  security: [{ scheme: "bearer", type: "http" }],
2039
2117
  url: "/catalog/taxonomies/application/{application_id}",
@@ -2172,6 +2250,15 @@ var postAgentsByIdRestoreVersion = (options) => (options.client ?? client).post(
2172
2250
  ...options.headers
2173
2251
  }
2174
2252
  });
2253
+ var patchWalletAutoTopUp = (options) => (options.client ?? client).patch({
2254
+ security: [{ scheme: "bearer", type: "http" }],
2255
+ url: "/wallet/auto-top-up",
2256
+ ...options,
2257
+ headers: {
2258
+ "Content-Type": "application/vnd.api+json",
2259
+ ...options.headers
2260
+ }
2261
+ });
2175
2262
  var postTokens = (options) => (options.client ?? client).post({
2176
2263
  security: [{ scheme: "bearer", type: "http" }],
2177
2264
  url: "/tokens",
@@ -2330,6 +2417,15 @@ var getEmailMarketingUnsubscribersWorkspaceByWorkspaceId = (options) => (options
2330
2417
  url: "/email-marketing/unsubscribers/workspace/{workspace_id}",
2331
2418
  ...options
2332
2419
  });
2420
+ var patchInvitationsByIdResend = (options) => (options.client ?? client).patch({
2421
+ security: [{ scheme: "bearer", type: "http" }],
2422
+ url: "/invitations/{id}/resend",
2423
+ ...options,
2424
+ headers: {
2425
+ "Content-Type": "application/vnd.api+json",
2426
+ ...options.headers
2427
+ }
2428
+ });
2333
2429
  var getSearchSaved = (options) => (options.client ?? client).get({
2334
2430
  security: [{ scheme: "bearer", type: "http" }],
2335
2431
  url: "/search/saved",
@@ -2575,6 +2671,15 @@ var postSupportTickets = (options) => (options.client ?? client).post({
2575
2671
  ...options.headers
2576
2672
  }
2577
2673
  });
2674
+ var patchInvitationsByIdAccept = (options) => (options.client ?? client).patch({
2675
+ security: [{ scheme: "bearer", type: "http" }],
2676
+ url: "/invitations/{id}/accept",
2677
+ ...options,
2678
+ headers: {
2679
+ "Content-Type": "application/vnd.api+json",
2680
+ ...options.headers
2681
+ }
2682
+ });
2578
2683
  var getCreditPackagesById = (options) => (options.client ?? client).get({
2579
2684
  security: [{ scheme: "bearer", type: "http" }],
2580
2685
  url: "/credit-packages/{id}",
@@ -2768,6 +2873,20 @@ var getSchedulingBookingsById = (options) => (options.client ?? client).get({
2768
2873
  url: "/scheduling/bookings/{id}",
2769
2874
  ...options
2770
2875
  });
2876
+ var getTenantMemberships = (options) => (options.client ?? client).get({
2877
+ security: [{ scheme: "bearer", type: "http" }],
2878
+ url: "/tenant-memberships",
2879
+ ...options
2880
+ });
2881
+ var postTenantMemberships = (options) => (options.client ?? client).post({
2882
+ security: [{ scheme: "bearer", type: "http" }],
2883
+ url: "/tenant-memberships",
2884
+ ...options,
2885
+ headers: {
2886
+ "Content-Type": "application/vnd.api+json",
2887
+ ...options.headers
2888
+ }
2889
+ });
2771
2890
  var getWebhookDeliveriesById = (options) => (options.client ?? client).get({
2772
2891
  security: [{ scheme: "bearer", type: "http" }],
2773
2892
  url: "/webhook-deliveries/{id}",
@@ -3370,11 +3489,21 @@ var getEmailTrackingEventsWorkspaceByWorkspaceId = (options) => (options.client
3370
3489
  url: "/email/tracking-events/workspace/{workspace_id}",
3371
3490
  ...options
3372
3491
  });
3492
+ var getTenants = (options) => (options.client ?? client).get({
3493
+ security: [{ scheme: "bearer", type: "http" }],
3494
+ url: "/tenants",
3495
+ ...options
3496
+ });
3373
3497
  var getExtractionSchemaDiscoveriesById = (options) => (options.client ?? client).get({
3374
3498
  security: [{ scheme: "bearer", type: "http" }],
3375
3499
  url: "/extraction/schema-discoveries/{id}",
3376
3500
  ...options
3377
3501
  });
3502
+ var getWalletInvoices = (options) => (options.client ?? client).get({
3503
+ security: [{ scheme: "bearer", type: "http" }],
3504
+ url: "/wallet/invoices",
3505
+ ...options
3506
+ });
3378
3507
  var getFieldTemplates = (options) => (options.client ?? client).get({
3379
3508
  security: [{ scheme: "bearer", type: "http" }],
3380
3509
  url: "/field-templates",
@@ -3460,6 +3589,15 @@ var postDocumentsPresignedUpload = (options) => (options.client ?? client).post(
3460
3589
  ...options.headers
3461
3590
  }
3462
3591
  });
3592
+ var postPaymentMethodsTokenize = (options) => (options.client ?? client).post({
3593
+ security: [{ scheme: "bearer", type: "http" }],
3594
+ url: "/payment-methods/tokenize",
3595
+ ...options,
3596
+ headers: {
3597
+ "Content-Type": "application/vnd.api+json",
3598
+ ...options.headers
3599
+ }
3600
+ });
3463
3601
  var getCrmContactsWorkspaceByWorkspaceIdArchived = (options) => (options.client ?? client).get({
3464
3602
  security: [{ scheme: "bearer", type: "http" }],
3465
3603
  url: "/crm/contacts/workspace/{workspace_id}/archived",
@@ -3765,6 +3903,15 @@ var getApplicationsById = (options) => (options.client ?? client).get({
3765
3903
  url: "/applications/{id}",
3766
3904
  ...options
3767
3905
  });
3906
+ var patchApplicationsById = (options) => (options.client ?? client).patch({
3907
+ security: [{ scheme: "bearer", type: "http" }],
3908
+ url: "/applications/{id}",
3909
+ ...options,
3910
+ headers: {
3911
+ "Content-Type": "application/vnd.api+json",
3912
+ ...options.headers
3913
+ }
3914
+ });
3768
3915
  var patchEmailOutboundEmailsByIdSchedule = (options) => (options.client ?? client).patch({
3769
3916
  security: [{ scheme: "bearer", type: "http" }],
3770
3917
  url: "/email/outbound-emails/{id}/schedule",
@@ -3829,6 +3976,15 @@ var postSearchSavedByIdRun = (options) => (options.client ?? client).post({
3829
3976
  ...options.headers
3830
3977
  }
3831
3978
  });
3979
+ var patchWalletPlan = (options) => (options.client ?? client).patch({
3980
+ security: [{ scheme: "bearer", type: "http" }],
3981
+ url: "/wallet/plan",
3982
+ ...options,
3983
+ headers: {
3984
+ "Content-Type": "application/vnd.api+json",
3985
+ ...options.headers
3986
+ }
3987
+ });
3832
3988
  var deleteCatalogProductsById = (options) => (options.client ?? client).delete({
3833
3989
  security: [{ scheme: "bearer", type: "http" }],
3834
3990
  url: "/catalog/products/{id}",
@@ -4230,15 +4386,6 @@ var getExtractionDocumentsWorkspaceByWorkspaceId = (options) => (options.client
4230
4386
  url: "/extraction/documents/workspace/{workspace_id}",
4231
4387
  ...options
4232
4388
  });
4233
- var patchApplicationsByIdAllocateCredits = (options) => (options.client ?? client).patch({
4234
- security: [{ scheme: "bearer", type: "http" }],
4235
- url: "/applications/{id}/allocate-credits",
4236
- ...options,
4237
- headers: {
4238
- "Content-Type": "application/vnd.api+json",
4239
- ...options.headers
4240
- }
4241
- });
4242
4389
  var postUsersAuthMagicLinkRequest = (options) => (options.client ?? client).post({
4243
4390
  security: [{ scheme: "bearer", type: "http" }],
4244
4391
  url: "/users/auth/magic-link/request",
@@ -4337,6 +4484,25 @@ var getExtractionDocuments = (options) => (options.client ?? client).get({
4337
4484
  url: "/extraction/documents",
4338
4485
  ...options
4339
4486
  });
4487
+ var getDataStoreRecordsByNamespace = (options) => (options.client ?? client).get({
4488
+ security: [{ scheme: "bearer", type: "http" }],
4489
+ url: "/data_store/records/by_namespace",
4490
+ ...options
4491
+ });
4492
+ var deleteTenantMembershipsByTenantIdByUserId = (options) => (options.client ?? client).delete({
4493
+ security: [{ scheme: "bearer", type: "http" }],
4494
+ url: "/tenant-memberships/{tenant_id}/{user_id}",
4495
+ ...options
4496
+ });
4497
+ var patchTenantMembershipsByTenantIdByUserId = (options) => (options.client ?? client).patch({
4498
+ security: [{ scheme: "bearer", type: "http" }],
4499
+ url: "/tenant-memberships/{tenant_id}/{user_id}",
4500
+ ...options,
4501
+ headers: {
4502
+ "Content-Type": "application/vnd.api+json",
4503
+ ...options.headers
4504
+ }
4505
+ });
4340
4506
  var getCrmDealsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
4341
4507
  security: [{ scheme: "bearer", type: "http" }],
4342
4508
  url: "/crm/deals/workspace/{workspace_id}",
@@ -4439,6 +4605,11 @@ var postSupportTags = (options) => (options.client ?? client).post({
4439
4605
  ...options.headers
4440
4606
  }
4441
4607
  });
4608
+ var getWalletPlanPreview = (options) => (options.client ?? client).get({
4609
+ security: [{ scheme: "bearer", type: "http" }],
4610
+ url: "/wallet/plan/preview",
4611
+ ...options
4612
+ });
4442
4613
  var postAgentVersionsByIdSetSystemFields = (options) => (options.client ?? client).post({
4443
4614
  security: [{ scheme: "bearer", type: "http" }],
4444
4615
  url: "/agent-versions/{id}/set-system-fields",
@@ -4796,6 +4967,11 @@ var deleteWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.clie
4796
4967
  url: "/workspace-memberships/{workspace_id}/{user_id}",
4797
4968
  ...options
4798
4969
  });
4970
+ var getWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.client ?? client).get({
4971
+ security: [{ scheme: "bearer", type: "http" }],
4972
+ url: "/workspace-memberships/{workspace_id}/{user_id}",
4973
+ ...options
4974
+ });
4799
4975
  var patchWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.client ?? client).patch({
4800
4976
  security: [{ scheme: "bearer", type: "http" }],
4801
4977
  url: "/workspace-memberships/{workspace_id}/{user_id}",
@@ -4848,6 +5024,15 @@ var getUsers = (options) => (options.client ?? client).get({
4848
5024
  url: "/users",
4849
5025
  ...options
4850
5026
  });
5027
+ var postDataStoreRecordsUpsert = (options) => (options.client ?? client).post({
5028
+ security: [{ scheme: "bearer", type: "http" }],
5029
+ url: "/data_store/records/upsert",
5030
+ ...options,
5031
+ headers: {
5032
+ "Content-Type": "application/vnd.api+json",
5033
+ ...options.headers
5034
+ }
5035
+ });
4851
5036
  var deleteSupportTicketsById = (options) => (options.client ?? client).delete({
4852
5037
  security: [{ scheme: "bearer", type: "http" }],
4853
5038
  url: "/support/tickets/{id}",
@@ -7134,22 +7319,169 @@ function createBillingNamespace(rb) {
7134
7319
  /**
7135
7320
  * Retrieves the current workspace wallet, including the available credit
7136
7321
  * balance, usage totals, and any pending charges.
7322
+ */
7323
+ get: async (options) => {
7324
+ return rb.execute(getWallet, {}, options);
7325
+ },
7326
+ /**
7327
+ * Preview the cost and effective date of a plan change before committing.
7137
7328
  *
7138
- * @param options - Optional request options such as custom headers or an
7139
- * abort signal.
7140
- * @returns A promise resolving to a record containing wallet fields such as
7141
- * `balance`, `currency`, and usage metadata.
7329
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
7330
+ * @returns A projected `Wallet` representing the hypothetical post-change
7331
+ * state **not** the caller's current wallet. Do not cache or use this
7332
+ * as live balance data. Call `wallet.get()` for authoritative state.
7333
+ */
7334
+ previewPlanChange: async (planSlug, options) => {
7335
+ return rb.execute(
7336
+ getWalletPlanPreview,
7337
+ { query: { plan_slug: planSlug } },
7338
+ options
7339
+ );
7340
+ },
7341
+ /**
7342
+ * Change the workspace's subscription plan.
7343
+ *
7344
+ * Two call signatures:
7345
+ * - `changePlan(planSlug)` — fetches the wallet automatically (recommended)
7346
+ * - `changePlan(walletId, planSlug)` — use when you already have the wallet ID
7347
+ *
7348
+ * Upgrades charge a prorated amount immediately against the default payment
7349
+ * method. Downgrades are deferred to the end of the current billing period.
7350
+ * Use `previewPlanChange` first to show the user a cost estimate.
7142
7351
  *
7143
7352
  * @example
7144
7353
  * ```typescript
7145
- * const client = new GptClient({ apiKey: 'sk_app_...' });
7354
+ * // Simple form no wallet ID needed
7355
+ * await client.billing.wallet.changePlan("pro-monthly");
7146
7356
  *
7147
- * const wallet = await client.billing.wallet.get();
7148
- * console.log(`Available credits: ${wallet.balance}`);
7357
+ * // Explicit form when walletId is already known
7358
+ * await client.billing.wallet.changePlan(wallet.id, "pro-monthly");
7149
7359
  * ```
7150
7360
  */
7151
- get: async (options) => {
7152
- return rb.execute(getWallet, {}, options);
7361
+ changePlan: async (walletIdOrSlug, planSlugOrOptions, options) => {
7362
+ let walletId;
7363
+ let planSlug;
7364
+ let reqOptions;
7365
+ if (typeof planSlugOrOptions === "string") {
7366
+ walletId = walletIdOrSlug;
7367
+ planSlug = planSlugOrOptions;
7368
+ reqOptions = options;
7369
+ } else {
7370
+ const wallet = await rb.execute(
7371
+ getWallet,
7372
+ {},
7373
+ planSlugOrOptions
7374
+ );
7375
+ walletId = wallet.id;
7376
+ planSlug = walletIdOrSlug;
7377
+ reqOptions = planSlugOrOptions;
7378
+ }
7379
+ return rb.execute(
7380
+ patchWalletPlan,
7381
+ {
7382
+ body: {
7383
+ data: {
7384
+ id: walletId,
7385
+ type: "wallet",
7386
+ attributes: { plan_slug: planSlug }
7387
+ }
7388
+ }
7389
+ },
7390
+ reqOptions
7391
+ );
7392
+ },
7393
+ /**
7394
+ * Purchase a credit package to top up the workspace wallet immediately.
7395
+ *
7396
+ * Charges the specified (or default) payment method. Credits are added to
7397
+ * the `purchased` bucket and never expire.
7398
+ *
7399
+ * @param walletId - The wallet UUID from `wallet.get()`.
7400
+ * @param packageSlug - The slug of the credit package to purchase.
7401
+ * @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
7402
+ */
7403
+ buyCredits: async (walletId, packageSlug, paymentMethodId, options) => {
7404
+ const attributes = {
7405
+ package_slug: packageSlug
7406
+ };
7407
+ if (paymentMethodId !== void 0) {
7408
+ attributes.payment_method_id = paymentMethodId;
7409
+ }
7410
+ return rb.execute(
7411
+ patchWalletCredits,
7412
+ { body: { data: { id: walletId, type: "wallet", attributes } } },
7413
+ options
7414
+ );
7415
+ },
7416
+ /**
7417
+ * Update the workspace's auto top-up settings.
7418
+ *
7419
+ * When enabled, the platform automatically purchases the specified credit
7420
+ * package whenever the balance drops below `threshold`.
7421
+ *
7422
+ * @param walletId - The wallet UUID from `wallet.get()`.
7423
+ * @param opts.enabled - Enable or disable auto top-up.
7424
+ * @param opts.threshold - Credit balance floor that triggers a purchase.
7425
+ * @param opts.amount - Credits to purchase per top-up event.
7426
+ * @param opts.packageId - Credit package UUID to auto-purchase.
7427
+ */
7428
+ updateAutoTopUp: async (walletId, opts, options) => {
7429
+ const attributes = { enabled: opts.enabled };
7430
+ if (opts.threshold !== void 0) attributes.threshold = opts.threshold;
7431
+ if (opts.amount !== void 0) attributes.amount = opts.amount;
7432
+ if (opts.packageId !== void 0)
7433
+ attributes.package_id = opts.packageId;
7434
+ return rb.execute(
7435
+ patchWalletAutoTopUp,
7436
+ { body: { data: { id: walletId, type: "wallet", attributes } } },
7437
+ options
7438
+ );
7439
+ },
7440
+ /**
7441
+ * Sub-namespace for invoice operations.
7442
+ *
7443
+ * Invoices are generated per billing period and carry a `pdf_url` for
7444
+ * receipt download. Use `invoices.list()` for the transaction history page.
7445
+ */
7446
+ invoices: {
7447
+ /**
7448
+ * Returns a single page of invoices for the current workspace.
7449
+ *
7450
+ * Each invoice includes `pdf_url` for receipt download.
7451
+ *
7452
+ * @example
7453
+ * ```typescript
7454
+ * const invoices = await client.billing.wallet.invoices.list();
7455
+ * const paidInvoices = invoices.filter(inv => inv.attributes?.status === "paid");
7456
+ * ```
7457
+ */
7458
+ list: async (options) => {
7459
+ return rb.execute(
7460
+ getWalletInvoices,
7461
+ buildPageQuery(options?.page, options?.pageSize),
7462
+ options
7463
+ );
7464
+ },
7465
+ /**
7466
+ * Fetches all invoices by automatically paginating through every page.
7467
+ *
7468
+ * @example
7469
+ * ```typescript
7470
+ * const all = await client.billing.wallet.invoices.listAll();
7471
+ * const downloadUrl = all[0].attributes?.pdf_url;
7472
+ * ```
7473
+ */
7474
+ listAll: async (options) => {
7475
+ return paginateToArray(
7476
+ rb.createPaginatedFetcher(
7477
+ getWalletInvoices,
7478
+ (page, pageSize) => ({
7479
+ query: { page: { number: page, size: pageSize } }
7480
+ }),
7481
+ options
7482
+ )
7483
+ );
7484
+ }
7153
7485
  }
7154
7486
  },
7155
7487
  /**
@@ -7524,8 +7856,12 @@ function createBillingNamespace(rb) {
7524
7856
  * const client = new GptClient({ apiKey: 'sk_app_...' });
7525
7857
  *
7526
7858
  * const method = await client.billing.paymentMethods.create({
7527
- * token: 'tok_visa_4242',
7528
- * billing_name: 'Acme Corp',
7859
+ * provider_token: 'tok_visa_4242',
7860
+ * type: 'card',
7861
+ * last4: '4242',
7862
+ * exp_month: 12,
7863
+ * exp_year: 2027,
7864
+ * brand: 'Visa',
7529
7865
  * });
7530
7866
  * console.log(`Added card ending in ${method.last4}`);
7531
7867
  * ```
@@ -7537,6 +7873,34 @@ function createBillingNamespace(rb) {
7537
7873
  options
7538
7874
  );
7539
7875
  },
7876
+ /**
7877
+ * Tokenizes a raw card server-side and saves the resulting payment method.
7878
+ *
7879
+ * @remarks **SERVER-SIDE ONLY — PCI-DSS.**
7880
+ * This method transmits raw card numbers (`card_number`, `cvc`) over the
7881
+ * network. It **must only be called from a trusted server context** (Node.js,
7882
+ * server-side rendering). Calling this method from browser/client-side code
7883
+ * (React, Vue, browser fetch) is a **PCI-DSS violation** — raw card numbers
7884
+ * must never pass through browser memory or JavaScript bundles.
7885
+ *
7886
+ * For browser flows, use the payment provider's hosted fields iframe to tokenize
7887
+ * on the client side, then call `paymentMethods.create({ provider_token })` instead.
7888
+ *
7889
+ * The platform forwards `cardDetails` to the payment gateway over TLS and stores
7890
+ * only the resulting token — raw card data is never persisted.
7891
+ *
7892
+ * @param cardDetails - Raw PCI-sensitive card fields. All fields must be treated
7893
+ * as sensitive: do not log, serialize, or pass through error reporters.
7894
+ */
7895
+ tokenize: async (cardDetails, options) => {
7896
+ return rb.execute(
7897
+ postPaymentMethodsTokenize,
7898
+ {
7899
+ body: { data: { type: "payment_method", attributes: cardDetails } }
7900
+ },
7901
+ options
7902
+ );
7903
+ },
7540
7904
  /**
7541
7905
  * Updates the mutable attributes of an existing payment method, such as
7542
7906
  * the billing name or expiry date override.
@@ -15960,8 +16324,12 @@ function createIdentityNamespace(rb, baseUrl) {
15960
16324
  );
15961
16325
  },
15962
16326
  /** Resend confirmation email to an unconfirmed user */
15963
- resendConfirmation: async (options) => {
15964
- return rb.execute(postUsersAuthResendConfirmation, {}, options);
16327
+ resendConfirmation: async (email, options) => {
16328
+ return rb.execute(
16329
+ postUsersAuthResendConfirmation,
16330
+ { body: { data: { type: "user", attributes: { email } } } },
16331
+ options
16332
+ );
15965
16333
  },
15966
16334
  /** Confirm an email address using the token from the confirmation email */
15967
16335
  confirmEmail: async (email, confirmationToken, options) => {
@@ -16002,7 +16370,7 @@ function createIdentityNamespace(rb, baseUrl) {
16002
16370
  requestPasswordReset: async (email, options) => {
16003
16371
  RequestPasswordResetSchema.parse({ email });
16004
16372
  return rb.execute(
16005
- postUsersAuthResetPasswordRequest,
16373
+ patchUsersAuthResetPassword,
16006
16374
  {
16007
16375
  body: {
16008
16376
  data: { type: "user", attributes: { email } }
@@ -16880,7 +17248,7 @@ function createPlatformNamespace(rb) {
16880
17248
  */
16881
17249
  update: async (id, attributes, options) => {
16882
17250
  return rb.execute(
16883
- patchApplicationsByIdAllocateCredits,
17251
+ patchApplicationsById,
16884
17252
  {
16885
17253
  path: { id },
16886
17254
  body: { data: { id, type: "application", attributes } }
@@ -16927,7 +17295,7 @@ function createPlatformNamespace(rb) {
16927
17295
  * ```
16928
17296
  */
16929
17297
  readCurrent: async (options) => {
16930
- return rb.execute(postApplications, {}, options);
17298
+ return rb.execute(getApplicationsCurrent, {}, options);
16931
17299
  }
16932
17300
  },
16933
17301
  /**
@@ -16939,45 +17307,65 @@ function createPlatformNamespace(rb) {
16939
17307
  */
16940
17308
  tenants: {
16941
17309
  /**
16942
- * List document statistics for tenants (paginated).
17310
+ * List all tenants (paginated).
16943
17311
  *
16944
- * Returns per-tenant document usage metrics, useful for billing
16945
- * dashboards and usage monitoring at the ISV level.
17312
+ * Returns tenants accessible to the current actor (application-scoped).
16946
17313
  *
16947
17314
  * @param options - Optional page number, page size, and request options.
16948
- * @returns A page of tenant document stat records (typed as `Tenant[]`).
16949
- *
16950
- * @example
16951
- * ```typescript
16952
- * const client = new GptClient({ apiKey: 'sk_app_...' });
16953
- * const stats = await client.platform.tenants.listDocumentStats();
17315
+ * @returns A page of `Tenant` records.
17316
+ */
17317
+ list: async (options) => {
17318
+ return rb.execute(
17319
+ getTenants,
17320
+ buildPageQuery(options?.page, options?.pageSize),
17321
+ options
17322
+ );
17323
+ },
17324
+ /**
17325
+ * List document statistics for tenants (paginated).
17326
+ *
17327
+ * Returns per-tenant document usage metrics, useful for billing
17328
+ * dashboards and usage monitoring at the ISV level.
17329
+ *
17330
+ * @param options - Optional page number, page size, and request options.
17331
+ * @returns A page of tenant document stat records (typed as `Tenant[]`).
17332
+ *
17333
+ * @example
17334
+ * ```typescript
17335
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
17336
+ * const stats = await client.platform.tenants.listDocumentStats();
16954
17337
  * stats.forEach(s => console.log(s.attributes?.document_count));
16955
17338
  * ```
16956
17339
  */
16957
- listDocumentStats: async (options) => {
17340
+ listDocumentStats: async (tenantId, options) => {
16958
17341
  return rb.execute(
16959
17342
  getTenantsByTenantIdDocumentStats,
16960
- buildPageQuery(options?.page, options?.pageSize),
17343
+ {
17344
+ path: { tenant_id: tenantId },
17345
+ ...buildPageQuery(options?.page, options?.pageSize)
17346
+ },
16961
17347
  options
16962
17348
  );
16963
17349
  },
16964
17350
  /**
16965
17351
  * List all document statistics for tenants, auto-paginating.
16966
17352
  *
17353
+ * @param tenantId - The UUID of the tenant.
16967
17354
  * @param options - Optional request options.
16968
17355
  * @returns All tenant document stat records as a flat array.
16969
17356
  *
16970
17357
  * @example
16971
17358
  * ```typescript
16972
17359
  * const client = new GptClient({ apiKey: 'sk_app_...' });
16973
- * const allStats = await client.platform.tenants.listAllDocumentStats();
17360
+ * const allStats = await client.platform.tenants.listAllDocumentStats('tenant_abc123');
16974
17361
  * ```
16975
17362
  */
16976
- listAllDocumentStats: async (options) => {
17363
+ listAllDocumentStats: async (tenantId, options) => {
16977
17364
  return paginateToArray(
16978
17365
  rb.createPaginatedFetcher(
16979
17366
  getTenantsByTenantIdDocumentStats,
16980
17367
  (page, pageSize) => ({
17368
+ path: { tenant_id: tenantId },
16981
17369
  query: { page: { number: page, size: pageSize } }
16982
17370
  }),
16983
17371
  options
@@ -17002,10 +17390,15 @@ function createPlatformNamespace(rb) {
17002
17390
  * console.log(tenant.attributes?.credit_balance);
17003
17391
  * ```
17004
17392
  */
17005
- credit: async (id, options) => {
17393
+ credit: async (id, amount, description, options) => {
17394
+ const attributes = { amount };
17395
+ if (description !== void 0) attributes.description = description;
17006
17396
  return rb.execute(
17007
17397
  postTenantsByIdCredit,
17008
- { path: { id }, body: {} },
17398
+ {
17399
+ path: { id },
17400
+ body: { data: { type: "tenant", attributes } }
17401
+ },
17009
17402
  options
17010
17403
  );
17011
17404
  },
@@ -17113,24 +17506,6 @@ function createPlatformNamespace(rb) {
17113
17506
  );
17114
17507
  },
17115
17508
  /**
17116
- * Add a payment method to a tenant via raw details (server-to-server proxy).
17117
- *
17118
- * Proxies payment method registration to the underlying payment provider
17119
- * on behalf of the tenant. Used in server-side flows where the payment
17120
- * form is embedded by the ISV rather than the platform.
17121
- *
17122
- * @param options - Optional request options.
17123
- * @returns The updated `Tenant` with new payment method reference.
17124
- *
17125
- * @example
17126
- * ```typescript
17127
- * const client = new GptClient({ apiKey: 'sk_app_...' });
17128
- * const tenant = await client.platform.tenants.addPaymentMethod();
17129
- * ```
17130
- */
17131
- addPaymentMethod: async (options) => {
17132
- return rb.execute(postTenantsIsv, {}, options);
17133
- },
17134
17509
  /**
17135
17510
  * Retrieve a single tenant by its ID.
17136
17511
  *
@@ -17147,6 +17522,33 @@ function createPlatformNamespace(rb) {
17147
17522
  */
17148
17523
  get: async (id, options) => {
17149
17524
  return rb.execute(getTenantsById, { path: { id } }, options);
17525
+ },
17526
+ /**
17527
+ * Transfer ownership of a tenant to another admin member.
17528
+ *
17529
+ * The new owner must already be a tenant admin. The previous owner
17530
+ * retains their admin role. Cannot be used on personal tenants.
17531
+ *
17532
+ * @param tenantId - The UUID of the tenant to transfer.
17533
+ * @param newOwnerId - The UUID of the user to become the new owner.
17534
+ * @param options - Optional request options.
17535
+ * @returns The updated `Tenant`.
17536
+ */
17537
+ transferOwnership: async (tenantId, newOwnerId, options) => {
17538
+ return rb.execute(
17539
+ patchTenantsById,
17540
+ {
17541
+ path: { id: tenantId },
17542
+ body: {
17543
+ data: {
17544
+ id: tenantId,
17545
+ type: "tenant",
17546
+ attributes: { new_owner_id: newOwnerId }
17547
+ }
17548
+ }
17549
+ },
17550
+ options
17551
+ );
17150
17552
  }
17151
17553
  },
17152
17554
  /**
@@ -17154,22 +17556,63 @@ function createPlatformNamespace(rb) {
17154
17556
  */
17155
17557
  invitations: {
17156
17558
  /**
17157
- * Delete (revoke) the current user's pending invitation.
17559
+ * Accept a pending invitation (authenticated user flow).
17158
17560
  *
17159
- * Removes the invitation so it can no longer be accepted or declined.
17160
- * Typically used by the inviting party to cancel an outstanding invite.
17561
+ * Accepts an invitation the current user received, creating
17562
+ * the appropriate membership records.
17161
17563
  *
17564
+ * @param id - The UUID of the invitation to accept.
17162
17565
  * @param options - Optional request options.
17163
- * @returns `true` on successful deletion.
17566
+ * @returns The updated `Invitation`.
17567
+ */
17568
+ accept: async (id, options) => {
17569
+ return rb.execute(
17570
+ patchInvitationsByIdAccept,
17571
+ {
17572
+ path: { id },
17573
+ body: { data: { id, type: "invitation", attributes: {} } }
17574
+ },
17575
+ options
17576
+ );
17577
+ },
17578
+ /**
17579
+ * Decline a pending invitation.
17164
17580
  *
17165
- * @example
17166
- * ```typescript
17167
- * const client = new GptClient({ apiKey: 'sk_app_...' });
17168
- * await client.platform.invitations.delete();
17169
- * ```
17581
+ * The invitation status is set to `:declined` and no membership is created.
17582
+ *
17583
+ * @param id - The UUID of the invitation to decline.
17584
+ * @param options - Optional request options.
17585
+ * @returns The updated `Invitation`.
17170
17586
  */
17171
- delete: async (options) => {
17172
- return rb.executeDelete(getInvitationsMe, { path: {} }, options);
17587
+ decline: async (id, options) => {
17588
+ return rb.execute(
17589
+ patchInvitationsByIdDecline,
17590
+ {
17591
+ path: { id },
17592
+ body: { data: { id, type: "invitation", attributes: {} } }
17593
+ },
17594
+ options
17595
+ );
17596
+ },
17597
+ /**
17598
+ * Revoke a pending invitation (inviter flow).
17599
+ *
17600
+ * Cancels the invitation so it can no longer be accepted or declined.
17601
+ * Callable by the original inviter or a tenant admin.
17602
+ *
17603
+ * @param id - The UUID of the invitation to revoke.
17604
+ * @param options - Optional request options.
17605
+ * @returns The updated `Invitation`.
17606
+ */
17607
+ revoke: async (id, options) => {
17608
+ return rb.execute(
17609
+ patchInvitationsByIdRevoke,
17610
+ {
17611
+ path: { id },
17612
+ body: { data: { id, type: "invitation", attributes: {} } }
17613
+ },
17614
+ options
17615
+ );
17173
17616
  },
17174
17617
  /**
17175
17618
  * List pending invitations for the currently authenticated user (paginated).
@@ -17248,31 +17691,119 @@ function createPlatformNamespace(rb) {
17248
17691
  );
17249
17692
  },
17250
17693
  /**
17251
- * Update an invitation (e.g., decline it).
17694
+ /**
17695
+ * Resend an invitation email with a refreshed token and new 7-day expiry.
17252
17696
  *
17253
- * Used by the invited user to respond to an invitation. Pass
17254
- * `{ status: "declined" }` in attributes to decline. Accepting
17255
- * an invitation is handled separately through the acceptance flow.
17697
+ * Only pending invitations can be resent. Generates a new token (invalidating
17698
+ * the old one) and re-sends the invitation email. Callable by the original
17699
+ * inviter or the tenant owner.
17256
17700
  *
17257
- * @param id - The UUID of the invitation to update.
17258
- * @param attributes - Attribute map, typically `{ status: "declined" }`.
17701
+ * @param id - The UUID of the invitation to resend.
17259
17702
  * @param options - Optional request options.
17260
17703
  * @returns The updated `Invitation`.
17261
17704
  *
17262
17705
  * @example
17263
17706
  * ```typescript
17264
17707
  * const client = new GptClient({ apiKey: 'sk_app_...' });
17265
- * const invite = await client.platform.invitations.update('inv_abc123', {
17266
- * status: 'declined',
17267
- * });
17708
+ * await client.platform.invitations.resend('inv_abc123');
17268
17709
  * ```
17269
17710
  */
17270
- update: async (id, attributes, options) => {
17711
+ resend: async (id, applicationId, options) => {
17271
17712
  return rb.execute(
17272
- patchInvitationsByIdDecline,
17713
+ patchInvitationsByIdResend,
17273
17714
  {
17274
17715
  path: { id },
17275
- body: { data: { id, type: "invitation", attributes } }
17716
+ body: {
17717
+ data: {
17718
+ id,
17719
+ type: "invitation",
17720
+ ...applicationId ? { attributes: { application_id: applicationId } } : {}
17721
+ }
17722
+ }
17723
+ },
17724
+ options
17725
+ );
17726
+ },
17727
+ /**
17728
+ * Look up a pending invitation by its raw token.
17729
+ *
17730
+ * Call this on the `/invite/:token` landing page to display invitation
17731
+ * details before the user accepts. Returns the full invitation record
17732
+ * including `email` (to pre-fill the register form), `role`, `scope_type`,
17733
+ * `scope_id`, `tenant_id`, `expires_at`, and the `inviter` relationship
17734
+ * (pass `include=inviter` via request options to embed inviter email).
17735
+ *
17736
+ * Returns `null` if the token is invalid, already used, or expired —
17737
+ * there is no partial response for consumed tokens.
17738
+ *
17739
+ * **Note:** The response does not include the workspace or tenant name.
17740
+ * Fetch it separately using `platform.workspaces.get(scope_id)` or
17741
+ * `platform.tenants.get(scope_id)` based on `scope_type`.
17742
+ *
17743
+ * @param token - The raw invitation token from the email link (`/invite/:token`).
17744
+ * @param options - Optional request options (e.g., `{ headers: { include: 'inviter' } }`).
17745
+ * @returns The pending `Invitation` record, or `null` if not found.
17746
+ *
17747
+ * @example
17748
+ * ```typescript
17749
+ * // On your /invite/:token page
17750
+ * const invite = await client.platform.invitations.consumeByToken(token);
17751
+ * if (!invite) {
17752
+ * // Token expired or already used
17753
+ * return redirect('/invite/expired');
17754
+ * }
17755
+ * // Pre-fill form
17756
+ * setEmail(invite.attributes?.email);
17757
+ * setRole(invite.attributes?.role);
17758
+ * ```
17759
+ */
17760
+ consumeByToken: async (token, options) => {
17761
+ try {
17762
+ return await rb.execute(
17763
+ getInvitationsConsumeByToken,
17764
+ { path: { token } },
17765
+ options
17766
+ );
17767
+ } catch {
17768
+ return null;
17769
+ }
17770
+ },
17771
+ /**
17772
+ * Accept a pending invitation using only the raw token.
17773
+ *
17774
+ * Call this after the user is authenticated (either via `registerViaInvitation`
17775
+ * or an existing account login). The platform validates the token, creates or
17776
+ * upgrades the user's `TenantMembership` and `WorkspaceMembership`, and returns
17777
+ * the accepted invitation.
17778
+ *
17779
+ * For new users: `registerViaInvitation` accepts the invitation atomically —
17780
+ * do NOT call `acceptByToken` again after registration. Only call this for
17781
+ * existing users accepting a new invite after sign-in.
17782
+ *
17783
+ * @param token - The raw invitation token from the email link.
17784
+ * @param options - Optional request options.
17785
+ * @returns The accepted `Invitation` with `scope_id` and `tenant_id` populated.
17786
+ *
17787
+ * @example
17788
+ * ```typescript
17789
+ * // Existing user accepting an invite after login
17790
+ * const accepted = await client.platform.invitations.acceptByToken(token);
17791
+ * const workspaceId = accepted.attributes?.scope_type === 'workspace'
17792
+ * ? accepted.attributes?.scope_id
17793
+ * : null;
17794
+ * const tenantId = accepted.attributes?.tenant_id;
17795
+ * ```
17796
+ */
17797
+ acceptByToken: async (token, options) => {
17798
+ return rb.execute(
17799
+ postInvitationsAcceptByToken,
17800
+ {
17801
+ body: {
17802
+ data: {
17803
+ type: "invitation",
17804
+ attributes: { token }
17805
+ }
17806
+ }
17276
17807
  },
17277
17808
  options
17278
17809
  );
@@ -17315,6 +17846,42 @@ function createPlatformNamespace(rb) {
17315
17846
  options
17316
17847
  );
17317
17848
  },
17849
+ /**
17850
+ * List workspace members with user profile data (name, email, avatar) included.
17851
+ *
17852
+ * Equivalent to `list()` with `?include=user,user.profile` appended. Each
17853
+ * membership in the response will have `relationships.user` and nested
17854
+ * `user.relationships.profile` populated in the JSON:API `included` array.
17855
+ *
17856
+ * The `RequestBuilder` flattens included relationships automatically, so
17857
+ * each membership object will have `user` and `user.profile` accessible.
17858
+ *
17859
+ * @param workspaceId - The UUID of the workspace to list members for.
17860
+ * @param options - Optional page number, page size, and request options.
17861
+ * @returns A page of `WorkspaceMembership` records with embedded user + profile.
17862
+ *
17863
+ * @example
17864
+ * ```typescript
17865
+ * const members = await client.platform.workspaceMembers.listWithProfiles('ws_abc123');
17866
+ * members.forEach(m => {
17867
+ * console.log(m.attributes?.user_id, m.attributes?.role);
17868
+ * // Profile fields come from included relationships
17869
+ * });
17870
+ * ```
17871
+ */
17872
+ listWithProfiles: async (workspaceId, options) => {
17873
+ return rb.execute(
17874
+ getWorkspaceMemberships,
17875
+ {
17876
+ query: {
17877
+ filter: { workspace_id: workspaceId },
17878
+ include: "user,user.profile",
17879
+ ...buildPageQuery(options?.page, options?.pageSize)?.query
17880
+ }
17881
+ },
17882
+ options
17883
+ );
17884
+ },
17318
17885
  /**
17319
17886
  * Retrieve the membership record for a specific user within a workspace.
17320
17887
  *
@@ -17334,8 +17901,9 @@ function createPlatformNamespace(rb) {
17334
17901
  * ```
17335
17902
  */
17336
17903
  get: async (workspaceId, memberId, options) => {
17337
- return rb.rawGet(
17338
- `/workspace-memberships/${workspaceId}/${memberId}`,
17904
+ return rb.execute(
17905
+ getWorkspaceMembershipsByWorkspaceIdByUserId,
17906
+ { path: { workspace_id: workspaceId, user_id: memberId } },
17339
17907
  options
17340
17908
  );
17341
17909
  },
@@ -17566,6 +18134,95 @@ function createPlatformNamespace(rb) {
17566
18134
  options
17567
18135
  );
17568
18136
  }
18137
+ },
18138
+ /**
18139
+ * Tenant Members — manage tenant-level membership (org roles).
18140
+ *
18141
+ * TenantMembership records represent a user's role within a tenant.
18142
+ * Roles are either `"admin"` or `"member"`.
18143
+ */
18144
+ tenantMembers: {
18145
+ /**
18146
+ * List members of a tenant (paginated).
18147
+ *
18148
+ * @param tenantId - The UUID of the tenant.
18149
+ * @param options - Optional page number, page size, and request options.
18150
+ * @returns A page of `TenantMembership` records.
18151
+ */
18152
+ list: async (tenantId, options) => {
18153
+ return rb.execute(
18154
+ getTenantMemberships,
18155
+ {
18156
+ query: {
18157
+ filter: { tenant_id: tenantId },
18158
+ ...buildPageQuery(options?.page, options?.pageSize).query
18159
+ }
18160
+ },
18161
+ options
18162
+ );
18163
+ },
18164
+ /**
18165
+ * Add a user to a tenant with the given role.
18166
+ *
18167
+ * @param tenantId - The UUID of the tenant.
18168
+ * @param userId - The UUID of the user to add.
18169
+ * @param role - The role to assign (`"admin"` or `"member"`).
18170
+ * @param options - Optional request options.
18171
+ * @returns The created `TenantMembership`.
18172
+ */
18173
+ create: async (tenantId, userId, role, options) => {
18174
+ return rb.execute(
18175
+ postTenantMemberships,
18176
+ {
18177
+ body: {
18178
+ data: {
18179
+ type: "tenant_membership",
18180
+ attributes: { tenant_id: tenantId, user_id: userId, role }
18181
+ }
18182
+ }
18183
+ },
18184
+ options
18185
+ );
18186
+ },
18187
+ /**
18188
+ * Change a member's role within a tenant.
18189
+ *
18190
+ * @param tenantId - The UUID of the tenant.
18191
+ * @param userId - The UUID of the user.
18192
+ * @param role - The new role (`"admin"` or `"member"`).
18193
+ * @param options - Optional request options.
18194
+ * @returns The updated `TenantMembership`.
18195
+ */
18196
+ updateRole: async (tenantId, userId, role, options) => {
18197
+ return rb.execute(
18198
+ patchTenantMembershipsByTenantIdByUserId,
18199
+ {
18200
+ path: { tenant_id: tenantId, user_id: userId },
18201
+ body: {
18202
+ data: {
18203
+ type: "tenant_membership",
18204
+ attributes: { role }
18205
+ }
18206
+ }
18207
+ },
18208
+ options
18209
+ );
18210
+ },
18211
+ /**
18212
+ * Remove a user from a tenant.
18213
+ *
18214
+ * @param tenantId - The UUID of the tenant.
18215
+ * @param userId - The UUID of the user to remove.
18216
+ * @param options - Optional request options.
18217
+ * @returns `true` on success.
18218
+ */
18219
+ remove: async (tenantId, userId, options) => {
18220
+ return rb.executeDelete(
18221
+ deleteTenantMembershipsByTenantIdByUserId,
18222
+ { path: { tenant_id: tenantId, user_id: userId } },
18223
+ options
18224
+ );
18225
+ }
17569
18226
  }
17570
18227
  };
17571
18228
  }
@@ -17854,6 +18511,42 @@ function createSchedulingNamespace(rb) {
17854
18511
  },
17855
18512
  options
17856
18513
  );
18514
+ },
18515
+ /**
18516
+ * List events that include a specific participant by email.
18517
+ *
18518
+ * Use this to retrieve all sessions for a client (e.g., all appointments
18519
+ * for a given patient). Filters events in the workspace where a Participant
18520
+ * record with the given email exists.
18521
+ *
18522
+ * @param email - The participant's email address to filter by.
18523
+ * @param workspaceId - The workspace to scope the query to.
18524
+ * @param options - Optional page number, page size, and request options.
18525
+ * @returns A flat array of `SchedulingEvent` records.
18526
+ *
18527
+ * @example
18528
+ * ```typescript
18529
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
18530
+ * const sessions = await client.scheduling.events.listByParticipant(
18531
+ * 'patient@example.com',
18532
+ * workspaceId,
18533
+ * );
18534
+ * sessions.forEach(s => console.log(s.attributes?.start_time, s.attributes?.status));
18535
+ * ```
18536
+ */
18537
+ listByParticipant: async (email, workspaceId, options) => {
18538
+ return rb.execute(
18539
+ getSchedulingEventsByParticipant,
18540
+ {
18541
+ query: {
18542
+ email,
18543
+ workspace_id: workspaceId,
18544
+ ...options?.pageSize && { "page[size]": options.pageSize },
18545
+ ...options?.page && { "page[number]": options.page }
18546
+ }
18547
+ },
18548
+ options
18549
+ );
17857
18550
  }
17858
18551
  },
17859
18552
  /**
@@ -18414,6 +19107,91 @@ function createSchedulingNamespace(rb) {
18414
19107
  options
18415
19108
  );
18416
19109
  }
19110
+ },
19111
+ /**
19112
+ * Session Notes — clinical notes per appointment, stored in DataStore.
19113
+ *
19114
+ * Notes are keyed by `{eventId}:{noteType}` under the `sessions` namespace.
19115
+ * Each event supports up to 4 note types: `adime`, `soap`, `goals`, `email`.
19116
+ *
19117
+ * Notes are versioned automatically by DataStore — each `upsert` increments
19118
+ * the version counter. Full version history retrieval requires a future
19119
+ * DataStore enhancement.
19120
+ *
19121
+ * @example
19122
+ * ```typescript
19123
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
19124
+ *
19125
+ * // Read an ADIME note
19126
+ * const note = await client.scheduling.sessionNotes.get(sessionId, 'adime');
19127
+ * console.log(note?.attributes?.value?.content);
19128
+ *
19129
+ * // Write/update a SOAP note
19130
+ * await client.scheduling.sessionNotes.upsert(sessionId, 'soap', {
19131
+ * content: 'S: Patient reports...',
19132
+ * reviewed_by_user_id: currentUserId,
19133
+ * reviewed_at: new Date().toISOString(),
19134
+ * });
19135
+ * ```
19136
+ */
19137
+ sessionNotes: {
19138
+ /**
19139
+ * Get the current version of a session note.
19140
+ *
19141
+ * Returns `null` if no note of this type exists for the event yet.
19142
+ *
19143
+ * @param eventId - The UUID of the scheduling event (session).
19144
+ * @param noteType - The note type: `"adime"`, `"soap"`, `"goals"`, or `"email"`.
19145
+ * @param workspaceId - The workspace UUID. Required for application-scoped API keys.
19146
+ * @param options - Optional request options.
19147
+ * @returns The `DataStoreRecord`, or `null` if not found.
19148
+ */
19149
+ get: async (eventId, noteType, workspaceId, options) => {
19150
+ const results = await rb.execute(
19151
+ getDataStoreRecordsByNamespace,
19152
+ {
19153
+ query: {
19154
+ workspace_id: workspaceId,
19155
+ namespace: "sessions",
19156
+ "filter[record_key]": `${eventId}:${noteType}`
19157
+ }
19158
+ },
19159
+ options
19160
+ );
19161
+ return results.length > 0 ? results[0] ?? null : null;
19162
+ },
19163
+ /**
19164
+ * Create or update a session note (auto-versions on update).
19165
+ *
19166
+ * If the note does not exist, it is created. If it exists, its value
19167
+ * is replaced and the version counter is incremented.
19168
+ *
19169
+ * @param eventId - The UUID of the scheduling event (session).
19170
+ * @param noteType - The note type: `"adime"`, `"soap"`, `"goals"`, or `"email"`.
19171
+ * @param workspaceId - The workspace UUID. Required for application-scoped API keys.
19172
+ * @param value - The note content and optional metadata.
19173
+ * @param options - Optional request options.
19174
+ * @returns The upserted `DataStoreRecord`.
19175
+ */
19176
+ upsert: async (eventId, noteType, workspaceId, value, options) => {
19177
+ return rb.execute(
19178
+ postDataStoreRecordsUpsert,
19179
+ {
19180
+ body: {
19181
+ data: {
19182
+ type: "data_store_record",
19183
+ attributes: {
19184
+ namespace: "sessions",
19185
+ record_key: `${eventId}:${noteType}`,
19186
+ workspace_id: workspaceId,
19187
+ value
19188
+ }
19189
+ }
19190
+ }
19191
+ },
19192
+ options
19193
+ );
19194
+ }
18417
19195
  }
18418
19196
  };
18419
19197
  }
@@ -22283,6 +23061,7 @@ export {
22283
23061
  AuthenticationError,
22284
23062
  AuthorizationError,
22285
23063
  BrowserApiKeyError,
23064
+ CardDeclinedError,
22286
23065
  ConflictError,
22287
23066
  DEFAULT_API_VERSION,
22288
23067
  DEFAULT_RETRY_CONFIG,
@@ -22292,12 +23071,14 @@ export {
22292
23071
  LOG_LEVELS,
22293
23072
  NetworkError,
22294
23073
  NotFoundError,
23074
+ PaymentRequiredError,
22295
23075
  RateLimitError,
22296
23076
  RequestBuilder,
22297
23077
  RetryTimeoutError,
22298
23078
  SDK_VERSION,
22299
23079
  SdkEventEmitter,
22300
23080
  ServerError,
23081
+ SubscriptionConflictError,
22301
23082
  TimeoutError,
22302
23083
  ValidationError,
22303
23084
  WebhookSignatureError,