# Artifacts API

> Publish a page or a small folder, get a stable URL, and ship new versions to it.


# Artifacts API

Publish a page (one file or a small folder) to a stable URL, `https://anyrouter.dev/a/{id}`. Publishing again makes a new numbered version at the same URL. Artifacts are **private by default**; `visibility` is one of:

| Value | Who can open it | Listed | Search engines |
|-------|-----------------|--------|----------------|
| `private` | Only you | No | No |
| `unlisted` | Anyone with the URL | No | No (`noindex`) |
| `public` | Anyone with the URL | In the [public gallery](#public-gallery) | Yes |

Authenticate with an inference key (`sk-ar-v1-…`), a [management key](/api-reference/management-keys) (`ak_…`), or a session. A management key needs `read:artifacts` to read and `write:artifacts` to change. An endpoint-restricted key must allow Artifacts.

## Publish one file

```bash
curl -sS https://anyrouter.dev/api/v1/artifacts \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"Hello","files":{"index.html":{"content":"<h1>Hi</h1>"}}}'
```

```json
{
  "id": "k3Vx9TqLm2Ab7Zcd",
  "version": 1,
  "url": "https://anyrouter.dev/a/k3Vx9TqLm2Ab7Zcd",
  "visibility": "private"
}
```

| Field | Type | Notes |
|---|---|---|
| `files` | object | Path to `{ "content": "...", "encoding": "utf8" \| "base64" }`. Use `base64` for images and fonts. Required unless you send `manifest`. |
| `title` | string | Up to 120 characters. Defaults to the page's `<title>` or first heading. |
| `description` | string | Up to 300 characters. |
| `visibility` | string | `private` (default), `unlisted` or `public`. |
| `show_author` | boolean | Show your name on the page. Defaults to `false`. See [Show your name](#show-your-name). |
| `entry_path` | string | The file to show at the URL. It must be one of your files, with an extension from the [Kinds](#kinds) table. See [How the entry is picked](#how-the-entry-is-picked). |
| `label` | string | A short note for this version, up to 60 characters. |

An inline publish carries up to 10 MB in total. For more, or for a folder, use the manifest flow.

## Publish a folder

List each file with its size and SHA-256. The response names the files still needed. Upload each, then commit.

```bash
# 1. Open the upload (202)
curl -sS https://anyrouter.dev/api/v1/artifacts \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Report",
    "manifest": [
      {"path": "index.html", "size": 1204, "sha256": "<64 hex chars>"},
      {"path": "app.js", "size": 5310, "sha256": "<64 hex chars>"}
    ]
  }'
```

```json
{
  "upload_id": "up_8Hq2...",
  "expires_at": "2026-10-23T12:00:00Z",
  "missing": [
    {"path": "index.html", "sha256": "…", "size": 1204,
     "put_url": "https://anyrouter.dev/api/v1/artifacts/uploads/up_8Hq2.../files/…"}
  ]
}
```

```bash
# 2. Upload each missing file to its put_url
curl -sS -X PUT "$PUT_URL" \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  --data-binary @index.html

# 3. Commit (201), same response as an inline publish
curl -sS -X POST https://anyrouter.dev/api/v1/artifacts/uploads/$UPLOAD_ID/commit \
  -H "Authorization: Bearer $ANYROUTER_API_KEY"
```

The upload stays open for one hour. Committing twice returns the same version. A SHA-256 mismatch is rejected.

## Publish a new version

Send the version you built on as `base_version`.

```bash
curl -sS https://anyrouter.dev/api/v1/artifacts/$ID/versions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"base_version":1,"label":"fix chart","files":{"index.html":{"content":"<h1>Hi again</h1>"}}}'
```

Listed files are added or replaced; others are kept. Set a path to `null` to remove it. The manifest flow also accepts `delete` (paths to remove) and `keep_unlisted: false` (the manifest is the whole file set).

If someone published a newer version first, you get `409 version_conflict` with the version to merge against:

```json
{
  "error": {
    "code": "version_conflict",
    "message": "Someone published version 2 first. Read it, merge, and retry with base_version 2.",
    "current_version": 2
  }
}
```

Set `"force": true` instead of `base_version` to publish on top of whatever is current.

## Read, list and version history

| Request | Returns |
|---|---|
| `GET /api/v1/artifacts` | Your live artifacts, newest first. Query `limit` (1 to 100, default 25) and `cursor`; the response carries `next_cursor`. |
| `GET /api/v1/artifacts/{id}` | Metadata, the current version and its file list. `?version=n` reads an older version (owner only). |
| `GET /api/v1/artifacts/{id}/versions` | The version history. |
| `GET /api/v1/artifacts/{id}/files/{path}` | The source of one file (owner only), as a download. |
| `GET /api/v1/artifacts/{id}/sources/{sourceId}` | One live source of a dashboard artifact, or of a page with a sources file, as a table. Anyone who can open the page may call it; `?v=n` reads a saved version (owner only). |
| `GET /api/v1/artifacts/{id}/download` | The current version's entry file, as a download. Works for your own artifacts and anyone's unlisted or public one. No sign-in needed for those. |

## Clone

Copy an artifact you can open (your own, or anyone's unlisted or public one) into a new private artifact you own:

```bash
curl -sS -X POST https://anyrouter.dev/api/v1/artifacts/$ID/clone \
  -H "Authorization: Bearer $ANYROUTER_API_KEY"
```

```json
{ "id": "Q8wLz2Rk5NbT1Yhe", "version": 1, "url": "https://anyrouter.dev/a/Q8wLz2Rk5NbT1Yhe", "visibility": "private", "cloned_from": "k3Vx9TqLm2Ab7Zcd" }
```

The copy holds the current version's files, is titled "Copy of" plus the original title, and starts private, without your name and without the original page's saved data. It counts toward your limits and publish rate. An artifact removed from the public gallery cannot be cloned.

## Create from a type

Create a private artifact from a starter file (session or management key). The dashboard's **Make something new** row does the same:

```bash
curl -sS -X POST https://anyrouter.dev/api/v1/artifacts/new \
  -H "Authorization: Bearer $ANYROUTER_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"dashboard"}'
```

```json
{ "id": "Q8wLz2Rk5NbT1Yhe", "version": 1, "url": "https://anyrouter.dev/a/Q8wLz2Rk5NbT1Yhe", "visibility": "private", "type": "dashboard" }
```

| Type | Starter file | Status |
|---|---|---|
| `docs` | `guide.doc.md`, a getting-started guide to edit into your own document | New |
| `slides` | `deck.slides.md`, a five-slide intro to AnyRouter | New |
| `sheet` | `prices.sheet.json`, a two-tab price comparison with formulas | New |
| `whiteboard` | `request-routing.whiteboard.json`, a flow of a request through the gateway with a fallback | New |
| `dashboard` | `model-latency.dashboard.json`, live first-token time and throughput per model | Beta |
| `design`, `motion` | | Coming soon (422 `type_unavailable`) |

To change it, edit the starter and publish a new version under the same file name:

```bash
anyr artifact publish ./model-latency.dashboard.json --id Q8wLz2Rk5NbT1Yhe
```

A new artifact counts toward your artifact limit and publish rate like any publish.

## Change visibility or details

```bash
curl -sS -X PATCH https://anyrouter.dev/api/v1/artifacts/$ID \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"visibility":"unlisted"}'
```

You can change `title`, `description`, `icon`, `visibility` and `show_author`. Only the owner can change an artifact; anyone else gets `404`.

### Show your name

By default the header reads "by an AnyRouter user". Set `show_author` to `true` to show your display name (or username) linked to your public profile:

```bash
curl -sS -X PATCH https://anyrouter.dev/api/v1/artifacts/$ID \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"show_author":true}'
```

Your email is never shown. The setting is per artifact and survives new versions. You can also change it in the dashboard.

## Public gallery

Public artifacts are listed at [anyrouter.dev/artifacts](https://anyrouter.dev/artifacts), newest first. Anyone can read the list:

```bash
curl -sS "https://anyrouter.dev/api/v1/artifacts/gallery?limit=24"
```

The response has `data` (each item has `id`, `title`, `description`, `author`, `url`, `updated_at` and `views`; `author` is `{ name, username, profile_url, image_url }` when the owner turned on `show_author`, otherwise `null`) and `next_cursor`. Pass `cursor` to get the next page. Add `sort=popular` to list the most viewed first.

To keep the gallery useful:

- An account can make artifacts `public` 24 hours after sign-up.
- An account can make up to 5 artifacts `public` per day.
- Every artifact page has a **Report** button. AnyRouter can remove an artifact from the gallery or take it down.

## Views

Views by others are counted per day; "visitors" counts each viewer once a day. Counts are approximate and store no IP or identity. Only you can read them:

```bash
curl -sS "https://anyrouter.dev/api/v1/artifacts/$ID/stats?days=30" \
  -H "Authorization: Bearer $ANYROUTER_API_KEY"
```

The response has `days` (UTC dates, oldest first), `views` and `visitors` (one number per day), `total` (all-time views), and all-time `downloads` and `clones` by other people. `GET /api/v1/artifacts/stats?days=14` returns the same series for all your artifacts at once, keyed by id. `days` goes up to 90.

## Delete

```bash
curl -sS -X DELETE https://anyrouter.dev/api/v1/artifacts/$ID \
  -H "Authorization: Bearer $ANYROUTER_API_KEY"
```

```json
{ "id": "k3Vx9TqLm2Ab7Zcd", "deleted": true }
```

The URL stops working at once.

## Kinds

The entry is the file shown at the URL; its extension decides how it renders.

| Extension | Kind | What viewers see |
|---|---|---|
| `.html` | Page | The page itself. |
| `.md` | Markdown | Formatted text. |
| `.slides.md` | Slides | A slide deck: Markdown split into 16:9 slides. See [Publish slides](#publish-slides). |
| `.doc.md` | Document | Long-form text with a title, byline and an outline beside it. See [Publish a document](#publish-a-document). |
| `.svg` | Image | The SVG as an image. Scripts in it do not run. |
| `.mmd`, `.mermaid` | Diagram | A [Mermaid](https://mermaid.js.org) diagram, drawn in the viewer's browser. |
| `.jsx`, `.tsx` | React | A single React component, compiled when you publish and run in the viewer's browser. See [Publish a React component](#publish-a-react-component). |
| `.sheet.json` | Sheet | A spreadsheet with tabs and formulas, read-only, with `.xlsx` and `.csv` downloads. See [Publish a sheet](#publish-a-sheet). |
| `.whiteboard.json` | Whiteboard | Notes, shapes and text boxes joined by arrows on a board you can pan and zoom, read-only. See [Publish a whiteboard](#publish-a-whiteboard). |
| `.design.json` | Design board | Frames from your other files (`.html`, `.svg`, `.png`) laid out on a canvas you can pan and zoom. See [Publish a design board](#publish-a-design-board). |
| `.motion.json` | Animation | Clips from your other files (`.html`, `.svg`) played on a timeline. See [Publish an animation](#publish-an-animation). |
| `.py` `.ts` `.sh` `.bash` `.sql` `.go` `.rs` `.rb` `.java` `.kt` `.swift` `.c` `.h` `.cpp` `.hpp` `.cs` `.php` `.lua` `.yaml` `.yml` `.toml` | Source code | The file as text, with syntax highlighting. |

`.js`, `.mjs`, `.css`, `.json`, `.csv` and `.txt` are never an entry. They are files a page loads, so `index.html` plus `app.js` still opens `index.html`.

### How the entry is picked

1. An `entry_path` always wins. It must be in `files` and have an extension from the table above, or you get `400 invalid_entry`.
2. Without `entry_path`, a folder with `.html` or `.md` files (a `.doc.md` or `.slides.md` counts as `.md`) opens `index.html`, then `index.md`. Next, a single `.design.json`, `.motion.json`, `.sheet.json` or `.whiteboard.json` file opens, because the pages beside it are its frames and clips. Otherwise the only `.html` or `.md` file opens. With several, you get `400 entry_ambiguous`.
3. A folder with no `.html` or `.md` file opens its only `.jsx`, `.tsx`, `.svg`, `.mmd`, `.mermaid`, `.design.json`, `.motion.json`, `.sheet.json`, `.whiteboard.json` or source file. With several, a lone `.jsx`, `.tsx`, `.design.json`, `.motion.json`, `.sheet.json` or `.whiteboard.json` file wins. Otherwise `index.tsx`, `index.jsx`, `index.svg` and `index.mmd` win, in that order. If none of those apply, you get `400 entry_ambiguous`.
4. A folder with no possible entry gets `400 no_entry`.

Set `entry_path` to open a `.py`, `.svg` or `.tsx` that sits next to a page.

### Publish a document

Name a Markdown file `*.doc.md` to show it as a document. An optional block at the top sets the header:

```markdown
---
title: Q3 routing review
author: Linh
date: 2026-10-30
description: What changed in routing this quarter.
---

## Summary
```

Each line is `key: value`; only `title`, `author`, `date` and `description` are shown. `##` and `###` headings form the outline beside the text on wide screens (hidden when printing).

### Publish slides

Name a Markdown file `*.slides.md` to show it as a slide deck. A line with only `---` starts a new slide. Put a blank line before and after it: a `---` directly under a line of text makes that line a heading instead.

```markdown
---
title: Q3 review
theme: dark
---

# Q3 review

---

## What shipped

- Faster fallback
- Two new providers
```

`theme` is `light` or `dark`; leave it out to follow the viewer's system. Keys: arrows or space to move, `O` for all slides, `F` for full screen. The URL ends in `#n` for slide n. Printing gives one slide per page.

### Publish a Mermaid diagram

```bash
curl -sS https://anyrouter.dev/api/v1/artifacts \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"Flow","files":{"flow.mmd":{"content":"graph TD\n  A[Request] --> B{Key valid?}\n  B -->|yes| C[Route]\n  B -->|no| D[401]"}}}'
```

### Publish a React component

A React entry is one file with a default export. Tailwind classes work.

```bash
curl -sS https://anyrouter.dev/api/v1/artifacts \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"Counter","files":{"App.tsx":{"content":"import { useState } from \"react\"\nexport default function App() {\n  const [n, setN] = useState(0)\n  return <button className=\"p-4\" onClick={() => setN(n + 1)}>Clicked {n}</button>\n}"}}}'
```

The component can import only these modules:

- `react`, `react/jsx-runtime`, `react-dom` and `react-dom/client`
- `lucide-react`, `recharts`, `d3`, `lodash`, `papaparse`, `mathjs`, `three`, `chart.js` (and `chart.js/auto`) and `xlsx`
- `@/components/ui/{alert,badge,button,card,input,label,progress,separator,switch,tabs,textarea}` and `@/lib/utils`, a small set of shadcn-style components

Any other import is refused with `422 unsupported_import`. A file with a syntax error or no default export is refused with `422 invalid_component`.

### Publish a sheet

A `.sheet.json` file is a spreadsheet: tabs of rows. A cell is a string, a number, `true`, `false` or `null`. A string that starts with `=` is a formula. AnyRouter computes every formula when it draws the page, so viewers see values, and a click on a cell shows its formula in the bar above the grid. The page is read-only; to change it, edit the file and publish a new version.

```json
{
  "version": 1,
  "title": "Model price comparison",
  "tabs": [
    {
      "id": "prices",
      "name": "Prices",
      "columns": [{ "width": 260 }, { "format": "usd", "decimals": 2 }, { "format": "usd", "decimals": 2 }, { "format": "usd", "decimals": 2 }],
      "rows": [
        ["Model", "Input / 1M", "Output / 1M", "Blended 3:1"],
        ["openai/gpt-5", 1.25, 10, "=(B2*3+C2)/4"],
        ["anthropic/claude-sonnet-4.5", 3, 15, "=(B3*3+C3)/4"]
      ]
    },
    {
      "id": "summary",
      "name": "Summary",
      "rows": [["Models", "=COUNT(prices!B2:B2000)"], ["Cheapest blended", "=MIN(prices!D2:D2000)"]]
    }
  ]
}
```

- `tabs`: 1 to 8. `id` is lowercase letters, digits, `_` and `-`, up to 31 characters, and starts with a letter. Formulas use it to reach another tab (`prices!B2`), and it is the sheet name in the `.xlsx` file. `name` is the label on the tab.
- `columns` is optional and may be shorter than the rows. Each column takes `width` (40 to 600 pixels), `format` (`text`, `number`, `usd` or `percent`), `decimals` (0 to 6, with a number format) and `align`. A `percent` cell holds 0.25 and shows 25%.
- `frozen_rows` (0 to 5, default 1) and `frozen_columns` (0 to 3, default 0) stay in view while the grid scrolls.
- A string that starts with `'` is text, and the apostrophe is not shown: `'=x` shows `=x`.
- Formulas: `+ - * / ^ &`, `%`, comparisons, parentheses, cell references (`B2`, `$B$2`), ranges (`B2:B9`) and references to another tab. Functions: `SUM`, `AVERAGE`, `MIN`, `MAX`, `COUNT`, `COUNTA`, `ROUND`, `ABS`, `IF`, `AND`, `OR`, `NOT`, `IFERROR`, `CONCAT` and `LEN`. A formula that fails shows an error code such as `#DIV/0!`, `#REF!`, `#NAME?`, `#VALUE!` or `#CYCLE!`.
- Limits: 512 KB, 2,000 rows and 52 columns per tab, 20,000 cells in all, 500 characters per cell.

A sheet that does not parse, or whose formulas read too many cells, is refused with `422 invalid_sheet`. The message says which field is wrong.

Add `?format=xlsx` or `?format=csv` to the download URL to get the computed sheet as a file. The sheet's viewers also get both in the page's menu.

```bash
curl -sSL -o prices.xlsx "https://anyrouter.dev/api/v1/artifacts/k3Vx9TqLm2Ab7Zcd/download?format=xlsx"
curl -sSL -o prices-summary.csv "https://anyrouter.dev/api/v1/artifacts/k3Vx9TqLm2Ab7Zcd/download?format=csv&tab=summary"
```

The `.xlsx` file keeps your formulas and their values, one sheet per tab, named by tab `id`. Column width, the header row, frozen panes and the `usd`, `percent` and `number` formats carry over; `decimals` does not. The `.csv` file is one tab (the first, or the one named in `tab`), holds computed values, and starts text that looks like a formula with `'` so a spreadsheet does not run it.

### Publish a whiteboard

A `.whiteboard.json` file draws notes, shapes and text boxes joined by arrows. Viewers pan and zoom it; nobody edits it in the browser. To change it, edit the file and publish a new version.

```json
{
  "version": 1,
  "title": "How a request routes",
  "nodes": [
    { "id": "app", "type": "rect", "x": 0, "y": 0, "width": 160, "height": 80, "text": "Your app", "color": "gray" },
    { "id": "gw", "type": "ellipse", "x": 300, "y": 0, "width": 160, "height": 80, "text": "AnyRouter", "color": "violet" },
    { "id": "note", "type": "note", "x": 300, "y": 160, "width": 200, "height": 100, "text": "Retries on a 429" }
  ],
  "edges": [
    { "id": "a", "from": "app", "to": "gw", "label": "request" },
    { "id": "b", "from": "gw", "to": "note", "arrow": "none", "dashed": true }
  ]
}
```

- `nodes`: 1 to 200. `type` is `note` (a sticky note, yellow unless you set a color), `rect`, `ellipse` or `text` (no box). `x` and `y` are whole numbers from -20000 to 20000, `width` and `height` from 16 to 4000. `text` is plain text, up to 500 characters. `color` is `yellow`, `blue`, `green`, `pink`, `violet` or `gray`.
- `edges`: 0 to 300. Each joins two different node ids with a straight arrow between the box borders. `arrow` is `end` (default), `both` or `none`. `label` is up to 80 characters and sits at the middle. `dashed` is `true` or `false`.
- The manifest is up to 64 KB. A manifest that does not parse, or an edge that names a node that is not there, is refused with `422 invalid_whiteboard`. The message says which field is wrong.

### Publish a design board

A `.design.json` file places other files of the same publish on a pan-and-zoom board.

```json
{
  "version": 1,
  "title": "Landing page",
  "frames": [
    { "id": "hero", "name": "Hero", "x": 0, "y": 0, "width": 1280, "height": 800, "src": "hero.svg" },
    { "id": "phone", "name": "Phone", "x": 1400, "y": 0, "width": 390, "height": 844, "src": "phone.png" }
  ]
}
```

- `frames`: 1 to 24. `x` and `y` are whole numbers from -20000 to 20000. `width` and `height` are whole numbers from 16 to 4000.
- `src` is the path of a file in the same publish, exactly as you publish it (not relative to the manifest). It must be `.html`, `.svg` or `.png`. `.svg` and `.png` frames show on the board. An `.html` frame shows as a card that opens the page in a new tab.
- `background` is optional, a `#rgb` or `#rrggbb` color.

### Publish an animation

A `.motion.json` file plays other files of the same publish as clips on a timeline. Viewers who ask for reduced motion see a still frame.

```json
{
  "version": 1,
  "title": "How a request routes",
  "width": 1280,
  "height": 720,
  "fps": 30,
  "duration_s": 6,
  "clips": [
    { "id": "title", "src": "title.svg", "start_s": 0, "duration_s": 3, "enter": "fade", "exit": "slide-up" },
    { "id": "chart", "src": "chart.svg", "start_s": 2.5, "duration_s": 3.5, "track": 1, "enter": "scale" }
  ]
}
```

- `width` and `height`: 120 to 3840. `fps`: 1 to 60. `duration_s`: 0.5 to 300 seconds.
- `clips`: 1 to 40. Each clip must end by `duration_s`. `src` is an `.html` or `.svg` file in the same publish. Use `.svg` for clips that play on the stage; an `.html` clip shows as a card that opens it in a new tab. Clips on a higher `track` (0 to 7) draw on top.
- `enter` and `exit`: `fade` (the default), `slide-up`, `slide-left`, `scale` or `none`.
- `poster_s` (optional) is the still frame for reduced motion, default 0. `background` is optional, a `#rgb` or `#rrggbb` color.

### Live data in an HTML page

Add `anyr.sources.json` next to an HTML page to show live numbers:

```json
{
  "version": 1,
  "sources": [
    { "id": "latency", "type": "anyrouter", "name": "model_latency", "refresh_seconds": 60 },
    { "id": "prices", "type": "url", "url": "https://example.com/prices.csv", "format": "csv" }
  ]
}
```

The page reads a source by id and gets a table, never the URL:

```js
await anyr.ready
const { table, fetched_at } = await anyr.sources.get("latency")
// table.columns: [{ name, type }], table.rows: [[...], ...]
```

Sources follow the same rules as a dashboard's: up to 8, `refresh_seconds` from 30 to 86400, and https URLs on public hosts only. A file that does not parse is refused at publish with `422 invalid_sources`, and the message names the field. Two AnyRouter sources are public: `model_latency` (first-token time and throughput per model) and `catalog_models` (one row per listed model: `model`, `owner`, `input_usd_per_m`, `output_usd_per_m`, `context` and `free`, 1 or 0). A source about your own usage (`owner_usage_daily`) is shown only to you, unless you publish with `"capabilities": { "owner_data": true }`. Anyone who can open the page can read the file with `?raw=1`, so never put a key in a source URL.

### Live data from your own APIs

For an API that needs a key, save a connection once: dashboard Artifacts page, **Connections**, then the API's origin (for example `https://api.example.com`) and a credential (bearer token, custom header, or `user:password`). The credential is stored encrypted and never shown again. Then name the connection from a source:

```json
{ "id": "signups", "type": "http", "connection": "artconn_…", "endpoint": "/v1/stats?days=7", "format": "json", "path": "data" }
```

`endpoint` is a path on the connection's origin. Requests never leave that origin and never follow a redirect.

Servers you added in MCP Gateway can feed a page too. Under **Connections**, tick the tools a page may call, then:

```json
{ "id": "deals", "type": "mcp", "connection": "mcpconn_…", "tool": "list_deals", "args": { "stage": "won" }, "path": "deals" }
```

A page calls only the tools you ticked, with the `args` in the file. AnyRouter signs in to the server as you and keeps that sign-in alive: viewers never see the credential, and a tool result over 1 MB is refused. Reads are cached for `refresh_seconds` (at least 30), so many viewers cost one call.

If the server stops answering, the page keeps the last good data for up to 24 hours and shows it with a **Stale** badge. If the server refuses to renew your sign-in, only you see the reason: the page tells you to reconnect, with a link to MCP Gateway, and viewers see the stale data or "source failed". AnyRouter also renews the sign-in of every connection a page uses once a day, so a page nobody opens for weeks does not break.

Only you see connection data, unless you publish with `"capabilities": { "owner_data": true }`. A copy made by someone else cannot use your connections. Deleting or rotating takes effect on the next refresh.

| Method and path | What it does |
|---|---|
| `GET /api/v1/artifacts/connections` | Your connections. Credentials are never returned, only a masked hint. |
| `POST /api/v1/artifacts/connections` | Save one: `name`, `origin`, `auth_type` (`bearer`, `header`, `basic` or `none`), `header_name` for `header`, `secret`. Up to 20. |
| `PATCH /api/v1/artifacts/connections/{id}` | Rename it, or rotate its `secret`. |
| `DELETE /api/v1/artifacts/connections/{id}` | Delete it and its credential. |
| `PUT /api/v1/artifacts/connections/{id}/tools` | `{ "tools": [...] }`: the tools of an MCP Gateway server a page may call. `[]` turns it off. |

These routes take a signed-in session or a management key (`read:artifacts` to list, `write:artifacts` to change). An inference key (`sk-ar-…`) is refused.

Adding or changing a connection source needs a session or management key. An inference key or MCP agent can publish new versions that leave the sources file unchanged; changing it returns `403 connection_requires_owner_session`.

### Limits per kind

- **SVG:** the file must start with `<svg` or `<?xml`. Anything else is refused with `422 invalid_svg`. Over 1 MB, the page shows "This file is too large to preview" with a link to the source.
- **React:** up to 256 KB. A larger file is refused with `413 too_large`.
- **Document:** up to 1 MB. A block that starts with `---` but never closes, or has a line that is not `key: value`, is refused with `422 invalid_doc`.
- **Slides:** up to 512 KB. A `theme` other than `light` or `dark`, or a block that does not parse, is refused with `422 invalid_slides`.
- **Mermaid:** up to 256 KB. A larger file is refused with `413 too_large`.
- **Sheet:** the manifest is up to 512 KB (`413 too_large`). Unknown fields are refused with `422 invalid_sheet`.
- **Whiteboard:** the manifest is up to 64 KB (`413 too_large`). Unknown fields are refused with `422 invalid_whiteboard`.
- **Design and animation:** the manifest is up to 64 KB (`413 too_large`). Unknown fields are refused. A manifest that does not parse, or a frame or clip whose `src` is not in the publish, is refused with `422 invalid_design` or `422 invalid_motion`. The message says which field is wrong.
- **Source code:** over 1 MB, the page shows the same "too large to preview" note and a source link.

The source link adds `?raw=1` to the artifact URL. It returns the stored file as plain text.

## Download buttons

A page can `fetch` any file of its own version, and nothing else. Saving to disk needs a dedicated content domain that is not enabled yet, so the browser blocks the save for now; the fetch works. This example is ready for then:

```html
<img src="img/a.jpg" alt="Shot 1"> <button data-file="img/a.jpg">Download</button>
<button id="all">Download all</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script>
  const files = ["img/a.jpg", "img/b.jpg"]
  function save(blob, name) {
    const a = document.createElement("a")
    a.href = URL.createObjectURL(blob)
    a.download = name
    a.click()
  }
  const get = (path) => fetch(path).then((r) => r.blob())
  document.querySelectorAll("[data-file]").forEach((b) => {
    b.onclick = async () => save(await get(b.dataset.file), b.dataset.file.split("/").pop())
  })
  document.getElementById("all").onclick = async () => {
    const zip = new JSZip()
    for (const path of files) zip.file(path, await get(path))
    save(await zip.generateAsync({ type: "blob" }), "all.zip")
  }
</script>
```

Use relative paths, as above. A request to another artifact, another version or any other URL is blocked.

## Limits

| Limit | Value |
|---|---|
| One image, font, script or other asset file | 10 MB on Free, 25 MB on Go, 50 MB on Pro |
| One page or source file (`html`, `md`, `svg`, `mmd`, source code) | 5 MB on Free, 10 MB on Go and Pro |
| One inline publish | 10 MB |
| One publish (manifest) | 200 files, 100 MB |
| One version | 200 files, 100 MB |
| Artifacts per account | 100 |
| Stored size per account, all versions | 100 MB on Free, 2 GB on Go, 10 GB on Pro |
| Publishes per hour | 20 |
| Path length | 200 characters |

A page or source file is 5 MB on Free and 10 MB on Go and Pro. Every version is kept; stored size counts each distinct file once. A refusal names your plan, the limit and your use. A higher plan raises the file cap and stored size; donating a key to the pool gives Go.

Allowed file types: `html`, `md`, `jsx`, `tsx`, `css`, `js`, `mjs`, `json`, `txt`, `csv`, `png`, `jpg`, `jpeg`, `gif`, `webp`, `avif`, `svg`, `woff2`, `ico`, `mmd`, `mermaid`, and the source extensions in the [Kinds](#kinds) table. Source and Mermaid files are stored as plain text. The server decides the content type from the extension and ignores the one you send.

## Errors

Errors look like `{ "error": { "code": "...", "message": "..." } }`.

| Status | Code | Meaning |
|---|---|---|
| 400 | `invalid_request` | A field is missing or has the wrong shape. |
| 400 | `base_version_required` | A new version needs `base_version` (or `force`). |
| 400 | `invalid_path`, `duplicate_path`, `invalid_entry`, `no_entry`, `entry_ambiguous`, `no_files` | The file set is not valid. |
| 400 | `hash_mismatch`, `missing_blobs`, `unknown_blob` | The upload does not match the manifest. |
| 400 | `invalid_encoding` | A `base64` file is not valid base64. |
| 401 | | No valid credential. |
| 403 | | The key lacks the scope or the endpoint. |
| 403 | `quota_exceeded` | You reached the artifact limit. |
| 403 | `account_too_new` | Accounts can make artifacts `public` 24 hours after sign-up. Use `unlisted` until then. |
| 403 | `listing_blocked` | AnyRouter removed this artifact from the public gallery. It can still be private or unlisted, and it cannot be cloned. |
| 404 | `not_found` | No such artifact, or you cannot see it. |
| 409 | `version_conflict` | `base_version` is behind. Merge and retry. |
| 409 | `already_committed` | The upload was already used. |
| 410 | `upload_expired` | The upload was open longer than an hour. |
| 413 | `file_too_large`, `inline_too_large`, `publish_too_large`, `version_too_large`, `too_many_files` | A size limit was exceeded. |
| 413 | `too_large` | A Mermaid or React entry is over 256 KB, or a design or animation manifest is over 64 KB. |
| 415 | `unsupported_media_type` | The file type is not allowed. |
| 422 | `invalid_svg` | An `.svg` entry does not start with `<svg` or `<?xml`. |
| 422 | `invalid_component` | A `.jsx` or `.tsx` entry has a syntax error or no default export. |
| 422 | `unsupported_import` | A React entry imports a module outside the supported list. |
| 422 | `invalid_whiteboard` | A `.whiteboard.json` entry does not parse, or an edge names a node that is not there. |
| 422 | `invalid_sheet` | A `.sheet.json` entry does not parse, or its formulas read too many cells. |
| 422 | `invalid_design`, `invalid_motion` | A `.design.json` or `.motion.json` entry does not parse, or names a file that is not in the publish. |
| 429 | `rate_limited` | More than 20 publishes in an hour, or more than 5 artifacts made `public` in a day. |

## From the CLI

```bash
anyr artifact publish ./report            # a file or a folder
anyr artifact publish ./report --id k3Vx9TqLm2Ab7Zcd --label "fix chart"
anyr artifact publish page.html --title "Weekly" --visibility unlisted --json
anyr artifact ls                          # your artifacts
anyr artifact visibility k3Vx9TqLm2Ab7Zcd public --yes
anyr artifact visibility k3Vx9TqLm2Ab7Zcd --show-author   # show your name on the page
anyr artifact rm k3Vx9TqLm2Ab7Zcd --yes
```

Flags: `--title`, `--visibility private|unlisted|public` (default `private`), `--id` (publish a new version), `--label`, `--show-author` / `--no-show-author` (on `publish` and `visibility`; leaving both out keeps the current setting), `--yes` (skip the confirmation for `public` and `rm`) and `--json`. The URL prints on stdout. A folder upload skips dotfiles, `node_modules` and `.git`. Exit codes: 2 for a usage error or a version conflict, 3 for not found, 4 for an auth error. `link` is accepted as an alias for `unlisted`.

The `artifact` command ships in CLI 0.1.22. Run `anyr upgrade` if `anyr artifact --help` is not found.

## From an AI agent

The [AnyRouter MCP server](/api-reference/mcp) exposes five tools: `publish_artifact`, `list_artifacts`, `get_artifact`, `delete_artifact` and `set_artifact_visibility`. `publish_artifact` takes text files only, up to 1 MB, accepts `entry_path`, and publishes privately unless you say otherwise. The entry can be any [kind](#kinds). Listing and reading need `read:artifacts`; the rest need `write:artifacts`. An inference key (`sk-ar-v1-…`) can use all five, unless its endpoint allow-list leaves out Artifacts. Connect `https://anyrouter.dev/api/v1/mcp?tools=artifacts` to get only the artifact tools.
