# Webhooks

Configure webhooks to receive real-time notifications about events in your Mailtrap account. For a complete guide, see [Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).

## List webhooks

> Returns all webhooks for the account.

```json
{"openapi":"3.1.0","info":{"title":"Email Sending","version":"2.0.0"},"tags":[{"name":"webhooks","description":"Configure webhooks to receive real-time notifications about events in\nyour Mailtrap account. For a complete guide, see \n[Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).\n"}],"servers":[{"description":"Mailtrap account API (`mailtrap.io`) for domains, suppressions, stats, and email logs.\nError JSON matches other account endpoints (`error` or string `errors`), not the `send.api` / `bulk.api` sending shape (`success` + `errors` array).\n","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"schemas":{"Webhook":{"type":"object","properties":{"id":{"type":"integer"},"url":{"type":"string","format":"uri"},"active":{"type":"boolean"},"webhook_type":{"type":"string","enum":["email_sending","campaigns","audit_log"]},"payload_format":{"type":"string","enum":["json","jsonlines"]},"sending_stream":{"type":["string","null"],"enum":["transactional","bulk",null],"description":"Sending stream the webhook is subscribed to. Applicable only for\n`email_sending` webhooks.\n"},"domain_id":{"type":["integer","null"],"description":"Scopes the webhook to a specific domain ID, or all domains if\nomitted. Applicable only for `email_sending` and `campaigns`\nwebhooks.\n"},"event_types":{"type":"array","description":"List of event types the webhook is subscribed to. Applicable only\nfor `email_sending` and `campaigns` webhooks.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}}},"responses":{"Unauthorized":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"Forbidden":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}}}},"paths":{"/api/webhooks":{"get":{"operationId":"listWebhooks","summary":"List webhooks","description":"Returns all webhooks for the account.","tags":["webhooks"],"responses":{"200":{"description":"List of webhooks","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}}}}
```

## Create a webhook

> Create a new webhook for the account. The response includes a\
> \`signing\_secret\` that is used to \[verify webhook signatures]\(<https://docs.mailtrap.io/email-api-smtp/advanced/webhooks#webhook-signature-verification>).<br>

```json
{"openapi":"3.1.0","info":{"title":"Email Sending","version":"2.0.0"},"tags":[{"name":"webhooks","description":"Configure webhooks to receive real-time notifications about events in\nyour Mailtrap account. For a complete guide, see \n[Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).\n"}],"servers":[{"description":"Mailtrap account API (`mailtrap.io`) for domains, suppressions, stats, and email logs.\nError JSON matches other account endpoints (`error` or string `errors`), not the `send.api` / `bulk.api` sending shape (`success` + `errors` array).\n","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"schemas":{"WebhookCreateResponse":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/Webhook"},{"type":"object","properties":{"signing_secret":{"type":"string","description":"Secret key for verifying webhook payload signatures using HMAC SHA-256. Only returned on creation.\n"}}}]}}},"Webhook":{"type":"object","properties":{"id":{"type":"integer"},"url":{"type":"string","format":"uri"},"active":{"type":"boolean"},"webhook_type":{"type":"string","enum":["email_sending","campaigns","audit_log"]},"payload_format":{"type":"string","enum":["json","jsonlines"]},"sending_stream":{"type":["string","null"],"enum":["transactional","bulk",null],"description":"Sending stream the webhook is subscribed to. Applicable only for\n`email_sending` webhooks.\n"},"domain_id":{"type":["integer","null"],"description":"Scopes the webhook to a specific domain ID, or all domains if\nomitted. Applicable only for `email_sending` and `campaigns`\nwebhooks.\n"},"event_types":{"type":"array","description":"List of event types the webhook is subscribed to. Applicable only\nfor `email_sending` and `campaigns` webhooks.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"UnprocessableEntity":{"type":"object","description":"Validation errors per field. Keys are attribute names; values are arrays of human-readable messages.\nSome endpoints may also return a `base` key with general validation errors.","properties":{"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}},"responses":{"Unauthorized":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"Forbidden":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"UnprocessableEntity":{"description":"Validation errors","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnprocessableEntity"}}}}}},"paths":{"/api/webhooks":{"post":{"operationId":"createWebhook","summary":"Create a webhook","description":"Create a new webhook for the account. The response includes a\n`signing_secret` that is used to [verify webhook signatures](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks#webhook-signature-verification).\n","tags":["webhooks"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["webhook"],"properties":{"webhook":{"type":"object","required":["url","webhook_type"],"properties":{"url":{"type":"string","format":"uri","description":"The URL that will receive webhook payloads."},"webhook_type":{"type":"string","description":"The type of webhook. Determines which events the webhook can subscribe to.\n","enum":["email_sending","campaigns","audit_log"]},"active":{"type":"boolean","description":"Whether the webhook is active. Defaults to `true`.","default":true},"payload_format":{"type":"string","description":"Format of the webhook payload.","enum":["json","jsonlines"],"default":"json"},"sending_stream":{"type":"string","description":"Sending stream the webhook subscribes to. Required for `email_sending` webhook type.\n","enum":["transactional","bulk"]},"event_types":{"type":"array","description":"List of event types to subscribe to. Required for `email_sending` and `campaigns` webhook types.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}},"domain_id":{"type":"integer","description":"Scopes the webhook to a specific domain ID, or all\ndomains if omitted. Applicable only for `email_sending`\nand `campaigns` webhooks.\n"}}}}}}}},"responses":{"200":{"description":"Webhook created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreateResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/UnprocessableEntity"}}}}}}
```

## Get a webhook

> Returns a single webhook by ID.

```json
{"openapi":"3.1.0","info":{"title":"Email Sending","version":"2.0.0"},"tags":[{"name":"webhooks","description":"Configure webhooks to receive real-time notifications about events in\nyour Mailtrap account. For a complete guide, see \n[Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).\n"}],"servers":[{"description":"Mailtrap account API (`mailtrap.io`) for domains, suppressions, stats, and email logs.\nError JSON matches other account endpoints (`error` or string `errors`), not the `send.api` / `bulk.api` sending shape (`success` + `errors` array).\n","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"parameters":{"webhook_id":{"name":"webhook_id","in":"path","required":true,"description":"Webhook ID","schema":{"type":"integer"}}},"schemas":{"Webhook":{"type":"object","properties":{"id":{"type":"integer"},"url":{"type":"string","format":"uri"},"active":{"type":"boolean"},"webhook_type":{"type":"string","enum":["email_sending","campaigns","audit_log"]},"payload_format":{"type":"string","enum":["json","jsonlines"]},"sending_stream":{"type":["string","null"],"enum":["transactional","bulk",null],"description":"Sending stream the webhook is subscribed to. Applicable only for\n`email_sending` webhooks.\n"},"domain_id":{"type":["integer","null"],"description":"Scopes the webhook to a specific domain ID, or all domains if\nomitted. Applicable only for `email_sending` and `campaigns`\nwebhooks.\n"},"event_types":{"type":"array","description":"List of event types the webhook is subscribed to. Applicable only\nfor `email_sending` and `campaigns` webhooks.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}},"responses":{"Unauthorized":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"Forbidden":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}}},"paths":{"/api/webhooks/{webhook_id}":{"get":{"operationId":"getWebhook","summary":"Get a webhook","description":"Returns a single webhook by ID.","tags":["webhooks"],"parameters":[{"$ref":"#/components/parameters/webhook_id"}],"responses":{"200":{"description":"Webhook details","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
```

## Delete a webhook

> Permanently delete a webhook.

```json
{"openapi":"3.1.0","info":{"title":"Email Sending","version":"2.0.0"},"tags":[{"name":"webhooks","description":"Configure webhooks to receive real-time notifications about events in\nyour Mailtrap account. For a complete guide, see \n[Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).\n"}],"servers":[{"description":"Mailtrap account API (`mailtrap.io`) for domains, suppressions, stats, and email logs.\nError JSON matches other account endpoints (`error` or string `errors`), not the `send.api` / `bulk.api` sending shape (`success` + `errors` array).\n","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"parameters":{"webhook_id":{"name":"webhook_id","in":"path","required":true,"description":"Webhook ID","schema":{"type":"integer"}}},"schemas":{"Webhook":{"type":"object","properties":{"id":{"type":"integer"},"url":{"type":"string","format":"uri"},"active":{"type":"boolean"},"webhook_type":{"type":"string","enum":["email_sending","campaigns","audit_log"]},"payload_format":{"type":"string","enum":["json","jsonlines"]},"sending_stream":{"type":["string","null"],"enum":["transactional","bulk",null],"description":"Sending stream the webhook is subscribed to. Applicable only for\n`email_sending` webhooks.\n"},"domain_id":{"type":["integer","null"],"description":"Scopes the webhook to a specific domain ID, or all domains if\nomitted. Applicable only for `email_sending` and `campaigns`\nwebhooks.\n"},"event_types":{"type":"array","description":"List of event types the webhook is subscribed to. Applicable only\nfor `email_sending` and `campaigns` webhooks.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}},"responses":{"Unauthorized":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"Forbidden":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}}},"paths":{"/api/webhooks/{webhook_id}":{"delete":{"operationId":"deleteWebhook","summary":"Delete a webhook","description":"Permanently delete a webhook.","tags":["webhooks"],"parameters":[{"$ref":"#/components/parameters/webhook_id"}],"responses":{"200":{"description":"Webhook deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
```

## Update a webhook

> Update an existing webhook.<br>

```json
{"openapi":"3.1.0","info":{"title":"Email Sending","version":"2.0.0"},"tags":[{"name":"webhooks","description":"Configure webhooks to receive real-time notifications about events in\nyour Mailtrap account. For a complete guide, see \n[Webhooks](https://docs.mailtrap.io/email-api-smtp/advanced/webhooks).\n"}],"servers":[{"description":"Mailtrap account API (`mailtrap.io`) for domains, suppressions, stats, and email logs.\nError JSON matches other account endpoints (`error` or string `errors`), not the `send.api` / `bulk.api` sending shape (`success` + `errors` array).\n","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"parameters":{"webhook_id":{"name":"webhook_id","in":"path","required":true,"description":"Webhook ID","schema":{"type":"integer"}}},"schemas":{"Webhook":{"type":"object","properties":{"id":{"type":"integer"},"url":{"type":"string","format":"uri"},"active":{"type":"boolean"},"webhook_type":{"type":"string","enum":["email_sending","campaigns","audit_log"]},"payload_format":{"type":"string","enum":["json","jsonlines"]},"sending_stream":{"type":["string","null"],"enum":["transactional","bulk",null],"description":"Sending stream the webhook is subscribed to. Applicable only for\n`email_sending` webhooks.\n"},"domain_id":{"type":["integer","null"],"description":"Scopes the webhook to a specific domain ID, or all domains if\nomitted. Applicable only for `email_sending` and `campaigns`\nwebhooks.\n"},"event_types":{"type":"array","description":"List of event types the webhook is subscribed to. Applicable only\nfor `email_sending` and `campaigns` webhooks.\n","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"UnprocessableEntity":{"type":"object","description":"Validation errors per field. Keys are attribute names; values are arrays of human-readable messages.\nSome endpoints may also return a `base` key with general validation errors.","properties":{"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}},"responses":{"Unauthorized":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"Forbidden":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}},"UnprocessableEntity":{"description":"Validation errors","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnprocessableEntity"}}}}}},"paths":{"/api/webhooks/{webhook_id}":{"patch":{"operationId":"updateWebhook","summary":"Update a webhook","description":"Update an existing webhook.\n","tags":["webhooks"],"parameters":[{"$ref":"#/components/parameters/webhook_id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["webhook"],"properties":{"webhook":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"The URL that will receive webhook payloads."},"active":{"type":"boolean","description":"Whether the webhook is active."},"payload_format":{"type":"string","description":"Format of the webhook payload.","enum":["json","jsonlines"]},"event_types":{"type":"array","description":"List of event types to subscribe to. Applicable only for `email_sending` and `campaigns` webhooks.","items":{"type":"string","enum":["delivery","soft_bounce","bounce","suspension","unsubscribe","open","spam_complaint","click","reject"]}}}}}}}}},"responses":{"200":{"description":"Webhook updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/UnprocessableEntity"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mailtrap.io/developers/email-sending/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
