Skip to content

Webhooks

Igor Balos edited this page Nov 5, 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();

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

Webhook webhookToCreate = client.createWebhook(new Webhook("http://example.com", new WebhookTriggers(true, true)));

// create a new webhook
Webhook response = client.createWebhook(webhookToCreate);

Update webhok by ID

Webhook webhookUpdated = client.setWebhook(12345, new Webhook("http://example-changed.com"));

Delete webhook by ID

String response = client.deleteWebhook(webhookId);