# API recipes

> Copy-paste API calls for the most common tasks, from creating a tagged instance to sending an invite link and reading costs.

Each recipe is one or two calls. Replace `<region>` with `eu1` or `na1`, and keep your key in an environment
variable: `export MOLTED_API_KEY=mk_live_…`. Field-by-field details are in the
[API reference](https://www.molted.net/api/docs/v2).

## Find your account id

Creating an instance needs your account id (`tenantId`). Every instance the API returns carries it:

```bash
curl "https://api.<region>.molted.net/v2/instances?limit=1" \
  -H "Authorization: Bearer $MOLTED_API_KEY"
```

## Create a tagged Mue instance from a template

```bash
curl -X POST "https://api.<region>.molted.net/v2/instances" \
  -H "Authorization: Bearer $MOLTED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "handle": "acme-sales",
    "tenantId": "<your account id>",
    "runtime": "molted-runtime",
    "instanceType": "small",
    "templates": [{ "name": "sales-agent" }],
    "ownerPath": "/clients/acme",
    "tags": [{ "key": "client", "value": "acme" }]
  }'
```

The answer contains the instance and its id (`inst-…`). It is online a few seconds later. A `402` means your
wallet needs credit; a `403 instance_limit_reached` means your account's instance limit is reached.

## List a client's instances

```bash
curl "https://api.<region>.molted.net/v2/instances?tagKey=client&tagValue=acme" \
  -H "Authorization: Bearer $MOLTED_API_KEY"
```

More filters in [Organise clients](organise-clients.md).

## Send a client an invite link

```bash
curl -X POST "https://api.<region>.molted.net/v2/instances/<instance id>/invite-link" \
  -H "Authorization: Bearer $MOLTED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "applicationId": "<your app id>", "expiresInHours": 48 }'
```

Your application ids come from `GET /v2/applications`. See [Access links](access-links.md).

## Read and write a file

```bash
# read
curl "https://api.<region>.molted.net/v2/instances/<instance id>/fs/read?path=workspace/notes.md" \
  -H "Authorization: Bearer $MOLTED_API_KEY"

# list a folder
curl "https://api.<region>.molted.net/v2/instances/<instance id>/fs/list?path=workspace" \
  -H "Authorization: Bearer $MOLTED_API_KEY"
```

Writing, deleting, searching, history and restore follow the same pattern. They work even when the instance
is stopped. See [Files](files.md).

## Read what an instance cost this month

```bash
curl "https://api.<region>.molted.net/v2/instances/<instance id>/cost?from=2026-11-01&to=2026-11-30" \
  -H "Authorization: Bearer $MOLTED_API_KEY"
```

## Set an instance's monthly usage cap

```bash
curl -X PUT "https://api.<region>.molted.net/v2/instances/<instance id>/usage-cap" \
  -H "Authorization: Bearer $MOLTED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "cap": 8 }'
```

## Publish a web app the agent built

```bash
curl -X POST "https://api.<region>.molted.net/v2/instances/<instance id>/ports" \
  -H "Authorization: Bearer $MOLTED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "port": 3000 }'
```

The answer contains the public HTTPS address. Anyone with it can open the app. See
[Network](network.md#public-urls).

## Start the management agent

```bash
curl -X POST "https://api.<region>.molted.net/v2/management-agent" \
  -H "Authorization: Bearer <owner session>"
```

This one needs the account owner, not an API key: the simplest is the round chat button of the dashboard.
See [The management agent](management-agent.md).

## Hand all of this to an agent

Paste this into Claude Code, Codex or your Mue agent:

> Read https://www.molted.net/docs/llms.txt and the OpenAPI reference at https://www.molted.net/api/docs/v2.
> My API key is in the environment variable MOLTED_API_KEY and my region is eu1. Ask me before anything that
> costs money or deletes something.
