-
Notifications
You must be signed in to change notification settings - Fork 21
Webhooks
Igor Balos edited this page Nov 6, 2019
·
4 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.
ApiClient client = Postmark.getApiClient(<server token>);
Get list of available webhooks
Webhooks webhooks = client.getWebhooks();
// get URL of the first webhook in the list
webhooks.getWebhooks().get(0).getUrl();
To retrieve webhooks per stream:
Webhooks webhooks = client.getWebhooks(Parameters.init().build("messageStream", "outbound"));
Get webhook by ID
Webhooks webhooks = client.getWebhooks();
Integer webhookId = webhooks.getWebhooks().get(0).getId();
// get webhook by ID
Webhook webhook = client.getWebhook(webhookId);
Create a new webhook
WebhookTriggers triggers = new WebhookTriggers();
triggers.setBounce(new BounceWebhookTrigger(true));
triggers.setClick(new WebhookTrigger(true));
// create a new webhook
Webhook webhookToCreate = client.createWebhook(new Webhook("http://example.com", triggers));
Update webhok by ID
Webhook webhookUpdated = client.setWebhook(12345, new Webhook("http://example-changed.com"));
Delete webhook by ID
String response = client.deleteWebhook(webhookId);
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.