Get started

Reference REST API 04 / 06

Desktop local API

The REST and MCP endpoints Writ Desktop serves on your machine, with local keys.

Runs on Writ Desktop

Markdown Open in Claude Open in ChatGPT

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:

Bases
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.

PresetWhat it allows
Read-onlyReading (GET calls): workflows, runs, data, monitors, status.
Run automationsRead-only, plus running and cancelling workflows, monitor checks, OpenAI-compatible calls and MCP.
Full accessRun automations, plus creating and changing workflows, monitors and other resources.
Device controlA 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

POST /v1/workflows/{id}/run free Run automations

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

wait boolean default false
Wait for the result.
timeout integer default 120
Seconds to wait, from 1 to 3600.
async boolean
Answer 202 at once, even with wait. Same as the header Prefer: respond-async.
max_age integer
Reuse a successful result with the same inputs younger than this many seconds. The answer then has X-Cache: HIT. The header Cache-Control: max-age=N does the same.

Body

inputs object
The workflow’s inputs.
function_name string
Run one function of an API, or function_names for several.
persona_id integer
Run as another saved sign-in.
mutation_mode string default live
For a function that writes: dry_run previews 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}}'
200 OK (wait=true)
{
  "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
}
202 Accepted
{
  "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"
}
504 Gateway Timeout
{
  "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

GET /v1/workflows/{id}/_runs/{run_id} Read-only

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

running in progress
Also repairing and awaiting_input.
success done
The run finished; data holds the result.
failed done
Also timeout, cancelled, captcha_required, twofa_required and interrupted. error says why.
curl "http://127.0.0.1:8131/v1/workflows/7/_runs/412" \
  -H "Authorization: Bearer $WRIT_LOCAL_KEY"
200 OK (running)
{
  "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"
}
200 OK (done)
{
  "success": true,
  "run_id": 412,
  "status": "success",
  "done": true,
  "data": { "stories": [ ... ] },
  "duration_ms": 3180
}

List workflows

GET /v1/workflows Read-only

Lists the workflows and APIs saved on this computer, newest first. Use an id from here in the other calls.

Query

active_only boolean
Only active workflows.
limit integer default 100
How many to return.
curl "http://127.0.0.1:8131/v1/workflows?limit=20" \
  -H "Authorization: Bearer $WRIT_LOCAL_KEY"
200 OK
{
  "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

GET /v1/runs Read-only

The run history of this computer: workflows, monitors, crawls and Scribe sessions, newest first.

Query

workflow_id integer
Runs of one workflow.
run_type string
One kind of run, such as workflow or crawl.
status string
One or more statuses, comma-separated.
since string
Runs after this time (ISO 8601). until sets the end.
limit integer
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"
200 OK
{
  "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

POST /v1/runs/{run_id}/cancel Run automations

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"
202 Accepted
{
  "run_id": 412,
  "status": "cancel_requested"
}

Read a workflow’s data

GET /v1/workflows/{id}/data Read-only

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

q string
Text filter across fields.
view string default all
all, latest (the last run) or run (with run_id).
sort_by string
A column, or run_at. sort_dir is asc or desc.
limit integer
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"
200 OK
{
  "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

GET /v1/workflows/{id}/data/export Read-only

Downloads the whole table as a file.

Query

format string default csv
csv, json, markdown or html.
curl "http://127.0.0.1:8131/v1/workflows/7/data/export?format=csv" \
  -H "Authorization: Bearer $WRIT_LOCAL_KEY" \
  -o top-stories.csv

Monitors and status

Check a monitor now

POST /v1/monitors/{id}/run Run automations

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"
200 OK
{
  "target_id": 3,
  "status": "changed",
  "change_id": 58
}

Check the engine

GET /v1/health Read-only

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"
200 OK
{
  "status": "ok",
  "version": "1.0.9",
  "db_ok": true,
  "keyring_ok": true
}

OpenAI-compatible, webhooks and MCP

Call a workflow as a chat model

POST /v1/workflows/{id}/v1/chat/completions Run automations

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}}'
200 OK
{
  "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

POST /v1/hooks/{token} token in the URL

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"
200 OK
{
  "run_id": 414,
  "accepted": true
}

MCP endpoint

POST /mcp Run automations or OAuth

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.

List the tools
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.

404 Not Found
{
  "error": "not found: workflow 7",
  "code": "not_found"
}
StatusCodeMeaning
400bad_requestAn input or parameter is wrong.
401unauthorizedNo key, or an unknown key.
402plan_requiredLAN mode or the public URL needs a paid plan.
403forbiddenThe key’s preset does not allow this call, or the workflow’s REST access is off.
404not_foundNo such workflow, run or monitor.
409conflictThe resource is not in a state for this call.
423vault_lockedThe 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.

Next