@sendly/node 3.12.3 → 3.13.1

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.mts CHANGED
@@ -1075,6 +1075,362 @@ interface ValidateSessionTokenResponse {
1075
1075
  verifiedAt?: string;
1076
1076
  metadata?: Record<string, unknown>;
1077
1077
  }
1078
+ /**
1079
+ * Campaign status values
1080
+ */
1081
+ type CampaignStatus = "draft" | "scheduled" | "sending" | "sent" | "paused" | "cancelled" | "failed";
1082
+ /**
1083
+ * A bulk SMS campaign
1084
+ */
1085
+ interface Campaign {
1086
+ /** Unique campaign identifier */
1087
+ id: string;
1088
+ /** Campaign name */
1089
+ name: string;
1090
+ /** Message text with optional {{variables}} */
1091
+ text: string;
1092
+ /** Template ID if using a template */
1093
+ templateId?: string | null;
1094
+ /** Contact list IDs to send to */
1095
+ contactListIds: string[];
1096
+ /** Current status */
1097
+ status: CampaignStatus;
1098
+ /** Total recipients */
1099
+ recipientCount: number;
1100
+ /** Messages sent so far */
1101
+ sentCount: number;
1102
+ /** Messages delivered */
1103
+ deliveredCount: number;
1104
+ /** Messages failed */
1105
+ failedCount: number;
1106
+ /** Estimated credits needed */
1107
+ estimatedCredits: number;
1108
+ /** Credits actually used */
1109
+ creditsUsed: number;
1110
+ /** Scheduled send time (ISO string) */
1111
+ scheduledAt?: string | null;
1112
+ /** Timezone for scheduled send */
1113
+ timezone?: string | null;
1114
+ /** When campaign started sending */
1115
+ startedAt?: string | null;
1116
+ /** When campaign finished */
1117
+ completedAt?: string | null;
1118
+ /** Creation timestamp */
1119
+ createdAt: string;
1120
+ /** Last update timestamp */
1121
+ updatedAt: string;
1122
+ }
1123
+ /**
1124
+ * Request to create a new campaign
1125
+ */
1126
+ interface CreateCampaignRequest {
1127
+ /** Campaign name */
1128
+ name: string;
1129
+ /** Message text with optional {{variables}} */
1130
+ text: string;
1131
+ /** Template ID to use (optional) */
1132
+ templateId?: string;
1133
+ /** Contact list IDs to send to */
1134
+ contactListIds: string[];
1135
+ }
1136
+ /**
1137
+ * Request to update a campaign
1138
+ */
1139
+ interface UpdateCampaignRequest {
1140
+ /** Campaign name */
1141
+ name?: string;
1142
+ /** Message text */
1143
+ text?: string;
1144
+ /** Template ID */
1145
+ templateId?: string | null;
1146
+ /** Contact list IDs */
1147
+ contactListIds?: string[];
1148
+ }
1149
+ /**
1150
+ * Request to schedule a campaign
1151
+ */
1152
+ interface ScheduleCampaignRequest {
1153
+ /** When to send (ISO 8601 string) */
1154
+ scheduledAt: string;
1155
+ /** Timezone (e.g., "America/New_York") */
1156
+ timezone?: string;
1157
+ }
1158
+ /**
1159
+ * Campaign preview with recipient count and cost estimate
1160
+ */
1161
+ interface CampaignPreview {
1162
+ /** Campaign ID */
1163
+ id: string;
1164
+ /** Total recipients */
1165
+ recipientCount: number;
1166
+ /** Estimated segments (based on message length) */
1167
+ estimatedSegments: number;
1168
+ /** Estimated credits needed */
1169
+ estimatedCredits: number;
1170
+ /** Current credit balance */
1171
+ currentBalance: number;
1172
+ /** Whether user has enough credits */
1173
+ hasEnoughCredits: boolean;
1174
+ /** Breakdown by country/pricing tier */
1175
+ breakdown?: Array<{
1176
+ country: string;
1177
+ count: number;
1178
+ creditsPerMessage: number;
1179
+ totalCredits: number;
1180
+ }>;
1181
+ /** Number of recipients blocked due to destination restrictions */
1182
+ blockedCount?: number;
1183
+ /** Number of recipients that can be reached */
1184
+ sendableCount?: number;
1185
+ /** Per-country breakdown with access info */
1186
+ byCountry?: Record<string, {
1187
+ count: number;
1188
+ credits: number;
1189
+ allowed: boolean;
1190
+ blockedReason?: string;
1191
+ }>;
1192
+ /** Validation warnings */
1193
+ warnings?: string[];
1194
+ /** User's messaging profile access info */
1195
+ messagingProfile?: {
1196
+ canSendDomestic: boolean;
1197
+ canSendInternational: boolean;
1198
+ verificationType: string | null;
1199
+ verificationStatus: string | null;
1200
+ };
1201
+ }
1202
+ /**
1203
+ * Options for listing campaigns
1204
+ */
1205
+ interface ListCampaignsOptions {
1206
+ /** Maximum campaigns to return */
1207
+ limit?: number;
1208
+ /** Offset for pagination */
1209
+ offset?: number;
1210
+ /** Filter by status */
1211
+ status?: CampaignStatus;
1212
+ }
1213
+ /**
1214
+ * Response from listing campaigns
1215
+ */
1216
+ interface CampaignListResponse {
1217
+ /** List of campaigns */
1218
+ campaigns: Campaign[];
1219
+ /** Total count (for pagination) */
1220
+ total: number;
1221
+ /** Current limit */
1222
+ limit: number;
1223
+ /** Current offset */
1224
+ offset: number;
1225
+ }
1226
+ /**
1227
+ * A contact in your address book
1228
+ */
1229
+ interface Contact {
1230
+ /**
1231
+ * Unique contact identifier
1232
+ */
1233
+ id: string;
1234
+ /**
1235
+ * Phone number in E.164 format
1236
+ */
1237
+ phoneNumber: string;
1238
+ /**
1239
+ * Contact name
1240
+ */
1241
+ name?: string | null;
1242
+ /**
1243
+ * Contact email
1244
+ */
1245
+ email?: string | null;
1246
+ /**
1247
+ * Custom metadata (key-value pairs)
1248
+ */
1249
+ metadata?: Record<string, any>;
1250
+ /**
1251
+ * Whether the contact has opted out
1252
+ */
1253
+ optedOut?: boolean;
1254
+ /**
1255
+ * When the contact was created
1256
+ */
1257
+ createdAt: string;
1258
+ /**
1259
+ * When the contact was last updated
1260
+ */
1261
+ updatedAt?: string;
1262
+ /**
1263
+ * Lists the contact belongs to (when fetching a single contact)
1264
+ */
1265
+ lists?: Array<{
1266
+ id: string;
1267
+ name: string;
1268
+ }>;
1269
+ }
1270
+ /**
1271
+ * Request to create a contact
1272
+ */
1273
+ interface CreateContactRequest {
1274
+ /**
1275
+ * Phone number in E.164 format (e.g., +15551234567)
1276
+ */
1277
+ phoneNumber: string;
1278
+ /**
1279
+ * Contact name
1280
+ */
1281
+ name?: string;
1282
+ /**
1283
+ * Contact email
1284
+ */
1285
+ email?: string;
1286
+ /**
1287
+ * Custom metadata
1288
+ */
1289
+ metadata?: Record<string, any>;
1290
+ }
1291
+ /**
1292
+ * Request to update a contact
1293
+ */
1294
+ interface UpdateContactRequest {
1295
+ /**
1296
+ * Contact name
1297
+ */
1298
+ name?: string;
1299
+ /**
1300
+ * Contact email
1301
+ */
1302
+ email?: string;
1303
+ /**
1304
+ * Custom metadata
1305
+ */
1306
+ metadata?: Record<string, any>;
1307
+ }
1308
+ /**
1309
+ * Options for listing contacts
1310
+ */
1311
+ interface ListContactsOptions {
1312
+ /**
1313
+ * Max contacts to return (default 50, max 100)
1314
+ */
1315
+ limit?: number;
1316
+ /**
1317
+ * Offset for pagination
1318
+ */
1319
+ offset?: number;
1320
+ /**
1321
+ * Search query (searches name, phone, email)
1322
+ */
1323
+ search?: string;
1324
+ /**
1325
+ * Filter by contact list ID
1326
+ */
1327
+ listId?: string;
1328
+ }
1329
+ /**
1330
+ * Response from listing contacts
1331
+ */
1332
+ interface ContactListResponse {
1333
+ contacts: Contact[];
1334
+ total: number;
1335
+ limit: number;
1336
+ offset: number;
1337
+ }
1338
+ /**
1339
+ * A contact list for organizing contacts
1340
+ */
1341
+ interface ContactList {
1342
+ /**
1343
+ * Unique list identifier
1344
+ */
1345
+ id: string;
1346
+ /**
1347
+ * List name
1348
+ */
1349
+ name: string;
1350
+ /**
1351
+ * List description
1352
+ */
1353
+ description?: string | null;
1354
+ /**
1355
+ * Number of contacts in the list
1356
+ */
1357
+ contactCount: number;
1358
+ /**
1359
+ * When the list was created
1360
+ */
1361
+ createdAt: string;
1362
+ /**
1363
+ * When the list was last updated
1364
+ */
1365
+ updatedAt?: string;
1366
+ /**
1367
+ * Contacts in the list (when fetching a single list with members)
1368
+ */
1369
+ contacts?: Array<{
1370
+ id: string;
1371
+ phoneNumber: string;
1372
+ name?: string | null;
1373
+ email?: string | null;
1374
+ }>;
1375
+ /**
1376
+ * Total contacts in the list (for pagination)
1377
+ */
1378
+ contactsTotal?: number;
1379
+ }
1380
+ /**
1381
+ * Request to create a contact list
1382
+ */
1383
+ interface CreateContactListRequest {
1384
+ /**
1385
+ * List name
1386
+ */
1387
+ name: string;
1388
+ /**
1389
+ * List description
1390
+ */
1391
+ description?: string;
1392
+ }
1393
+ /**
1394
+ * Request to update a contact list
1395
+ */
1396
+ interface UpdateContactListRequest {
1397
+ /**
1398
+ * List name
1399
+ */
1400
+ name?: string;
1401
+ /**
1402
+ * List description
1403
+ */
1404
+ description?: string;
1405
+ }
1406
+ /**
1407
+ * Response from listing contact lists
1408
+ */
1409
+ interface ContactListsResponse {
1410
+ lists: ContactList[];
1411
+ }
1412
+ interface ImportContactItem {
1413
+ phone: string;
1414
+ name?: string;
1415
+ email?: string;
1416
+ optedInAt?: string;
1417
+ }
1418
+ interface ImportContactsRequest {
1419
+ contacts: ImportContactItem[];
1420
+ listId?: string;
1421
+ optedInAt?: string;
1422
+ }
1423
+ interface ImportContactsError {
1424
+ index: number;
1425
+ phone: string;
1426
+ error: string;
1427
+ }
1428
+ interface ImportContactsResponse {
1429
+ imported: number;
1430
+ skippedDuplicates: number;
1431
+ errors: ImportContactsError[];
1432
+ totalErrors: number;
1433
+ }
1078
1434
 
1079
1435
  /**
1080
1436
  * HTTP Client Utility
@@ -1765,6 +2121,48 @@ declare class AccountResource {
1765
2121
  * ```
1766
2122
  */
1767
2123
  revokeApiKey(id: string): Promise<void>;
2124
+ /**
2125
+ * Rename an API key
2126
+ *
2127
+ * @param id - API key ID
2128
+ * @param name - New name for the API key
2129
+ * @returns Updated API key
2130
+ *
2131
+ * @example
2132
+ * ```typescript
2133
+ * const key = await sendly.account.renameApiKey('key_xxx', 'Production Key');
2134
+ * console.log(`Renamed to: ${key.name}`);
2135
+ * ```
2136
+ */
2137
+ renameApiKey(id: string, name: string): Promise<ApiKey>;
2138
+ /**
2139
+ * Rotate an API key
2140
+ *
2141
+ * Creates a new key while optionally keeping the old one active for a grace period.
2142
+ *
2143
+ * @param id - API key ID to rotate
2144
+ * @param options - Rotation options
2145
+ * @returns New API key with the full key value
2146
+ *
2147
+ * @example
2148
+ * ```typescript
2149
+ * // Rotate immediately (old key stops working instantly)
2150
+ * const { newKey, key } = await sendly.account.rotateApiKey('key_xxx');
2151
+ * console.log(`New key: ${key}`); // Save this!
2152
+ *
2153
+ * // Rotate with 24-hour grace period (both keys work for 24h)
2154
+ * const { newKey, key } = await sendly.account.rotateApiKey('key_xxx', {
2155
+ * gracePeriodHours: 24
2156
+ * });
2157
+ * ```
2158
+ */
2159
+ rotateApiKey(id: string, options?: {
2160
+ gracePeriodHours?: number;
2161
+ }): Promise<{
2162
+ newKey: ApiKey;
2163
+ key: string;
2164
+ oldKeyExpiresAt?: string;
2165
+ }>;
1768
2166
  }
1769
2167
 
1770
2168
  /**
@@ -2045,9 +2443,457 @@ declare class TemplatesResource {
2045
2443
  * ```
2046
2444
  */
2047
2445
  delete(id: string): Promise<void>;
2446
+ /**
2447
+ * Clone a template
2448
+ *
2449
+ * Creates a copy of an existing template (including presets).
2450
+ *
2451
+ * @param id - Template ID to clone
2452
+ * @param options - Optional clone options
2453
+ * @returns The cloned template (as draft)
2454
+ *
2455
+ * @example
2456
+ * ```typescript
2457
+ * // Clone a preset template
2458
+ * const myOtp = await sendly.templates.clone('tpl_preset_otp', {
2459
+ * name: 'My Custom OTP'
2460
+ * });
2461
+ *
2462
+ * // Modify and publish
2463
+ * await sendly.templates.update(myOtp.id, {
2464
+ * text: 'Your {{app_name}} code: {{code}}. Expires in 5 min.'
2465
+ * });
2466
+ * await sendly.templates.publish(myOtp.id);
2467
+ * ```
2468
+ */
2469
+ clone(id: string, options?: {
2470
+ name?: string;
2471
+ }): Promise<Template>;
2048
2472
  private transformTemplate;
2049
2473
  }
2050
2474
 
2475
+ /**
2476
+ * Campaigns Resource - Bulk SMS Campaign Management
2477
+ * @packageDocumentation
2478
+ */
2479
+
2480
+ /**
2481
+ * Campaigns API resource for managing bulk SMS campaigns
2482
+ *
2483
+ * @example
2484
+ * ```typescript
2485
+ * // Create a campaign
2486
+ * const campaign = await sendly.campaigns.create({
2487
+ * name: 'Welcome Campaign',
2488
+ * text: 'Hello {{name}}, welcome to our service!',
2489
+ * contactListIds: ['lst_xxx']
2490
+ * });
2491
+ *
2492
+ * // Preview before sending
2493
+ * const preview = await sendly.campaigns.preview(campaign.id);
2494
+ * console.log(`Will send to ${preview.recipientCount} recipients`);
2495
+ * console.log(`Cost: ${preview.estimatedCredits} credits`);
2496
+ *
2497
+ * // Send immediately or schedule
2498
+ * await sendly.campaigns.send(campaign.id);
2499
+ * // or
2500
+ * await sendly.campaigns.schedule(campaign.id, {
2501
+ * scheduledAt: '2024-01-15T10:00:00Z',
2502
+ * timezone: 'America/New_York'
2503
+ * });
2504
+ * ```
2505
+ */
2506
+ declare class CampaignsResource {
2507
+ private readonly http;
2508
+ constructor(http: HttpClient);
2509
+ /**
2510
+ * Create a new campaign
2511
+ *
2512
+ * @param request - Campaign details
2513
+ * @returns The created campaign (as draft)
2514
+ *
2515
+ * @example
2516
+ * ```typescript
2517
+ * const campaign = await sendly.campaigns.create({
2518
+ * name: 'Black Friday Sale',
2519
+ * text: 'Hi {{name}}! 50% off everything today only. Shop now!',
2520
+ * contactListIds: ['lst_customers', 'lst_subscribers']
2521
+ * });
2522
+ * ```
2523
+ */
2524
+ create(request: CreateCampaignRequest): Promise<Campaign>;
2525
+ /**
2526
+ * List campaigns with optional filtering
2527
+ *
2528
+ * @param options - Filter and pagination options
2529
+ * @returns List of campaigns
2530
+ *
2531
+ * @example
2532
+ * ```typescript
2533
+ * // List all campaigns
2534
+ * const { campaigns } = await sendly.campaigns.list();
2535
+ *
2536
+ * // List only scheduled campaigns
2537
+ * const { campaigns } = await sendly.campaigns.list({ status: 'scheduled' });
2538
+ *
2539
+ * // Paginate
2540
+ * const { campaigns, total } = await sendly.campaigns.list({ limit: 10, offset: 20 });
2541
+ * ```
2542
+ */
2543
+ list(options?: ListCampaignsOptions): Promise<CampaignListResponse>;
2544
+ /**
2545
+ * Get a campaign by ID
2546
+ *
2547
+ * @param id - Campaign ID
2548
+ * @returns The campaign
2549
+ *
2550
+ * @example
2551
+ * ```typescript
2552
+ * const campaign = await sendly.campaigns.get('cmp_xxx');
2553
+ * console.log(`Status: ${campaign.status}`);
2554
+ * console.log(`Delivered: ${campaign.deliveredCount}/${campaign.recipientCount}`);
2555
+ * ```
2556
+ */
2557
+ get(id: string): Promise<Campaign>;
2558
+ /**
2559
+ * Update a campaign (draft or scheduled only)
2560
+ *
2561
+ * @param id - Campaign ID
2562
+ * @param request - Fields to update
2563
+ * @returns The updated campaign
2564
+ *
2565
+ * @example
2566
+ * ```typescript
2567
+ * const campaign = await sendly.campaigns.update('cmp_xxx', {
2568
+ * name: 'Updated Campaign Name',
2569
+ * text: 'New message text with {{variable}}'
2570
+ * });
2571
+ * ```
2572
+ */
2573
+ update(id: string, request: UpdateCampaignRequest): Promise<Campaign>;
2574
+ /**
2575
+ * Delete a campaign
2576
+ *
2577
+ * Only draft and cancelled campaigns can be deleted.
2578
+ *
2579
+ * @param id - Campaign ID
2580
+ *
2581
+ * @example
2582
+ * ```typescript
2583
+ * await sendly.campaigns.delete('cmp_xxx');
2584
+ * ```
2585
+ */
2586
+ delete(id: string): Promise<void>;
2587
+ /**
2588
+ * Preview a campaign before sending
2589
+ *
2590
+ * Returns recipient count, credit estimate, and breakdown by country.
2591
+ *
2592
+ * @param id - Campaign ID
2593
+ * @returns Campaign preview with cost estimate
2594
+ *
2595
+ * @example
2596
+ * ```typescript
2597
+ * const preview = await sendly.campaigns.preview('cmp_xxx');
2598
+ *
2599
+ * console.log(`Recipients: ${preview.recipientCount}`);
2600
+ * console.log(`Estimated cost: ${preview.estimatedCredits} credits`);
2601
+ * console.log(`Your balance: ${preview.currentBalance} credits`);
2602
+ *
2603
+ * if (!preview.hasEnoughCredits) {
2604
+ * console.log('Not enough credits! Please top up.');
2605
+ * }
2606
+ * ```
2607
+ */
2608
+ preview(id: string): Promise<CampaignPreview>;
2609
+ /**
2610
+ * Send a campaign immediately
2611
+ *
2612
+ * @param id - Campaign ID
2613
+ * @returns The updated campaign (status: sending)
2614
+ *
2615
+ * @example
2616
+ * ```typescript
2617
+ * const campaign = await sendly.campaigns.send('cmp_xxx');
2618
+ * console.log(`Campaign is now ${campaign.status}`);
2619
+ * ```
2620
+ */
2621
+ send(id: string): Promise<Campaign>;
2622
+ /**
2623
+ * Schedule a campaign for later
2624
+ *
2625
+ * @param id - Campaign ID
2626
+ * @param request - Schedule details
2627
+ * @returns The updated campaign (status: scheduled)
2628
+ *
2629
+ * @example
2630
+ * ```typescript
2631
+ * const campaign = await sendly.campaigns.schedule('cmp_xxx', {
2632
+ * scheduledAt: '2024-01-15T10:00:00Z',
2633
+ * timezone: 'America/New_York'
2634
+ * });
2635
+ *
2636
+ * console.log(`Scheduled for ${campaign.scheduledAt}`);
2637
+ * ```
2638
+ */
2639
+ schedule(id: string, request: ScheduleCampaignRequest): Promise<Campaign>;
2640
+ /**
2641
+ * Cancel a scheduled campaign
2642
+ *
2643
+ * @param id - Campaign ID
2644
+ * @returns The updated campaign (status: cancelled)
2645
+ *
2646
+ * @example
2647
+ * ```typescript
2648
+ * const campaign = await sendly.campaigns.cancel('cmp_xxx');
2649
+ * console.log(`Campaign cancelled`);
2650
+ * ```
2651
+ */
2652
+ cancel(id: string): Promise<Campaign>;
2653
+ /**
2654
+ * Clone a campaign
2655
+ *
2656
+ * Creates a new draft campaign with the same settings.
2657
+ *
2658
+ * @param id - Campaign ID to clone
2659
+ * @returns The new campaign (as draft)
2660
+ *
2661
+ * @example
2662
+ * ```typescript
2663
+ * const cloned = await sendly.campaigns.clone('cmp_xxx');
2664
+ * console.log(`Created clone: ${cloned.id}`);
2665
+ * ```
2666
+ */
2667
+ clone(id: string): Promise<Campaign>;
2668
+ private transformCampaign;
2669
+ }
2670
+
2671
+ /**
2672
+ * Contacts Resource - Contact & List Management
2673
+ * @packageDocumentation
2674
+ */
2675
+
2676
+ /**
2677
+ * Contacts API resource for managing contacts and contact lists
2678
+ *
2679
+ * @example
2680
+ * ```typescript
2681
+ * // Create a contact
2682
+ * const contact = await sendly.contacts.create({
2683
+ * phoneNumber: '+15551234567',
2684
+ * name: 'John Doe',
2685
+ * email: 'john@example.com'
2686
+ * });
2687
+ *
2688
+ * // Create a list and add contacts
2689
+ * const list = await sendly.contacts.lists.create({ name: 'Newsletter Subscribers' });
2690
+ * await sendly.contacts.lists.addContacts(list.id, [contact.id]);
2691
+ * ```
2692
+ */
2693
+ declare class ContactsResource {
2694
+ private readonly http;
2695
+ readonly lists: ContactListsResource;
2696
+ constructor(http: HttpClient);
2697
+ /**
2698
+ * List contacts with optional filtering
2699
+ *
2700
+ * @param options - Filter and pagination options
2701
+ * @returns List of contacts
2702
+ *
2703
+ * @example
2704
+ * ```typescript
2705
+ * // List all contacts
2706
+ * const { contacts, total } = await sendly.contacts.list();
2707
+ *
2708
+ * // Search contacts
2709
+ * const { contacts } = await sendly.contacts.list({ search: 'john' });
2710
+ *
2711
+ * // List contacts in a specific list
2712
+ * const { contacts } = await sendly.contacts.list({ listId: 'lst_xxx' });
2713
+ * ```
2714
+ */
2715
+ list(options?: ListContactsOptions): Promise<ContactListResponse>;
2716
+ /**
2717
+ * Get a contact by ID
2718
+ *
2719
+ * @param id - Contact ID
2720
+ * @returns The contact with associated lists
2721
+ *
2722
+ * @example
2723
+ * ```typescript
2724
+ * const contact = await sendly.contacts.get('cnt_xxx');
2725
+ * console.log(`${contact.name}: ${contact.phoneNumber}`);
2726
+ * console.log(`In ${contact.lists?.length || 0} lists`);
2727
+ * ```
2728
+ */
2729
+ get(id: string): Promise<Contact>;
2730
+ /**
2731
+ * Create a new contact
2732
+ *
2733
+ * @param request - Contact details
2734
+ * @returns The created contact
2735
+ *
2736
+ * @example
2737
+ * ```typescript
2738
+ * const contact = await sendly.contacts.create({
2739
+ * phoneNumber: '+15551234567',
2740
+ * name: 'Jane Smith',
2741
+ * email: 'jane@example.com',
2742
+ * metadata: { source: 'signup_form', plan: 'premium' }
2743
+ * });
2744
+ * ```
2745
+ */
2746
+ create(request: CreateContactRequest): Promise<Contact>;
2747
+ /**
2748
+ * Update a contact
2749
+ *
2750
+ * @param id - Contact ID
2751
+ * @param request - Fields to update
2752
+ * @returns The updated contact
2753
+ *
2754
+ * @example
2755
+ * ```typescript
2756
+ * const contact = await sendly.contacts.update('cnt_xxx', {
2757
+ * name: 'Jane Doe',
2758
+ * metadata: { plan: 'enterprise' }
2759
+ * });
2760
+ * ```
2761
+ */
2762
+ update(id: string, request: UpdateContactRequest): Promise<Contact>;
2763
+ /**
2764
+ * Delete a contact
2765
+ *
2766
+ * @param id - Contact ID
2767
+ *
2768
+ * @example
2769
+ * ```typescript
2770
+ * await sendly.contacts.delete('cnt_xxx');
2771
+ * ```
2772
+ */
2773
+ delete(id: string): Promise<void>;
2774
+ import(request: ImportContactsRequest): Promise<ImportContactsResponse>;
2775
+ private transformContact;
2776
+ }
2777
+ /**
2778
+ * Contact Lists sub-resource
2779
+ */
2780
+ declare class ContactListsResource {
2781
+ private readonly http;
2782
+ constructor(http: HttpClient);
2783
+ /**
2784
+ * List all contact lists
2785
+ *
2786
+ * @returns All contact lists
2787
+ *
2788
+ * @example
2789
+ * ```typescript
2790
+ * const { lists } = await sendly.contacts.lists.list();
2791
+ * for (const list of lists) {
2792
+ * console.log(`${list.name}: ${list.contactCount} contacts`);
2793
+ * }
2794
+ * ```
2795
+ */
2796
+ list(): Promise<ContactListsResponse>;
2797
+ /**
2798
+ * Get a contact list by ID
2799
+ *
2800
+ * @param id - Contact list ID
2801
+ * @param options - Pagination options for contacts
2802
+ * @returns The contact list with members
2803
+ *
2804
+ * @example
2805
+ * ```typescript
2806
+ * const list = await sendly.contacts.lists.get('lst_xxx');
2807
+ * console.log(`${list.name}: ${list.contactCount} contacts`);
2808
+ *
2809
+ * // Get list with paginated contacts
2810
+ * const list = await sendly.contacts.lists.get('lst_xxx', { limit: 100 });
2811
+ * console.log(`Showing ${list.contacts?.length} of ${list.contactsTotal}`);
2812
+ * ```
2813
+ */
2814
+ get(id: string, options?: {
2815
+ limit?: number;
2816
+ offset?: number;
2817
+ }): Promise<ContactList>;
2818
+ /**
2819
+ * Create a new contact list
2820
+ *
2821
+ * @param request - List details
2822
+ * @returns The created list
2823
+ *
2824
+ * @example
2825
+ * ```typescript
2826
+ * const list = await sendly.contacts.lists.create({
2827
+ * name: 'VIP Customers',
2828
+ * description: 'High-value customers for priority messaging'
2829
+ * });
2830
+ * ```
2831
+ */
2832
+ create(request: CreateContactListRequest): Promise<ContactList>;
2833
+ /**
2834
+ * Update a contact list
2835
+ *
2836
+ * @param id - Contact list ID
2837
+ * @param request - Fields to update
2838
+ * @returns The updated list
2839
+ *
2840
+ * @example
2841
+ * ```typescript
2842
+ * const list = await sendly.contacts.lists.update('lst_xxx', {
2843
+ * name: 'Premium Subscribers',
2844
+ * description: 'Updated description'
2845
+ * });
2846
+ * ```
2847
+ */
2848
+ update(id: string, request: UpdateContactListRequest): Promise<ContactList>;
2849
+ /**
2850
+ * Delete a contact list
2851
+ *
2852
+ * This does not delete the contacts in the list.
2853
+ *
2854
+ * @param id - Contact list ID
2855
+ *
2856
+ * @example
2857
+ * ```typescript
2858
+ * await sendly.contacts.lists.delete('lst_xxx');
2859
+ * ```
2860
+ */
2861
+ delete(id: string): Promise<void>;
2862
+ /**
2863
+ * Add contacts to a list
2864
+ *
2865
+ * @param listId - Contact list ID
2866
+ * @param contactIds - Array of contact IDs to add
2867
+ * @returns Number of contacts added
2868
+ *
2869
+ * @example
2870
+ * ```typescript
2871
+ * const result = await sendly.contacts.lists.addContacts('lst_xxx', [
2872
+ * 'cnt_abc',
2873
+ * 'cnt_def',
2874
+ * 'cnt_ghi'
2875
+ * ]);
2876
+ * console.log(`Added ${result.addedCount} contacts`);
2877
+ * ```
2878
+ */
2879
+ addContacts(listId: string, contactIds: string[]): Promise<{
2880
+ addedCount: number;
2881
+ }>;
2882
+ /**
2883
+ * Remove a contact from a list
2884
+ *
2885
+ * @param listId - Contact list ID
2886
+ * @param contactId - Contact ID to remove
2887
+ *
2888
+ * @example
2889
+ * ```typescript
2890
+ * await sendly.contacts.lists.removeContact('lst_xxx', 'cnt_abc');
2891
+ * ```
2892
+ */
2893
+ removeContact(listId: string, contactId: string): Promise<void>;
2894
+ private transformList;
2895
+ }
2896
+
2051
2897
  /**
2052
2898
  * Sendly Client
2053
2899
  * @packageDocumentation
@@ -2177,6 +3023,47 @@ declare class Sendly {
2177
3023
  * ```
2178
3024
  */
2179
3025
  readonly templates: TemplatesResource;
3026
+ /**
3027
+ * Campaigns API resource - Bulk SMS campaign management
3028
+ *
3029
+ * @example
3030
+ * ```typescript
3031
+ * // Create a campaign
3032
+ * const campaign = await sendly.campaigns.create({
3033
+ * name: 'Welcome Campaign',
3034
+ * text: 'Hello {{name}}!',
3035
+ * contactListIds: ['lst_xxx']
3036
+ * });
3037
+ *
3038
+ * // Preview cost
3039
+ * const preview = await sendly.campaigns.preview(campaign.id);
3040
+ * console.log(`Cost: ${preview.estimatedCredits} credits`);
3041
+ *
3042
+ * // Send or schedule
3043
+ * await sendly.campaigns.send(campaign.id);
3044
+ * ```
3045
+ */
3046
+ readonly campaigns: CampaignsResource;
3047
+ /**
3048
+ * Contacts API resource - Contact and list management
3049
+ *
3050
+ * @example
3051
+ * ```typescript
3052
+ * // Create a contact
3053
+ * const contact = await sendly.contacts.create({
3054
+ * phoneNumber: '+15551234567',
3055
+ * name: 'John Doe'
3056
+ * });
3057
+ *
3058
+ * // Create a list and add contacts
3059
+ * const list = await sendly.contacts.lists.create({ name: 'VIPs' });
3060
+ * await sendly.contacts.lists.addContacts(list.id, [contact.id]);
3061
+ *
3062
+ * // List all contacts
3063
+ * const { contacts } = await sendly.contacts.list();
3064
+ * ```
3065
+ */
3066
+ readonly contacts: ContactsResource;
2180
3067
  private readonly http;
2181
3068
  private readonly config;
2182
3069
  /**
@@ -2627,4 +3514,4 @@ declare class Webhooks {
2627
3514
  */
2628
3515
  type WebhookMessageData = WebhookMessageObject;
2629
3516
 
2630
- export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
3517
+ export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type Campaign, type CampaignListResponse, type CampaignPreview, type CampaignStatus, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type Contact, type ContactList, type ContactListResponse, type ContactListsResponse, type CreateCampaignRequest, type CreateContactListRequest, type CreateContactRequest, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, type ImportContactItem, type ImportContactsError, type ImportContactsRequest, type ImportContactsResponse, InsufficientCreditsError, type ListBatchesOptions, type ListCampaignsOptions, type ListContactsOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleCampaignRequest, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateCampaignRequest, type UpdateContactListRequest, type UpdateContactRequest, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };