perspectapi-ts-sdk 3.7.0 → 5.0.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.
package/dist/index.d.ts CHANGED
@@ -277,6 +277,239 @@ interface NewsletterUnsubscribeResponse {
277
277
  message: string;
278
278
  status?: string;
279
279
  }
280
+ interface NewsletterManagementListMembership {
281
+ id: string;
282
+ list_name: string;
283
+ slug: string;
284
+ }
285
+ interface NewsletterManagementSubscription {
286
+ id: string;
287
+ site_id: string;
288
+ site_name: string;
289
+ email: string;
290
+ name?: string | null;
291
+ status: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
292
+ confirmation_token?: string | null;
293
+ unsubscribe_token: string;
294
+ double_opt_in: boolean;
295
+ confirmed_at?: string | null;
296
+ source?: string | null;
297
+ source_url?: string | null;
298
+ frequency: 'instant' | 'daily' | 'weekly' | 'monthly';
299
+ topics?: string[] | string | null;
300
+ language: string;
301
+ tags?: string[] | string | null;
302
+ custom_fields?: Record<string, any> | string | null;
303
+ notes?: string | null;
304
+ unsubscribed_at?: string | null;
305
+ unsubscribe_reason?: string | null;
306
+ created_at: string;
307
+ updated_at: string;
308
+ lists: NewsletterManagementListMembership[];
309
+ }
310
+ interface NewsletterSubscriptionSyncRequest {
311
+ email: string;
312
+ name?: string | null;
313
+ status?: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
314
+ list_ids?: string[];
315
+ frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
316
+ topics?: string[];
317
+ language?: string | null;
318
+ source?: string | null;
319
+ source_url?: string | null;
320
+ notes?: string | null;
321
+ tags?: string[];
322
+ metadata?: Record<string, any>;
323
+ resubscribe_override?: boolean;
324
+ }
325
+ interface NewsletterSubscriptionSyncResponse {
326
+ applied: boolean;
327
+ code: 'CREATED' | 'UPDATED' | 'RESUBSCRIBED' | 'ALREADY_UNSUBSCRIBED';
328
+ skipped_unsubscribed: boolean;
329
+ resubscribed: boolean;
330
+ created: boolean;
331
+ updated: boolean;
332
+ subscription_id: string;
333
+ subscription: NewsletterManagementSubscription;
334
+ }
335
+ type NewsletterSubscriptionsBulkAction = 'confirm' | 'unsubscribe' | 'delete' | 'add_to_list' | 'remove_from_list';
336
+ interface NewsletterSubscriptionsBulkUpdateRequest {
337
+ ids: string[];
338
+ action: NewsletterSubscriptionsBulkAction;
339
+ list_id?: string;
340
+ resubscribe_override?: boolean;
341
+ }
342
+ interface NewsletterSubscriptionsBulkOutcome {
343
+ id: string;
344
+ applied: boolean;
345
+ code: string;
346
+ error?: string;
347
+ skipped_unsubscribed?: boolean;
348
+ }
349
+ interface NewsletterSubscriptionsBulkUpdateResponse {
350
+ succeeded: number;
351
+ failed: number;
352
+ skipped_unsubscribed: number;
353
+ outcomes: NewsletterSubscriptionsBulkOutcome[];
354
+ }
355
+ interface NewsletterSubscriptionMembershipUpdateRequest {
356
+ mode: 'add' | 'remove' | 'replace';
357
+ list_ids: string[];
358
+ }
359
+ interface NewsletterSubscriptionImportRowRequest {
360
+ email: string;
361
+ name?: string | null;
362
+ status?: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
363
+ list_ids?: string[];
364
+ frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
365
+ topics?: string[];
366
+ language?: string | null;
367
+ source?: string | null;
368
+ source_url?: string | null;
369
+ notes?: string | null;
370
+ tags?: string[];
371
+ metadata?: Record<string, any>;
372
+ resubscribe_override?: boolean;
373
+ }
374
+ interface NewsletterSubscriptionsImportRequest {
375
+ rows: NewsletterSubscriptionImportRowRequest[];
376
+ resubscribe_override?: boolean;
377
+ }
378
+ interface NewsletterSubscriptionsImportRowResult {
379
+ index: number;
380
+ email: string;
381
+ applied: boolean;
382
+ code: string;
383
+ skipped_unsubscribed: boolean;
384
+ resubscribed: boolean;
385
+ subscription_id: string;
386
+ }
387
+ interface NewsletterSubscriptionsImportResponse {
388
+ total: number;
389
+ processed: number;
390
+ applied: number;
391
+ created: number;
392
+ updated: number;
393
+ resubscribed: number;
394
+ skipped_unsubscribed: number;
395
+ rows: NewsletterSubscriptionsImportRowResult[];
396
+ }
397
+ interface NewsletterManagementPagination {
398
+ page: number;
399
+ limit: number;
400
+ total: number;
401
+ pages: number;
402
+ }
403
+ interface NewsletterManagementSubscriptionsListResponse {
404
+ items: NewsletterManagementSubscription[];
405
+ pagination: NewsletterManagementPagination;
406
+ }
407
+ interface NewsletterManagementList extends NewsletterList {
408
+ site_id: string;
409
+ site_name: string;
410
+ description?: string;
411
+ is_public: boolean;
412
+ is_default: boolean;
413
+ double_opt_in: boolean;
414
+ welcome_email_enabled: boolean;
415
+ subscriber_count: number;
416
+ status: 'active' | 'archived';
417
+ created_at: string;
418
+ updated_at: string;
419
+ }
420
+ interface NewsletterManagementSeries {
421
+ id: string;
422
+ site_id: string;
423
+ site_name: string;
424
+ series_name: string;
425
+ description?: string | null;
426
+ list_ids?: string | null;
427
+ from_name?: string | null;
428
+ from_email?: string | null;
429
+ reply_to_email?: string | null;
430
+ subject_prefix?: string | null;
431
+ cadence: 'manual' | 'daily' | 'weekly' | 'monthly';
432
+ timezone?: string | null;
433
+ send_time?: string | null;
434
+ day_of_week?: number | null;
435
+ day_of_month?: number | null;
436
+ status: 'active' | 'paused' | 'archived';
437
+ last_sent_at?: string | null;
438
+ next_send_at?: string | null;
439
+ tags?: string | null;
440
+ notes?: string | null;
441
+ created_at: string;
442
+ updated_at: string;
443
+ created_by?: string | null;
444
+ }
445
+ interface NewsletterManagementCampaign {
446
+ id: string;
447
+ site_id: string;
448
+ site_name: string;
449
+ series_id?: string | null;
450
+ series_name?: string | null;
451
+ campaign_name: string;
452
+ slug?: string | null;
453
+ slug_prefix?: string | null;
454
+ subject: string;
455
+ markdown_content?: string | null;
456
+ template_id?: string | null;
457
+ list_ids?: string | null;
458
+ tags?: string | null;
459
+ notes?: string | null;
460
+ preview_text?: string | null;
461
+ from_name?: string | null;
462
+ from_email?: string | null;
463
+ reply_to_email?: string | null;
464
+ status: 'draft' | 'scheduled' | 'sending' | 'sent' | 'cancelled';
465
+ scheduled_at?: string | null;
466
+ sent_at?: string | null;
467
+ completed_at?: string | null;
468
+ total_recipients?: number | null;
469
+ sent_count?: number | null;
470
+ delivered_count?: number | null;
471
+ opened_count?: number | null;
472
+ clicked_count?: number | null;
473
+ unsubscribed_count?: number | null;
474
+ bounced_count?: number | null;
475
+ complained_count?: number | null;
476
+ created_at: string;
477
+ updated_at: string;
478
+ }
479
+ interface NewsletterManagementCampaignListResponse {
480
+ items: NewsletterManagementCampaign[];
481
+ pagination: NewsletterManagementPagination;
482
+ }
483
+ interface NewsletterCampaignTestSendRequest {
484
+ to: string | string[];
485
+ subject?: string | null;
486
+ }
487
+ interface NewsletterCampaignTestSendResponse {
488
+ sent: number;
489
+ recipients: string[];
490
+ campaign_id: string;
491
+ }
492
+ interface NewsletterManagementStatsResponse {
493
+ total: number;
494
+ byStatus: Record<string, number>;
495
+ recentActivity: Array<{
496
+ date: string;
497
+ count: number;
498
+ }>;
499
+ }
500
+ interface NewsletterExportCreateRequest {
501
+ format?: 'csv' | 'json' | 'xlsx';
502
+ status?: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
503
+ list_id?: string;
504
+ search?: string | null;
505
+ }
506
+ interface NewsletterExportCreateResponse {
507
+ exportId: string;
508
+ downloadUrl: string;
509
+ expiresAt: string;
510
+ format: 'csv' | 'json';
511
+ rowCount: number;
512
+ }
280
513
  type ContentStatus = 'draft' | 'publish' | 'private' | 'trash';
281
514
  type ContentType = 'post' | 'page' | 'block';
282
515
  interface Content {
@@ -683,7 +916,7 @@ interface SiteUserSubscription {
683
916
  provider_subscription_id?: string;
684
917
  plan_name?: string;
685
918
  plan_id?: string;
686
- status: 'active' | 'past_due' | 'canceled' | 'paused' | 'trialing' | 'expired';
919
+ status: 'active' | 'past_due' | 'canceled' | 'paused' | 'trialing' | 'expired' | 'incomplete';
687
920
  amount?: number;
688
921
  currency?: string;
689
922
  billing_interval?: string;
@@ -705,10 +938,30 @@ interface SiteUserOrder {
705
938
  currency: string;
706
939
  status: string;
707
940
  payment_status?: string;
941
+ fulfillment_status?: string;
708
942
  line_items: any[];
709
943
  created_at: string;
710
944
  completed_at?: string;
711
945
  }
946
+ type SubscriptionCancellationMode = 'immediate' | 'period_end' | 'scheduled';
947
+ interface CancelSubscriptionRequest {
948
+ mode?: SubscriptionCancellationMode;
949
+ cancel_at?: string;
950
+ delay_days?: number;
951
+ delay_hours?: number;
952
+ delay_minutes?: number;
953
+ }
954
+ interface CancelSubscriptionResponse {
955
+ success: boolean;
956
+ message: string;
957
+ cancellation?: {
958
+ mode: SubscriptionCancellationMode;
959
+ status: string;
960
+ cancel_at_period_end: boolean;
961
+ effective_at: string | null;
962
+ scheduled_cancel_at: string | null;
963
+ };
964
+ }
712
965
  interface CreditTransaction {
713
966
  id: number;
714
967
  amount_cents: number;
@@ -2134,150 +2387,6 @@ declare class NewsletterClient extends BaseClient {
2134
2387
  * Check subscription status by email
2135
2388
  */
2136
2389
  getStatus(siteName: string, email: string): Promise<ApiResponse<NewsletterStatusResponse>>;
2137
- /**
2138
- * Get all newsletter subscriptions (admin only)
2139
- */
2140
- getSubscriptions(siteName: string, params?: {
2141
- page?: number;
2142
- limit?: number;
2143
- status?: string;
2144
- list_id?: string;
2145
- search?: string;
2146
- startDate?: string;
2147
- endDate?: string;
2148
- }): Promise<PaginatedResponse<NewsletterSubscription>>;
2149
- /**
2150
- * Get subscription by ID (admin only)
2151
- */
2152
- getSubscriptionById(siteName: string, id: string): Promise<ApiResponse<NewsletterSubscription>>;
2153
- /**
2154
- * Update subscription status (admin only)
2155
- */
2156
- updateSubscriptionStatus(siteName: string, id: string, status: 'confirmed' | 'unsubscribed' | 'bounced' | 'complained', notes?: string): Promise<ApiResponse<{
2157
- message: string;
2158
- }>>;
2159
- /**
2160
- * Delete subscription (admin only)
2161
- */
2162
- deleteSubscription(siteName: string, id: string): Promise<ApiResponse<{
2163
- message: string;
2164
- }>>;
2165
- /**
2166
- * Bulk update subscriptions (admin only)
2167
- */
2168
- bulkUpdateSubscriptions(siteName: string, data: {
2169
- ids: string[];
2170
- action: 'confirm' | 'unsubscribe' | 'delete' | 'add_to_list' | 'remove_from_list';
2171
- list_id?: string;
2172
- }): Promise<ApiResponse<{
2173
- success: boolean;
2174
- updatedCount: number;
2175
- failedCount: number;
2176
- }>>;
2177
- /**
2178
- * Create newsletter list (admin only)
2179
- */
2180
- createList(siteName: string, data: {
2181
- list_name: string;
2182
- slug: string;
2183
- description?: string;
2184
- is_public?: boolean;
2185
- is_default?: boolean;
2186
- double_opt_in?: boolean;
2187
- welcome_email_enabled?: boolean;
2188
- }): Promise<ApiResponse<NewsletterList>>;
2189
- /**
2190
- * Update newsletter list (admin only)
2191
- */
2192
- updateList(siteName: string, listId: string, data: Partial<{
2193
- list_name: string;
2194
- description: string;
2195
- is_public: boolean;
2196
- is_default: boolean;
2197
- double_opt_in: boolean;
2198
- welcome_email_enabled: boolean;
2199
- }>): Promise<ApiResponse<{
2200
- message: string;
2201
- }>>;
2202
- /**
2203
- * Delete newsletter list (admin only)
2204
- */
2205
- deleteList(siteName: string, listId: string): Promise<ApiResponse<{
2206
- message: string;
2207
- }>>;
2208
- /**
2209
- * Get newsletter statistics (admin only)
2210
- */
2211
- getStatistics(siteName: string, params?: {
2212
- startDate?: string;
2213
- endDate?: string;
2214
- list_id?: string;
2215
- }): Promise<ApiResponse<{
2216
- totalSubscribers: number;
2217
- confirmedSubscribers: number;
2218
- pendingSubscribers: number;
2219
- unsubscribedCount: number;
2220
- bouncedCount: number;
2221
- subscribersByDay: Array<{
2222
- date: string;
2223
- count: number;
2224
- }>;
2225
- subscribersByList: Array<{
2226
- list_id: string;
2227
- list_name: string;
2228
- count: number;
2229
- }>;
2230
- engagementMetrics: {
2231
- averageOpenRate: number;
2232
- averageClickRate: number;
2233
- };
2234
- }>>;
2235
- /**
2236
- * Export newsletter subscriptions (admin only)
2237
- */
2238
- exportSubscriptions(siteName: string, params?: {
2239
- format?: 'csv' | 'json' | 'xlsx';
2240
- status?: string;
2241
- list_id?: string;
2242
- startDate?: string;
2243
- endDate?: string;
2244
- }): Promise<ApiResponse<{
2245
- downloadUrl: string;
2246
- expiresAt: string;
2247
- }>>;
2248
- /**
2249
- * Import newsletter subscriptions (admin only)
2250
- */
2251
- importSubscriptions(siteName: string, data: {
2252
- subscriptions: Array<{
2253
- email: string;
2254
- name?: string;
2255
- status?: string;
2256
- lists?: string[];
2257
- }>;
2258
- skip_confirmation?: boolean;
2259
- update_existing?: boolean;
2260
- }): Promise<ApiResponse<{
2261
- imported: number;
2262
- updated: number;
2263
- failed: number;
2264
- errors?: Array<{
2265
- email: string;
2266
- error: string;
2267
- }>;
2268
- }>>;
2269
- /**
2270
- * Send test newsletter (admin only)
2271
- */
2272
- sendTestNewsletter(siteName: string, data: {
2273
- to: string;
2274
- subject: string;
2275
- html_content: string;
2276
- text_content?: string;
2277
- }): Promise<ApiResponse<{
2278
- message: string;
2279
- sent: boolean;
2280
- }>>;
2281
2390
  /**
2282
2391
  * Track email open event.
2283
2392
  * Called by client sites when their tracking pixel route is hit.
@@ -2312,6 +2421,171 @@ declare class NewsletterClient extends BaseClient {
2312
2421
  private isCachePolicy;
2313
2422
  }
2314
2423
 
2424
+ /**
2425
+ * Newsletter management client for PerspectAPI SDK
2426
+ * Strict management surface under /newsletter/management/*
2427
+ */
2428
+
2429
+ declare class NewsletterManagementClient extends BaseClient {
2430
+ constructor(http: any, cache?: CacheManager);
2431
+ private managementEndpoint;
2432
+ listSubscriptions(siteName: string, params?: {
2433
+ page?: number;
2434
+ limit?: number;
2435
+ status?: 'pending' | 'confirmed' | 'unsubscribed' | 'bounced' | 'complained';
2436
+ list_id?: string;
2437
+ search?: string;
2438
+ startDate?: string;
2439
+ endDate?: string;
2440
+ }): Promise<ApiResponse<NewsletterManagementSubscriptionsListResponse>>;
2441
+ getSubscriptionById(siteName: string, subscriptionId: string): Promise<ApiResponse<NewsletterManagementSubscription>>;
2442
+ getSubscriptionByEmail(siteName: string, email: string): Promise<ApiResponse<NewsletterManagementSubscription>>;
2443
+ syncSubscription(siteName: string, data: NewsletterSubscriptionSyncRequest): Promise<ApiResponse<NewsletterSubscriptionSyncResponse>>;
2444
+ updateSubscription(siteName: string, subscriptionId: string, data: Omit<NewsletterSubscriptionSyncRequest, 'email'>): Promise<ApiResponse<NewsletterSubscriptionSyncResponse>>;
2445
+ deleteSubscription(siteName: string, subscriptionId: string): Promise<ApiResponse<{
2446
+ deleted: boolean;
2447
+ subscription_id: string;
2448
+ }>>;
2449
+ bulkUpdateSubscriptions(siteName: string, data: NewsletterSubscriptionsBulkUpdateRequest): Promise<ApiResponse<NewsletterSubscriptionsBulkUpdateResponse>>;
2450
+ updateSubscriptionListMembership(siteName: string, subscriptionId: string, data: NewsletterSubscriptionMembershipUpdateRequest): Promise<ApiResponse<{
2451
+ subscription: NewsletterManagementSubscription;
2452
+ mode: 'add' | 'remove' | 'replace';
2453
+ list_ids: string[];
2454
+ }>>;
2455
+ importSubscriptions(siteName: string, data: NewsletterSubscriptionsImportRequest): Promise<ApiResponse<NewsletterSubscriptionsImportResponse>>;
2456
+ listLists(siteName: string, params?: {
2457
+ status?: 'active' | 'archived';
2458
+ }): Promise<ApiResponse<{
2459
+ items: NewsletterManagementList[];
2460
+ total: number;
2461
+ }>>;
2462
+ getListById(siteName: string, listId: string): Promise<ApiResponse<NewsletterManagementList>>;
2463
+ createList(siteName: string, data: {
2464
+ list_name: string;
2465
+ slug: string;
2466
+ description?: string | null;
2467
+ is_public?: boolean;
2468
+ is_default?: boolean;
2469
+ double_opt_in?: boolean;
2470
+ welcome_email_enabled?: boolean;
2471
+ }): Promise<ApiResponse<NewsletterManagementList>>;
2472
+ updateList(siteName: string, listId: string, data: Partial<{
2473
+ list_name: string | null;
2474
+ slug: string | null;
2475
+ description: string | null;
2476
+ is_public: boolean;
2477
+ is_default: boolean;
2478
+ double_opt_in: boolean;
2479
+ welcome_email_enabled: boolean;
2480
+ status: 'active' | 'archived';
2481
+ }>): Promise<ApiResponse<NewsletterManagementList>>;
2482
+ deleteList(siteName: string, listId: string): Promise<ApiResponse<{
2483
+ deleted: boolean;
2484
+ list_id: string;
2485
+ }>>;
2486
+ listSeries(siteName: string, params?: {
2487
+ status?: 'active' | 'paused' | 'archived';
2488
+ }): Promise<ApiResponse<{
2489
+ items: NewsletterManagementSeries[];
2490
+ total: number;
2491
+ }>>;
2492
+ getSeriesById(siteName: string, seriesId: string): Promise<ApiResponse<NewsletterManagementSeries>>;
2493
+ createSeries(siteName: string, data: {
2494
+ series_name: string;
2495
+ description?: string | null;
2496
+ status?: 'active' | 'paused' | 'archived';
2497
+ cadence?: 'manual' | 'daily' | 'weekly' | 'monthly';
2498
+ timezone?: string | null;
2499
+ send_time?: string | null;
2500
+ day_of_week?: number | null;
2501
+ day_of_month?: number | null;
2502
+ next_send_at?: string | null;
2503
+ list_ids?: string[];
2504
+ from_name?: string | null;
2505
+ from_email?: string | null;
2506
+ reply_to_email?: string | null;
2507
+ subject_prefix?: string | null;
2508
+ tags?: string[];
2509
+ notes?: string | null;
2510
+ }): Promise<ApiResponse<NewsletterManagementSeries>>;
2511
+ updateSeries(siteName: string, seriesId: string, data: Partial<{
2512
+ series_name: string;
2513
+ description?: string | null;
2514
+ status?: 'active' | 'paused' | 'archived';
2515
+ cadence?: 'manual' | 'daily' | 'weekly' | 'monthly';
2516
+ timezone?: string | null;
2517
+ send_time?: string | null;
2518
+ day_of_week?: number | null;
2519
+ day_of_month?: number | null;
2520
+ next_send_at?: string | null;
2521
+ list_ids?: string[];
2522
+ from_name?: string | null;
2523
+ from_email?: string | null;
2524
+ reply_to_email?: string | null;
2525
+ subject_prefix?: string | null;
2526
+ tags?: string[];
2527
+ notes?: string | null;
2528
+ }>): Promise<ApiResponse<NewsletterManagementSeries>>;
2529
+ deleteSeries(siteName: string, seriesId: string): Promise<ApiResponse<{
2530
+ deleted: boolean;
2531
+ series_id: string;
2532
+ }>>;
2533
+ listCampaigns(siteName: string, params?: {
2534
+ page?: number;
2535
+ limit?: number;
2536
+ status?: 'draft' | 'scheduled' | 'sending' | 'sent' | 'cancelled';
2537
+ }): Promise<ApiResponse<NewsletterManagementCampaignListResponse>>;
2538
+ getCampaignById(siteName: string, campaignId: string): Promise<ApiResponse<NewsletterManagementCampaign>>;
2539
+ createCampaign(siteName: string, data: {
2540
+ campaign_name: string;
2541
+ subject: string;
2542
+ markdown_content: string;
2543
+ slug?: string | null;
2544
+ slug_prefix?: string | null;
2545
+ status?: 'draft' | 'scheduled' | 'cancelled';
2546
+ scheduled_at?: string | null;
2547
+ preview_text?: string | null;
2548
+ from_name?: string | null;
2549
+ from_email?: string | null;
2550
+ reply_to_email?: string | null;
2551
+ template_id?: string | null;
2552
+ series_id?: string | null;
2553
+ list_ids?: string[];
2554
+ tags?: string[];
2555
+ notes?: string | null;
2556
+ }): Promise<ApiResponse<NewsletterManagementCampaign>>;
2557
+ updateCampaign(siteName: string, campaignId: string, data: Partial<{
2558
+ campaign_name: string;
2559
+ subject: string;
2560
+ markdown_content: string;
2561
+ slug?: string | null;
2562
+ slug_prefix?: string | null;
2563
+ status?: 'draft' | 'scheduled' | 'cancelled';
2564
+ scheduled_at?: string | null;
2565
+ preview_text?: string | null;
2566
+ from_name?: string | null;
2567
+ from_email?: string | null;
2568
+ reply_to_email?: string | null;
2569
+ template_id?: string | null;
2570
+ series_id?: string | null;
2571
+ list_ids?: string[];
2572
+ tags?: string[];
2573
+ notes?: string | null;
2574
+ }>): Promise<ApiResponse<NewsletterManagementCampaign>>;
2575
+ deleteCampaign(siteName: string, campaignId: string): Promise<ApiResponse<{
2576
+ deleted: boolean;
2577
+ campaign_id: string;
2578
+ }>>;
2579
+ sendCampaignTest(siteName: string, campaignId: string, data: NewsletterCampaignTestSendRequest): Promise<ApiResponse<NewsletterCampaignTestSendResponse>>;
2580
+ getStats(siteName: string, params?: {
2581
+ startDate?: string;
2582
+ endDate?: string;
2583
+ list_id?: string;
2584
+ }): Promise<ApiResponse<NewsletterManagementStatsResponse>>;
2585
+ createExport(siteName: string, data: NewsletterExportCreateRequest): Promise<ApiResponse<NewsletterExportCreateResponse>>;
2586
+ downloadExport(siteName: string, exportId: string): Promise<ApiResponse<string>>;
2587
+ }
2588
+
2315
2589
  /**
2316
2590
  * Site Users client for PerspectAPI SDK
2317
2591
  * Handles per-site customer accounts (OTP-based auth, profiles, orders, subscriptions)
@@ -2467,15 +2741,13 @@ declare class SiteUsersClient extends BaseClient {
2467
2741
  subscription: SiteUserSubscription;
2468
2742
  }>>;
2469
2743
  /**
2470
- * Cancel a subscription (marks for cancellation at period end)
2744
+ * Cancel a subscription.
2471
2745
  * @param siteName - The site name
2472
2746
  * @param id - Subscription ID
2473
2747
  * @param csrfToken - CSRF token (required)
2748
+ * @param options - Cancellation mode/details
2474
2749
  */
2475
- cancelSubscription(siteName: string, id: string, csrfToken?: string): Promise<ApiResponse<{
2476
- success: boolean;
2477
- message: string;
2478
- }>>;
2750
+ cancelSubscription(siteName: string, id: string, csrfToken?: string, options?: CancelSubscriptionRequest): Promise<ApiResponse<CancelSubscriptionResponse>>;
2479
2751
  /**
2480
2752
  * Pause a subscription via Stripe pause_collection
2481
2753
  * @param siteName - The site name
@@ -2648,11 +2920,9 @@ declare class SiteUsersClient extends BaseClient {
2648
2920
  * @param siteName - The site name
2649
2921
  * @param userId - User ID
2650
2922
  * @param subscriptionId - Subscription ID
2923
+ * @param options - Cancellation mode/details
2651
2924
  */
2652
- cancelUserSubscription(siteName: string, userId: string, subscriptionId: string): Promise<ApiResponse<{
2653
- success: boolean;
2654
- message: string;
2655
- }>>;
2925
+ cancelUserSubscription(siteName: string, userId: string, subscriptionId: string, options?: CancelSubscriptionRequest): Promise<ApiResponse<CancelSubscriptionResponse>>;
2656
2926
  /**
2657
2927
  * Get a user's credit balance (admin only)
2658
2928
  * @param siteName - The site name
@@ -2713,6 +2983,7 @@ declare class PerspectApiClient {
2713
2983
  readonly checkout: CheckoutClient;
2714
2984
  readonly contact: ContactClient;
2715
2985
  readonly newsletter: NewsletterClient;
2986
+ readonly newsletterManagement: NewsletterManagementClient;
2716
2987
  readonly siteUsers: SiteUsersClient;
2717
2988
  readonly bundles: BundlesClient;
2718
2989
  constructor(config: PerspectApiConfig);
@@ -2801,6 +3072,616 @@ declare class PerspectApiClient {
2801
3072
  */
2802
3073
  declare function createPerspectApiClient(config: PerspectApiConfig): PerspectApiClient;
2803
3074
 
3075
+ /**
3076
+ * v2 SDK Types — matches the API wire format exactly (snake_case).
3077
+ *
3078
+ * These types reflect the actual JSON returned by /api/v2/ endpoints.
3079
+ * No transformation layer is needed in the SDK.
3080
+ */
3081
+ interface V2Object {
3082
+ object: string;
3083
+ id: string;
3084
+ }
3085
+ interface V2List<T> {
3086
+ object: "list";
3087
+ data: T[];
3088
+ has_more: boolean;
3089
+ url: string;
3090
+ }
3091
+ interface V2Deleted {
3092
+ object: string;
3093
+ id: string;
3094
+ deleted: true;
3095
+ }
3096
+ interface V2Error {
3097
+ error: {
3098
+ type: V2ErrorType;
3099
+ code: string;
3100
+ message: string;
3101
+ param?: string;
3102
+ };
3103
+ }
3104
+ type V2ErrorType = "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "rate_limit_error" | "api_error";
3105
+ interface V2PaginationParams {
3106
+ limit?: number;
3107
+ starting_after?: string;
3108
+ ending_before?: string;
3109
+ }
3110
+ interface V2Content extends V2Object {
3111
+ object: "content";
3112
+ title: string;
3113
+ content: string;
3114
+ markdown: string | null;
3115
+ slug: string;
3116
+ slug_prefix: string | null;
3117
+ type: "post" | "page" | "block";
3118
+ status: "draft" | "publish" | "private" | "trash" | "scheduled";
3119
+ author: string | null;
3120
+ custom: Record<string, unknown> | null;
3121
+ featured_image?: string | null;
3122
+ scheduled_at: string | null;
3123
+ published_at: string;
3124
+ updated_at: string;
3125
+ }
3126
+ interface V2ContentCreateParams {
3127
+ title: string;
3128
+ content: string;
3129
+ markdown?: string;
3130
+ custom?: Record<string, unknown>;
3131
+ slug?: string;
3132
+ slug_prefix?: string;
3133
+ published_at?: string;
3134
+ scheduled_at?: string | null;
3135
+ status?: "draft" | "publish" | "private" | "trash" | "scheduled";
3136
+ type?: "post" | "page" | "block";
3137
+ }
3138
+ interface V2ContentUpdateParams extends Partial<V2ContentCreateParams> {
3139
+ }
3140
+ interface V2ContentListParams extends V2PaginationParams {
3141
+ status?: "draft" | "publish" | "private" | "trash" | "scheduled";
3142
+ type?: "post" | "page" | "block";
3143
+ search?: string;
3144
+ slug_prefix?: string;
3145
+ }
3146
+ interface V2Product extends V2Object {
3147
+ object: "product";
3148
+ name: string;
3149
+ description: string | null;
3150
+ excerpt: string | null;
3151
+ meta_description: string | null;
3152
+ price: number;
3153
+ unit_amount: number;
3154
+ currency: string;
3155
+ sku: string | null;
3156
+ slug: string | null;
3157
+ slug_prefix: string | null;
3158
+ published: boolean;
3159
+ stock_quantity: number | null;
3160
+ custom: Record<string, unknown> | null;
3161
+ recurring: {
3162
+ interval: string;
3163
+ interval_count?: number;
3164
+ } | null;
3165
+ tax_behavior: "inclusive" | "exclusive" | "unspecified" | null;
3166
+ category_id: string | null;
3167
+ created_at: string | null;
3168
+ updated_at: string | null;
3169
+ }
3170
+ interface V2ProductCreateParams {
3171
+ name: string;
3172
+ description?: string;
3173
+ excerpt?: string;
3174
+ meta_description?: string;
3175
+ category_id?: string;
3176
+ price: number;
3177
+ unit_amount: number;
3178
+ currency?: string;
3179
+ sku?: string;
3180
+ custom?: Record<string, unknown>;
3181
+ slug?: string;
3182
+ slug_prefix?: string;
3183
+ published?: boolean;
3184
+ stock_quantity?: number | null;
3185
+ recurring?: {
3186
+ interval: "day" | "week" | "month" | "year";
3187
+ interval_count?: number;
3188
+ };
3189
+ tax_behavior?: "inclusive" | "exclusive" | "unspecified";
3190
+ attachment_ids?: number[];
3191
+ }
3192
+ interface V2ProductUpdateParams extends Partial<V2ProductCreateParams> {
3193
+ }
3194
+ interface V2ProductListParams extends V2PaginationParams {
3195
+ published?: boolean;
3196
+ category_id?: string;
3197
+ search?: string;
3198
+ slug_prefix?: string;
3199
+ }
3200
+ interface V2Category extends V2Object {
3201
+ object: "category";
3202
+ name: string;
3203
+ description: string | null;
3204
+ slug: string | null;
3205
+ slug_prefix: string | null;
3206
+ parent_id: string | null;
3207
+ type: "post" | "product" | null;
3208
+ created_at: string | null;
3209
+ updated_at: string | null;
3210
+ }
3211
+ interface V2CategoryCreateParams {
3212
+ name: string;
3213
+ description?: string;
3214
+ slug?: string;
3215
+ slug_prefix?: string;
3216
+ parent_id?: string;
3217
+ type?: "post" | "product";
3218
+ }
3219
+ interface V2CategoryUpdateParams extends Partial<V2CategoryCreateParams> {
3220
+ }
3221
+ interface V2Collection extends V2Object {
3222
+ object: "collection";
3223
+ name: string;
3224
+ description: string | null;
3225
+ available_from: string | null;
3226
+ available_until: string | null;
3227
+ published: boolean;
3228
+ created_at: string | null;
3229
+ updated_at: string | null;
3230
+ }
3231
+ interface V2CollectionItem extends V2Object {
3232
+ object: "collection_item";
3233
+ collection_id: string;
3234
+ product_id: string;
3235
+ max_quantity: number | null;
3236
+ position: number;
3237
+ }
3238
+ interface V2CollectionCreateParams {
3239
+ name: string;
3240
+ description?: string | null;
3241
+ available_from?: string | null;
3242
+ available_until?: string | null;
3243
+ published?: boolean;
3244
+ }
3245
+ interface V2CollectionUpdateParams extends Partial<V2CollectionCreateParams> {
3246
+ }
3247
+ interface V2Order extends V2Object {
3248
+ object: "checkout_session";
3249
+ customer_email: string;
3250
+ customer_name: string | null;
3251
+ customer_phone: string | null;
3252
+ customer_details: Record<string, unknown> | null;
3253
+ shipping_details: Record<string, unknown> | null;
3254
+ order_id: string | null;
3255
+ line_items: unknown[] | null;
3256
+ amount_total: number;
3257
+ currency: string;
3258
+ tax_summary: Record<string, unknown> | null;
3259
+ status: string;
3260
+ payment_status: string | null;
3261
+ fulfillment_status: string | null;
3262
+ tracking_number: string | null;
3263
+ notes: string | null;
3264
+ live_mode: boolean;
3265
+ metadata: Record<string, unknown> | null;
3266
+ created_at: string;
3267
+ completed_at: string | null;
3268
+ expires_at: string | null;
3269
+ }
3270
+ interface V2OrderListParams extends V2PaginationParams {
3271
+ status?: string;
3272
+ customer_email?: string;
3273
+ date_from?: string;
3274
+ date_to?: string;
3275
+ }
3276
+ interface V2SiteUser extends V2Object {
3277
+ object: "site_user";
3278
+ email: string;
3279
+ email_verified: boolean;
3280
+ first_name: string | null;
3281
+ last_name: string | null;
3282
+ avatar_url: string | null;
3283
+ status: string;
3284
+ waitlist: boolean;
3285
+ metadata: Record<string, unknown> | null;
3286
+ created_at: string | null;
3287
+ updated_at: string | null;
3288
+ last_login_at: string | null;
3289
+ }
3290
+ interface V2SiteUserUpdateParams {
3291
+ first_name?: string;
3292
+ last_name?: string;
3293
+ avatar_url?: string;
3294
+ status?: "active" | "suspended" | "pending_verification";
3295
+ metadata?: Record<string, unknown>;
3296
+ }
3297
+ interface V2SiteUserListParams extends V2PaginationParams {
3298
+ status?: "active" | "suspended" | "pending_verification";
3299
+ email?: string;
3300
+ }
3301
+ interface V2NewsletterSubscription extends V2Object {
3302
+ object: "newsletter_subscription";
3303
+ email: string;
3304
+ name: string | null;
3305
+ status: string;
3306
+ double_opt_in: boolean;
3307
+ confirmed_at: string | null;
3308
+ source: string | null;
3309
+ frequency: string | null;
3310
+ topics: string[] | null;
3311
+ language: string | null;
3312
+ tags: string[] | null;
3313
+ custom_fields: Record<string, unknown> | null;
3314
+ unsubscribed_at: string | null;
3315
+ created_at: string | null;
3316
+ updated_at: string | null;
3317
+ }
3318
+ interface V2NewsletterList extends V2Object {
3319
+ object: "newsletter_list";
3320
+ name: string;
3321
+ slug: string;
3322
+ description: string | null;
3323
+ is_default: boolean;
3324
+ subscriber_count: number;
3325
+ created_at: string | null;
3326
+ updated_at: string | null;
3327
+ }
3328
+ interface V2NewsletterCampaign extends V2Object {
3329
+ object: "newsletter_campaign";
3330
+ name: string;
3331
+ slug: string | null;
3332
+ subject: string;
3333
+ preview_text: string | null;
3334
+ status: string;
3335
+ sent_at: string | null;
3336
+ completed_at: string | null;
3337
+ total_recipients: number;
3338
+ sent_count: number;
3339
+ opened_count: number;
3340
+ clicked_count: number;
3341
+ created_at: string | null;
3342
+ updated_at: string | null;
3343
+ }
3344
+ interface V2ContactSubmission extends V2Object {
3345
+ object: "contact_submission";
3346
+ name: string | null;
3347
+ first_name: string | null;
3348
+ last_name: string | null;
3349
+ email: string;
3350
+ subject: string | null;
3351
+ message: string;
3352
+ phone: string | null;
3353
+ company: string | null;
3354
+ status: string;
3355
+ metadata: Record<string, unknown> | null;
3356
+ created_at: string | null;
3357
+ processed_at: string | null;
3358
+ }
3359
+ interface V2Organization extends V2Object {
3360
+ object: "organization";
3361
+ name: string;
3362
+ slug: string | null;
3363
+ endpoint_status: string | null;
3364
+ endpoint_url: string | null;
3365
+ created_at: string | null;
3366
+ updated_at: string | null;
3367
+ }
3368
+ interface V2Site extends V2Object {
3369
+ object: "site";
3370
+ name: string;
3371
+ title: string | null;
3372
+ description: string | null;
3373
+ domain: string | null;
3374
+ custom_domain: string | null;
3375
+ organization_id: string | null;
3376
+ tax_enabled: boolean;
3377
+ lifecycle_status: string | null;
3378
+ created_at: string | null;
3379
+ updated_at: string | null;
3380
+ }
3381
+ interface V2ApiKey extends V2Object {
3382
+ object: "api_key";
3383
+ name: string;
3384
+ description: string | null;
3385
+ organization_id: string | null;
3386
+ site_name: string | null;
3387
+ permissions: string[] | null;
3388
+ is_active: boolean;
3389
+ expires_at: string | null;
3390
+ last_used_at: string | null;
3391
+ created_at: string | null;
3392
+ updated_at: string | null;
3393
+ }
3394
+ interface V2Webhook extends V2Object {
3395
+ object: "webhook";
3396
+ url: string;
3397
+ description: string | null;
3398
+ events: string[] | null;
3399
+ is_active: boolean;
3400
+ created_at: string | null;
3401
+ updated_at: string | null;
3402
+ }
3403
+ interface V2WebhookCreateParams {
3404
+ url: string;
3405
+ description?: string;
3406
+ events?: string[];
3407
+ is_active?: boolean;
3408
+ }
3409
+ interface V2WebhookUpdateParams extends Partial<V2WebhookCreateParams> {
3410
+ }
3411
+
3412
+ /**
3413
+ * v2 Base Client — cursor pagination, expand support, typed errors.
3414
+ */
3415
+
3416
+ declare class PerspectV2Error extends Error {
3417
+ readonly type: string;
3418
+ readonly code: string;
3419
+ readonly param?: string;
3420
+ readonly status: number;
3421
+ constructor(error: V2Error['error'], status: number);
3422
+ }
3423
+ declare abstract class BaseV2Client {
3424
+ protected http: HttpClient;
3425
+ protected basePath: string;
3426
+ constructor(http: HttpClient, basePath: string);
3427
+ protected buildPath(endpoint: string): string;
3428
+ protected sitePath(siteName: string, resource: string, suffix?: string): string;
3429
+ private toParams;
3430
+ /** GET a single resource. */
3431
+ protected getOne<T>(path: string, params?: object): Promise<T>;
3432
+ /** GET a list of resources with cursor pagination. */
3433
+ protected getList<T>(path: string, params?: object): Promise<V2List<T>>;
3434
+ /** POST to create a resource. */
3435
+ protected post<T>(path: string, body?: unknown): Promise<T>;
3436
+ /** PATCH to update a resource. */
3437
+ protected patchOne<T>(path: string, body?: unknown): Promise<T>;
3438
+ /** DELETE a resource. */
3439
+ protected deleteOne(path: string): Promise<V2Deleted>;
3440
+ /**
3441
+ * Auto-paginating async generator.
3442
+ * Yields every item across all pages.
3443
+ *
3444
+ * Usage:
3445
+ * for await (const item of client.listAutoPaginate(path, params)) { ... }
3446
+ */
3447
+ protected listAutoPaginate<T extends {
3448
+ id: string;
3449
+ }>(path: string, params?: object): AsyncGenerator<T, void, unknown>;
3450
+ private toError;
3451
+ }
3452
+
3453
+ /**
3454
+ * v2 Content Client
3455
+ */
3456
+
3457
+ declare class ContentV2Client extends BaseV2Client {
3458
+ list(siteName: string, params?: V2ContentListParams): Promise<V2List<V2Content>>;
3459
+ listAutoPaginated(siteName: string, params?: Omit<V2ContentListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Content, void, unknown>;
3460
+ get(siteName: string, idOrSlug: string): Promise<V2Content>;
3461
+ create(siteName: string, data: V2ContentCreateParams): Promise<V2Content>;
3462
+ update(siteName: string, id: string, data: V2ContentUpdateParams): Promise<V2Content>;
3463
+ del(siteName: string, id: string): Promise<V2Deleted>;
3464
+ publish(siteName: string, id: string): Promise<V2Content>;
3465
+ unpublish(siteName: string, id: string): Promise<V2Content>;
3466
+ }
3467
+
3468
+ /**
3469
+ * v2 Products Client
3470
+ */
3471
+
3472
+ declare class ProductsV2Client extends BaseV2Client {
3473
+ list(siteName: string, params?: V2ProductListParams): Promise<V2List<V2Product>>;
3474
+ listAutoPaginated(siteName: string, params?: Omit<V2ProductListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Product, void, unknown>;
3475
+ get(siteName: string, idOrSlug: string): Promise<V2Product>;
3476
+ create(siteName: string, data: V2ProductCreateParams): Promise<V2Product>;
3477
+ update(siteName: string, id: string, data: V2ProductUpdateParams): Promise<V2Product>;
3478
+ del(siteName: string, id: string): Promise<V2Deleted>;
3479
+ }
3480
+
3481
+ /**
3482
+ * v2 Categories Client
3483
+ */
3484
+
3485
+ declare class CategoriesV2Client extends BaseV2Client {
3486
+ list(siteName: string, params?: V2PaginationParams & {
3487
+ type?: string;
3488
+ }): Promise<V2List<V2Category>>;
3489
+ get(siteName: string, id: string): Promise<V2Category>;
3490
+ create(siteName: string, data: V2CategoryCreateParams): Promise<V2Category>;
3491
+ update(siteName: string, id: string, data: V2CategoryUpdateParams): Promise<V2Category>;
3492
+ del(siteName: string, id: string): Promise<V2Deleted>;
3493
+ }
3494
+
3495
+ /**
3496
+ * v2 Collections Client
3497
+ */
3498
+
3499
+ declare class CollectionsV2Client extends BaseV2Client {
3500
+ list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Collection>>;
3501
+ getCurrent(siteName: string): Promise<V2Collection | null>;
3502
+ get(siteName: string, id: string): Promise<V2Collection>;
3503
+ create(siteName: string, data: V2CollectionCreateParams): Promise<V2Collection>;
3504
+ update(siteName: string, id: string, data: V2CollectionUpdateParams): Promise<V2Collection>;
3505
+ del(siteName: string, id: string): Promise<V2Deleted>;
3506
+ listItems(siteName: string, collectionId: string): Promise<V2List<V2CollectionItem>>;
3507
+ addItem(siteName: string, collectionId: string, data: {
3508
+ product_id: string;
3509
+ max_quantity?: number | null;
3510
+ position?: number;
3511
+ }): Promise<V2CollectionItem>;
3512
+ removeItem(siteName: string, collectionId: string, itemId: string): Promise<V2Deleted>;
3513
+ }
3514
+
3515
+ /**
3516
+ * v2 Orders Client (checkout sessions)
3517
+ */
3518
+
3519
+ declare class OrdersV2Client extends BaseV2Client {
3520
+ list(siteName: string, params?: V2OrderListParams): Promise<V2List<V2Order>>;
3521
+ listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2Order, void, unknown>;
3522
+ get(siteName: string, id: string): Promise<V2Order>;
3523
+ }
3524
+
3525
+ /**
3526
+ * v2 Site Users Client
3527
+ */
3528
+
3529
+ interface V2OtpRequestResponse {
3530
+ object: 'otp_request';
3531
+ email: string;
3532
+ expires_in: number;
3533
+ }
3534
+ interface V2OtpVerifyResponse extends V2SiteUser {
3535
+ token: string;
3536
+ }
3537
+ declare class SiteUsersV2Client extends BaseV2Client {
3538
+ requestOtp(siteName: string, data: {
3539
+ email: string;
3540
+ waitlist?: boolean;
3541
+ metadata?: Record<string, unknown>;
3542
+ }): Promise<V2OtpRequestResponse>;
3543
+ verifyOtp(siteName: string, data: {
3544
+ email: string;
3545
+ code: string;
3546
+ }): Promise<V2OtpVerifyResponse>;
3547
+ list(siteName: string, params?: V2SiteUserListParams): Promise<V2List<V2SiteUser>>;
3548
+ listAutoPaginated(siteName: string, params?: Omit<V2SiteUserListParams, 'starting_after' | 'ending_before'>): AsyncGenerator<V2SiteUser, void, unknown>;
3549
+ get(siteName: string, id: string): Promise<V2SiteUser>;
3550
+ update(siteName: string, id: string, data: V2SiteUserUpdateParams): Promise<V2SiteUser>;
3551
+ }
3552
+
3553
+ /**
3554
+ * v2 Newsletter Client
3555
+ */
3556
+
3557
+ declare class NewsletterV2Client extends BaseV2Client {
3558
+ subscribe(siteName: string, data: {
3559
+ email: string;
3560
+ name?: string;
3561
+ list_ids?: string[];
3562
+ double_opt_in?: boolean;
3563
+ source?: string;
3564
+ source_url?: string;
3565
+ frequency?: 'instant' | 'daily' | 'weekly' | 'monthly';
3566
+ topics?: string[];
3567
+ language?: string;
3568
+ metadata?: Record<string, unknown>;
3569
+ }): Promise<V2NewsletterSubscription>;
3570
+ confirm(siteName: string, token: string): Promise<V2NewsletterSubscription>;
3571
+ unsubscribe(siteName: string, data: {
3572
+ token?: string;
3573
+ email?: string;
3574
+ reason?: string;
3575
+ }): Promise<V2NewsletterSubscription>;
3576
+ listSubscriptions(siteName: string, params?: V2PaginationParams & {
3577
+ status?: string;
3578
+ }): Promise<V2List<V2NewsletterSubscription>>;
3579
+ getSubscription(siteName: string, id: string): Promise<V2NewsletterSubscription>;
3580
+ listLists(siteName: string): Promise<V2List<V2NewsletterList>>;
3581
+ listCampaigns(siteName: string, params?: V2PaginationParams & {
3582
+ status?: string;
3583
+ }): Promise<V2List<V2NewsletterCampaign>>;
3584
+ getCampaign(siteName: string, idOrSlug: string): Promise<V2NewsletterCampaign>;
3585
+ }
3586
+
3587
+ /**
3588
+ * v2 Contacts Client
3589
+ */
3590
+
3591
+ declare class ContactsV2Client extends BaseV2Client {
3592
+ submit(siteName: string, data: {
3593
+ email: string;
3594
+ message: string;
3595
+ name?: string;
3596
+ first_name?: string;
3597
+ last_name?: string;
3598
+ subject?: string;
3599
+ phone?: string;
3600
+ company?: string;
3601
+ metadata?: Record<string, unknown>;
3602
+ }): Promise<V2ContactSubmission>;
3603
+ list(siteName: string, params?: V2PaginationParams & {
3604
+ status?: string;
3605
+ }): Promise<V2List<V2ContactSubmission>>;
3606
+ get(siteName: string, id: string): Promise<V2ContactSubmission>;
3607
+ }
3608
+
3609
+ /**
3610
+ * v2 Organizations Client
3611
+ */
3612
+
3613
+ declare class OrganizationsV2Client extends BaseV2Client {
3614
+ list(): Promise<V2List<V2Organization>>;
3615
+ get(id: string): Promise<V2Organization>;
3616
+ }
3617
+
3618
+ /**
3619
+ * v2 Sites Client
3620
+ */
3621
+
3622
+ declare class SitesV2Client extends BaseV2Client {
3623
+ list(params?: V2PaginationParams): Promise<V2List<V2Site>>;
3624
+ get(name: string): Promise<V2Site>;
3625
+ }
3626
+
3627
+ /**
3628
+ * v2 API Keys Client
3629
+ */
3630
+
3631
+ declare class ApiKeysV2Client extends BaseV2Client {
3632
+ list(params?: V2PaginationParams): Promise<V2List<V2ApiKey>>;
3633
+ get(id: string): Promise<V2ApiKey>;
3634
+ del(id: string): Promise<V2Deleted>;
3635
+ }
3636
+
3637
+ /**
3638
+ * v2 Webhooks Client
3639
+ */
3640
+
3641
+ declare class WebhooksV2Client extends BaseV2Client {
3642
+ list(siteName: string, params?: V2PaginationParams): Promise<V2List<V2Webhook>>;
3643
+ get(siteName: string, id: string): Promise<V2Webhook>;
3644
+ create(siteName: string, data: V2WebhookCreateParams): Promise<V2Webhook>;
3645
+ update(siteName: string, id: string, data: V2WebhookUpdateParams): Promise<V2Webhook>;
3646
+ del(siteName: string, id: string): Promise<V2Deleted>;
3647
+ }
3648
+
3649
+ /**
3650
+ * PerspectAPI v2 SDK Client
3651
+ *
3652
+ * Stripe-style API with consistent envelopes, prefixed IDs,
3653
+ * cursor pagination, and snake_case responses.
3654
+ *
3655
+ * Usage:
3656
+ * import { PerspectApiV2Client } from 'perspectapi-ts-sdk/v2';
3657
+ * const client = new PerspectApiV2Client({ baseUrl: '...', apiKey: '...' });
3658
+ * const posts = await client.content.list('mysite', { type: 'post', limit: 10 });
3659
+ */
3660
+
3661
+ declare class PerspectApiV2Client {
3662
+ private http;
3663
+ readonly content: ContentV2Client;
3664
+ readonly products: ProductsV2Client;
3665
+ readonly categories: CategoriesV2Client;
3666
+ readonly collections: CollectionsV2Client;
3667
+ readonly orders: OrdersV2Client;
3668
+ readonly siteUsers: SiteUsersV2Client;
3669
+ readonly newsletter: NewsletterV2Client;
3670
+ readonly contacts: ContactsV2Client;
3671
+ readonly organizations: OrganizationsV2Client;
3672
+ readonly sites: SitesV2Client;
3673
+ readonly apiKeys: ApiKeysV2Client;
3674
+ readonly webhooks: WebhooksV2Client;
3675
+ constructor(config: PerspectApiConfig);
3676
+ /** Update the JWT token for authenticated requests. */
3677
+ setAuth(jwt: string): void;
3678
+ /** Update the API key. */
3679
+ setApiKey(apiKey: string): void;
3680
+ /** Clear authentication. */
3681
+ clearAuth(): void;
3682
+ }
3683
+ declare function createPerspectApiV2Client(config: PerspectApiConfig): PerspectApiV2Client;
3684
+
2804
3685
  /**
2805
3686
  * Simple in-memory cache adapter primarily suited for development and testing.
2806
3687
  */
@@ -3119,4 +4000,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
3119
4000
  error: string;
3120
4001
  }>;
3121
4002
 
3122
- export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, type ProductSku, type ProductSkuMediaItem, type ProductSkuOption, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
4003
+ export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, type CancelSubscriptionRequest, type CancelSubscriptionResponse, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateProductSkuRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, type NewsletterCampaignDetail, type NewsletterCampaignListResponse, type NewsletterCampaignSummary, type NewsletterCampaignTestSendRequest, type NewsletterCampaignTestSendResponse, NewsletterClient, type NewsletterConfirmResponse, type NewsletterExportCreateRequest, type NewsletterExportCreateResponse, type NewsletterList, type NewsletterManagementCampaign, type NewsletterManagementCampaignListResponse, NewsletterManagementClient, type NewsletterManagementList, type NewsletterManagementListMembership, type NewsletterManagementPagination, type NewsletterManagementSeries, type NewsletterManagementStatsResponse, type NewsletterManagementSubscription, type NewsletterManagementSubscriptionsListResponse, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterSubscriptionImportRowRequest, type NewsletterSubscriptionMembershipUpdateRequest, type NewsletterSubscriptionSyncRequest, type NewsletterSubscriptionSyncResponse, type NewsletterSubscriptionsBulkAction, type NewsletterSubscriptionsBulkOutcome, type NewsletterSubscriptionsBulkUpdateRequest, type NewsletterSubscriptionsBulkUpdateResponse, type NewsletterSubscriptionsImportRequest, type NewsletterSubscriptionsImportResponse, type NewsletterSubscriptionsImportRowResult, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, PerspectApiV2Client, PerspectV2Error, type Product, type ProductBundleGroup, type ProductQueryParams, type ProductSku, type ProductSkuMediaItem, type ProductSkuOption, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type SubscriptionCancellationMode, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, createPerspectApiV2Client, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };