Reference REST API 04 / 06
Desktop local API
The REST and MCP endpoints Writ Desktop serves on your machine, with local keys.
On this page
Writ Desktop serves a REST API and an MCP server on your computer. Your scripts, apps and agents call the APIs you built there, read their data and check monitors, with no account and no credits. Calls stay on your machine unless you open it to your network.
Base URL and keys
The API answers at http://127.0.0.1:8131/v1 while Writ Desktop is running. The same API
is available on other bases when you turn them on in the app:
http://127.0.0.1:8131/v1 this computer
https://127.0.0.1:8132/v1 this computer, HTTPS (after Trust certificate)
http://<your-lan-ip>:8131/v1 LAN mode (paid plans)
https://<words>.trycloudflare.com/v1 public URL (paid plans) HTTPS on your computer is set up in MCP & APIs → Endpoints → Secure connection (HTTPS). LAN mode and the public URL are set up in Settings → Engine & Data → Network access and need a paid plan (Starter and up): see Writ Desktop.
Keys
Every call sends Authorization: Bearer wlk_.... Create local keys in MCP & APIs → API Keys. A key is shown once.
| Preset | What it allows |
|---|---|
| Read-only | Reading (GET calls): workflows, runs, data, monitors, status. |
| Run automations | Read-only, plus running and cancelling workflows, monitor checks, OpenAI-compatible calls and MCP. |
| Full access | Run automations, plus creating and changing workflows, monitors and other resources. |
| Device control | A separate permission, not part of Full access: app lock, data reset and restore, issuing keys, LAN exposure, unlinking the cloud account. |
Writ Desktop also keeps an app token (wlt_) for programs on the same computer, such as the
SDKs’ local client. It works on this computer only and is refused over the public URL. MCP clients
can sign in with OAuth instead of a key; Writ asks you to approve each one.
Run workflows
Run a workflow
/v1/workflows/{id}/run
Starts a run with new inputs. By default it answers 202 at once with a run_id and a status_url to poll. With wait=true it waits for the result
and answers 200, also when the run failed (read status). Past the wait it
answers 504, and the run keeps going.
The workflow’s REST access must be on in its Call tab (it is on by default). Off, a
key gets 403.
Query
-
waitboolean defaultfalse - Wait for the result.
-
timeoutinteger default120 - Seconds to wait, from 1 to 3600.
-
asyncboolean - Answer
202at once, even withwait. Same as the headerPrefer: respond-async. -
max_ageinteger - Reuse a successful result with the same inputs younger than this many seconds. The answer then has
X-Cache: HIT. The headerCache-Control: max-age=Ndoes the same.
Body
-
inputsobject - The workflow’s inputs.
-
function_namestring - Run one function of an API, or
function_namesfor several. -
persona_idinteger - Run as another saved sign-in.
-
mutation_modestring defaultlive - For a function that writes:
dry_runpreviews it without sending.
curl -X POST "http://127.0.0.1:8131/v1/workflows/7/run?wait=true" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs": {"limit": 3}}' import os, requests
res = requests.post(
"http://127.0.0.1:8131/v1/workflows/7/run",
params={"wait": "true"},
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
json={"inputs": {"limit": 3}},
timeout=130,
)
print(res.json()["data"]) const res = await fetch("http://127.0.0.1:8131/v1/workflows/7/run?wait=true", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ inputs: { limit: 3 } }),
});
console.log((await res.json()).data); {
"run_id": 412,
"status": "success",
"done": true,
"data": {
"stories": [
{ "rank": 1, "title": "...", "points": 412 },
{ "rank": 2, "title": "...", "points": 288 },
{ "rank": 3, "title": "...", "points": 175 }
]
},
"duration_ms": 3180
} {
"success": true,
"run_id": 412,
"status": "running",
"status_url": "http://127.0.0.1:8131/v1/workflows/7/_runs/412",
"events_url": "http://127.0.0.1:8131/v1/runs/412/events"
} {
"success": false,
"run_id": 412,
"status": "running",
"done": false,
"error": "Run did not finish within 120s and is still in progress. ...",
"status_url": "http://127.0.0.1:8131/v1/workflows/7/_runs/412",
"events_url": "http://127.0.0.1:8131/v1/runs/412/events"
} Get a run’s result
/v1/workflows/{id}/_runs/{run_id}
Poll the status_url until done is true. A run in progress
answers with Retry-After: 2. A run waiting for you (a sign-in or a CAPTCHA) adds "needs_user": true; finish it on the Needs you page.
Status values
-
runningin progress - Also
repairingandawaiting_input. -
successdone - The run finished;
dataholds the result. -
faileddone - Also
timeout,cancelled,captcha_required,twofa_requiredandinterrupted.errorsays why.
curl "http://127.0.0.1:8131/v1/workflows/7/_runs/412" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/workflows/7/_runs/412",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.json()) const res = await fetch("http://127.0.0.1:8131/v1/workflows/7/_runs/412", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
console.log(await res.json()); {
"success": true,
"run_id": 412,
"status": "running",
"done": false,
"status_url": "http://127.0.0.1:8131/v1/workflows/7/_runs/412",
"events_url": "http://127.0.0.1:8131/v1/runs/412/events"
} {
"success": true,
"run_id": 412,
"status": "success",
"done": true,
"data": { "stories": [ ... ] },
"duration_ms": 3180
} List workflows
/v1/workflows Lists the workflows and APIs saved on this computer, newest first. Use an id from here in the other calls.
Query
-
active_onlyboolean - Only active workflows.
-
limitinteger default100 - How many to return.
curl "http://127.0.0.1:8131/v1/workflows?limit=20" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/workflows?limit=20",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.json()["data"]) const res = await fetch("http://127.0.0.1:8131/v1/workflows?limit=20", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
console.log((await res.json()).data); {
"data": [
{
"id": 7,
"name": "Top stories",
"description": "Top stories from news.ycombinator.com",
"workflow_type": "api_recorded",
"entry_url": "https://news.ycombinator.com",
"is_active": 1,
"schedule_enabled": 0
}
],
"count": 1
} Runs and data
List runs
/v1/runs The run history of this computer: workflows, monitors, crawls and Scribe sessions, newest first.
Query
-
workflow_idinteger - Runs of one workflow.
-
run_typestring - One kind of run, such as
workfloworcrawl. -
statusstring - One or more statuses, comma-separated.
-
sincestring - Runs after this time (ISO 8601).
untilsets the end. -
limitinteger - At most 1000. Page with
offset.
curl "http://127.0.0.1:8131/v1/runs?workflow_id=7&status=failed&limit=10" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/runs?workflow_id=7&status=failed&limit=10",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.json()["data"]) const res = await fetch("http://127.0.0.1:8131/v1/runs?workflow_id=7&status=failed&limit=10", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
console.log((await res.json()).data); {
"data": [
{
"id": "workflow-409",
"run_type": "workflow",
"entity_id": 7,
"entity_name": "Top stories",
"status": "failed",
"started_at": "2026-10-31T08:02:11Z",
"finished_at": "2026-10-31T08:02:40Z",
"duration_ms": 29110,
"trigger_source": "schedule",
"error": "The page did not load in time."
}
],
"count": 1,
"total": 1,
"limit": 10,
"offset": 0
} Cancel a run
/v1/runs/{run_id}/cancel Stops a run in progress and answers 202. A run that already ended answers 409 with "status": "not_running".
curl -X POST "http://127.0.0.1:8131/v1/runs/412/cancel" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.post(
"http://127.0.0.1:8131/v1/runs/412/cancel",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.status_code, res.json()) const res = await fetch("http://127.0.0.1:8131/v1/runs/412/cancel", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}`,
},
});
console.log(res.status, await res.json()); {
"run_id": 412,
"status": "cancel_requested"
} Read a workflow’s data
/v1/workflows/{id}/data
Everything a workflow collected, as a table: one row per record, with the run it came from and the
data under fields. Nothing runs.
Query
-
qstring - Text filter across fields.
-
viewstring defaultall all,latest(the last run) orrun(withrun_id).-
sort_bystring - A column, or
run_at.sort_dirisascordesc. -
limitinteger - Rows per page. Page with
offset.
curl "http://127.0.0.1:8131/v1/workflows/7/data?q=show&limit=50" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/workflows/7/data?q=show&limit=50",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.json()["rows"]) const res = await fetch("http://127.0.0.1:8131/v1/workflows/7/data?q=show&limit=50", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
console.log((await res.json()).rows); {
"workflow_id": 7,
"workflow_name": "Top stories",
"columns": ["rank", "title", "points"],
"declared": true,
"rows": [
{
"run_id": 412,
"run_at": "2026-10-31T09:15:02Z",
"status": "success",
"record_index": 0,
"fields": { "rank": 1, "title": "Show HN: ...", "points": 412 }
}
],
"total": 1,
"scanned_runs": 24,
"truncated": false,
"limit": 50,
"offset": 0
} Export a workflow’s data
/v1/workflows/{id}/data/export Downloads the whole table as a file.
Query
-
formatstring defaultcsv csv,json,markdownorhtml.
curl "http://127.0.0.1:8131/v1/workflows/7/data/export?format=csv" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" \
-o top-stories.csv import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/workflows/7/data/export",
params={"format": "csv"},
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
open("top-stories.csv", "wb").write(res.content) import { writeFile } from "node:fs/promises";
const res = await fetch("http://127.0.0.1:8131/v1/workflows/7/data/export?format=csv", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
await writeFile("top-stories.csv", Buffer.from(await res.arrayBuffer())); Monitors and status
Check a monitor now
/v1/monitors/{id}/run
Runs one check right away, outside the schedule. status is unchanged, changed, error, timeout, skipped or awaiting_input. GET /v1/monitors lists your monitors and GET /v1/monitors/{id}/changes their history.
curl -X POST "http://127.0.0.1:8131/v1/monitors/3/run" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.post(
"http://127.0.0.1:8131/v1/monitors/3/run",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.status_code, res.json()) const res = await fetch("http://127.0.0.1:8131/v1/monitors/3/run", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}`,
},
});
console.log(res.status, await res.json()); {
"target_id": 3,
"status": "changed",
"change_id": 58
} Check the engine
/v1/health Whether the engine is up and its version. status is ok or degraded.
curl "http://127.0.0.1:8131/v1/health" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" import os, requests
res = requests.get(
"http://127.0.0.1:8131/v1/health",
headers={"Authorization": f"Bearer {os.environ['WRIT_LOCAL_KEY']}"},
)
print(res.json()) const res = await fetch("http://127.0.0.1:8131/v1/health", {
headers: { Authorization: `Bearer ${process.env.WRIT_LOCAL_KEY}` },
});
console.log(await res.json()); {
"status": "ok",
"version": "1.0.9",
"db_ok": true,
"keyring_ok": true
} OpenAI-compatible, webhooks and MCP
Call a workflow as a chat model
/v1/workflows/{id}/v1/chat/completions
Point any OpenAI client at /v1/workflows/{id}/v1 and the workflow answers as
the assistant. The last user message reaches the workflow as the input message; an input object passes named inputs. /v1/responses and /v1/models work
at the same base. Set stream: true for a live session workflow.
The workflow’s OpenAI access must be on in its Call tab; off, the call answers 404.
curl -X POST "http://127.0.0.1:8131/v1/workflows/7/v1/chat/completions" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Top 3 stories"}], "input": {"limit": 3}}' import os
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8131/v1/workflows/7/v1",
api_key=os.environ["WRIT_LOCAL_KEY"],
)
reply = client.chat.completions.create(
model="writ:workflow:7",
messages=[{"role": "user", "content": "Top 3 stories"}],
)
print(reply.choices[0].message.content) import OpenAI from "openai";
const client = new OpenAI({
baseURL: "http://127.0.0.1:8131/v1/workflows/7/v1",
apiKey: process.env.WRIT_LOCAL_KEY,
});
const reply = await client.chat.completions.create({
model: "writ:workflow:7",
messages: [{ role: "user", content: "Top 3 stories" }],
});
console.log(reply.choices[0].message.content); {
"id": "chatcmpl-writ-413",
"object": "chat.completion",
"model": "writ:workflow:7",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "{ \"stories\": [ ... ] }" },
"finish_reason": "stop"
}
]
} Receive a webhook
/v1/hooks/{token}
An incoming webhook runs the workflow it is linked to, with inputs taken from the JSON body. It
needs no key: the token in the URL is the access. When the webhook has a secret, send X-Writ-Signature with the hex HMAC-SHA256 of
the raw body (a sha256= prefix is accepted). A wrong signature answers 401,
an unknown token 404.
Create webhooks in MCP & APIs → Endpoints → Incoming webhooks. Over the public URL, use https://<words>.trycloudflare.com/v1/hooks/<token>.
BODY='{"sku": "A-1042"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" -hex | sed 's/^.* //')
curl -X POST "http://127.0.0.1:8131/v1/hooks/<token>" \
-H "Content-Type: application/json" \
-H "X-Writ-Signature: sha256=$SIG" \
-d "$BODY" import hashlib, hmac, os, requests
body = b'{"sku": "A-1042"}'
sig = hmac.new(os.environ["WEBHOOK_SECRET"].encode(), body, hashlib.sha256).hexdigest()
res = requests.post(
"http://127.0.0.1:8131/v1/hooks/<token>",
data=body,
headers={"Content-Type": "application/json", "X-Writ-Signature": f"sha256={sig}"},
)
print(res.json()) import { createHmac } from "node:crypto";
const body = JSON.stringify({ sku: "A-1042" });
const sig = createHmac("sha256", process.env.WEBHOOK_SECRET!).update(body).digest("hex");
const res = await fetch("http://127.0.0.1:8131/v1/hooks/<token>", {
method: "POST",
headers: { "Content-Type": "application/json", "X-Writ-Signature": `sha256=${sig}` },
body,
});
console.log(await res.json()); {
"run_id": 414,
"accepted": true
} MCP endpoint
/mcp
Writ Desktop’s MCP server over HTTP, at http://127.0.0.1:8131/mcp. Add ?tools=all for every tool’s full reference. Most clients connect with the local
command instead: see Connect an AI assistant.
curl -X POST "http://127.0.0.1:8131/mcp" \
-H "Authorization: Bearer $WRIT_LOCAL_KEY" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' Errors
Every error has the same shape: a readable error and a stable code.
{
"error": "not found: workflow 7",
"code": "not_found"
} | Status | Code | Meaning |
|---|---|---|
| 400 | bad_request | An input or parameter is wrong. |
| 401 | unauthorized | No key, or an unknown key. |
| 402 | plan_required | LAN mode or the public URL needs a paid plan. |
| 403 | forbidden | The key’s preset does not allow this call, or the workflow’s REST access is off. |
| 404 | not_found | No such workflow, run or monitor. |
| 409 | conflict | The resource is not in a state for this call. |
| 423 | vault_locked | The app lock is on. Unlock Writ Desktop, then call again. |
| 504 | (run still going) | A waited run did not finish in time. Poll its status_url. |