-
Notifications
You must be signed in to change notification settings - Fork 33
Webhooks
Igor Balos edited this page Jul 31, 2023
·
6 revisions
For these API requests you will need to use a server API token. Once you obtain it, you will need to use server API client.
let postmark = require("postmark")
const serverToken = "xxxx-xxxxx-xxxx-xxxxx-xxxxxx"
let client = new postmark.ServerClient(serverToken);
Get the list of all available webhooks with triggers enabled on them and other details.
client.getWebhooks().then(result => {
console.log(result);
console.log(result.Webhooks[0].ID);
console.log(result.Webhooks[0].Url);
console.log(result.Webhooks[0].Triggers.Bounce.Enabled);
console.log(result.Webhooks[0].Triggers.Delivery.Enabled);
console.log(result.Webhooks[0].Triggers.Open.Enabled);
});
client.getWebhook(12345).then(result => {
console.log(result.ID);
console.log(result.Url);
});
client.createWebhook({
Url: 'https://example.com',
HttpAuth: {
Username: 'test',
Password: 'test'
},
Triggers: {
Open: {
Enabled: true,
PostFirstOpenOnly: true
},
Click: {
Enabled: true
},
SpamComplaint: {
Enabled: true
}
}
}).then(result => {
console.log(result);
});
If MessageStream
field is provided, webhook will be created on specific stream. By default webhook is created on default Transactioal stream.
When retrieving webhooks, in case you want to use types, check out the following article.
client.editWebhook(12345, {
Url: 'https://tester.com',
HttpAuth: { Username: 'test', Password: 'test'},
Triggers: { Open: { Enabled: true }
}}).then(result => {
console.log(result);
});
client.deleteWebhook(123456).then(result => {
console.log(result.Message);
});
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.
- Overview
- Migration from older version
- Getting started
- Email sending
- Bounces
- Templates
- Templates Push
- Server
- Servers
- Message Streams
- Webhooks
- Messages
- Domains
- Sender Signatures
- Stats
- Trigger Inbound Rules
- Suppressions
- Data Removal
- Embedding images in emails
- Error Handling
- Handling Web Hooks
- Mocking requests
- Troubleshooting
- Known issues and how to resolve them