@@ -34,6 +34,29 @@ const tempmail = new TempMail();
3434const tempmail = new TempMail (" 24-number id" , " 32-character token" );
3535```
3636
37+ ### Types
38+
39+ Email:
40+ ``` ts
41+ type Email = {
42+ from: string ,
43+ to: string ,
44+ subject: string ,
45+ body: string ,
46+ html: string | null , // only if the email is HTML
47+ date: number , // date in unix millis
48+ ip: string , // IP address of sender
49+ }
50+ ` ` `
51+
52+ Inbox:
53+ ` ` ` ts
54+ type Inbox = {
55+ address: string , // address of inbox
56+ token: string , // token to use for checkInbox
57+ }
58+ ` ` `
59+
3760### Create inbox
3861
3962To create an inbox:
@@ -44,15 +67,18 @@ tempmail.createInbox().then(inbox => {
4467 console .log (` Inbox: ${inbox .address } with a token of ${inbox .token } ` );
4568});
4669
70+ // Or as async
71+ const inbox: Inbox = await tempmail .createInbox ();
72+
4773// there are some advanced options as well
4874
4975// whether or not to create a community address
50- const community = false ;
76+ const community = true ;
5177tempmail .createInbox (community );
5278
5379
54- // or to use a custom domain
55- const domain = " example .com" ;
80+ // or to use a specific domain
81+ const domain = " cringemonster .com" ;
5682tempmail .createInbox (false , domain );
5783```
5884
@@ -93,3 +119,28 @@ tempmail.checkCustomDomain("example.com", "token").then(emails => {
93119You can obtain a token by visiting https://tempmail.lol/custom.html
94120
95121Custom domains will NOT alert you if the token is invalid.
122+
123+ ### Webhooks
124+
125+ You can set up a webhook to be called when an email is received.
126+
127+ ``` js
128+ tempmail .setWebhook (" https://example.com/webhook" ).then (() => {
129+ console .log (" Webhook set!" );
130+ });
131+ ```
132+
133+ You can also remove the webhook:
134+
135+ ``` js
136+ tempmail .removeWebhook ().then (() => {
137+ console .log (" Webhook removed!" );
138+ });
139+ ```
140+
141+ This feature is only available to TempMail Ultra subscribers. Any email created after setting the webhook will trigger the webhook.
142+ The email will not be returned in the ` checkInbox ` function.
143+
144+ Failed webhooks will not be retried unless a 429 Too Many Requests error is returned.
145+
146+ Webhooks will send data in a JSON format as an array of Email objects.
0 commit comments