# Test and edit an API

> Functions, inputs and outputs, test runs, the Call tab, and changing an API after it is built.

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

An API in Writ is a set of functions: one per thing it can do, such as “search listings” or “get one
order”. Each function has its own inputs, outputs and price. You try, publish and change them all from
the API’s page, under **APIs**.

## The API page

| Tab | What it is for |
| --- | --- |
| Overview | What the API does, how its last runs went, which sign-in it uses, and how well its functions are tested. Advanced — how it runs holds the browser settings, where it runs and AI Auto-Repair. |
| Functions | Every callable function: try it, see its price, set how it signs in and whether its data is kept. Shown when the API has functions. |
| Implementation | The steps behind the functions. Named Steps when the API has no functions yet. |
| Call | The REST endpoint, the MCP tool, the agent skill, triggers, and where the API runs. |
| Data | Every row the API saved. Sort, filter and export it as CSV or JSON. |
| Documentation | A reference for each function, with a form to try it and OpenAPI and Postman downloads. |

The header has **Edit workflow** (name, description and entry URL), **Run**,
the link **Missing a function? Tell Scribe →**, and a More menu with **Publish to marketplace**, **Use on a website** and **Delete workflow**.
Writ Desktop shows the same tabs for the APIs on your computer.

## Try a function

On the **Functions** tab, each row shows the function’s name, how many inputs it takes, and
a tag: **live-tested** (it was called once and gave a real response) or **unverified**. Next to it are its price per cloud call in credits and its last five calls.

- **Run** (tooltip **Run just this function**) opens the Run window for that one function. Writ runs it with the sign-in and any function it depends on, and nothing else.
- Open the row to get **Try it**: a form built from the function’s inputs. Click **Send** to see the live response in place. For a function that changes something on the site, tick **Preview only: read the page, do not send the write** to test it without sending the change.
- The **curl** button (**Copy a curl for this function**) copies a ready request for the function. Replace `YOUR_API_KEY` with a key from **Developers → API Keys**.

The open row also shows what the function **Reads** (its inputs), what it **Produces** (its outputs), what it **Depends on** and which steps it runs.

### Price per call

The price shows what one call of this function usually costs on Writ Cloud, learned from its recent
successful calls. It starts at 2 credits for a call that needs no browser and
20 for one that does, and rises when calls often need a CAPTCHA solved, a
residential connection or long browser time. Until a function has 20 calls, the price is marked **estimated from fewer than 20 calls**. Each call is still charged for what it actually
used, and calls on Writ Desktop are free.

### Sign-in and data settings

- **Sign-in policy**: **Reuse banked session** keeps using a session that is still signed in, which is faster. **Always re-authenticate** signs in again on every call.
- **What happens to the data**: **Save the data** adds every call’s rows to the API’s data, where you can search and export them. **Return only** sends the rows to the caller and keeps nothing.

### Run the whole API

**Run** in the header runs every function. Its menu, **Choose where to run**,
offers **Run on Writ Cloud**, **Run on Local Agent** (a machine of yours
that is online), **Run on a device** and **Auto (prefer local)**. To add your
own machine, see [Your own machines](https://usewrit.app/docs/agents).

## Publish it on the Call tab

The **Call** tab opens with **Publish & call**: a live REST URL for your
code and an MCP tool for your AI assistant.

- **Publish REST endpoint** gives the API a stable URL, secured by a scoped API key, and working code samples. Under **Response behavior**, **Caller gets** sets the samples to **Wait for result** (the call returns the data, or a run id to collect after the timeout), **Return immediately** (answers `202` with a run id you poll) or **Allow cached** (reuses a recent result). How long a result is kept, the cache window, is set in **Developers → Endpoints**.
- **Enable MCP** exposes the functions as tools on the API’s own MCP server and shows the server URL and the list of **Exposed functions**.
- **Agent skill** writes a SKILL.md that teaches Claude, or any agent that loads skills, when and how to call this API through Writ’s MCP tools. Use **Generate skill**, edit it, **Improve with Scribe**, then **Download .zip**. The agent also needs the Writ MCP connection.
- **Triggers** run the API on a schedule or when a monitored page changes. **Automations** react when it finishes and list every trigger linked to it.
- **Execution target** chooses where it runs: **Writ Cloud**, **Auto (local, else cloud)** or **Local agent**. **Move to an agent** moves its runs and its data onto one of your machines for good.

A live-session API shows an **OpenAI-compatible API** card here instead of the REST endpoint;
see [Live sessions](https://usewrit.app/docs/streaming). Requests, responses, caching and errors: [Call your API](https://usewrit.app/docs/call). Connecting assistants: [Connect an AI assistant](https://usewrit.app/docs/mcp).

> **note:** On Writ Desktop, the Call tab also has Callable from the cloud: Writ Cloud, your assistant and your code can then call an API that runs on your computer. See Link Desktop to Writ Cloud.

## The Documentation tab

Writ writes a reference for every function: its authentication, endpoint, inputs (with type, whether
each is required, and the values it accepts), responses and examples, for REST, MCP and the
OpenAI-compatible API when it applies.

- **Try the function** runs it with real values on the execution target you pick, and shows the response.
- **Download OpenAPI** and **Postman Collection** export the whole API for your tools. **Markdown view** shows the same reference as text.
- An API with no functions shows **No API docs yet**. **Generate with Scribe** asks Scribe to find and add its functions, which creates the docs.

## Change an API

- **Add a function**: click **Missing a function? Tell Scribe →**. Scribe asks what it should do, builds it, tests it on the live site and adds it.
- **Re-test everything**: on **Overview**, **Verify with a deep pass** asks Scribe to map the site again and call each function live.
- **Edit one function**: open its row to change its **Description** (used by the docs and the MCP tool), switch it off with **Enabled** (it then never runs and cannot be called), or click **Delete function**. Functions that read its outputs stop working.
- **Edit the steps**: the **Implementation** tab lets you reorder, add, disable or delete steps, and **Group into a function** turns steps into a new callable function. See [Record a workflow](https://usewrit.app/docs/workflows) and the [Step reference](https://usewrit.app/docs/workflows/steps).
- **Rename**: **Edit workflow** changes the name, the description and the entry URL.
- **Delete the API**: More menu → **Delete workflow**. This removes its steps and run history for good.

From your AI assistant, `writ_update_workflow` makes the same kind of changes. See [Keep an API working](https://usewrit.app/docs/keep-it-working).

## Next

-
- [Call your API](https://usewrit.app/docs/call): Endpoints, keys, waiting for results, caching and errors.
-
- [Keep an API working](https://usewrit.app/docs/keep-it-working): Daily checks, automatic repairs and troubleshooting.
-
- [Outputs and exports](https://usewrit.app/docs/storage): Search, filter and export the data your API saves.
