# Allow writes in a simulator

A simulator refuses writes until you allow them. Allow them when a test needs to create data and read it back. You need a simulator you run yourself (see [Run a simulator](https://console.era.eon.io/docs/run-a-simulator.md)). Companies the console builds are always read-only (see [What your agent can and can't change](https://console.era.eon.io/docs/what-your-agent-can-and-cant-change.md)).

**A simulator is read-only by default.** A client's write is refused with `403` and a body that says why:

```
{"error": "writes_disabled",
 "message": "this simulator is read-only: POST /api/chat.postMessage would change
             the tenant's data. An operator enables writes with SIMCORE_ALLOW_CLIENT_WRITES."}
```

`GET /_meta` reports the setting as `{"writes": {"allowed": false}}`, so a client can check first instead of finding out partway through a task.

## Turn on writes

To turn on writes, start the simulator with `SIMCORE_ALLOW_CLIENT_WRITES=1`:

```
$ docker run --rm -p 8115:8080 -e SIMCORE_ALLOW_CLIENT_WRITES=1 erabyeon/slack:latest
```

The setting never affects two things. `/_admin` always works, so loading and injecting data keep working in a read-only simulator. The sign-in routes a client POSTs to for its credentials always work too.

## What counts as a write

A simulator decides for each request, not by HTTP method. Half the simulators' reads are POSTs (`conversations.list`, `_msearch`, `/graphql`, a SQL statement, every `search` endpoint). It checks, in order, the route's handler, then the body when the operation is *in* it (GraphQL `query` or `mutation`, `SELECT` or `INSERT`), then the MCP tool's read-only hint. An operation that none of these recognise counts as a write. Refusing too much only costs a route name, but refusing too little lets through the writes the check exists to stop.

## Choose a setting for each test

| Test | Setting |
|---|---|
| An agent that should only ever read (the common case) | Read-only. The refusal *is* the assertion, so an agent that tries to write fails the test |
| Round-tripping your own writes (create, then read back) | `SIMCORE_ALLOW_CLIENT_WRITES=1` |
| Asserting your client handles a refusal | Read-only, and assert the `403` |

Writes over MCP are refused too. A `tools/call` that would change data comes back as a JSON-RPC error, not a `403`: *"this simulator is read-only: `slack_send_message` would change the tenant's data. Only read-only tools are available."*

> If you leave writes on in a long-lived shared simulator, a tenant that has been written to can no longer be rebuilt from its recipe. So the simulator can never drop it from memory and rebuild it later. In a short-lived CI container, that doesn't matter.
