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

# Send Prompt (v0)

> Send a follow-up prompt to a running session and stream the response over SSE

Sends a prompt to a session that is already in `running` state. The response is a Server-Sent Events (SSE) stream of the agent's output (tool calls, plan, intermediate results) terminated by a `done` event.

Use this when you want to stream output in real time. If you'd rather kick off the prompt as a background task and poll for completion, [`POST /api/v0/sessions/launch`](/cloud-api/sessions/launch) and then poll [`GET /api/v0/sessions/{id}`](/cloud-api/sessions/v0-get) is the better pattern.

The session must be in `running` state - call [`POST /api/v0/sessions`](/cloud-api/sessions/v0-create) first if you haven't already.

**Required scope:** `sessions:prompt`

## Path Parameters

<ParamField path="session_id" type="string" required>
  The session ID.
</ParamField>

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token. Example: `Bearer runtm_xxx`
</ParamField>

<ParamField header="Accept" type="string">
  `text/event-stream` (recommended for SSE clients).
</ParamField>

## Body

<ParamField body="prompt" type="string" required>
  The prompt to send (0–100,000 characters).
</ParamField>

<ParamField body="model" type="string">
  Model override: `sonnet`, `opus`, `haiku`, `opusplan`. Defaults to `sonnet`.
</ParamField>

<ParamField body="plan_mode" type="boolean" default={false}>
  Run in plan mode (read-only - agent analyzes without making changes).
</ParamField>

<ParamField body="continue_session" type="string">
  Claude Code session ID for conversation continuity.
</ParamField>

<ParamField body="new_session" type="boolean" default={false}>
  Force a new agent session instead of resuming the previous one.
</ParamField>

<ParamField body="attachments" type="array">
  Up to 5 base64-encoded files included as content blocks. Each entry: `{ "filename": "diagram.png", "media_type": "image/png", "data": "<base64>" }`.
</ParamField>

## Response

`200 text/event-stream`. Each event has the shape:

```
event: <event_type>
data: <json>

```

Common `event_type` values:

| Event | Meaning |
| - | - |
| `assistant_message` | Streaming text from the agent |
| `tool_use` | Tool invocation (file edit, bash command, etc.) |
| `tool_result` | Tool output |
| `result` | Final result with `cost_usd` metadata |
| `error` | Fatal error - stream terminates |
| `done` | Stream complete (always last event) |

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -N -X POST "https://app.runtm.com/api/v0/sessions/86e11104-.../prompt" \
    -H "Authorization: Bearer runtm_xxx" \
    -H "Accept: text/event-stream" \
    -H "Content-Type: application/json" \
    -d '{"prompt": "Add a /health endpoint that returns 200"}'
  ```

  ```python Python theme={null}
  import requests

  with requests.post(
      "https://app.runtm.com/api/v0/sessions/86e11104-.../prompt",
      headers={
          "Authorization": "Bearer runtm_xxx",
          "Accept": "text/event-stream",
      },
      json={"prompt": "Add a /health endpoint that returns 200"},
      stream=True,
  ) as response:
      for line in response.iter_lines():
          if line:
              print(line.decode())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://app.runtm.com/api/v0/sessions/86e11104-.../prompt",
    {
      method: "POST",
      headers: {
        "Authorization": "Bearer runtm_xxx",
        "Accept": "text/event-stream",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ prompt: "Add a /health endpoint that returns 200" }),
    }
  );

  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  while (true) {
    const { value, done } = await reader.read();
    if (done) break;
    process.stdout.write(decoder.decode(value));
  }
  ```
</RequestExample>

<ResponseExample>
  ```text 200 theme={null}
  event: assistant_message
  data: {"type":"assistant_message","content":"I'll add a /health endpoint…"}

  event: tool_use
  data: {"type":"tool_use","name":"Edit","input":{"file":"main.py"}}

  event: tool_result
  data: {"type":"tool_result","content":"File updated"}

  event: result
  data: {"type":"result","content":"Added /health endpoint","metadata":{"cost_usd":0.018}}

  event: done
  data: {"type":"done","message":"Stream complete"}

  ```
</ResponseExample>
