> For the complete documentation index, see [llms.txt](https://docs.mailtrap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailtrap.io/developers/email-sending/webhooks/update-a-webhook.md).

# Update a webhook

Update an existing 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, tracking opt-outs, 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","inbound_receiving"]},"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"},"inbound_inbox_id":{"type":["integer","null"],"description":"ID of the inbound inbox the webhook is linked to. Applicable only\nfor `inbound_receiving` webhooks.\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"]}},"inbound_inbox_id":{"type":"integer","description":"ID of the inbound inbox the webhook is linked to.\nApplicable only for `inbound_receiving` webhooks.\n"}}}}}}}},"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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mailtrap.io/developers/email-sending/webhooks/update-a-webhook.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
