Automating Notifications with Mattermost Incoming Webhooks
Learn how to use Mattermost Incoming Webhooks to centralize DevOps alerts. This guide covers payload customization, security risks, and a practical curl example for automated notifications.
23 Feb 2026, 22:07 UTC

The Noise Problem in DevOps
When monitoring tools, CI/CD pipelines, and security scanners all send alerts to different places, critical failures get lost in the noise. The goal is to centralize these signals into a single source of truth—your team's chat—without manually copying and pasting logs or switching tabs every five minutes.
The most efficient way to achieve this in Mattermost is through Incoming Webhooks. These are unique HTTP endpoints that allow external systems to push JSON-formatted messages directly into a specific channel. Instead of building a full-blown bot with a complex API handshake, a webhook provides a "fire-and-forget" mechanism for one-way notifications.
How Incoming Webhooks Function
An incoming webhook acts as a gateway. When you create a webhook in the Mattermost System Console or Integration settings, the server generates a unique URL. This URL contains a secret token that serves as the authentication; anyone who possesses the URL can post to that channel.
The server expects an HTTP POST request with a application/json content type. While a simple string can be sent, Mattermost supports a structured payload that allows you to control the identity of the sender and the visual presentation of the data.
Payload Customization
- Username Override: You can specify a
usernamein the JSON to make the alert appear as "Jenkins-Build-Bot" or "Sentry-Alerts" rather than a generic webhook user. - Icon URL: The
icon_urlfield allows you to point to an external image (PNG/JPG), giving each integrated service a distinct visual identity in the chat stream. - Attachments: For complex data, the
attachmentsarray allows you to create structured blocks with color-coded sidebars (e.g., red for critical, green for success) and metadata fields.
Practical Example: Sending a Build Failure Alert
Assume you have a CI pipeline that needs to notify a #dev-ops channel when a production deployment fails. You have generated a webhook URL from the Mattermost Integration menu.
Run the following command from your build server or a local terminal. Replace https://your-mattermost.com/hooks/xxx with your actual generated URL.
curl -i -X POST -H 'Content-Type: application/json' \
-d '{
"username": "CI-Pipeline",
"icon_url": "https://example.com/ci-icon.png",
"text": "### ❌ Deployment Failed: Production Branch\nBuild #402 failed during the Integration Test phase.",
"attachments": [
{
"color": "#FF0000",
"fields": [
{ "short": true, "text": "**Commit:** a1b2c3d" },
{ "short": true, "text": "**Author:** Jane Doe" },
{ "short": false, "text": "**Error:** Timeout waiting for database migration to complete." }
]
}
]
}' https://your-mattermost.com/hooks/xxx
Expected Result: A message appears in the channel with a red sidebar, a custom "CI-Pipeline" name, and a formatted table showing the commit and error details. If the request returns a 200 OK, the message was accepted.
Trade-offs and Security Constraints
While webhooks are easy to deploy, they come with specific limitations that impact architectural decisions:
- Security Risk: Webhook URLs are "bearer tokens." If a URL is accidentally committed to a public Git repository, any external actor can spam your channel. Always treat these URLs as secrets (e.g., store them in environment variables or a secret manager).
- One-Way Communication: Webhooks cannot "read" messages or respond to user commands. If you need an interactive bot that answers questions, you must use the Mattermost REST API or a plugin.
- Rate Limiting: To prevent Denial-of-Service (DoS) attacks, Mattermost servers may rate-limit incoming requests. If your system sends hundreds of alerts per second, you may see
429 Too Many Requestserrors. In such cases, implement a queue or a batching mechanism before sending the POST request.
Verification and Maintenance
To verify your integration is healthy, check the System Console > Integrations menu to ensure the webhook is still active. If a message is not appearing, verify the network path between your external system and the Mattermost server (check firewalls/proxies) and ensure the JSON payload is valid. You can use a tool like Postman to isolate whether the issue lies with the payload format or the network connectivity.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.