> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formation.texturehq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sketch requests

> Let an agent ask for a drawing when something is easier to sketch than to describe.

Some things are easier to draw than to describe: a page layout, how services
connect, a floor plan, a process with branches. An agent can ask the person it
is talking to for a drawing. It posts a one-time link, the person draws on a
canvas in their browser, and the drawing comes back to the agent as an image in
the same conversation.

The canvas starts blank. Agents cannot yet open the canvas with their own
drawing for the person to correct; that is proposed in
[Sketch requests: agent draws first](https://github.com/TextureHQ/formation/blob/main/docs/design/sketches-draw-first.md)
(repository).

## Requirements

* **The instance must be reachable at `PUBLIC_URL` by the person drawing.** The
  link is `PUBLIC_URL/sketch/{token}`, and the canvas page submits to
  `PUBLIC_URL/api/sketch-links/{token}`, so whoever the agent sends the link to
  must be able to open that address from their own browser. On an install run
  by a hosting operator this is already the case. A self-hosted instance behind
  a VPN or private network works only for people on that network; to collect
  drawings from anyone else, expose at least those two paths publicly.
  Formation does not check reachability; an unreachable `PUBLIC_URL` produces
  links that fail to open.
* `PUBLIC_URL` must be an `https` URL, or plain `http` on a loopback host for
  local development. A sketch link is a bearer credential, so Formation does not
  issue one that would travel in cleartext. With any other `PUBLIC_URL`,
  `sketch_request` is not offered.
* A database. Without one, no sketch tool is offered and the sketch routes return
  `503 sketches_unavailable`.

There is no setting to turn sketches on.

## How a person experiences it

Someone describes a dashboard layout in three paragraphs. The agent replies that
this would be quicker to sketch and posts a link. The person opens it on a
laptop or phone without signing in, sees which agent is asking and what it asked
for, draws, optionally adds a note, and sends it. The agent then replies in the
same thread with what it understood and continues the work.

A person can also simply ask for a canvas ("let me just draw it"); the agent
calls the tool because they asked.

## Tools

The agent's primary model decides when to ask, with a tool call.

| Tool | Offered when | What it does |
| - | - | - |
| `sketch_request` | Links can be issued and the turn answers a stored message | Creates a link for this conversation and returns its `url` and expiry for the agent to post. Takes `prompt` (required, 1 to 500 characters, shown on the canvas page) and an optional `title` (up to 80 characters, used in listings). |
| `sketch_list` | A sketch has been requested in this conversation | Lists the conversation's sketches: status (`open`, `submitted`, `expired`, or `revoked`) and, for submitted ones, the `submission_id`, the person's note, and the text in the drawing. Never image data. |
| `view_sketch` | A drawing has been submitted in this conversation | Shows a submitted drawing to the agent again, with its note and text labels, in a later turn. Takes a `submission_id` from `sketch_list`. |

The tool description tells the agent to ask only when a layout, interface,
architecture, flow, or physical space would be quicker to sketch than to
describe, never in place of a question with a short text answer, and at most
once per thread unless the person asks for a canvas.

## What the agent receives

Submitting a drawing wakes the agent in the thread it asked from. The wake run
is anchored to the message the agent was answering, so the reply lands in the
same place. If the conversation already has an active run, for example the
agent's own turn is still finishing, the wake is retried every five seconds
until it can start. Each wake starts exactly one run.

The wake run carries:

* the drawing as a PNG image;
* the person's note, if any;
* the text labels in the drawing, extracted from the Excalidraw scene, at most
  100 labels and 4,000 characters in drawing order, with a notice when text was
  left out.

The link does not prove who used it, so the drawing is attributed as "submitted
through your link (the submitter is not authenticated)", not as a message from
a specific person. Text in the drawing and the note are untrusted user-role
input, never instructions.

A wake run and any turn that offers `view_sketch` require an image-capable model
from [automatic model routing](https://docs.formation.texturehq.com/runtime/adaptive-model-routing.md). If the model
that runs still cannot accept images, the agent gets the note and labels and is
told the drawing itself is not shown.

## Links

* A link accepts **one drawing** within **24 hours**. There is no renewal; the
  agent can ask again.
* Opening or previewing a link does not use it, so chat link unfurling cannot
  consume it.
* Unknown, used, revoked, and expired links all show the same "no longer active"
  state.
* Operators can list open links and revoke them.

Anyone holding a link can see the agent's name, the title, and the prompt, and
can submit one drawing. Nothing else is shown: no history, other sketches, or
participant names. Tokens are 32 random bytes and only their SHA-256 hash is
stored. The public routes share the sign-in throttle, the submit route rejects
cross-origin requests, and every sketch response is sent with
`Cache-Control: no-store`. Token path parameters are scrubbed from audit logs.

The agent has to post the link, so the full URL is conversation content: it is
stored in the posted message, the tool result, and the model requests recorded
for that turn, the same as a [vault](https://docs.formation.texturehq.com/runtime/agent-vault.md) drop link.

## The canvas page

The page is `PUBLIC_URL/sketch/{token}`. It uses Excalidraw, loaded only on
this route. Fonts are served by Formation itself, so the page makes no
third-party requests and works on air-gapped installs. The CJK handwriting font
is not bundled; drawings with CJK text use the browser's own font.

Limits are kept while drawing, so a finished drawing is never rejected:

| Limit | Value | How the page keeps it |
| - | - | - |
| Image | PNG, 2 MiB, at most 2048 px on either side | Exported on send at 2048 px on the long edge, then 1600, 1280, 1024, and 768 px until it fits. If even 768 px is too large, the page asks the person to remove detail. |
| Drawing data | 512 KiB of Excalidraw JSON | Pasted and dropped pictures are removed. A meter appears past 75%; a change that would go over is undone. |
| Note | 1,000 characters | A counter on the field. |

The page warns when text in the drawing would be too small to read in the
export. A draft is saved in the browser's local storage per link, so a closed
tab does not lose the drawing; it is cleared after a successful send.

The server enforces every limit again. It checks the PNG's declared dimensions
before decoding, then decodes it fully and refuses malformed files.

## Storage and retention

Drawings are stored in Postgres: the PNG in an `images` table, the Excalidraw
scene and note beside it. Every row belongs to a conversation and is deleted
with it. Deleting the anchor message removes its sketch request, submission, and
image. Sketch content is stored the same way as message bodies; see
[Content protection](https://docs.formation.texturehq.com/content-protection.md).

## Operator API

| Route | Result |
| - | - |
| `GET /api/agents/{slug}/sketches` | Open links, without tokens. |
| `DELETE /api/agents/{slug}/sketches/{id}` | Revoke an open link. A used link cannot be revoked. |
| `GET /api/agents/{slug}/conversations/{conversationID}/sketches` | The conversation's requests and submissions, with notes and labels. |
| `GET /api/agents/{slug}/conversations/{conversationID}/sketches/{submissionID}/image` | The submitted drawing as `image/png`. |
| `GET /api/sketch-links/{token}` | Public: agent name, title, prompt, and expiry. |
| `POST /api/sketch-links/{token}` | Public: multipart `image`, `scene`, and optional `note`. |

Request and response shapes and error codes are in
[Sketch requests](https://docs.formation.texturehq.com/operator-api.md#sketch-requests) in the operator API. The
dashboard has no sketch views yet; use these routes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.