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

# Send Stdin

> Write data to the stdin of a running background process.

Sends a string to the standard input of a background process. The target process
must have been started with `stdin: true` in the
[run command](/api-reference/command/run) request so that a stdin pipe was reserved.

Returns an empty `{}` body.

<Note>
  For full interactive stdin with streaming output, back-pressure, and
  separate stdout/stderr callbacks, see the dedicated
  [stdio API](/features/stdio). This command-level endpoint is a simpler
  alternative for one-shot stdin writes.
</Note>

## Path Parameters

<ParamField path="sandbox_id" type="string" required>
  The sandbox identifier. Format: `sbx-<8 chars>`.
</ParamField>

<ParamField path="pid" type="integer" required>
  Process ID of the background command to write to.

  Example: `42`
</ParamField>

## Request Body

<ParamField body="data" type="string" required>
  String data to write to the process stdin. Include a newline (`\n`) to
  simulate pressing Enter.

  Example: `"yes\n"`
</ParamField>

## Response

Returns an empty JSON object `{}`.

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands/42/stdin \
    -H "X-API-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "data": "yes\n" }'
  ```

  ```python Python theme={null}
  from declaw import Sandbox

  sbx = Sandbox.connect("sbx-a1b2c3d4", api_key="YOUR_API_KEY", domain="api.declaw.ai")

  # Start an interactive process
  handle = sbx.commands.run("cat", background=True, stdin=True)

  # Send data to it
  sbx.commands.send_stdin(handle.pid, "hello\n")
  ```
</CodeGroup>

```json Response theme={null}
{}
```

## Error Responses

| Status | Cause                      |
| ------ | -------------------------- |
| `401`  | Missing or invalid API key |
