Webhooks
Receive run, deployment, drift and retraining events over HTTP.
A webhook tells your own system when something happens in mlflow. When an event occurs, for example a training run finishes or a deployment starts to drift, mlflow sends an HTTP POST request with a JSON body to an address you choose. You can use it to post a message in a chat tool, open a ticket, start a pipeline of your own or keep a log, without polling the API.
Webhooks belong to a workspace. Everyone in the workspace can see them; only workspace administrators can create, change, test and delete them.
Create a webhook
Open the webhooks area
Open your workspace, select Settings, then Integrations. The Webhooks area has the form New webhook and the list Subscriptions.
Fill in the form
- Target URL: the address that should receive the events, for example
https://example.com/hook. mlflow's server must be able to reach it. - Shared secret (optional, ≥ 8 chars): a secret that mlflow uses to sign every delivery, so that you can check that a request really comes from mlflow. Use a long random value. Without a secret the webhook is marked unsigned.
- Event types: select the events to receive. By default
run.succeededanddrift.alertare selected.
Select Create webhook.
Check it with a test
In the Subscriptions table, select Test in the Actions column. mlflow sends a test.ping event to this webhook only. The Last fired column then shows the HTTP status your server answered, for example HTTP 200, and the time. A red status or an error means your server was unreachable or refused the request.
The table shows each webhook's URL, Events, Secret (signed or unsigned), Last fired and Enabled. Clear Enabled to pause a webhook without deleting it. Select Delete to remove it.
Use the API
curl -s -X POST "$BASE/workspaces/$WS/webhooks" \
-H "X-API-Key: $MLFLOW_API_KEY" -H "Content-Type: application/json" \
-d '{
"url": "https://example.com/hook",
"event_types": ["run.succeeded", "run.failed"],
"secret": "a-long-random-secret"
}'The response (201) describes the webhook. It never contains the secret; has_secret says whether one is set. Other endpoints: GET /workspaces/{workspace_id}/webhooks (list), GET /webhooks/{id}, PATCH /webhooks/{id} (change url, event_types, secret, filters, enabled), DELETE /webhooks/{id} and POST /webhooks/{id}/test. A key needs the write scope for changes, and its owner must be a workspace administrator. Unknown event names are rejected with 400.
mlflow stores the secret encrypted. It is not possible to read it back; to change it, send a new secret.
Events
| Event | Sent when |
|---|---|
run.succeeded | A training run finished successfully |
run.failed | A training run failed |
run.cancelled | A training run was cancelled |
drift.alert | A deployment's drift alert opens: a feature's PSI first exceeded its threshold |
retrain.decision | A scheduled retraining settled its decision |
You can also subscribe to deployment.created, deployment.deleted, deployment.rollback and schedule.failed. These names are accepted, but the current release does not send them yet, so a webhook that listens only to them receives nothing. Check this page after an upgrade.
drift.alert is sent once per drift incident, when the alert opens. It is not repeated while the alert stays open, and not for every drift check. For the meaning of PSI and thresholds, see Drift and alerts.
Filters
By default a webhook receives the selected events of the whole workspace. With the API you can narrow it with filters: an object of fields and values. An event is delivered only when each field of the filter equals the same field in the event's data. For example, {"filters": {"deployment_id": "..."}} on a drift.alert webhook delivers alerts for that deployment only. The app does not show filters.
Payload
Every delivery is an HTTP POST with a JSON body in this envelope:
{
"event": "run.succeeded",
"delivery_id": "6f1c0d9e-...",
"fired_at": "2026-11-22T10:15:30.123456+00:00",
"data": {
"workspace_id": "...",
"run_id": "...",
"experiment_id": "...",
"status": "succeeded",
"duration_ms": 84213,
"error": null
}
}data depends on the event.
| Event | Fields in data |
|---|---|
run.succeeded, run.failed, run.cancelled | workspace_id, run_id, experiment_id, status, duration_ms, error (the message for a failed run, otherwise null) |
drift.alert | workspace_id, deployment_id, event (opened), alert_id, status, report_id, drift_score, drift_status, psi_threshold, max_psi, breached_features (a list of objects with the feature, its PSI and its threshold) |
retrain.decision | workspace_id, deployment_id, decision_id, status, run_id, primary_metric, current_value, candidate_value, margin, margin_type, new_pipeline_id, reason |
test.ping (the Test button) | workspace_id and test: true |
New fields can be added at any time; ignore the ones you do not use. The request also carries these headers:
| Header | Value |
|---|---|
Content-Type | application/json |
X-PyCaret-Event | The event name, for example run.succeeded |
X-PyCaret-Delivery | A unique id for this delivery |
X-PyCaret-Signature | The signature, only when the webhook has a secret |
Header names
The header names keep their original X-PyCaret- prefix so that integrations that already exist keep working.
Verify the signature
When a webhook has a secret, mlflow computes an HMAC with SHA-256 over the raw request body, using the secret as the key, and sends it as a lowercase hexadecimal string in X-PyCaret-Signature. Compute the same value on your side and compare the two with a constant-time comparison. Reject the request if they differ.
Use the raw bytes exactly as received. If your framework parses the JSON first, the re-serialised text can differ and the check will fail.
import hashlib
import hmac
def is_valid(secret: str, raw_body: bytes, signature: str) -> bool:
expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)import crypto from "node:crypto";
export function isValid(secret, rawBody, signature) {
const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature || "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}Unsigned webhooks
Without a secret, anyone who knows your URL can send you fake events. Always set a secret for a webhook that triggers an action.
Retries and testing
- No automatic retries. mlflow sends each event once and waits at most 5 seconds for an answer. Answer quickly with a
2xxstatus and do the real work afterwards, for example in a queue. - Delivery never affects your work. If your server is down, the run, the deployment or the alert is not affected. The failure is recorded in the Last fired column of the webhook (the status code or the error); look there first when events seem to be missing.
- Events are not stored. An event that could not be delivered is not sent again later. If you must not miss one, also read the state from the API, for example
GET /projects/{project_id}/runs. - Order is not guaranteed. Events are sent from background tasks.
- Test any time. Select Test in the app, or call
POST /webhooks/{id}/test. The test event is sent to that webhook only, even if it does not subscribe totest.ping.
Related
Updated 2026-11-22