# routeup inspect

> Show captured request and response data for a specific request.

`routeup inspect` shows the retained request and response data for a request
that was recorded by an opted-in route.

```bash
routeup inspect <request-id>
```

Get the request id from `routeup logs`:

```bash
routeup logs example-app --limit 1
```

```txt frame="terminal" title="terminal"
TIME      ROUTE                         SOURCE  STATUS  ID                    METHOD   DURATION  PATH
12:41:03  example-app                   public  200     req_Ap7kQ3mN8vR2xLzC  POST     38ms      /api/webhooks/github
```

```bash
routeup inspect req_Ap7kQ3mN8vR2xLzC
```

## Example output

```txt frame="terminal" title="terminal"
Request req_Ap7kQ3mN8vR2xLzC

Metadata
--------
Source: public
Route: example-app
Target: /:8080
Status: 200
Duration: 38ms
Method: POST
Path: /api/webhooks/github
Host: example-app.try.routeup.dev

Request
-------
Capture: complete
Body bytes: 63
Redacted: authorization, cookie, x-hub-signature-256
X-Github-Event: push

Body
----
{
  "ref": "refs/heads/main",
  "repository": {
    "full_name": "acme/api"
  }
}

Response
--------
Capture: complete
Body bytes: 11
Redacted: authorization, cookie, x-hub-signature-256
Content-Type: application/json

Body
----
{
  "ok": true
}
```

## Export as curl

Export a complete captured request as a curl command targeting its corresponding
local `.localhost` URL:

```bash
routeup inspect req_Ap7kQ3mN8vR2xLzC --curl
```

```bash frame="terminal" title="terminal"
curl \
  --ipv4 \
  --path-as-is \
  --request 'POST' \
  --header 'Content-Type: application/json' \
  --header 'X-Github-Event: push' \
  --data-raw '{"ref":"refs/heads/main"}' \
  --url 'https://example-app.localhost/api/webhooks/github'
```

`--path-as-is` is a boolean curl option that prevents curl from normalizing the
captured path; the complete path and query remain in `--url`. Safe text bodies
are embedded directly, while binary bodies use a base64 decode pipe.

Every retained header is included. Headers listed in `redact_headers` remain
absent because routeup never stored them. The generated command can therefore
contain credentials or other sensitive captured values when they were not
redacted. Curl export requires a complete request capture, and its local route
must be active when you execute the command.

## Enabling capture

Capture is disabled by default. Enable it per-route in `routeup.json`:

```json title="routeup.json"
{
  "name": "example-app",
  "port": 8080,
  "capture": {
    "request": true,
    "response": true,
    "redact_headers": ["authorization", "cookie", "x-hub-signature-256"]
  }
}
```

`request` captures incoming headers and body. `response` captures the upstream's
headers and body. Both are independent; you can enable either or both.

Headers listed in `redact_headers` are omitted from the captured copy but are
still forwarded to the upstream service unchanged.

## Retention

Captured data is stored in the same in-memory ring buffer as request logs (last
1,024 entries). It is cleared when the agent restarts. Each captured request and
response message is independently bounded to 256 KiB. Larger bodies are captured as a prefix and marked
`partial`.

## Privacy

`routeup inspect` is only accessible over the local Unix socket (mode 0600).
It is not reachable from the network.

By default, captured bytes and header values are escaped before they reach the
terminal, so a captured payload cannot emit terminal control sequences. Use
`--raw` only when you intentionally need the original bytes, usually with
redirection. `--json` emits the complete structured exchange; captured byte
slices use JSON's base64 encoding. `--raw`, `--json`, and `--curl` are mutually
exclusive.
