@gpt-platform/client 0.4.0 → 0.4.2

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.d.ts CHANGED
@@ -575,7 +575,7 @@ declare class BrowserApiKeyError extends Error {
575
575
  }
576
576
 
577
577
  /** SDK version — updated automatically by mix update.sdks */
578
- declare const SDK_VERSION = "0.4.0";
578
+ declare const SDK_VERSION = "0.4.2";
579
579
  /** Default API version sent in every request — updated automatically by mix update.sdks */
580
580
  declare const DEFAULT_API_VERSION = "2026-02-27";
581
581
 
@@ -1308,6 +1308,131 @@ type CrmRelationshipType = {
1308
1308
  };
1309
1309
  type: string;
1310
1310
  };
1311
+ /**
1312
+ * A "Resource object" representing a wallet
1313
+ */
1314
+ type Wallet = {
1315
+ /**
1316
+ * An attributes object for a wallet
1317
+ */
1318
+ attributes?: {
1319
+ /**
1320
+ * Field included by default.
1321
+ */
1322
+ accounts?: Array<{
1323
+ [key: string]: unknown;
1324
+ }> | null | unknown;
1325
+ /**
1326
+ * Field included by default.
1327
+ */
1328
+ addons?: Array<{
1329
+ [key: string]: unknown;
1330
+ }> | null | unknown;
1331
+ /**
1332
+ * Optional application context - wallets belong to tenants, not applications. Field included by default.
1333
+ */
1334
+ application_id?: string | null | unknown;
1335
+ /**
1336
+ * Amount in credits. Field included by default.
1337
+ */
1338
+ auto_top_up_amount?: number | null | unknown;
1339
+ /**
1340
+ * Field included by default.
1341
+ */
1342
+ auto_top_up_enabled: boolean;
1343
+ /**
1344
+ * Threshold in credits. Field included by default.
1345
+ */
1346
+ auto_top_up_threshold?: number | null | unknown;
1347
+ /**
1348
+ * Field included by default.
1349
+ */
1350
+ credits: number;
1351
+ /**
1352
+ * Field included by default.
1353
+ */
1354
+ credits_free?: number | null | unknown;
1355
+ /**
1356
+ * Field included by default.
1357
+ */
1358
+ credits_paid?: number | null | unknown;
1359
+ /**
1360
+ * Total promotional credits ever allocated to this tenant. Field included by default.
1361
+ */
1362
+ credits_promotional_allocated?: number | null | unknown;
1363
+ /**
1364
+ * Total purchased credits ever allocated to this tenant. Field included by default.
1365
+ */
1366
+ credits_purchased_allocated?: number | null | unknown;
1367
+ /**
1368
+ * Field included by default.
1369
+ */
1370
+ credits_subscription?: number | null | unknown;
1371
+ /**
1372
+ * Total subscription credits ever allocated to this tenant. Field included by default.
1373
+ */
1374
+ credits_subscription_allocated?: number | null | unknown;
1375
+ /**
1376
+ * Field included by default.
1377
+ */
1378
+ payment_methods?: Array<{
1379
+ [key: string]: unknown;
1380
+ }> | null | unknown;
1381
+ /**
1382
+ * Field included by default.
1383
+ */
1384
+ plan_id?: string | null | unknown;
1385
+ /**
1386
+ * Field included by default.
1387
+ */
1388
+ plan_slug?: string | null | unknown;
1389
+ /**
1390
+ * Field included by default.
1391
+ */
1392
+ storage_quota_bytes: number;
1393
+ /**
1394
+ * Field included by default.
1395
+ */
1396
+ storage_used_bytes: number;
1397
+ /**
1398
+ * Daily usage history entries. Field included by default.
1399
+ */
1400
+ usage_history?: Array<{
1401
+ [key: string]: unknown;
1402
+ }> | null | unknown;
1403
+ /**
1404
+ * Storage breakdown by workspace (Top 3 + Others). Field included by default.
1405
+ */
1406
+ workspace_storage?: Array<{
1407
+ [key: string]: unknown;
1408
+ }> | null | unknown;
1409
+ /**
1410
+ * Usage breakdown by workspace (Top 3 + Others). Field included by default.
1411
+ */
1412
+ workspace_usage?: Array<{
1413
+ [key: string]: unknown;
1414
+ }> | null | unknown;
1415
+ };
1416
+ id: string;
1417
+ /**
1418
+ * A relationships object for a wallet
1419
+ */
1420
+ relationships?: {
1421
+ plan?: {
1422
+ /**
1423
+ * An identifier for plan
1424
+ */
1425
+ data?: {
1426
+ id: string;
1427
+ meta?: {
1428
+ [key: string]: unknown;
1429
+ };
1430
+ type: string;
1431
+ } | null;
1432
+ };
1433
+ };
1434
+ type: string;
1435
+ };
1311
1436
  /**
1312
1437
  * A "Resource object" representing a email-marketing-sender-profile
1313
1438
  */
@@ -1811,6 +1936,12 @@ type EmailOutboundEmail = {
1811
1936
  * Field included by default.
1812
1937
  */
1813
1938
  ai_generated?: boolean | null | unknown;
1939
+ /**
1940
+ * Field included by default.
1941
+ */
1942
+ attachments?: Array<{
1943
+ [key: string]: unknown;
1944
+ }> | null | unknown;
1814
1945
  /**
1815
1946
  * Field included by default.
1816
1947
  */
@@ -3312,6 +3443,62 @@ type CrmCustomEntity = {
3312
3443
  };
3313
3444
  type: string;
3314
3445
  };
3446
+ /**
3447
+ * A "Resource object" representing a invoice
3448
+ */
3449
+ type Invoice = {
3450
+ /**
3451
+ * An attributes object for a invoice
3452
+ */
3453
+ attributes?: {
3454
+ /**
3455
+ * Field included by default.
3456
+ */
3457
+ amount_due?: number | null | unknown;
3458
+ /**
3459
+ * Field included by default.
3460
+ */
3461
+ amount_paid?: number | null | unknown;
3462
+ /**
3463
+ * Field included by default.
3464
+ */
3465
+ created_at?: unknown;
3466
+ /**
3467
+ * Field included by default.
3468
+ */
3469
+ currency?: string | null | unknown;
3470
+ /**
3471
+ * Field included by default.
3472
+ */
3473
+ due_date?: unknown;
3474
+ /**
3475
+ * Field included by default.
3476
+ */
3477
+ invoice_number?: string | null | unknown;
3478
+ /**
3479
+ * Field included by default.
3480
+ */
3481
+ line_items?: Array<{
3482
+ [key: string]: unknown;
3483
+ }> | null | unknown;
3484
+ /**
3485
+ * Field included by default.
3486
+ */
3487
+ pdf_url?: string | null | unknown;
3488
+ /**
3489
+ * Field included by default.
3490
+ */
3491
+ status?: "draft" | "open" | "paid" | "void" | unknown;
3492
+ };
3493
+ id: string;
3494
+ /**
3495
+ * A relationships object for a invoice
3496
+ */
3497
+ relationships?: {
3498
+ [key: string]: never;
3499
+ };
3500
+ type: string;
3501
+ };
3315
3502
  /**
3316
3503
  * A "Resource object" representing a transaction
3317
3504
  */
@@ -4901,19 +5088,27 @@ type ConsentRecord = {
4901
5088
  /**
4902
5089
  * Field included by default.
4903
5090
  */
4904
- purpose: "ai_document_processing" | "data_analytics" | "marketing_communications" | "third_party_sharing";
5091
+ purpose: "ai_document_processing" | "data_analytics" | "marketing_communications" | "third_party_sharing" | "session_recording";
4905
5092
  /**
4906
5093
  * Field included by default.
4907
5094
  */
4908
5095
  status: "granted" | "withdrawn";
5096
+ /**
5097
+ * Non-user subject identifier for consent (e.g., CRM contact UUID for HIPAA recording consent). Field included by default.
5098
+ */
5099
+ subject_id?: string | null | unknown;
4909
5100
  /**
4910
5101
  * Field included by default.
4911
5102
  */
4912
- user_id: string;
5103
+ user_id?: string | null | unknown;
4913
5104
  /**
4914
5105
  * Field included by default.
4915
5106
  */
4916
5107
  withdrawn_at?: unknown;
5108
+ /**
5109
+ * Workspace scope for subject-based consent records. Field included by default.
5110
+ */
5111
+ workspace_id?: string | null | unknown;
4917
5112
  };
4918
5113
  id: string;
4919
5114
  /**
@@ -6139,6 +6334,15 @@ type Workspace = {
6139
6334
  * Explicitly enabled AI features for this workspace. Field included by default.
6140
6335
  */
6141
6336
  enabled_capabilities?: Array<string> | null | unknown;
6337
+ /**
6338
+ * Maps diarization speaker IDs to role labels for transcript formatting.
6339
+ * E.g.: %{"SPEAKER_00" => "RD", "SPEAKER_01" => "Client"}
6340
+ * ISV-configured. The platform normalizes transcripts to these labels before passing to agents.
6341
+ * . Field included by default.
6342
+ */
6343
+ speaker_role_map: {
6344
+ [key: string]: unknown;
6345
+ };
6142
6346
  /**
6143
6347
  * Agent that validates extracted data post-extraction. Field included by default.
6144
6348
  */
@@ -7100,6 +7304,98 @@ declare function createVoiceNamespace(rb: RequestBuilder): {
7100
7304
  page?: number;
7101
7305
  pageSize?: number;
7102
7306
  } & RequestOptions) => Promise<VoiceTranscriptionResult[]>;
7307
+ /**
7308
+ * Create a transcript record manually.
7309
+ *
7310
+ * Creates a `VoiceTranscriptionResult` record in the current workspace.
7311
+ * Useful when you have a pre-computed transcript (e.g. from an external STT
7312
+ * service) that you want to associate with a recording or session.
7313
+ *
7314
+ * @param attributes - Transcript data. Required: `text` (string).
7315
+ * Optional: `recording_id`, `session_id`, `document_id`, `segments`,
7316
+ * `language_detected`, `duration_seconds`, `processing_seconds`,
7317
+ * `stt_engine`, `stt_model`, `metadata`.
7318
+ * @param options - Optional request options.
7319
+ * @returns The created `VoiceTranscriptionResult`.
7320
+ *
7321
+ * @example
7322
+ * ```typescript
7323
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
7324
+ * const result = await client.voice.transcriptionResults.create({
7325
+ * text: 'Patient reports chest pain since this morning.',
7326
+ * session_id: 'vs_abc123',
7327
+ * language_detected: 'en',
7328
+ * duration_seconds: 47.2,
7329
+ * });
7330
+ * console.log(result.id);
7331
+ * ```
7332
+ */
7333
+ create: (attributes: {
7334
+ text: string;
7335
+ recording_id?: string;
7336
+ session_id?: string;
7337
+ document_id?: string;
7338
+ segments?: Array<{
7339
+ text: string;
7340
+ start: number;
7341
+ end: number;
7342
+ confidence?: number;
7343
+ }>;
7344
+ language_detected?: string;
7345
+ duration_seconds?: number;
7346
+ processing_seconds?: number;
7347
+ stt_engine?: string;
7348
+ stt_model?: string;
7349
+ metadata?: Record<string, unknown>;
7350
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
7351
+ /**
7352
+ * Update a transcript's text, segments, or metadata.
7353
+ *
7354
+ * Allows correcting transcript text after review, updating segments
7355
+ * with corrected timestamps or confidence scores, or annotating with
7356
+ * additional metadata. `recording_id`, `session_id`, and STT engine
7357
+ * fields are immutable after creation.
7358
+ *
7359
+ * @param id - The UUID of the transcription result to update.
7360
+ * @param attributes - Fields to update. One or more of: `text`, `segments`, `metadata`.
7361
+ * @param options - Optional request options.
7362
+ * @returns The updated `VoiceTranscriptionResult`.
7363
+ *
7364
+ * @example
7365
+ * ```typescript
7366
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
7367
+ * const updated = await client.voice.transcriptionResults.update('tr_abc123', {
7368
+ * text: 'Patient reports chest pain since yesterday morning.',
7369
+ * });
7370
+ * ```
7371
+ */
7372
+ update: (id: string, attributes: {
7373
+ text?: string;
7374
+ segments?: Array<{
7375
+ text: string;
7376
+ start: number;
7377
+ end: number;
7378
+ confidence?: number;
7379
+ }>;
7380
+ metadata?: Record<string, unknown>;
7381
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
7382
+ /**
7383
+ * Delete a transcription result by its ID.
7384
+ *
7385
+ * Permanently removes the transcript record. Associated recordings and
7386
+ * voice sessions are not affected.
7387
+ *
7388
+ * @param id - The UUID of the transcription result to delete.
7389
+ * @param options - Optional request options.
7390
+ * @returns A promise that resolves when the record is deleted.
7391
+ *
7392
+ * @example
7393
+ * ```typescript
7394
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
7395
+ * await client.voice.transcriptionResults.destroy('tr_abc123');
7396
+ * ```
7397
+ */
7398
+ destroy: (id: string, options?: RequestOptions) => Promise<void>;
7103
7399
  };
7104
7400
  };
7105
7401
 
@@ -11063,7 +11359,23 @@ declare class GptClient extends BaseClient {
11063
11359
  /** Wallet, plans, transactions, and payment methods */
11064
11360
  readonly billing: {
11065
11361
  wallet: {
11066
- get: (options?: RequestOptions) => Promise<Record<string, unknown>>;
11362
+ get: (options?: RequestOptions) => Promise<Wallet>;
11363
+ previewPlanChange: (planSlug: string, options?: RequestOptions) => Promise<Wallet>;
11364
+ changePlan: (walletId: string, planSlug: string, options?: RequestOptions) => Promise<Wallet>;
11365
+ buyCredits: (walletId: string, packageSlug: string, paymentMethodId?: string, options?: RequestOptions) => Promise<Wallet>;
11366
+ updateAutoTopUp: (walletId: string, opts: {
11367
+ enabled: boolean;
11368
+ threshold?: number;
11369
+ amount?: number;
11370
+ packageId?: string;
11371
+ }, options?: RequestOptions) => Promise<Wallet>;
11372
+ invoices: {
11373
+ list: (options?: {
11374
+ page?: number;
11375
+ pageSize?: number;
11376
+ } & RequestOptions) => Promise<Invoice[]>;
11377
+ listAll: (options?: RequestOptions) => Promise<Invoice[]>;
11378
+ };
11067
11379
  };
11068
11380
  plans: {
11069
11381
  list: (options?: {
@@ -11096,7 +11408,29 @@ declare class GptClient extends BaseClient {
11096
11408
  pageSize?: number;
11097
11409
  } & RequestOptions) => Promise<PaymentMethod[]>;
11098
11410
  listAll: (options?: RequestOptions) => Promise<PaymentMethod[]>;
11099
- create: (attributes: Record<string, unknown>, options?: RequestOptions) => Promise<PaymentMethod>;
11411
+ create: (attributes: {
11412
+ provider_token: string;
11413
+ type?: "card" | "bank_account";
11414
+ last4?: string;
11415
+ exp_month?: number;
11416
+ exp_year?: number;
11417
+ brand?: string;
11418
+ nickname?: string;
11419
+ }, options?: RequestOptions) => Promise<PaymentMethod>;
11420
+ tokenize: (cardDetails: {
11421
+ card_number: string;
11422
+ exp_month: number;
11423
+ exp_year: number;
11424
+ cvc: string;
11425
+ holder_name: string;
11426
+ billing_address: string;
11427
+ billing_city: string;
11428
+ billing_state: string;
11429
+ zip_code: string;
11430
+ phone?: string;
11431
+ nickname?: string;
11432
+ customer_id?: string;
11433
+ }, options?: RequestOptions) => Promise<PaymentMethod>;
11100
11434
  update: (id: string, attributes: Record<string, unknown>, options?: RequestOptions) => Promise<PaymentMethod>;
11101
11435
  get: (id: string, options?: RequestOptions) => Promise<PaymentMethod>;
11102
11436
  setDefault: (id: string, options?: RequestOptions) => Promise<PaymentMethod>;
@@ -11960,6 +12294,8 @@ declare class GptClient extends BaseClient {
11960
12294
  send: (threadId: string, content: string, attributes?: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
11961
12295
  stream: (threadId: string, body: Record<string, unknown>, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
11962
12296
  };
12297
+ complete: (threadId: string, options?: RequestOptions) => Promise<Thread>;
12298
+ completeStream: (threadId: string, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
11963
12299
  };
11964
12300
  /** Training examples and sessions */
11965
12301
  readonly training: {
@@ -12046,6 +12382,35 @@ declare class GptClient extends BaseClient {
12046
12382
  page?: number;
12047
12383
  pageSize?: number;
12048
12384
  } & RequestOptions) => Promise<VoiceTranscriptionResult[]>;
12385
+ create: (attributes: {
12386
+ text: string;
12387
+ recording_id?: string;
12388
+ session_id?: string;
12389
+ document_id?: string;
12390
+ segments?: Array<{
12391
+ text: string;
12392
+ start: number;
12393
+ end: number;
12394
+ confidence?: number;
12395
+ }>;
12396
+ language_detected?: string;
12397
+ duration_seconds?: number;
12398
+ processing_seconds?: number;
12399
+ stt_engine?: string;
12400
+ stt_model?: string;
12401
+ metadata?: Record<string, unknown>;
12402
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
12403
+ update: (id: string, attributes: {
12404
+ text?: string;
12405
+ segments?: Array<{
12406
+ text: string;
12407
+ start: number;
12408
+ end: number;
12409
+ confidence?: number;
12410
+ }>;
12411
+ metadata?: Record<string, unknown>;
12412
+ }, options?: RequestOptions) => Promise<VoiceTranscriptionResult>;
12413
+ destroy: (id: string, options?: RequestOptions) => Promise<void>;
12049
12414
  };
12050
12415
  };
12051
12416
  /** File watcher claims and event management */
@@ -12612,6 +12977,59 @@ declare function createThreadsNamespace(rb: RequestBuilder): {
12612
12977
  */
12613
12978
  stream: (threadId: string, body: Record<string, unknown>, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
12614
12979
  };
12980
+ /**
12981
+ * Trigger AI inference on a thread without sending a new user message.
12982
+ *
12983
+ * Runs the full RAG pipeline (VectorSearch + GraphLookup + SynthesizeResponse)
12984
+ * using the thread's last user message as query context. Saves the AI response
12985
+ * as an assistant message and returns the updated Thread.
12986
+ *
12987
+ * Use this to let the AI proactively continue a conversation — for example,
12988
+ * after a voice session finalizes, to generate a follow-up or summary without
12989
+ * requiring the user to explicitly ask.
12990
+ *
12991
+ * @param threadId - The UUID of the thread to run AI completion on.
12992
+ * @param options - Optional request options.
12993
+ * @returns A promise resolving to the updated `Thread` after the assistant
12994
+ * message has been saved.
12995
+ *
12996
+ * @example
12997
+ * ```typescript
12998
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
12999
+ *
13000
+ * // After a voice session finalizes, trigger AI continuation:
13001
+ * const thread = await client.threads.complete('thr_01HXYZ...');
13002
+ * console.log(`Thread updated at: ${thread.attributes?.updated_at}`);
13003
+ * ```
13004
+ */
13005
+ complete: (threadId: string, options?: RequestOptions) => Promise<Thread>;
13006
+ /**
13007
+ * Trigger AI inference on a thread and receive the response via Server-Sent Events.
13008
+ *
13009
+ * Identical to {@link complete} in behavior but delivers the result as an SSE
13010
+ * stream. The stream yields a single `StreamMessageChunk` with `done: true`
13011
+ * when the AI response is ready.
13012
+ *
13013
+ * Note: This endpoint delivers the full response as one event (not token-by-token).
13014
+ * It gives the frontend a consistent SSE interface for uniform handling of both
13015
+ * streaming and non-streaming completions.
13016
+ *
13017
+ * @param threadId - The UUID of the thread to run AI completion on.
13018
+ * @param options - Optional request options (e.g. abort signal).
13019
+ * @param streamOptions - Optional streaming configuration.
13020
+ * @returns A promise resolving to an `AsyncIterableIterator<StreamMessageChunk>`.
13021
+ *
13022
+ * @example
13023
+ * ```typescript
13024
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
13025
+ *
13026
+ * const stream = await client.threads.completeStream('thr_01HXYZ...');
13027
+ * for await (const chunk of stream) {
13028
+ * if (chunk.type === 'done') console.log(`AI response: ${chunk.content}`);
13029
+ * }
13030
+ * ```
13031
+ */
13032
+ completeStream: (threadId: string, options?: RequestOptions, streamOptions?: StreamOptions) => Promise<AsyncIterableIterator<StreamMessageChunk>>;
12615
13033
  };
12616
13034
 
12617
13035
  /**
@@ -12811,6 +13229,32 @@ declare function createSearchNamespace(rb: RequestBuilder): {
12811
13229
  };
12812
13230
  };
12813
13231
 
13232
+ /** Attributes for saving a pre-tokenized payment method. */
13233
+ type PaymentMethodCreateAttributes = {
13234
+ /** Provider token from a hosted fields flow (e.g. QorPay hosted iframe). Never pass raw card numbers here. */
13235
+ provider_token: string;
13236
+ type?: "card" | "bank_account";
13237
+ last4?: string;
13238
+ exp_month?: number;
13239
+ exp_year?: number;
13240
+ brand?: string;
13241
+ nickname?: string;
13242
+ };
13243
+ /** Attributes for S2S card tokenization (raw card details). Server tokenizes with QorPay. */
13244
+ type PaymentMethodTokenizeAttributes = {
13245
+ card_number: string;
13246
+ exp_month: number;
13247
+ exp_year: number;
13248
+ cvc: string;
13249
+ holder_name: string;
13250
+ billing_address: string;
13251
+ billing_city: string;
13252
+ billing_state: string;
13253
+ zip_code: string;
13254
+ phone?: string;
13255
+ nickname?: string;
13256
+ customer_id?: string;
13257
+ };
12814
13258
  /**
12815
13259
  * Creates the billing namespace, providing access to wallet balances, subscription
12816
13260
  * plans, transaction history, credit packages, and payment methods for the
@@ -12836,21 +13280,87 @@ declare function createBillingNamespace(rb: RequestBuilder): {
12836
13280
  /**
12837
13281
  * Retrieves the current workspace wallet, including the available credit
12838
13282
  * balance, usage totals, and any pending charges.
13283
+ */
13284
+ get: (options?: RequestOptions) => Promise<Wallet>;
13285
+ /**
13286
+ * Preview the cost and effective date of a plan change before committing.
12839
13287
  *
12840
- * @param options - Optional request options such as custom headers or an
12841
- * abort signal.
12842
- * @returns A promise resolving to a record containing wallet fields such as
12843
- * `balance`, `currency`, and usage metadata.
13288
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
13289
+ */
13290
+ previewPlanChange: (planSlug: string, options?: RequestOptions) => Promise<Wallet>;
13291
+ /**
13292
+ * Change the workspace's subscription plan.
12844
13293
  *
12845
- * @example
12846
- * ```typescript
12847
- * const client = new GptClient({ apiKey: 'sk_app_...' });
13294
+ * Upgrades charge a prorated amount immediately against the default payment
13295
+ * method. Downgrades are deferred to the end of the current billing period.
13296
+ * Use `previewPlanChange` first to show the user a cost estimate.
12848
13297
  *
12849
- * const wallet = await client.billing.wallet.get();
12850
- * console.log(`Available credits: ${wallet.balance}`);
12851
- * ```
13298
+ * @param walletId - The wallet UUID from `wallet.get()`.
13299
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
12852
13300
  */
12853
- get: (options?: RequestOptions) => Promise<Record<string, unknown>>;
13301
+ changePlan: (walletId: string, planSlug: string, options?: RequestOptions) => Promise<Wallet>;
13302
+ /**
13303
+ * Purchase a credit package to top up the workspace wallet immediately.
13304
+ *
13305
+ * Charges the specified (or default) payment method. Credits are added to
13306
+ * the `purchased` bucket and never expire.
13307
+ *
13308
+ * @param walletId - The wallet UUID from `wallet.get()`.
13309
+ * @param packageSlug - The slug of the credit package to purchase.
13310
+ * @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
13311
+ */
13312
+ buyCredits: (walletId: string, packageSlug: string, paymentMethodId?: string, options?: RequestOptions) => Promise<Wallet>;
13313
+ /**
13314
+ * Update the workspace's auto top-up settings.
13315
+ *
13316
+ * When enabled, the platform automatically purchases the specified credit
13317
+ * package whenever the balance drops below `threshold`.
13318
+ *
13319
+ * @param walletId - The wallet UUID from `wallet.get()`.
13320
+ * @param opts.enabled - Enable or disable auto top-up.
13321
+ * @param opts.threshold - Credit balance floor that triggers a purchase.
13322
+ * @param opts.amount - Credits to purchase per top-up event.
13323
+ * @param opts.packageId - Credit package UUID to auto-purchase.
13324
+ */
13325
+ updateAutoTopUp: (walletId: string, opts: {
13326
+ enabled: boolean;
13327
+ threshold?: number;
13328
+ amount?: number;
13329
+ packageId?: string;
13330
+ }, options?: RequestOptions) => Promise<Wallet>;
13331
+ /**
13332
+ * Sub-namespace for invoice operations.
13333
+ *
13334
+ * Invoices are generated per billing period and carry a `pdf_url` for
13335
+ * receipt download. Use `invoices.list()` for the transaction history page.
13336
+ */
13337
+ invoices: {
13338
+ /**
13339
+ * Returns a single page of invoices for the current workspace.
13340
+ *
13341
+ * Each invoice includes `pdf_url` for receipt download.
13342
+ *
13343
+ * @example
13344
+ * ```typescript
13345
+ * const invoices = await client.billing.wallet.invoices.list();
13346
+ * const paidInvoices = invoices.filter(inv => inv.attributes?.status === "paid");
13347
+ * ```
13348
+ */
13349
+ list: (options?: {
13350
+ page?: number;
13351
+ pageSize?: number;
13352
+ } & RequestOptions) => Promise<Invoice[]>;
13353
+ /**
13354
+ * Fetches all invoices by automatically paginating through every page.
13355
+ *
13356
+ * @example
13357
+ * ```typescript
13358
+ * const all = await client.billing.wallet.invoices.listAll();
13359
+ * const downloadUrl = all[0].attributes?.pdf_url;
13360
+ * ```
13361
+ */
13362
+ listAll: (options?: RequestOptions) => Promise<Invoice[]>;
13363
+ };
12854
13364
  };
12855
13365
  /**
12856
13366
  * Sub-namespace for subscription plan operations.
@@ -13158,7 +13668,20 @@ declare function createBillingNamespace(rb: RequestBuilder): {
13158
13668
  * console.log(`Added card ending in ${method.last4}`);
13159
13669
  * ```
13160
13670
  */
13161
- create: (attributes: Record<string, unknown>, options?: RequestOptions) => Promise<PaymentMethod>;
13671
+ create: (attributes: PaymentMethodCreateAttributes, options?: RequestOptions) => Promise<PaymentMethod>;
13672
+ /**
13673
+ * Tokenizes a raw card server-side and saves the resulting payment method.
13674
+ *
13675
+ * Use this for direct card collection flows where your server handles card
13676
+ * data (PCI-DSS scope applies). The platform tokenizes the card with QorPay
13677
+ * and stores only the token — raw card data is never persisted.
13678
+ *
13679
+ * For hosted-fields flows where the client tokenizes the card, use
13680
+ * `paymentMethods.create({ provider_token })` instead.
13681
+ *
13682
+ * @param cardDetails - Raw card fields including number, CVC, expiry, and billing address.
13683
+ */
13684
+ tokenize: (cardDetails: PaymentMethodTokenizeAttributes, options?: RequestOptions) => Promise<PaymentMethod>;
13162
13685
  /**
13163
13686
  * Updates the mutable attributes of an existing payment method, such as
13164
13687
  * the billing name or expiry date override.