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

# Resource

> A stateful, multi-step workflow for generating classroom resources.

Unlike the other capabilities, `/resource` is a **session-based workflow**. You
dispatch on an `action` field and carry a `sessionId` between calls.

## Workflow

**1. start**

Open a session. Returns a `sessionId`.

```json theme={null}
{ "action": "start", "resourceType": "worksheet", "unitId": "..." }
```

Optionally scope with `contextMode`, `unitId` or `lessonId`.

**2. configure**

Supply the topic and resource configuration.

```json theme={null}
{ "action": "configure", "sessionId": "...", "topic": "Photosynthesis",
  "config": { }, "additionalInstructions": "..." }
```

**3. generate**

Produce the resource.

```json theme={null}
{ "action": "generate", "sessionId": "..." }
```

**4. refine (optional, repeatable)**

Iterate on the result.

```json theme={null}
{ "action": "refine", "sessionId": "...", "refinementInstructions": "..." }
```

**5. persist**

Save it to the library.

```json theme={null}
{ "action": "persist", "sessionId": "...", "title": "...", "tags": ["..."] }
```

## Other actions

**get\_session** `action`

`{ "action": "get_session", "sessionId": "..." }` — read current session state.

**cancel** `action`

`{ "action": "cancel", "sessionId": "..." }` — abandon the session.

> [!WARNING]
>
> Persisted resources carry a `structured_content` payload. That is the
> authoritative form — render from it rather than from any markdown field, or you
> will reproduce the mangled-markdown class of bug.


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