Skip to Content
mlab docs

API and AI agents

List, read, validate, save, publish and run RedKit flows from the REST API with a scoped key, or from an MCP client such as Claude.

Flows can be managed and run outside the editor: keep them in git and publish them from CI, run a check after each deployment, or let an AI agent write one for you. Every call goes through the same checks as the editor: plan, role, quotas, verified domains.

REST API

Base URL https://mlab.sh/api/v1, with an API key: Authorization: token mlab_… (see API keys). Every route answers 403 on the Free plan.

RouteScopeWhat it does
GET /flowsflows.readThe organization's flows: uuid, name, schedule, domains, published version, next run.
GET /flows/catalogflows.readHow a flow is written, every block kind with its fields and facts, limits, templates, your plan's flow limits, runs used this month, the ids you can point at (trackers, PagerDuty services, webhooks, Capri models, flows) and your verified domains.
POST /flows/getflows.readOne flow as an export, its draft (version 0 or absent) or a published version, and whether it can run.
POST /flows/validateflows.readChecks a graph without saving it: valid, the error, can_run, cannot_run_because, and the graph as it would be stored.
POST /flows/versionsflows.readThe published versions.
POST /flows/historyflows.readRecent runs, filtered by status, kind (manual, schedule, test, rerun), target, limit (up to 200).
POST /flows/run/statusflows.readOne run: its status and each block's status, port, findings and facts.
POST /flows/saveflows.writeCreates a flow (no uuid) or replaces a draft. Accepts {name, graph} or an export as flow.
POST /flows/publishflows.writePublishes the draft (or the graph sent) as the next version.
POST /flows/runflows.runRuns the live version on target (one domain), or targets: all, tag (with tag) or criticality (with criticality). Returns the first run, the batch and the count.
POST /flows/run/cancelflows.runCancels a queued or running run.

flows.write is not part of full access: tick it by name on the key. flows.write and flows.run both grant flows.read. No key can delete a flow, roll back, rerun or test a block: those stay in the editor. The full reference, with bodies and responses, is in the API reference.

Run after a deployment

RUN=$(curl -s -X POST https://mlab.sh/api/v1/flows/run \
  -H "Authorization: token $MLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"uuid":"FLOW_UUID","target":"example.com"}' | jq -r .run)

curl -s -X POST https://mlab.sh/api/v1/flows/run/status \
  -H "Authorization: token $MLAB_API_KEY" -H "Content-Type: application/json" \
  -d "{\"run\":\"$RUN\"}" | jq '.run.status'

Poll run/status every few seconds until the status is succeeded, failed or cancelled.

Keep flows in git

Export a flow from the editor (.flow.json), commit it, then from CI:

curl -s -X POST https://mlab.sh/api/v1/flows/save \
  -H "Authorization: token $MLAB_API_KEY" -H "Content-Type: application/json" \
  -d "{\"uuid\":\"FLOW_UUID\",\"flow\":$(cat mail-hygiene.flow.json)}"

curl -s -X POST https://mlab.sh/api/v1/flows/publish \
  -H "Authorization: token $MLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"uuid":"FLOW_UUID"}'

The export format:

{
  "format": "mlab.redkit.flow",
  "format_version": 1,
  "name": "Mail hygiene",
  "version": 0,
  "graph": { "nodes": [], "edges": [], "notes": [] }
}

AI agents (MCP)

The MCP server has ten flow tools, on paid plans. They act as you, with your role.

ToolWhat it doesSwitch
flows_list, flow_catalog, flow_get, flow_validate, flow_runs, flow_run_statusRead flows, the catalog, runs and results; check a flow without saving it.Read flows (on by default)
flow_save, flow_publishCreate or change a draft, publish it.Write and publish flows (off until you turn it on)
flow_run, flow_run_cancelRun a flow on verified domains, cancel a run. Each run counts against the month's quota, and its outputs act.Run flows (off until you turn it on)

No tool deletes a flow. Run results reach the agent with a warning that findings come from the checked sites and may contain text planted to steer it.

Ask, for example: "Write a flow that checks every Monday that our verified domains have DMARC at p=reject and alerts on anything new; validate it and save it as a draft."

Webhooks

Send alert and Call webhook send the event scan.redkit.flow.alert: payload in Webhooks.

On this page