forked from SparkPost/node-sparkpost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
1680 lines (1625 loc) · 68.3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for sparkpost 2.1
// Project: https://github.com/SparkPost/node-sparkpost
// Definitions by: Joshua DeVinney <https://github.com/geoffreak>, Bond <https://github.com/bondz>, Victor <https://github.com/vvu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node"/>
import * as Request from 'request'
import * as Http from 'http'
declare class SparkPost {
/** Specifying an inbound domain enables you to customize the address to which inbound messages are sent. */
inboundDomains: {
/**
* List all your inbound domains.
* @param callback The request callback with Domain results array
*/
list(callback: SparkPost.ResultsCallback<SparkPost.Domain[]>): void
/**
* List all your inbound domains.
* @returns Promise The Domain results array
*/
list(): SparkPost.ResultsPromise<SparkPost.Domain[]>
/**
* Retrieve an inbound domain by specifying its domain name in the URI path.
* @param domain Domain name
* @param callback The request callback with Domain results
*/
get(domain: string, callback: SparkPost.ResultsCallback<SparkPost.Domain>): void
/**
* Retrieve an inbound domain by specifying its domain name in the URI path.
* @param domain Domain name
* @returns Promise The Domain results
*/
get(domain: string): SparkPost.ResultsPromise<SparkPost.Domain>
/**
* Create an inbound domain by providing an inbound domains object as the POST request body.
* @param createOpts a hash of [inbound domain attributes]{@link https://developers.sparkpost.com/api/inbound-domains#header-inbound-domains-attributes}
* @param callback The request callback
*/
create(createOpts: SparkPost.CreateOpts, callback: SparkPost.Callback<void>): void
/**
* Create an inbound domain by providing an inbound domains object as the POST request body.
* @param createOpts a hash of [inbound domain attributes]{@link https://developers.sparkpost.com/api/inbound-domains#header-inbound-domains-attributes}
* @returns Promise void
*/
create(createOpts: SparkPost.CreateOpts): Promise<void>
/**
* Delete an inbound domain by specifying its domain name in the URI path.
* @param domain Domain name
* @param callback The request callback
*/
delete(domain: string, callback: SparkPost.Callback<void>): void
/**
* Delete an inbound domain by specifying its domain name in the URI path.
* @param domain Domain name
* @returns Promise void
*/
delete(domain: string): Promise<void>
}
/** The Message Events API provides the means to search the raw events generated by SparkPost. */
messageEvents: {
/**
* Retrieves list of message events according to given params
* @param parameters Query parameters
* @param callback The request callback with MessageEvent results array
*/
search(parameters: SparkPost.MessageEventParameters, callback: SparkPost.ResultsCallback<SparkPost.MessageEvent[]>): void
/**
* Retrieves list of message events according to given params
* @param parameters Query parameters
* @returns Promise The MessageEvent results array
*/
search(parameters: SparkPost.MessageEventParameters): SparkPost.ResultsPromise<SparkPost.MessageEvent[]>
}
/** A recipient list is a collection of recipients that can be used in a transmission. */
recipientLists: {
/**
* List a summary of all recipient lists. The recipients for each list are not included in the results.
* To retrieve recipient details, use the [Retrieve a Recipient List endpoint]{@link https://developers.sparkpost.com/api/recipient-lists.html#recipient-lists-retrieve-get},
* and specify the recipient list.
*
* @param callback The request callback with RecipientList results array
*/
list(callback: SparkPost.ResultsCallback<SparkPost.RecipientList[]>): void
/**
* List a summary of all recipient lists. The recipients for each list are not included in the results.
* To retrieve recipient details, use the [Retrieve a Recipient List endpoint]{@link https://developers.sparkpost.com/api/recipient-lists.html#recipient-lists-retrieve-get},
* and specify the recipient list.
*
* @returns Promise The RecipientList results array
*/
list(): SparkPost.ResultsPromise<SparkPost.RecipientList[]>
/**
* Retrieve details about a specified recipient list by specifying its id in the URI path.
* To retrieve the recipients contained in a list, the show_recipients parameter must be set to true.
*
* @param specifies whether to retrieve the recipients. Defaults to false
*/
get(
id: string,
options: { show_recipients?: boolean | undefined },
callback: SparkPost.Callback<SparkPost.RecipientListWithRecipients>
): void
/**
* Retrieve details about a specified recipient list by specifying its id in the URI path.
* To retrieve the recipients contained in a list, the show_recipients parameter must be set to true.
*
*/
get(id: string, callback: SparkPost.Callback<SparkPost.RecipientListWithRecipients>): void
/**
* Retrieve details about a specified recipient list by specifying its id in the URI path.
* To retrieve the recipients contained in a list, the show_recipients parameter must be set to true.
*
* @param [options] specifies whether to retrieve the recipients. Defaults to false
*/
get(id: string, options?: { show_recipients?: boolean | undefined }): SparkPost.ResultsPromise<SparkPost.RecipientListWithRecipients>
/**
* Create a recipient list by providing a recipient list object as the POST request body.
* At a minimum, the “recipients” array is required, which must contain a valid “address”.
* If the recipient list “id” is not provided in the POST request body, one will be generated and returned in the results body.
* Use the num_rcpt_errors parameter to limit the number of recipient errors returned.
* @param options The create options
* @param callback The request callback with metadata results
*/
create(options: SparkPost.CreateRecipientList, callback: SparkPost.ResultsCallback<SparkPost.RecipientListMetadata>): void
/**
* Create a recipient list by providing a recipient list object as the POST request body.
* At a minimum, the “recipients” array is required, which must contain a valid “address”.
* If the recipient list “id” is not provided in the POST request body, one will be generated and returned in the results body.
* Use the num_rcpt_errors parameter to limit the number of recipient errors returned.
* @param options The create options
* @returns Promise metadata results
*/
create(options: SparkPost.CreateRecipientList): SparkPost.ResultsPromise<SparkPost.RecipientListMetadata>
/**
* Update an existing recipient list by specifying its ID in the URI path and use a recipient list object as the PUT request body.
* Use the num_rcpt_errors parameter to limit the number of recipient errors returned.
*
* @param id Identifier of the recipient list
* @param options The update options
* @param callback The request callback with metadata results
*/
update(id: string, options: SparkPost.UpdateRecipientList, callback: SparkPost.ResultsCallback<SparkPost.RecipientListMetadata>): void
/**
* Update an existing recipient list by specifying its ID in the URI path and use a recipient list object as the PUT request body.
* Use the num_rcpt_errors parameter to limit the number of recipient errors returned.
*
* @param id Identifier of the recipient list
*/
update(id: string, options: SparkPost.UpdateRecipientList): SparkPost.ResultsPromise<SparkPost.RecipientListMetadata>
/**
* Permanently delete the specified recipient list.
*
* @param id The list id
* @param callback The request callback
*/
delete(id: string, callback: SparkPost.Callback<void>): void
/**
* Permanently delete the specified recipient list.
*
* @param id The list id
* @returns Promise void
*/
delete(id: string): Promise<void>
}
/** Relay Webhooks are a way to instruct SparkPost to accept inbound email on your behalf and forward it to you over HTTP for your own consumption. */
relayWebhooks: {
/**
* List all your relay webhooks.
* @param callback The request callback with RelayWebhook results array
*/
list(callback: SparkPost.ResultsCallback<SparkPost.RelayWebhook[]>): void
/**
* List all your relay webhooks.
* @returns Promise The RelayWebhook results array
*/
list(): SparkPost.ResultsPromise<SparkPost.RelayWebhook[]>
/**
* Delete a relay webhook by specifying the webhook ID in the URI path.
* @param relayWebhookId The webhook id
* @param callback The request callback with RelayWebhook results
*/
get(relayWebhookId: string, callback: SparkPost.ResultsCallback<SparkPost.RelayWebhook>): void
/**
* Delete a relay webhook by specifying the webhook ID in the URI path.
* @param relayWebhookId The webhook id
* @returns Promise The RelayWebhook results
*/
get(relayWebhookId: string): SparkPost.ResultsPromise<SparkPost.RelayWebhook>
/**
* Create a relay webhook by providing a relay webhooks object as the POST request body.
* @param options The create options
* @param callback The request callback with webhook id results
*/
create(options: SparkPost.RelayWebhook, callback: SparkPost.ResultsCallback<{ id: string }>): void
/**
* Create a relay webhook by providing a relay webhooks object as the POST request body.
* @param options The create options
* @returns Promise The webhook id results
*/
create(options: SparkPost.RelayWebhook): SparkPost.ResultsPromise<{ id: string }>
/**
* Update a relay webhook by specifying the webhook ID in the URI path.
* @param options The update options
* @param callback The request callback with webhook id results
*/
update(id: string, options: SparkPost.UpdateRelayWebhook, callback: SparkPost.ResultsCallback<{ id: string }>): void
/**
* Update a relay webhook by specifying the webhook ID in the URI path.
* @param options The update options
* @returns Promise The webhook id results
*/
update(id: string, options: SparkPost.UpdateRelayWebhook): SparkPost.ResultsPromise<{ id: string }>
/**
* Delete a relay webhook by specifying the webhook ID in the URI path.
* @param relayWebhookId The webhook id
* @param callback The request callback
*/
delete(relayWebhookId: string, callback: SparkPost.Callback<void>): void
/**
* Delete a relay webhook by specifying the webhook ID in the URI path.
* @param relayWebhookId The webhook id
* @returns Promise void
*/
delete(relayWebhookId: string): Promise<void>
}
sendingDomains: {
/**
* List an overview of all sending domains in the system.
*
* @returns The SendingDomain results array
*/
list(subAccountOptions?: SparkPost.SubAccountOptions): SparkPost.ResultsPromise<SparkPost.SendingDomain[]>
/**
* Retrieve a sending domain by specifying its domain name in the URI path. The response includes details about its DKIM key configuration.
*
* @param domain The domain
* @returns Promise The SendingDomain results
*/
get(domain: string, subAccountOptions?: SparkPost.SubAccountOptions): SparkPost.ResultsPromise<SparkPost.SendingDomain>
/**
* Create a sending domain by providing a sending domain object as the POST request body.
*
* @param options The create options
* @returns Promise The basic info results
*/
create(
options: SparkPost.CreateSendingDomain,
subAccountOptions?: SparkPost.SubAccountOptions
): SparkPost.ResultsPromise<{
message: string
domain: string
dkim?: SparkPost.DKIM
}>
/**
* Update the attributes of an existing sending domain by specifying its domain name in the URI path and use a sending domain object as the PUT request body.
*
* @param domain The domain
* @param updateOpts The update options
* @returns Promise The basic info results
*/
update(
domain: string,
updateOpts: SparkPost.UpdateSendingDomain,
subAccountOptions?: SparkPost.SubAccountOptions
): SparkPost.ResultsPromise<{ message: string; domain: string }>
/**
* Delete an existing sending domain.
*
* @param domain The domain
* @returns Promise void
*/
delete(domain: string, subAccountOptions?: SparkPost.SubAccountOptions): Promise<void>
/**
* Verify a Sending Domain
*
* @param domain The domain
* @param options a hash of [verify attributes]{@link https://developers.sparkpost.com/api/sending-domains#header-verify-attributes}
* @returns Promise The verify results
*/
verify(
domain: string,
options: SparkPost.VerifyOptions,
subAccountOptions?: SparkPost.SubAccountOptions
): SparkPost.ResultsPromise<SparkPost.VerifyResults>
}
subaccounts: {
/**
* Endpoint for retrieving a list of your subaccounts.
* This endpoint only returns information about the subaccounts themselves, not the data associated with the subaccount.
* @param callback The request callback with subaccount information results array
*/
list(callback: SparkPost.ResultsCallback<SparkPost.SubaccountInformation[]>): void
/**
* Endpoint for retrieving a list of your subaccounts.
* This endpoint only returns information about the subaccounts themselves, not the data associated with the subaccount.
*
* @returns Promise The subaccount information results array
*/
list(): SparkPost.ResultsPromise<SparkPost.SubaccountInformation[]>
/**
* Get details about a specified subaccount by its id
*
* @param id the id of the subaccount you want to look up
* @param callback The request callback with subaccount information results
*/
get(id: string | number, callback: SparkPost.ResultsCallback<SparkPost.SubaccountInformation>): void
/**
* Get details about a specified subaccount by its id
*
* @param id the id of the subaccount you want to look up
* @returns Promise The subaccount information results
*/
get(id: string | number): SparkPost.ResultsPromise<SparkPost.SubaccountInformation>
/**
* Provisions a new subaccount and an initial subaccount API key.
* @param subaccount The create options
* @param callback The request callback with basic subaccount information results
*/
create(subaccount: SparkPost.CreateSubaccount, callback: SparkPost.ResultsCallback<SparkPost.CreateSubaccountResponse>): void
/**
* Provisions a new subaccount and an initial subaccount API key.
*
* @param subaccount The create options
* @returns Promise The basic subaccount information results
*/
create(subaccount: SparkPost.CreateSubaccount): SparkPost.ResultsPromise<SparkPost.CreateSubaccountResponse>
/**
* Update an existing subaccount’s information.
*
* @param id the id of the subaccount you want to update
* @param subaccount an object of [updatable subaccount attributes]{@link https://developers.sparkpost.com/api/subaccounts#header-request-body-attributes-1}
* @param callback The request callback with webhook id results
*/
update(id: string, subaccount: SparkPost.UpdateSubaccount, callback: SparkPost.ResultsCallback<{ message: string }>): void
/**
* Update an existing subaccount’s information.
*
* @param id the id of the subaccount you want to update
* @param subaccount an object of [updatable subaccount attributes]{@link https://developers.sparkpost.com/api/subaccounts#header-request-body-attributes-1}
* @returns Promise The webhook id results
*/
update(id: string, subaccount: SparkPost.UpdateSubaccount): SparkPost.ResultsPromise<{ message: string }>
}
suppressionList: {
/**
* List all entries in your suppression list, filtered by an optional set of search parameters.
*
* @param callback The request callback with supression lists.
*/
list(callback: SparkPost.ResultsCallback<SparkPost.SupressionListEntry[]>): void
/**
* List all entries in your suppression list, filtered by an optional set of search parameters.
*
* @param parameters an object of [search parameters]{@link https://developers.sparkpost.com/api/suppression-list#suppression-list-search-get}
* @param callback The request callback with supression lists.
*/
list(parameters: SparkPost.SupressionSearchParameters, callback: SparkPost.ResultsCallback<SparkPost.SupressionListEntry[]>): void
/**
* List all entries in your suppression list, filtered by an optional set of search parameters.
*
* @param [parameters] an object of [search parameters]{@link https://developers.sparkpost.com/api/suppression-list#suppression-list-search-get}
* @returns Promise The supression lists
*/
list(parameters?: SparkPost.SupressionSearchParameters): SparkPost.ResultsPromise<SparkPost.SupressionListEntry[]>
/**
* Retrieve an entry by recipient email.
*
* @param email address to check
* @returns void
*/
get(email: string, callback: SparkPost.ResultsCallback<SparkPost.SupressionListEntry[]>): void
/**
* Retrieve an entry by recipient email.
*
* @param email address to check
* @returns void
*/
get(email: string): SparkPost.ResultsPromise<SparkPost.SupressionListEntry[]>
/**
* Delete a recipient from the list by specifying the recipient’s email address in the URI path.
*
* @param email Recipient email address
*/
delete(email: string, callback: SparkPost.Callback<void>): void
/**
* Delete a recipient from the list by specifying the recipient’s email address in the URI path.
*
* @param email Recipient email address
* @returns void
*/
delete(email: string): Promise<void>
/**
* Insert or update one or many entries.
*
* @param listEntries The suppression entry list
* @param callback The request callback
*/
upsert(
listEntries: SparkPost.CreateSupressionListEntry | SparkPost.CreateSupressionListEntry[],
callback: SparkPost.ResultsCallback<{ message: string }>
): void
/**
* Insert or update one or many entries.
*
* @param listEntries The suppression entry list
*/
upsert(
listEntries: SparkPost.CreateSupressionListEntry | SparkPost.CreateSupressionListEntry[]
): SparkPost.ResultsPromise<{ message: string }>
}
templates: {
/**
* List a summary of all templates.
* @param callback The request callback with TemplateMeta results array
*/
list(callback: SparkPost.ResultsCallback<SparkPost.TemplateMeta[]>): void
/**
* List a summary of all templates.
*
* @returns The TemplateMeta results array
*/
list(): SparkPost.ResultsPromise<SparkPost.TemplateMeta[]>
/**
* Retrieve details about a specified template by its id
*
* @param id the id of the template you want to look up
* @param options specifies a draft or published template
* @param callback The request callback with Template results
*/
get(id: string, options: { draft?: boolean | undefined }, callback: SparkPost.ResultsCallback<SparkPost.Template>): void
/**
* Retrieve details about a specified template by its id
*
* @param id the id of the template you want to look up
* @param callback The request callback with Template results
*/
get(id: string, callback: SparkPost.ResultsCallback<SparkPost.Template>): void
/**
* Retrieve details about a specified template by its id
*
* @param id the id of the template you want to look up
* @param [options] specifies a draft or published template
* @returns The Template results
*/
get(id: string, options?: { draft?: boolean | undefined }): SparkPost.ResultsPromise<SparkPost.Template>
/**
* Create a new template
*
* @param template an object of [template attributes]{@link https://developers.sparkpost.com/api/templates#header-template-attributes}
* @param callback The request callback with template id results
*/
create(template: SparkPost.CreateTemplate, callback: SparkPost.ResultsCallback<{ id: string }>): void
/**
* Create a new template
*
* @param template an object of [template attributes]{@link https://developers.sparkpost.com/api/templates#header-template-attributes}
* @returns The template id results
*/
create(template: SparkPost.CreateTemplate): SparkPost.ResultsPromise<{ id: string }>
/**
* Update an existing template
*
* @param id the id of the template you want to update
* @param template an object of [template attributes]{@link https://developers.sparkpost.com/api/templates#header-template-attributes}
* @param options The create options. If true, directly overwrite the existing published template. If false, create a new draft
* @param callback The request callback with template id results
*/
update(
id: string,
template: SparkPost.UpdateTemplate,
options: { update_published?: boolean | undefined },
callback: SparkPost.ResultsCallback<{ id: string }>
): void
/**
* Update an existing template
*
* @param id the id of the template you want to update
* @param template an object of [template attributes]{@link https://developers.sparkpost.com/api/templates#header-template-attributes}
* @param callback The request callback with template id results
*/
update(id: string, template: SparkPost.UpdateTemplate, callback: SparkPost.ResultsCallback<{ id: string }>): void
/**
* Update an existing template
*
* @param id the id of the template you want to update
* @param template an object of [template attributes]{@link https://developers.sparkpost.com/api/templates#header-template-attributes}
* @param options If true, directly overwrite the existing published template. If false, create a new draft
* @returns The template id results
*/
update(
id: string,
template: SparkPost.UpdateTemplate,
options?: {
update_published?: boolean | undefined
}
): SparkPost.ResultsPromise<{ id: string }>
/**
* Delete an existing template
* @param id The template id
* @param callback The request callback
*/
delete(id: string, callback: SparkPost.Callback<void>): void
/**
* Delete an existing template
*
* @param id The template id
* @returns Promise void
*/
delete(id: string): Promise<void>
/**
* Preview the most recent version of an existing template by id
*
* @param id the id of the template you want to look up
* @param options The preview options
* @param callback The request callback with webhook id results
*/
preview(
id: string,
options: { substitution_data?: any; draft?: boolean | undefined },
callback: SparkPost.ResultsCallback<SparkPost.TemplateContent>
): void
/**
* Preview the most recent version of an existing template by id
*
* @param id the id of the template you want to look up
* @param callback The request callback with webhook id results
*/
preview(id: string, callback: SparkPost.ResultsCallback<SparkPost.TemplateContent>): void
/**
* Preview the most recent version of an existing template by id
*
* @param id the id of the template you want to look up
* @returns The webhook id results
*/
preview(
id: string,
options?: { substitution_data?: any; draft?: boolean | undefined }
): SparkPost.ResultsPromise<SparkPost.TemplateContent>
}
transmissions: {
/**
* List an overview of all transmissions in the account
*
* @returns The Transmission results array
*/
list(
options?: {
campaign_id?: string | undefined
template_id?: string | undefined
},
subAccountOptions?: SparkPost.SubAccountOptions
): SparkPost.ResultsPromise<SparkPost.TransmissionSummary[]>
/**
* Retrieve the details about a transmission by its ID
*
* @param id The id of the transmission you want to look up
* @returns The Transmission results
*/
get(id: string, subAccountOptions?: SparkPost.SubAccountOptions): SparkPost.ResultsPromise<SparkPost.Transmission>
/**
* Sends a message by creating a new transmission
*
* @param transmission an object of [transmission attributes]{@link https://developers.sparkpost.com/api/transmissions#header-transmission-attributes}
* @param [options] specify maximum number of recipient errors returned
* @returns The metadata and id results
*/
send(
transmission: SparkPost.CreateTransmission,
options?: { num_rcpt_errors?: number | undefined },
subAccountOptions?: SparkPost.SubAccountOptions
): SparkPost.ResultsPromise<{
total_rejected_recipients: number
total_accepted_recipients: number
id: string
}>
}
webhooks: {
/**
* List currently existing webhooks.
* @param callback The request callback with RelayWebhook results array
*/
list(callback: SparkPost.ResultsCallback<Array<SparkPost.WebhookLinks & SparkPost.Webhook>>): void
/**
* List currently existing webhooks.
* @param options Object containing optional timezone
* @param callback The request callback with RelayWebhook results array
*/
list(
options: { timezone?: string | undefined },
callback: SparkPost.ResultsCallback<Array<SparkPost.WebhookLinks & SparkPost.Webhook>>
): void
/**
* List currently existing webhooks.the timezone to use for the last_successful and last_failure properties | Default: UTC
*
*/
list(options?: { timezone?: string | undefined }): SparkPost.ResultsPromise<Array<SparkPost.WebhookLinks & SparkPost.Webhook>>
/**
* Retrieve details about a specified webhook by its id
*
* @param id The id of the webhook to get
* @param options Object containing id and optional timezone
* @param callback The request callback with RelayWebhook results
*/
get(
id: string,
options: { timezone?: string | undefined },
callback: SparkPost.ResultsCallback<SparkPost.WebhookLinks & SparkPost.Webhook>
): void
/**
* Retrieve details about a specified webhook by its id
*
* @param id The id of the webhook to get
* @param callback The request callback with RelayWebhook results
*/
get(id: string, callback: SparkPost.ResultsCallback<SparkPost.WebhookLinks & SparkPost.Webhook>): void
/**
* Retrieve details about a specified webhook by its id
*
* @param id The id of the webhook to get
* @param [options] the timezone to use for the last_successful and last_failure properties
* @returns The RelayWebhook results
*/
get(id: string, options?: { timezone?: string | undefined }): SparkPost.ResultsPromise<SparkPost.WebhookLinks & SparkPost.Webhook>
/**
* Create a new webhook
*
* @param options a hash of [webhook attributes]{@link https://developers.sparkpost.com/api/webhooks#header-webhooks-object-properties}
* @param callback The request callback with webhook id results
*/
create(options: SparkPost.Webhook, callback: SparkPost.ResultsCallback<SparkPost.WebhookLinks & { id: string }>): void
/**
* Create a new webhook
*
* @param options a hash of [webhook attributes]{@link https://developers.sparkpost.com/api/webhooks#header-webhooks-object-properties}
* @returns The webhook id results
*/
create(options: SparkPost.Webhook): SparkPost.ResultsPromise<SparkPost.WebhookLinks & { id: string }>
/**
* Update an existing webhook
* @param id the id of the webhook to update
* @param options A hash of [webhook attribues]{@link https://developers.sparkpost.com/api/webhooks#header-webhooks-object-properties}
* @param callback The request callback with webhook id results
*/
update(id: string, options: SparkPost.UpdateWebhook, callback: SparkPost.ResultsCallback<SparkPost.WebhookLinks & { id: string }>): void
/**
* Update an existing webhook
*
*/
update(id: string, options: SparkPost.UpdateWebhook): SparkPost.ResultsPromise<SparkPost.WebhookLinks & { id: string }>
/**
* Delete an existing webhook
* @param id The webhook id
* @param callback The request callback
*/
delete(id: string, callback: SparkPost.Callback<void>): void
/**
* Delete an existing webhook.
*
* @param id The id of the webhook to delete
*/
delete(id: string): Promise<void>
/**
* Sends an example message event batch from the Webhook API to the target URL
*
* @param id The id of the webhook to validate
* @param options the message (payload) to send to the webhook consumer
* @param callback The request callback with validation results
*/
validate(
id: string,
options: { message: any },
callback: SparkPost.ResultsCallback<{
msg: string
response: {
status: number
headers: any
body: string
}
}>
): void
/**
* Sends an example message event batch from the Webhook API to the target URL.
*
* @param id The id of the webhook to validate
* @param options The message (payload) to send to the webhook consumer
* @returns The validation results
*/
validate(
id: string,
options: { message: any }
): SparkPost.ResultsPromise<{
msg: string
response: {
status: number
headers: any
body: string
}
}>
/**
* Gets recent status information about a webhook.
*
* @param id The id of the webhook
* @param options An optional limit that specifies the maximum number of results to return. Defaults to 1000
* @param callback The request callback with status results
*/
getBatchStatus(
id: string,
options: { limit?: number | undefined },
callback: SparkPost.ResultsCallback<
Array<{
batch_id: string
ts: string
attempts: number
response_code: number
}>
>
): void
/**
* Gets recent status information about a webhook.
*
* @param id The id of the webhook
* @param callback The request callback with status results
*/
getBatchStatus(
id: string,
callback: SparkPost.ResultsCallback<
Array<{
batch_id: string
ts: string
attempts: number
response_code: number
}>
>
): void
/**
* Gets recent status information about a webhook.
*
* @param id The id of the webhook
* @param Maximum number of results to return. Defaults to 1000
* @returns The status results
*/
getBatchStatus(
id: string,
options: { limit?: number | undefined }
): SparkPost.ResultsPromise<
Array<{
batch_id: string
ts: string
attempts: number
response_code: number
}>
>
/**
* Lists descriptions of the events, event types, and event fields that could be included in a Webhooks post to your target URL.
* @param callback The request callback containing documentation results
*/
getDocumentation(callback: SparkPost.ResultsCallback<any>): void
/**
* Lists descriptions of the events, event types, and event fields that could be included in a Webhooks post to your target URL.
*
* @returns The documentation results
*/
getDocumentation(): SparkPost.ResultsPromise<any>
/**
* List an example of the event data that will be posted by a Webhook for the specified events.
* @param callback The request callback containing examples
*/
getSamples(callback: SparkPost.Callback<any>): void
/**
* List an example of the event data that will be posted by a Webhook for the specified events.
* @param options The optional event name
* @param callback The request callback containing examples
*/
getSamples(options: { events?: string | undefined }, callback: SparkPost.Callback<any>): void
/**
* List an example of the event data that will be posted by a Webhook for the specified events.
*
* @param options [event types]{@link https://support.sparkpost.com/customer/portal/articles/1976204} for which to get a sample payload
* Default: all event types returned
*/
getSamples(options?: { events?: string | undefined }): Promise<SparkPost.Response<any>>
}
/**
* The official Node.js binding for your favorite SparkPost APIs!
* @param apiKey A passed in apiKey will take precedence over an environment variable
* @param options Additional options
*/
constructor(apiKey?: string, options?: SparkPost.ConstructorOptions)
request(options: Request.Options, callback: SparkPost.Callback<any>): void
request(options: Request.Options): Promise<SparkPost.Response<any>>
get(options: Request.Options, callback: SparkPost.Callback<any>): void
get(options: Request.Options): Promise<SparkPost.Response<any>>
post(options: Request.Options, callback: SparkPost.Callback<any>): void
post(options: Request.Options): Promise<SparkPost.Response<any>>
put(options: Request.Options, callback: SparkPost.Callback<any>): void
put(options: Request.Options): Promise<SparkPost.Response<any>>
delete(options: Request.Options, callback: SparkPost.Callback<any>): void
delete(options: Request.Options): Promise<SparkPost.Response<any>>
}
declare namespace SparkPost {
interface ErrorWithDescription {
message: string
code: string
description: string
}
interface ErrorWithParam {
message: string
param: string
value: string | null
}
interface SparkPostError extends Error {
name: 'SparkPostError'
errors: ErrorWithDescription[] | ErrorWithParam[]
statusCode: number
}
interface ConstructorOptions {
origin?: string | undefined
endpoint?: string | undefined
apiVersion?: string | undefined
headers?: any
}
interface Response<T> extends Http.IncomingMessage {
body: T
}
type Callback<T> = (err: Error | SparkPostError | null, res: Response<T>) => void
type ResultsCallback<T> = Callback<{ results: T }>
type ResultsPromise<T> = Promise<{ results: T }>
type SubAccountOptions = {
subAccountId?: number | string | null
subAccountApiKey?: string | null
}
interface Domain {
domain: string
}
interface MessageEvent {
/** Type of event this record describes */
type: string
/** Classification code for a given message (see [Bounce Classification Codes](https://support.sparkpost.com/customer/portal/articles/1929896)) */
bounce_class: string
/** Campaign of which this message was a part */
campaign_id: string
/** SparkPost-customer identifier through which this message was sent */
customer_id: string
/** Protocol by which SparkPost delivered this message */
delv_method: string
/** Token of the device / application targeted by this PUSH notification message. Applies only when delv_method is gcm or apn. */
device_token: string
/** Error code by which the remote server described a failed delivery attempt */
error_code: string
/** IP address of the host to which SparkPost delivered this message; in engagement events, the IP address of the host where the HTTP request originated */
ip_address: string
/** SparkPost-cluster-wide unique identifier for this message */
message_id: string
/** Sender address used on this message"s SMTP envelope */
msg_from: string
/** Message"s size in bytes */
msg_size: string
/** Number of failed attempts before this message was successfully delivered; when the first attempt succeeds, zero */
num_retries: string
/** Metadata describing the message recipient */
rcpt_meta: any
/** Tags applied to the message which generated this event */
rcpt_tags: string[]
/** Recipient address used on this message"s SMTP envelope */
rcpt_to: string
/** Indicates that a recipient address appeared in the Cc or Bcc header or the archive JSON array */
rcpt_type: string
/** Unmodified, exact response returned by the remote server due to a failed delivery attempt */
raw_reason: string
/** Canonicalized text of the response returned by the remote server due to a failed delivery attempt */
reason: string
/** Domain receiving this message */
routing_domain: string
/** Subject line from the email header */
subject: string
/** Slug of the template used to construct this message */
template_id: string
/** Version of the template used to construct this message */
template_version: string
/** Event date and time formatted as: YYYY-MM-DDTHH:MM:SS.SSS±hh:mm */
timestamp: string
/** Transmission which originated this message */
transmission_id: string
}
interface MessageEventParameters {
/** delimited list of bounce classification codes to search. (See Bounce Classification Codes.) */
bounce_classes?: Array<string | number> | string | number | undefined
/** delimited list of campaign ID’s to search (i.e. the campaign id used during creation of a transmission). */
campaign_ids?: string[] | string | undefined
/** Specifies the delimiter for query parameter lists */
delimiter?: string | undefined
/** delimited list of event types to search. Defaults to all event types. */
events?: string[] | string | undefined
/** delimited list of friendly from emails to search. */
friendly_froms?: string[] | string | undefined
/** Datetime in format of YYYY-MM-DDTHH:MM. */
from?: string | undefined
/** delimited list of message ID’s to search. */
message_ids?: string[] | string | undefined
/** The results page number to return. Used with per_page for paging through results. */
page?: number | undefined
/** Number of results to return per page. Must be between 1 and 10,000 (inclusive). */
per_page?: number | undefined
/** Bounce/failure/rejection reason that will be matched using a wildcard (e.g., %reason%). */
reason?: string[] | string | undefined
/** delimited list of recipients to search. */
recipients?: string[] | string | undefined
/** delimited list of subaccount ID’s to search. */
subaccounts?: number[] | number | undefined
/** delimited list of template ID’s to search. */
template_ids?: string[] | string | undefined
/** Standard timezone identification string. */
timezone?: string | undefined
/** Datetime in format of YYYY-MM-DDTHH:MM. */
to?: string | undefined
/** delimited list of transmission ID’s to search (i.e. id generated during creation of a transmission). */
transmission_ids?: string[] | string | undefined
}
interface RecipientListMetadata {
total_rejected_recipients: number
total_accepted_recipients: number
id: string
name: string
}
interface RecipientList {
/** Short, unique, recipient list identifier */
id: string
/** Short, pretty/readable recipient list display name, not required to be unique */
name: string
/** Detailed description of the recipient list */
description: string
/** Recipient list attribute object */
attributes: any
/** Number of accepted recipients */
total_accepted_recipients: number
}
interface RecipientListWithRecipients extends RecipientList {
/** Array of recipient objects */
recipients: Recipient[]
}
interface CreateRecipientList {
/** Short, unique, recipient list identifier */
id?: string | undefined
/** Short, pretty/readable recipient list display name, not required to be unique */
name?: string | undefined
/** Detailed description of the recipient list */
description?: string | undefined
/** Recipient list attribute object */
attributes?: any
/** limit the number of recipient errors returned. */
num_rcpt_errors?: number | undefined
/** Array of recipient objects */
recipients: Recipient[]
}
interface UpdateRecipientList {
/** Short, unique, recipient list identifier */
id?: string | undefined
/** Short, pretty/readable recipient list display name, not required to be unique */
name?: string | undefined
/** Detailed description of the recipient list */
description?: string | undefined
/** Recipient list attribute object */
attributes?: any
/** Array of recipient objects */
recipients: Recipient[]
}
interface BaseRecipient {
/** SparkPost Enterprise API only. Email to use for envelope FROM. */
return_path?: string | undefined
/** Array of text labels associated with a recipient. */
tags?: string[] | undefined
/** Key/value pairs associated with a recipient. */
metadata?: any
/** Key/value pairs associated with a recipient that are provided to the substitution engine. */
substitution_data?: any
}
interface RecipientWithAddress {
/** Address information for a recipient At a minimum, address or multichannel_addresses is required. */
address: Address | string
}
interface RecipientWithMultichannelAddresses {
/**
* Address information for a recipient. At a minimum, address or multichannel_addresses is required.
* If both address and multichannel_addresses are specified only multichannel_addresses will be used.