# REST API reference

> Every customer endpoint of Writ Cloud, grouped by resource, with requests and responses.

Source: https://usewrit.app/docs/api/

Writ Cloud's REST API covers most of what you do in the web app: call the APIs you built, run workflows,
read pages, harvest sites, read collected data, and manage monitors and automations. Each section
below is one resource. Each operation shows the scope your key needs, what it costs, a request and
the response.

## Before you call

| Topic | How it works |
| --- | --- |
| Base URL | https://api.usewrit.app. Every path on this page starts there. |
| Authentication | Send Authorization: Bearer wt_... on every call, except keyless calls and signed webhooks. Each operation names the scope it needs. A key without that scope gets 403, and so does any route that is not open to keys. OAuth tokens (wto_) follow the same scopes, except on published endpoints and runs by workflow id, which take API keys only. See API keys and OAuth. |
| Format | Request and response bodies are JSON (Content-Type: application/json). File uploads use multipart form data, and exports return CSV, Markdown or HTML when you ask for them. |
| Pagination | List operations take limit and offset query parameters. The largest limit is listed with each operation. A page shorter than limit is the last one. |
| Errors | Most errors answer {"detail": ...}. Published endpoints answer {"success": false, "error": ..., "detail": ...}. Codes and bodies: Errors and limits. |
| Rate limits | Your plan sets the calls per minute, shared by every key and token of the account. Past it you get 429 with a Retry-After header. |
| Retries | Send an Idempotency-Key header on POST, PUT and PATCH. The same key within 24 hours replays the first answer instead of running the call again. |
| Cost headers | A call that waits for a run answers with X-Writ-Credits-Charged, X-Writ-Credits-Remaining and X-Writ-Ran-On (local, cloud or cloud-wall). |
| OpenAPI | There is no OpenAPI file for the whole API. Each API you build exports its own: GET /api/v1/workflows/{id}/api-docs?format=openapi, or Download OpenAPI on its Documentation tab. |

Check your key with a small read. This one lists your last five runs:

```bash
curl "https://api.usewrit.app/api/runs?limit=5" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/runs",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 5},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/runs?limit=5", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

## Published endpoints

A published endpoint is the stable URL of an API you built, turned on with **Publish REST endpoint** on the API's **Call** tab. `{ref}` is your organization's public id or vanity
name. More on waiting, caching and envelopes: [Call your API](https://usewrit.app/docs/call).

### Call a published endpoint

POST `/v1/{ref}/{path}` 2 or 20 cr / call workflows:execute

Runs the API with the inputs in the body and waits for the result, up to the endpoint's timeout
(5 to 300 seconds, 120 by default). The endpoint's own method can also be `GET`, `PUT`, `PATCH` or `DELETE`.

Path

- `ref` (string, required): Your organization's public id or vanity name.
- `path` (string, required): The path you gave the endpoint.

Query and headers

- `Prefer: respond-async` (header): Answer 202 at once with a run_id, a status_url and a Location header. Same as ?async=true.
- `Cache-Control: max-age=N` (header): Accept a stored answer up to N seconds old. Same as ?max_age=N. 0 forces a fresh run. The response carries X-Cache: HIT or MISS and Age.

Body

- `(inputs)` (object): The function's inputs as JSON fields.
- `function_name` (string): For an API with several functions: the one to run. Without it, the whole API runs.

A run that outlives the timeout answers `504` with `run_id` and `status_url`. The run keeps going; collect it with the next operation. Your plan's calls per minute apply, and each key may also make 60 calls a minute here.

```bash
curl -X POST "https://api.usewrit.app/v1/your-org/top-stories" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"limit": 3}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/v1/your-org/top-stories",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"limit": 3},
    timeout=130,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/v1/your-org/top-stories", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ limit: 3 }),
});
console.log(await res.json());
```

```json
{
  "success": true,
  "data": {
    "stories": [
      { "rank": 1, "title": "...", "points": 412, "url": "https://..." },
      { "rank": 2, "title": "...", "points": 288, "url": "https://..." },
      { "rank": 3, "title": "...", "points": 175, "url": "https://..." }
    ]
  }
}
```

### Collect a run

GET `/v1/{ref}/_runs/{run_id}` free same key

Reads a run started with `Prefer: respond-async`, or one that timed out. Use the key that
started it. The answer is `200` even when the run failed: read `status` and `error`.

Path

- `run_id` (string, required): The run_id from the 202 or 504 answer.

While `done` is `false`, the response has a `Retry-After: 2` header. Polls do not count against your calls per minute.

```bash
curl "https://api.usewrit.app/v1/your-org/_runs/run_Xb2c9T0qLm4sV8eYp1Aw" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/v1/your-org/_runs/run_Xb2c9T0qLm4sV8eYp1Aw",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/v1/your-org/_runs/run_Xb2c9T0qLm4sV8eYp1Aw", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "success": true,
  "run_id": "run_Xb2c9T0qLm4sV8eYp1Aw",
  "status": "running",
  "done": false,
  "status_url": "https://api.usewrit.app/v1/your-org/_runs/run_Xb2c9T0qLm4sV8eYp1Aw"
}
```

```json
{
  "success": true,
  "run_id": "run_Xb2c9T0qLm4sV8eYp1Aw",
  "status": "success",
  "done": true,
  "data": { "stories": [ { "rank": 1, "title": "...", "points": 412 } ] }
}
```

## APIs by workflow id

These operations address an API or workflow by its numeric id, the number in its address in the app.
They work without publishing an endpoint.

### List workflows with data

GET `/api/v1/workflows` workflows:read

Lists your workflows that have collected data, most recent data first, with their run count.

Query

- `limit` (integer): Page size, 1 to 500. Without it, every workflow is returned.
- `offset` (integer): Rows to skip.

```bash
curl "https://api.usewrit.app/api/v1/workflows?limit=20" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/workflows",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 20},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/workflows?limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "workflows": [
    {
      "workflow_id": 412,
      "workflow_name": "Hacker News top stories",
      "entry_url": "https://news.ycombinator.com",
      "run_count": 37,
      "last_data_at": "2026-10-31T13:58:06+00:00"
    }
  ]
}
```

### Run a workflow

POST `/api/v1/workflows/{id}/runs` 2 or 20 cr / run workflows:execute

Runs the whole workflow with new inputs. By default the call waits and returns the extracted data. To
run one function of a multi-function API, call its published endpoint with `function_name`.

Query

- `wait` (boolean): Wait for the result. With false, the answer is {"task_id", "status": "pending"} at once.
- `timeout` (integer): Seconds to wait, 10 to 300. Past it the answer carries error and task_id, and the run continues.

Body

- `form_data` (object): The workflow's inputs. Without it, the saved inputs are used.

```bash
curl -X POST "https://api.usewrit.app/api/v1/workflows/412/runs?wait=true&timeout=120" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"form_data": {"limit": 3}}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/v1/workflows/412/runs",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"wait": "true", "timeout": 120},
    json={"form_data": {"limit": 3}},
    timeout=130,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/workflows/412/runs?wait=true&timeout=120", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ form_data: { limit: 3 } }),
});
console.log(await res.json());
```

```json
{
  "stories": [
    { "rank": 1, "title": "...", "points": 412 },
    { "rank": 2, "title": "...", "points": 288 },
    { "rank": 3, "title": "...", "points": 175 }
  ]
}
```

### Get a run's result

GET `/api/v1/workflows/{id}/runs/{task_id}` workflows:execute

Reads one run of the workflow: its status, extracted data, error and duration.

Path

- `id` (integer, required): The workflow id.
- `task_id` (integer, required): The run's task_id.

```bash
curl "https://api.usewrit.app/api/v1/workflows/412/runs/98123" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/workflows/412/runs/98123",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/workflows/412/runs/98123", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "task_id": 98123,
  "status": "success",
  "success": true,
  "extracted_data": { "stories": [ { "rank": 1, "title": "...", "points": 412 } ] },
  "result_data": { "extracted_data": { "stories": [ "..." ] } },
  "error": null,
  "duration_ms": 4210
}
```

### Export an API's description

GET `/api/v1/workflows/{id}/api-docs` workflows:read

Returns the API's functions as an OpenAPI 3 document, Markdown, a Postman collection or an agent skill file.

Query

- `format` (string): openapi, markdown, postman, bundle (all of them) or skill (a SKILL.md for AI agents).

```bash
curl "https://api.usewrit.app/api/v1/workflows/412/api-docs?format=openapi" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/workflows/412/api-docs",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"format": "openapi"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/workflows/412/api-docs?format=openapi", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "openapi": "3.0.3",
  "info": { "title": "Hacker News", "version": "1.0.0", "description": "Auto-generated API for Hacker News. ..." },
  "tags": [ { "name": "Stories", "description": "Stories functions" } ],
  "paths": {
    "/top_stories": {
      "post": {
        "tags": ["Stories"],
        "summary": "Top stories with title, points and link",
        "operationId": "top_stories",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object" } } } },
        "responses": { "200": { "description": "Success" } }
      }
    }
  },
  "servers": [ { "url": "https://api.usewrit.app" } ]
}
```

## Website to API

Describe what you need from a site and Writ's builder makes the API. A build runs in the background:
start it, then poll it. Details: [Turn a website into an API](https://usewrit.app/docs/website-to-api).

### Start a build

POST `/api/v1/website-to-api` 1 AI build workflows:write

Answers `202` in one of three ways. `"status": "existing_workflows"` means your own
workflows already cover the goal; `"marketplace_candidates"` means ready-made APIs do. Neither
spends a build. Otherwise the answer is a new build with `"status": "queued"`.

Body

- `url` (string, required): The site to start on.
- `goal` (string, required): What the API should return or do, in plain words. Up to 5,000 characters.
- `persona_id` (integer): A persona to sign in with, for data behind a login.
- `tier` (string): standard or deep. A deep build covers the whole site with bigger bounds and always costs 6,000 credits, never an included build.
- `accept_credits` (boolean): Consent to pay credits for this build: a standard build past your plan’s monthly count (1,500 credits) or a deep build. Held while the build runs, charged in full only when it delivers a working API; a build you stop pays what it used, never more than its price.
- `save_as` (string): Name of the API the build saves.
- `skip_existing` (boolean): Build even if your own workflows match.
- `skip_marketplace` (boolean): Build even if a ready-made API matches.
- `contribute_to_catalog` (boolean): Marketplace choice for this build. Left out, a free build is submitted to the Marketplace for review and a paid one stays private. true submits it; false keeps it private, on Starter and up or during a trial.

> **limit:** A standard build counts against your plan's Writ AI builds per month. Past that number the call answers 402 with build_quota_exhausted and the price_credits (1,500 credits); a deep build without accept_credits answers build_credits_consent_required. Send the same request again with accept_credits: true to pay; the full price is charged only when the build delivers a working API. A failed or parked build charges nothing; a build you stop pays what it used so far, never more than its price. A build started with an API key fails instead of waiting for you when it meets a CAPTCHA or a sign-in.

```bash
curl -X POST "https://api.usewrit.app/api/v1/website-to-api" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.ycombinator.com",
    "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
    "save_as": "Hacker News"
  }'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/v1/website-to-api",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={
        "url": "https://news.ycombinator.com",
        "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
        "save_as": "Hacker News",
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/website-to-api", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://news.ycombinator.com",
    goal: "Top stories with title, points, comment count and link. Let me ask for how many.",
    save_as: "Hacker News",
  }),
});
console.log(await res.json());
```

```json
{
  "build_id": 5821,
  "status": "queued",
  "url": "https://news.ycombinator.com",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "created_at": "2026-10-31T14:02:11+00:00",
  "completed_at": null,
  "workflow_id": null,
  "error": null
}
```

### Get a build

GET `/api/v1/website-to-api/{build_id}` workflows:read

Reads a build. `status` goes from `queued` to `building`, then ends as `succeeded`, `failed` or `cancelled`. A finished build carries the new API's `workflow_id`.

While it builds, the answer adds `progress`, `steps_taken` and `current_url`. If it
has `fallback_build_id`, Writ moved the work to a new build: poll that id instead. A build that a
site refused carries `site_block`.

```bash
curl "https://api.usewrit.app/api/v1/website-to-api/5821" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/website-to-api/5821",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/website-to-api/5821", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "build_id": 5821,
  "status": "succeeded",
  "url": "https://news.ycombinator.com",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "created_at": "2026-10-31T14:02:11+00:00",
  "completed_at": "2026-10-31T14:06:40+00:00",
  "workflow_id": 981,
  "error": null
}
```

## Read pages

One-off reads of a page or a site's links, without saving anything.

### Read a page

POST `/api/crawl/scrape` 0.5 or 1 cr / page scrape:execute

Reads one page and returns its main content as Markdown, or its HTML. A page read with a plain fetch
costs 0.5 credit, one that needs a browser 1. On Pro and up, a CAPTCHA passed by a paid solver adds 10.

Body

- `url` (string, required): The page to read.
- `format` (string): markdown, html (the raw page) or both.
- `render_mode` (string): auto tries a plain fetch first, then a browser. http or browser force one.
- `persona_id` (integer): Read the page signed in as this persona.
- `use_residential` (boolean): Read through a residential address, billed at 7 credits per MB.

A page that cannot be read answers `422` with a code such as `scrape_not_found` or `scrape_bot_wall`, and `retry_with` when another read could work.

```bash
curl -X POST "https://api.usewrit.app/api/crawl/scrape" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/pricing", "format": "markdown"}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/crawl/scrape",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"url": "https://example.com/pricing", "format": "markdown"},
    timeout=100,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com/pricing", format: "markdown" }),
});
console.log(await res.json());
```

```json
{
  "verb": "scrape",
  "url": "https://example.com/pricing",
  "title": "Pricing",
  "format": "markdown",
  "markdown": "# Pricing\n\n...",
  "counts": { "chars": 5120, "raw_tokens_est": 9800, "clean_tokens_est": 1280 },
  "tier": "metered"
}
```

### Map a site

POST `/api/crawl/map` free scrape:execute

Lists the URLs a harvest of this site would reach, ranked by how well they match `search`.

Body

- `url` (string, required): The site to map.
- `search` (string): Rank URLs by relevance to this text.
- `limit` (integer): URLs to return, 1 to 500.
- `max_depth` (integer): Link hops from the start page, 0 to 10. 0 reads the start page and its sitemap only.
- `persona_id` (integer): Map the site signed in as this persona.

`limits` says what stopped the walk, so a partial map does not read as a complete one.

```bash
curl -X POST "https://api.usewrit.app/api/crawl/map" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "search": "pricing", "limit": 50}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/crawl/map",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"url": "https://example.com", "search": "pricing", "limit": 50},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/map", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com", search: "pricing", limit: 50 }),
});
console.log(await res.json());
```

```json
{
  "urls": [
    { "url": "https://example.com/pricing", "score": 0.91, "title": "Pricing", "depth": 1, "source": "link" },
    { "url": "https://example.com/plans", "score": 0.64, "title": "Plans", "depth": 0, "source": "sitemap" }
  ],
  "count": 86,
  "limits": { "max_depth": 1, "depth_reached": 1, "pages_fetched": 12, "budget_exhausted": false }
}
```

## Harvest

A harvest collects many pages of a site into a dataset. Writ decides per page whether it needs a
browser. Details: [Harvest a site](https://usewrit.app/docs/crawl).

### Start a harvest

POST `/api/crawl` 0.5 or 1 cr / page crawl:execute

Starts collecting pages and returns the harvest at once. Each page costs what it needed: 0.5 credit for
a plain page or document, 2 for OCR, 1 for a browser, plus 10 for a CAPTCHA passed by a paid solver (Pro and up).

Body

- `url` (string, required): The start page.
- `intent` (string): What you want from the site, in plain words. Writ uses it to pick and rank pages.
- `page_budget` (integer): Most pages to collect, 1 to 50,000.
- `credit_budget` (integer): Most credits this harvest may spend. Pages stop once it is reached.
- `extract_mode` (string): markdown, html or schema (with extract_schema).
- `persona_id` (integer): Collect signed in as this persona.
- `include_paths` (string[]): Only follow URLs that match these patterns.
- `exclude_paths` (string[]): Skip URLs that match these patterns.

Read the collected pages with the Data operations below, using `data_workflow_id` as the workflow or dataset id. Sending the same request again within two minutes returns the running harvest with `"deduplicated": true`.

```bash
curl -X POST "https://api.usewrit.app/api/crawl" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://books.toscrape.com",
    "intent": "Every book with title, price and stock",
    "page_budget": 200
  }'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/crawl",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={
        "url": "https://books.toscrape.com",
        "intent": "Every book with title, price and stock",
        "page_budget": 200,
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://books.toscrape.com",
    intent: "Every book with title, price and stock",
    page_budget: 200,
  }),
});
console.log(await res.json());
```

```json
{
  "id": 7310,
  "seed_url": "https://books.toscrape.com",
  "status": "queued",
  "intent": "Every book with title, price and stock",
  "extract_mode": "markdown",
  "pages_discovered": 0,
  "pages_done": 0,
  "pages_failed": 0,
  "page_budget": 200,
  "credit_budget_micros": 5000000,
  "data_workflow_id": 1204,
  "created_at": "2026-10-31T14:10:00+00:00"
}
```

### Get a harvest

GET `/api/crawl/{crawl_id}` crawl:read

Reads a harvest's status and page counts. `status` ends as `completed`, `failed` or `cancelled`. A harvest that a site refused also carries `site_block`.

```bash
curl "https://api.usewrit.app/api/crawl/7310" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/crawl/7310",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/7310", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "id": 7310,
  "seed_url": "https://books.toscrape.com",
  "status": "completed",
  "pages_discovered": 214,
  "pages_done": 200,
  "pages_failed": 3,
  "pages_skipped": 11,
  "records_total": 200,
  "data_workflow_id": 1204,
  "completed_at": "2026-10-31T14:16:52+00:00"
}
```

### Cancel a harvest

POST `/api/crawl/{crawl_id}/cancel` crawl:execute

Stops the harvest at once. Pages already saved stay in the dataset; pages that were still being read
are dropped.

```bash
curl -X POST "https://api.usewrit.app/api/crawl/7310/cancel" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/crawl/7310/cancel",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/7310/cancel", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "id": 7310,
  "status": "cancelled",
  "pages_done": 88,
  "data_workflow_id": 1204
}
```

### Estimate a harvest

GET `/api/crawl/meta/estimate` free crawl:read

What a harvest may cost before you start it. Nothing is fetched. Amounts ending in `_micros` are thousandths of a credit: `500000` is 500 credits.

Query

- `url` (string): The site. With it, the estimate uses what Writ remembers about the site (it needs a browser, it shows a CAPTCHA).
- `pages` (integer): Pages the harvest may collect, 1 to 50,000.

`low_micros` assumes every page is plain, `high_micros` that every page needs a browser.

```bash
curl "https://api.usewrit.app/api/crawl/meta/estimate?url=https%3A%2F%2Fbooks.toscrape.com&pages=500" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/crawl/meta/estimate",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"url": "https://books.toscrape.com", "pages": 500},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/meta/estimate?url=https%3A%2F%2Fbooks.toscrape.com&pages=500", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "pages": 500,
  "low_micros": 500000,
  "high_micros": 2500000,
  "likely_rung": "http",
  "likely_micros": 500000,
  "per_page": {
    "http_micros": 1000,
    "doc_micros": 1000,
    "ocr_micros": 2000,
    "browser_micros": 5000,
    "ai_micros": 5000,
    "captcha_micros": 10000
  },
  "captchas": null,
  "learned": { "render": null, "residential": false, "captcha": false },
  "default_credit_budget_micros": 5000000
}
```

### Run a saved harvest

POST `/api/crawl/definitions/{ref}/run` 0.5 or 1 cr / page crawl:execute

Runs a harvest you saved with **Make callable**, with its saved settings. `{ref}` is
its id, its slug or its exact name. With `max_age`, a recent enough run is returned at once
with `"cached": true` and costs nothing.

Body

- `max_age` (integer): Reuse the last completed run if it finished within this many seconds (up to 30 days).
- `wait` (boolean): Wait for the harvest to finish. Without it, a fresh run answers 202 with status_url.
- `timeout` (integer): Seconds to wait, 5 to 300. Past it the answer is 504 with crawl_id, and the harvest continues.
- `limit` (integer): Rows of data to include, 1 to 500.

```bash
curl -X POST "https://api.usewrit.app/api/crawl/definitions/books-catalog/run" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"max_age": 86400, "wait": true, "timeout": 120, "limit": 20}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/crawl/definitions/books-catalog/run",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"max_age": 86400, "wait": True, "timeout": 120, "limit": 20},
    timeout=130,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/definitions/books-catalog/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ max_age: 86400, wait: true, timeout: 120, limit: 20 }),
});
console.log(await res.json());
```

```json
{
  "cached": true,
  "definition": {
    "id": 18,
    "slug": "books-catalog",
    "name": "Books catalog",
    "run_url": "/api/crawl/definitions/books-catalog/run",
    "data_url": "/api/crawl/definitions/books-catalog/data"
  },
  "crawl": { "id": 7310, "status": "completed", "pages_done": 200 },
  "status_url": "/api/crawl/7310",
  "data": {
    "columns": ["url", "title", "markdown"],
    "rows": [
      { "run_id": 98501, "record_index": 0, "fields": { "url": "https://books.toscrape.com/...", "title": "...", "markdown": "..." } }
    ],
    "total": 200
  }
}
```

### Read a saved harvest's data

GET `/api/crawl/definitions/{ref}/data` free crawl:read

Returns the data of the saved harvest's last completed run. It never starts a harvest.

Query

- `limit` (integer): Rows to return, 1 to 500.

`age_seconds` says how old the data is. Before the first run, `data` is `null`.

```bash
curl "https://api.usewrit.app/api/crawl/definitions/books-catalog/data?limit=50" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/crawl/definitions/books-catalog/data",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 50},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/crawl/definitions/books-catalog/data?limit=50", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "definition": { "id": 18, "slug": "books-catalog", "name": "Books catalog" },
  "crawl": { "id": 7310, "status": "completed" },
  "age_seconds": 5400,
  "data": {
    "columns": ["url", "title", "markdown"],
    "rows": [
      { "run_id": 98501, "record_index": 0, "fields": { "url": "https://books.toscrape.com/...", "title": "...", "markdown": "..." } }
    ],
    "total": 200
  }
}
```

## Data

Everything your workflows and harvests collect is a dataset. A dataset's id is the id of the workflow
that collected it. These operations need `datasets:read` and `workflows:read`. More: [Outputs and exports](https://usewrit.app/docs/storage).

### Read a workflow's data

GET `/api/v1/workflows/{id}/data` datasets:read

Pages through everything the workflow collected as one table. A run that extracted a list gives one
row per item, and each row names the run it came from.

Query

- `q` (string): Keep rows that contain this text in any field.
- `filter` (string): A column filter as column:text. Repeat it for several columns.
- `sort_by` (string): A column, or run_at, status, duration_ms.
- `sort_dir` (string): asc or desc.
- `limit` (integer): Rows per page, 1 to 500.
- `offset` (integer): Rows to skip.
- `include_inputs` (boolean): Add each run's inputs as input. columns.

`GET /api/v1/workflows/{id}/data/facets` describes each column, and `/data/export` downloads the whole table.

```bash
curl "https://api.usewrit.app/api/v1/workflows/412/data?q=show%20hn&sort_by=points&sort_dir=desc&limit=50" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/workflows/412/data",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={
        "q": "show hn",
        "sort_by": "points",
        "sort_dir": "desc",
        "limit": 50,
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/workflows/412/data?q=show%20hn&sort_by=points&sort_dir=desc&limit=50", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "workflow": { "id": 412, "name": "Hacker News top stories" },
  "columns": ["rank", "title", "points", "url"],
  "rows": [
    {
      "run_id": 98123,
      "run_at": "2026-10-31T13:58:06+00:00",
      "status": "success",
      "record_index": 0,
      "fields": { "rank": 1, "title": "Show HN: ...", "points": 412, "url": "https://..." }
    }
  ],
  "pagination": { "limit": 50, "offset": 0, "total": 1, "scanned_runs": 37, "truncated": false }
}
```

### List datasets

GET `/api/v1/datasets` datasets:read

Lists every dataset you own, most recently updated first. `source_type` is `crawl` for a harvest, else `workflow`.

Query

- `limit` (integer): Page size, 1 to 500. Without it, every dataset is returned.
- `offset` (integer): Rows to skip.

```bash
curl "https://api.usewrit.app/api/v1/datasets?limit=20" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/datasets",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 20},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/datasets?limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "datasets": [
    { "id": 412, "name": "Hacker News top stories", "source_type": "workflow", "run_count": 37, "last_updated": "2026-10-31T13:58:06+00:00" },
    { "id": 1204, "name": "books.toscrape.com", "source_type": "crawl", "run_count": 11, "last_updated": "2026-10-31T14:16:52+00:00" }
  ]
}
```

### Search all datasets

GET `/api/v1/datasets/search` datasets:read

Full-text search across every dataset, newest first. Each result names its dataset and the field
that matched. To search one dataset, use `GET /api/v1/datasets/{id}/search`.

Query

- `q` (string, required): Keywords. All must match; case does not matter; a word matches its start.
- `limit` (integer): Results per page, 1 to 200.
- `offset` (integer): Results to skip.
- `format` (string): json, csv, markdown or html.

```bash
curl "https://api.usewrit.app/api/v1/datasets/search?q=rust%20compiler&limit=20" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/datasets/search",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"q": "rust compiler", "limit": 20},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/datasets/search?q=rust%20compiler&limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "query": "rust compiler",
  "terms": ["rust", "compiler"],
  "results": [
    {
      "dataset": { "id": 412, "name": "Hacker News top stories", "source_type": "workflow" },
      "run_id": 98123,
      "run_at": "2026-10-31T13:58:06+00:00",
      "fields": { "title": "A faster Rust compiler", "points": 288 },
      "highlight": { "field": "title", "snippet": "A faster Rust compiler" }
    }
  ],
  "total": 1,
  "truncated": false,
  "scanned_runs": 48
}
```

### Read a dataset's records

GET `/api/v1/datasets/{id}/records` datasets:read

The same table as a workflow's data, with the same `q`, `filter`, `sort_by`, `limit` and `offset` parameters. `GET /api/v1/datasets/{id}` returns the dataset's columns and row count.

Query

- `limit` (integer): Records per page, 1 to 500.
- `format` (string): json, csv, markdown or html. Paging still applies.

```bash
curl "https://api.usewrit.app/api/v1/datasets/1204/records?limit=100&offset=0" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/datasets/1204/records",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 100, "offset": 0},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/datasets/1204/records?limit=100&offset=0", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "dataset": { "id": 1204, "name": "books.toscrape.com", "source_type": "crawl" },
  "columns": ["url", "title", "markdown"],
  "records": [
    { "run_id": 98501, "record_index": 0, "fields": { "url": "https://books.toscrape.com/...", "title": "...", "markdown": "..." } }
  ],
  "pagination": { "limit": 100, "offset": 0, "total": 200, "scanned_runs": 11, "truncated": false }
}
```

### Export a dataset

GET `/api/v1/datasets/{id}/export` datasets:read

Downloads the whole dataset, with your search, filters and sort applied and no paging. Harvested pages
download as readable documents in Markdown and HTML.

Query

- `format` (string): csv, json, markdown or html.

```bash
curl "https://api.usewrit.app/api/v1/datasets/412/export?format=csv" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -o stories.csv
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/datasets/412/export",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"format": "csv"},
)
res.raise_for_status()
open("stories.csv", "wb").write(res.content)
```

```typescript
import { writeFile } from "node:fs/promises";

const res = await fetch("https://api.usewrit.app/api/v1/datasets/412/export?format=csv", {
  headers: { Authorization: `Bearer ${process.env.WRIT_API_KEY}` },
});
await writeFile("stories.csv", Buffer.from(await res.arrayBuffer()));
```

```
rank,title,points,url
1,Show HN: ...,412,https://...
2,A faster Rust compiler,288,https://...
```

## Files

Files you upload for workflows to use, and files your runs produce. The shape follows OpenAI's Files
API, so an OpenAI client pointed at `https://api.usewrit.app/api/v1` can use it.

### Upload a file

POST `/api/v1/files` files:write

Stores a file and returns its id. Files count against your plan's storage.

Form fields

- `file` (file, required): The file, as multipart form data.
- `purpose` (string): A tag of your choice. user_data when empty.

```bash
curl -X POST "https://api.usewrit.app/api/v1/files" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -F "file=@invoices.csv" \
  -F "purpose=user_data"
```

```python
import os, requests

with open("invoices.csv", "rb") as f:
    res = requests.post(
        "https://api.usewrit.app/api/v1/files",
        headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
        files={"file": f},
        data={"purpose": "user_data"},
    )
res.raise_for_status()
print(res.json())
```

```typescript
import { readFile } from "node:fs/promises";

const form = new FormData();
form.append("file", new Blob([await readFile("invoices.csv")]), "invoices.csv");
form.append("purpose", "user_data");

const res = await fetch("https://api.usewrit.app/api/v1/files", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.WRIT_API_KEY}` },
  body: form,
});
console.log(await res.json());
```

```json
{
  "id": "file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d",
  "object": "file",
  "bytes": 18244,
  "created_at": 1761919200,
  "filename": "invoices.csv",
  "purpose": "user_data",
  "content_type": "text/csv",
  "status": "ready",
  "source": "api"
}
```

### List files

GET `/api/v1/files` files:read

Lists your files, newest first. `GET /api/v1/files/{file_id}` returns one.

Query

- `purpose` (string): Only files with this tag.
- `limit` (integer): Files per page, 1 to 200.
- `offset` (integer): Files to skip.

```bash
curl "https://api.usewrit.app/api/v1/files?limit=50" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/files",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 50},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/files?limit=50", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "object": "list",
  "data": [
    {
      "id": "file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d",
      "object": "file",
      "bytes": 18244,
      "created_at": 1761919200,
      "filename": "invoices.csv",
      "purpose": "user_data",
      "content_type": "text/csv",
      "status": "ready",
      "source": "api"
    }
  ]
}
```

### Download a file

GET `/api/v1/files/{file_id}/content` files:read

Returns the file's bytes, often as a redirect to a short-lived download link. Follow redirects.

```bash
curl -L "https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d/content" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -o invoices.csv
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d/content",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
open("invoices.csv", "wb").write(res.content)
```

```typescript
import { writeFile } from "node:fs/promises";

const res = await fetch(
  "https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d/content",
  { headers: { Authorization: `Bearer ${process.env.WRIT_API_KEY}` } },
);
await writeFile("invoices.csv", Buffer.from(await res.arrayBuffer()));
```

### Delete a file

DELETE `/api/v1/files/{file_id}` files:delete, files:write

Deletes the file and its stored bytes. The key needs both scopes.

```bash
curl -X DELETE "https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.delete(
    "https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

```typescript
const res = await fetch("https://api.usewrit.app/api/v1/files/file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(res.status);
```

```json
{
  "id": "file_5d0c1f9a2b7e4c6f8a1d3e5b7c9f0a2d",
  "object": "file",
  "deleted": true
}
```

## Monitors

A monitor checks a page on a schedule and records each change. Responses use camelCase field names.
More: [Monitor a page](https://usewrit.app/docs/monitors).

### List monitors

GET `/api/targets` monitors:read

Lists your monitors with their state and last check. `GET /api/targets/{id}` returns one.

Query

- `enabled` (boolean): Only active (true) or paused (false) monitors.
- `limit` (integer): Page size, 1 to 500. Without it, every monitor is returned.
- `offset` (integer): Rows to skip.

```bash
curl "https://api.usewrit.app/api/targets?limit=50" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/targets",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 50},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets?limit=50", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
[
  {
    "id": 311,
    "url": "https://example.com/product/42",
    "checkType": "content",
    "selector": ".price",
    "checkPeriodMs": 3600000,
    "enabled": true,
    "state": "ok",
    "lastCheckedAt": "2026-10-31T15:20:02+00:00",
    "changesCount": 2
  }
]
```

### Create a monitor

POST `/api/targets` monitors:write

Starts watching a page. A plain check costs 0.5 credit, a browser check 5. Your plan sets the fastest
interval; a faster one answers `402`.

Body

- `url` (string, required): The page to watch.
- `selector` (string): A CSS selector for the part to watch. Without it, the main content is watched.
- `check_period_ms` (integer): Time between checks, in milliseconds. Without it, your plan's default is used.
- `schedule_kind` (string): interval, daily or weekly, with schedule_time (HH:MM), schedule_days (1 = Monday) and schedule_tz.
- `requires_playwright` (boolean): Check the page in a browser, for pages that need JavaScript.
- `persona_id` (integer): Check the page signed in as this persona.
- `auto_repair` (boolean): Repair the selector automatically when it stops matching.
- `enabled` (boolean): Start active.

```bash
curl -X POST "https://api.usewrit.app/api/targets" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/product/42",
    "selector": ".price",
    "check_period_ms": 3600000
  }'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/targets",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={
        "url": "https://example.com/product/42",
        "selector": ".price",
        "check_period_ms": 3600000,
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://example.com/product/42",
    selector: ".price",
    check_period_ms: 3600000,
  }),
});
console.log(await res.json());
```

```json
{
  "id": 311,
  "url": "https://example.com/product/42",
  "checkType": "content",
  "selector": ".price",
  "checkPeriodMs": 3600000,
  "scheduleKind": "interval",
  "enabled": true,
  "requiresPlaywright": false,
  "createdAt": "2026-10-31T14:20:00+00:00",
  "lastCheckedAt": "2026-10-31T15:20:02+00:00",
  "changesCount": 2,
  "state": "ok",
  "lastChangeAt": "2026-10-31T15:20:02+00:00",
  "autoRepair": true
}
```

### Update a monitor

PATCH `/api/targets/{id}` monitors:write

Changes any field you send, with the same names as when you create a monitor. Returns the monitor.

```bash
curl -X PATCH "https://api.usewrit.app/api/targets/311" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"check_period_ms": 1800000, "selector": ".price-now"}'
```

```python
import os, requests

res = requests.patch(
    "https://api.usewrit.app/api/targets/311",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"check_period_ms": 1800000, "selector": ".price-now"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets/311", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ check_period_ms: 1800000, selector: ".price-now" }),
});
console.log(await res.json());
```

### Check now

POST `/api/targets/{id}/run` 0.5 or 5 cr monitors:execute, monitors:write

Runs one check right away, outside the schedule. Its result arrives like any other check. A paused
monitor answers `409`. If no checker has picked up the monitor yet, the answer has `"ok": false` and the monitor runs at its next scheduled check. The key needs both scopes.

```bash
curl -X POST "https://api.usewrit.app/api/targets/311/run" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/targets/311/run",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets/311/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{ "ok": true, "dispatched": 1 }
```

### Pause or resume a monitor

PATCH `/api/targets/{id}/toggle` monitors:write

Pauses (`enabled=false`) or resumes (`enabled=true`) the monitor. Returns the monitor.

Query

- `enabled` (boolean, required): The new state.

```bash
curl -X PATCH "https://api.usewrit.app/api/targets/311/toggle?enabled=false" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.patch(
    "https://api.usewrit.app/api/targets/311/toggle",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"enabled": "false"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets/311/toggle?enabled=false", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

### Delete a monitor

DELETE `/api/targets/{id}` monitors:delete

Deletes the monitor and its change history. Answers `204` with no body.

```bash
curl -X DELETE "https://api.usewrit.app/api/targets/311" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.delete(
    "https://api.usewrit.app/api/targets/311",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets/311", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(res.status);
```

### List changes

GET `/api/targets/{id}/changes` monitors:read

Lists the changes a monitor detected, newest first. `GET /api/targets/changes/recent` lists
recent changes across all monitors.

Query

- `limit` (integer): Changes to return, 1 to 1,000.
- `since` (string): Only changes detected after this ISO 8601 time, oldest first. To page, pass the last row's lastDetectedAt.
- `since_id` (integer): With since: the last row's id, for rows with the same time.

```bash
curl "https://api.usewrit.app/api/targets/311/changes?limit=20" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/targets/311/changes",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"limit": 20},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/targets/311/changes?limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
[
  {
    "id": "9811",
    "targetId": "311",
    "timestamp": "2026-10-31T15:20:02+00:00",
    "oldContent": "$129.00",
    "newContent": "$119.00",
    "diff": "- $129.00\n+ $119.00",
    "firstDetectedAt": "2026-10-31T15:20:02+00:00",
    "lastDetectedAt": "2026-10-31T15:20:02+00:00",
    "selectorId": null,
    "selectorName": null,
    "reviewed": false,
    "reviewedAt": null
  }
]
```

## Automations

An automation runs actions when an event happens: a monitor change, a webhook, a schedule, a run that
finishes. Automations are easiest to build in the app; these operations list, run and manage them.
More: [Schedules, triggers and webhooks](https://usewrit.app/docs/automations-webhooks).

### List automations

GET `/api/triggers/all` triggers:read

Lists your automations, highest priority first. `GET /api/triggers/{id}` returns one.

Query

- `enabled_only` (boolean): Only active automations.
- `event_type` (string): Only automations for this event, such as change_detected.
- `workflow_id` (integer): Only automations tied to this workflow.
- `fields` (string): summary leaves out the blocks of each automation.
- `limit` (integer): Page size, 1 to 500. Without it, every automation is returned.

```bash
curl "https://api.usewrit.app/api/triggers/all?fields=summary&limit=50" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/triggers/all",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"fields": "summary", "limit": 50},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers/all?fields=summary&limit=50", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
[
  {
    "id": 57,
    "target_id": 311,
    "event_type": "change_detected",
    "name": "Price drop: reorder",
    "enabled": true,
    "priority": 0,
    "actions": [ { "type": "workflow", "config": { "workflow_id": 412 } } ],
    "last_triggered_at": "2026-10-31T15:20:03+00:00",
    "trigger_count": 4
  }
]
```

### Create an automation

POST `/api/triggers` triggers:write

Creates an automation from an event and a list of actions. This example runs workflow 412 each time
monitor 311 sees a change.

Body

- `name` (string, required): A name, up to 255 characters.
- `event_type` (string): The event: change_detected, webhook_received, scheduled, workflow_started, workflow_completed, monitor_down, monitor_stale, monitor_recovered, crawl_started, crawl_completed, crawl_failed, ai_session_started or ai_session_completed.
- `target_id` (integer): The monitor, for monitor events.
- `workflow_id` (integer): The workflow, for workflow events.
- `actions` (object[]): What to do: each item has a type (workflow, notification, crawl, scrape...) and a config.
- `enabled` (boolean): Start active.

```bash
curl -X POST "https://api.usewrit.app/api/triggers" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Price drop: reorder",
    "event_type": "change_detected",
    "target_id": 311,
    "actions": [{"type": "workflow", "config": {"workflow_id": 412}}]
  }'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/triggers",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={
        "name": "Price drop: reorder",
        "event_type": "change_detected",
        "target_id": 311,
        "actions": [{"type": "workflow", "config": {"workflow_id": 412}}],
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Price drop: reorder",
    event_type: "change_detected",
    target_id: 311,
    actions: [{ type: "workflow", config: { workflow_id: 412 } }],
  }),
});
console.log(await res.json());
```

```json
{
  "id": 57,
  "target_id": 311,
  "event_type": "change_detected",
  "workflow_id": null,
  "name": "Price drop: reorder",
  "description": null,
  "enabled": true,
  "priority": 0,
  "conditions": {},
  "actions": [ { "type": "workflow", "config": { "workflow_id": 412 } } ],
  "blocks": null,
  "last_triggered_at": null,
  "next_scheduled_at": null,
  "trigger_count": 0,
  "created_at": "2026-10-31T15:30:00+00:00",
  "updated_at": "2026-10-31T15:30:00+00:00"
}
```

### Run an automation

POST `/api/triggers/{id}/run` triggers:write

Runs the automation's actions now, as if its event had happened. Workflows it starts are billed as usual.

Body

- `context` (object): Values to pass to the actions, as the event would.

```bash
curl -X POST "https://api.usewrit.app/api/triggers/57/run" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"note": "manual test"}}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/triggers/57/run",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"context": {"note": "manual test"}},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers/57/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ context: { note: "manual test" } }),
});
console.log(await res.json());
```

```json
{
  "trigger_id": 57,
  "execution_id": 3301,
  "status": "completed",
  "action_results": [
    { "index": 0, "type": "workflow", "status": "completed", "task_id": 98160, "workflow_id": 412 }
  ],
  "error": null
}
```

### Pause, resume or delete an automation

PATCH `/api/triggers/{id}/toggle` triggers:write

DELETE `/api/triggers/{id}` triggers:delete

`toggle` switches the automation between active and paused and returns it. `DELETE` removes it and answers `204`.

```bash
curl -X PATCH "https://api.usewrit.app/api/triggers/57/toggle" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.patch(
    "https://api.usewrit.app/api/triggers/57/toggle",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers/57/toggle", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```bash
curl -X DELETE "https://api.usewrit.app/api/triggers/57" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.delete(
    "https://api.usewrit.app/api/triggers/57",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers/57", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(res.status);
```

### List an automation's runs

GET `/api/triggers/{id}/executions` triggers:read

The automation's past runs: what started each one, what each action did, and any error.

```bash
curl "https://api.usewrit.app/api/triggers/57/executions" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/triggers/57/executions",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/triggers/57/executions", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
[
  {
    "id": 3301,
    "trigger_rule_id": 57,
    "detected_change_id": 9811,
    "status": "completed",
    "trigger_context": { "event_type": "change_detected" },
    "action_results": [ { "index": 0, "type": "workflow", "status": "completed", "task_id": 98152 } ],
    "triggered_at": "2026-10-31T15:20:03",
    "completed_at": "2026-10-31T15:20:04",
    "error_message": null
  }
]
```

## Inbound webhooks

An incoming webhook lets another system start a workflow or an automation with a plain HTTP call. Create
one in **Developers → Endpoints → Incoming webhooks** or in an automation's webhook trigger.

### Call a webhook

POST `/api/webhooks/hook/{token}` signed, no key

The JSON body becomes the run's inputs. Every request must be signed with the webhook's secret, shown
once when you set it with **Set a new signing secret**.

Headers

- `X-Writ-Timestamp` (header, required): The current time in Unix seconds. Requests more than 5 minutes off are refused.
- `X-Writ-Signature` (header, required): sha256= plus the hex HMAC-SHA256 of "{timestamp}.{body}", keyed with the secret. X-Hub-Signature-256 is also accepted.

Query

- `wait` (boolean): Hold the request until the run finishes and return its data.
- `timeout` (integer): Seconds to wait, 10 to 300.

An unsigned or stale request answers `401`. A request replayed with the same signature answers `403`. Each webhook accepts 30 calls a minute.

```bash
BODY='{"query": "laptops"}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$WRIT_WEBHOOK_SECRET" | sed 's/^.* //')

curl -X POST "https://api.usewrit.app/api/webhooks/hook/Kq3vN8sPz1mY0aT6rB4wXe7Lc9Hd2Jf5" \
  -H "Content-Type: application/json" \
  -H "X-Writ-Timestamp: $TS" \
  -H "X-Writ-Signature: sha256=$SIG" \
  -d "$BODY"
```

```python
import hashlib, hmac, json, os, time, requests

body = json.dumps({"query": "laptops"}).encode()
ts = str(int(time.time()))
sig = hmac.new(
    os.environ["WRIT_WEBHOOK_SECRET"].encode(),
    f"{ts}.".encode() + body,
    hashlib.sha256,
).hexdigest()

res = requests.post(
    "https://api.usewrit.app/api/webhooks/hook/Kq3vN8sPz1mY0aT6rB4wXe7Lc9Hd2Jf5",
    data=body,
    headers={
        "Content-Type": "application/json",
        "X-Writ-Timestamp": ts,
        "X-Writ-Signature": f"sha256={sig}",
    },
)
print(res.json())
```

```typescript
import { createHmac } from "node:crypto";

const body = JSON.stringify({ query: "laptops" });
const ts = Math.floor(Date.now() / 1000).toString();
const sig = createHmac("sha256", process.env.WRIT_WEBHOOK_SECRET!)
  .update(`${ts}.${body}`)
  .digest("hex");

const res = await fetch("https://api.usewrit.app/api/webhooks/hook/Kq3vN8sPz1mY0aT6rB4wXe7Lc9Hd2Jf5", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Writ-Timestamp": ts,
    "X-Writ-Signature": `sha256=${sig}`,
  },
  body,
});
console.log(await res.json());
```

```json
{
  "success": true,
  "triggered": true,
  "action": "run_workflow",
  "data": { "task_id": 98140, "workflow_id": 412 }
}
```

## Sign-in links

When your code needs to act on a site behind a login, it can ask you for that login without ever seeing
it. Writ makes a link; you open it, sign in on Writ's own form, and a persona is saved. More: [Sign-ins and secrets](https://usewrit.app/docs/personas).

### Create a sign-in link

POST `/api/personas/links` personas:write

Returns a link for one site. Send `url` to the person; it expires after 30 minutes. If a link for
the site is already open, you get that one back with `"created": false`.

Body

- `domain` (string, required): The site, such as github.com, or a URL on it.
- `login_url` (string): The site's sign-in page.
- `why` (string): One line shown to the person: what you need the login for. Up to 300 characters.

> **note:** Only the person, signed in to Writ in their browser, can fill the form. The key that made the link can only read its status, never the login.

```bash
curl -X POST "https://api.usewrit.app/api/personas/links" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "github.com",
    "login_url": "https://github.com/login",
    "why": "Read your open pull requests"
  }'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/personas/links",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={
        "domain": "github.com",
        "login_url": "https://github.com/login",
        "why": "Read your open pull requests",
    },
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/personas/links", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    domain: "github.com",
    login_url: "https://github.com/login",
    why: "Read your open pull requests",
  }),
});
console.log(await res.json());
```

```json
{
  "link_id": "q8Zr1mT0bV3xK9pL2wYc4nHa",
  "url": "https://app.usewrit.app/persona-link/q8Zr1mT0bV3xK9pL2wYc4nHa",
  "site": "github.com",
  "login_url": "https://github.com/login",
  "why": "Read your open pull requests",
  "requested_by": "Reporting script",
  "status": "pending",
  "closed_for_good": false,
  "created_at": "2026-10-31T15:40:00+00:00",
  "expires_at": "2026-10-31T16:10:00+00:00",
  "expires_in_s": 1800,
  "opened_at": null,
  "saved_at": null,
  "finished_at": null,
  "created": true
}
```

### Wait for a sign-in link

GET `/api/personas/links/{link_id}` personas:read

Reads the link. `status` is `pending`, `opened`, `saved`, `completed`, `cancelled` or `closed`. When it is `completed`, `persona.id` is the persona to use.

Query

- `wait` (number): Hold the call up to this many seconds (75 at most) and answer as soon as the person saves or declines.

```bash
curl "https://api.usewrit.app/api/personas/links/q8Zr1mT0bV3xK9pL2wYc4nHa?wait=60" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/personas/links/q8Zr1mT0bV3xK9pL2wYc4nHa",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"wait": 60},
    timeout=70,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/personas/links/q8Zr1mT0bV3xK9pL2wYc4nHa?wait=60", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "link_id": "q8Zr1mT0bV3xK9pL2wYc4nHa",
  "site": "github.com",
  "status": "completed",
  "expires_in_s": 1310,
  "finished_at": "2026-10-31T15:48:11+00:00",
  "persona": { "id": 77, "name": "GitHub (work)" },
  "sign_in": "ready",
  "source": "link"
}
```

## Runs feed

### List runs

GET `/api/runs` runs:read

One feed of every run in the account: workflows, monitor checks, AI sessions, automations and harvests,
newest first. It is what the **Runs** page shows.

Query

- `run_type` (string): workflow, check, ai_session, automation or crawl.
- `status` (string): pending, running, success, failed, cancelled, paused or skipped.
- `since` (string): Only runs started at or after this ISO 8601 time. until sets the end.
- `entity_id` (integer): Only runs of this workflow, monitor, session or automation.
- `limit` (integer): Runs per page, 1 to 200.
- `offset` (integer): Runs to skip.

```bash
curl "https://api.usewrit.app/api/runs?run_type=workflow&status=failed&limit=20" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/runs",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"run_type": "workflow", "status": "failed", "limit": 20},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/runs?run_type=workflow&status=failed&limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
[
  {
    "id": "workflow-98123",
    "run_type": "workflow",
    "entity_id": 412,
    "entity_name": "Hacker News top stories",
    "status": "failed",
    "started_at": "2026-10-31T13:58:02Z",
    "finished_at": "2026-10-31T13:58:06Z",
    "duration_ms": 4210,
    "trigger_source": "manual",
    "error": "..."
  }
]
```

## Live sessions

A live session keeps a signed-in browser open for a workflow recorded with **Run style: Live session**, so each call acts at once. A live browser costs 2 credits a minute, and a session ends after
one hour. More: [Live sessions](https://usewrit.app/docs/streaming).

### Start a session

POST `/api/streaming/sessions/start` 2 cr / min streaming:execute

Opens the browser and returns a `session_key`. Call handlers once `status` is `running` (read it with `GET /api/streaming/sessions/{session_key}`). End it early
with `POST /api/streaming/sessions/{session_key}/end`.

Body

- `workflow_id` (integer, required): The live-session workflow.
- `target_url` (string, required): The page to open.

> **limit:** The Free plan allows one live session at a time. Starting another answers 429.

```bash
curl -X POST "https://api.usewrit.app/api/streaming/sessions/start" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"workflow_id": 512, "target_url": "https://web.whatsapp.com"}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/streaming/sessions/start",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"workflow_id": 512, "target_url": "https://web.whatsapp.com"},
    timeout=100,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/streaming/sessions/start", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ workflow_id: 512, target_url: "https://web.whatsapp.com" }),
});
console.log(await res.json());
```

```json
{
  "session_key": "c41d7e0f9a2b4d38b6e1f05a7c3d9e21",
  "status": "starting",
  "target_url": "https://web.whatsapp.com",
  "current_url": null,
  "agent_id": null,
  "workflow_id": 512,
  "handlers": [],
  "max_duration_seconds": 3600
}
```

### Call a handler

POST `/api/streaming/sessions/{session_key}/invoke/{handler}` streaming:execute

Runs one of the workflow's handlers in the open browser and returns its result.

Body

- `data` (object): The handler's inputs.
- `timeout` (number): Seconds to wait for the handler, 1 to 120.

```bash
curl -X POST "https://api.usewrit.app/api/streaming/sessions/c41d7e0f9a2b4d38b6e1f05a7c3d9e21/invoke/send_message" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": {"to": "Alex", "text": "On my way"}, "timeout": 30}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/streaming/sessions/c41d7e0f9a2b4d38b6e1f05a7c3d9e21/invoke/send_message",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"data": {"to": "Alex", "text": "On my way"}, "timeout": 30},
    timeout=45,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/streaming/sessions/c41d7e0f9a2b4d38b6e1f05a7c3d9e21/invoke/send_message", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ data: { to: "Alex", text: "On my way" }, timeout: 30 }),
});
console.log(await res.json());
```

```json
{
  "session_key": "c41d7e0f9a2b4d38b6e1f05a7c3d9e21",
  "handler": "send_message",
  "result": { "sent": true }
}
```

### Chat with a session (OpenAI-compatible)

POST `/api/streaming/workflows/{id}/v1/chat/completions` streaming:execute

Talks to the workflow's live sessions with the OpenAI Chat Completions format, so any OpenAI client
works. A conversation stays on the same session. `/v1/responses` and `GET /v1/models` exist under the same base.

Body and headers

- `messages` (object[], required): The conversation, as in the OpenAI API.
- `stream` (boolean): Stream the answer as server-sent events.
- `X-Session-Key` (header): Send the conversation to this session.

```bash
curl -X POST "https://api.usewrit.app/api/streaming/workflows/512/v1/chat/completions" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "streaming", "messages": [{"role": "user", "content": "Send Alex: on my way"}]}'
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.usewrit.app/api/streaming/workflows/512/v1",
    api_key=os.environ["WRIT_API_KEY"],
)
reply = client.chat.completions.create(
    model="streaming",
    messages=[{"role": "user", "content": "Send Alex: on my way"}],
)
print(reply.choices[0].message.content)
```

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.usewrit.app/api/streaming/workflows/512/v1",
  apiKey: process.env.WRIT_API_KEY,
});
const reply = await client.chat.completions.create({
  model: "streaming",
  messages: [{ role: "user", content: "Send Alex: on my way" }],
});
console.log(reply.choices[0].message.content);
```

```json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1761925200,
  "model": "streaming",
  "choices": [
    { "index": 0, "message": { "role": "assistant", "content": "Sent to Alex." }, "finish_reason": "stop" }
  ]
}
```

## Marketplace

Ready-made APIs that others published and that pass live tests. Installing is free; a call costs credits
only when it succeeds. Runs always happen on Writ Cloud. More: [Ready-made APIs](https://usewrit.app/docs/marketplace).

### Search listings

GET `/api/marketplace/listings` marketplace:read

Searches public listings. Each one has a `slug`, used by the next two operations.

Query

- `q` (string): Search text.
- `target_site` (string): Only listings for this site, such as news.ycombinator.com.
- `sort` (string): rank, most_used, newest, success, fastest or cheapest.
- `limit` (integer): Listings per page, 1 to 100.

```bash
curl "https://api.usewrit.app/api/marketplace/listings?q=hacker%20news&sort=most_used&limit=10" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.get(
    "https://api.usewrit.app/api/marketplace/listings",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    params={"q": "hacker news", "sort": "most_used", "limit": 10},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/marketplace/listings?q=hacker%20news&sort=most_used&limit=10", {
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "listings": [
    {
      "listing_id": 93,
      "slug": "hacker-news-top-stories",
      "title": "Hacker News top stories",
      "summary": "Front-page stories with points and comment counts.",
      "target_domain": "news.ycombinator.com",
      "required_plan": null
    }
  ],
  "total": 1
}
```

### Install a listing

POST `/api/marketplace/listings/{slug}/install` free marketplace:write

Adds the listing to your account. Installing twice returns the same install. If the listing needs your
own login or inputs, attach them in the app before you run it.

```bash
curl -X POST "https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/install" \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/install",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/install", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  },
});
console.log(await res.json());
```

```json
{
  "install_id": 640,
  "workflow_id": 2210,
  "proxy_workflow_id": 2304,
  "listing_id": 93,
  "slug": "hacker-news-top-stories",
  "status": "active"
}
```

### Run a listing

POST `/api/marketplace/listings/{slug}/run` credits on success marketplace:write

Runs the listing with your inputs, billed to your account.

Body

- `form_data` (object): The listing's inputs.
- `wait` (boolean or number): Wait for the result: true waits up to 90 seconds, a number waits that many. Without it, the answer has a task_id at once.

```bash
curl -X POST "https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/run" \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"form_data": {"limit": 3}, "wait": true}'
```

```python
import os, requests

res = requests.post(
    "https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/run",
    headers={"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"},
    json={"form_data": {"limit": 3}, "wait": True},
    timeout=100,
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/api/marketplace/listings/hacker-news-top-stories/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ form_data: { limit: 3 }, wait: true }),
});
console.log(await res.json());
```

```json
{
  "task_id": 98207,
  "call_task_id": 98207,
  "status": "success",
  "success": true,
  "extracted_data": { "stories": [ { "rank": 1, "title": "...", "points": 412 } ] },
  "output_files": [],
  "error": null,
  "duration_ms": 3880
}
```

### Run a listing without a key

GET `/api/marketplace/listings/{slug}/run` keyless allowance no key

For AI assistants and tools that can only open a URL. Name the function and give each input as a query parameter; the answer holds the function's data. A GET never uses a key or a session: it runs public functions that only read, on the keyless allowance (10 free credits a day per IP address; a call costs the price shown on the listing). Without `function_name` nothing runs, and the answer lists the functions, each with a ready URL. A call still running after 60 seconds answers with a `result_url`: open it to read the answer.

Query

- `function_name` (string): The function to run. Left out, the answer lists them.
- `{input}` (string): Each input of the function, by name.

```http
GET https://api.usewrit.app/api/marketplace/listings/fide-chess-ratings-players/run?function_name=get_player_profile&fide_id=1503014
```

```json
{
  "tier": "keyless",
  "slug": "fide-chess-ratings-players",
  "function_name": "get_player_profile",
  "inputs": { "fide_id": "1503014" },
  "status": "success",
  "success": true,
  "price_credits": 2,
  "charged_credits": 2,
  "extracted_data": {
    "name": "Carlsen, Magnus",
    "fide_id": "1503014",
    "fide_title": "GM",
    "federation": "NOR",
    "birth_year": "1990",
    "std_rating": "2823",
    "rapid_rating": "2801",
    "blitz_rating": "2860"
  },
  "truncated": false,
  "duration_ms": 2490,
  "quota": {
    "tier": "keyless",
    "credits_remaining": 8,
    "credits_per_day": 10,
    "reset_at": "2026-11-08T00:00:00Z"
  }
}
```

## Keyless

Read pages without an account or a key, to try Writ. Send any stable id in `X-Writ-Client-Id`;
it counts your daily allowance. Writ may answer with an `X-Writ-Device-Token` header: send it
back on later calls.

Tools that can only open a URL, such as an AI assistant's browser, can make the same calls as a GET: the body's fields go in the query string, no header needed, and the call counts against the IP address's allowance.

```http
GET https://api.usewrit.app/v1/keyless/scrape?url=https://news.ycombinator.com
```

### Read, map or crawl without a key

POST `/v1/keyless/scrape` no key

POST `/v1/keyless/map` no key

POST `/v1/keyless/crawl` no key

GET `/v1/keyless/scrape` no key

GET `/v1/keyless/map` no key

GET `/v1/keyless/crawl` no key

`scrape` reads one page as Markdown. `map` lists a site's links (add `search` and `limit`). `crawl` reads up to 5 linked pages, one level deep: as many as the day's credits pay for.

Body, or query string for a GET

- `url` (string, required): The page or site.
- `search` (string): For map and crawl: rank links by relevance to this text.
- `limit` (integer): For map and crawl: how many URLs or pages.

> **limit:** Each device, and separately each IP address, gets 10 free credits a day: a read or a map spends 2, a crawled page 1. A call that fails is given back. Past that the answer is 429 with keyless_rate_limited, until midnight UTC.

```bash
curl -X POST "https://api.usewrit.app/v1/keyless/scrape" \
  -H "X-Writ-Client-Id: 6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://news.ycombinator.com"}'
```

```python
import requests

res = requests.post(
    "https://api.usewrit.app/v1/keyless/scrape",
    headers={"X-Writ-Client-Id": "6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11"},
    json={"url": "https://news.ycombinator.com"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/v1/keyless/scrape", {
  method: "POST",
  headers: {
    "X-Writ-Client-Id": "6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://news.ycombinator.com" }),
});
console.log(await res.json());
```

```json
{
  "verb": "scrape",
  "url": "https://news.ycombinator.com",
  "title": "Hacker News",
  "format": "markdown",
  "markdown": "1. Show HN: ...",
  "quota": {
    "tier": "keyless",
    "requests_remaining": 9,
    "pages_remaining": 19,
    "credits_remaining": 8,
    "requests_per_day": 10,
    "pages_per_day": 20,
    "credits_per_day": 10,
    "reset_at": "2026-11-01T00:00:00Z",
    "upgrade_url": "https://usewrit.app/pricing"
  }
}
```

### Check the keyless allowance

GET `/v1/keyless/quota` free no key

What is left of today's allowance for this device. It resets at midnight UTC.

```bash
curl "https://api.usewrit.app/v1/keyless/quota" \
  -H "X-Writ-Client-Id: 6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11"
```

```python
import requests

res = requests.get(
    "https://api.usewrit.app/v1/keyless/quota",
    headers={"X-Writ-Client-Id": "6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11"},
)
res.raise_for_status()
print(res.json())
```

```typescript
const res = await fetch("https://api.usewrit.app/v1/keyless/quota", {
  headers: {
    "X-Writ-Client-Id": "6f1d2c4e-0b7a-4c1e-9f3a-2d5e8b9c0a11",
  },
});
console.log(await res.json());
```

```json
{
  "tier": "keyless",
  "requests_remaining": 9,
  "pages_remaining": 19,
  "credits_remaining": 8,
  "requests_per_day": 10,
  "pages_per_day": 20,
  "credits_per_day": 10,
  "reset_at": "2026-11-01T00:00:00Z",
  "upgrade_url": "https://usewrit.app/pricing",
  "shared_pool": { "available": true }
}
```

## Next

-
- [API keys and OAuth](https://usewrit.app/docs/authentication): Create keys, choose scopes and connect apps.
-
- [Errors and limits](https://usewrit.app/docs/errors): Status codes, error bodies, rate limits and retries.
-
- [Call your API](https://usewrit.app/docs/call): Waiting, async runs, caching and response formats.
-
- [SDKs](https://usewrit.app/docs/sdks): Python, TypeScript, Go and Rust clients for the same API.
