# Inspecting messages

Read text, HTML, links and attachments after a matching email arrives.

<a id="guide-content"></a>



For the Bash commands below, continue in the same terminal after the Bash / curl tab of the [first-email quickstart](https://www.inboxspec.com/docs/markdown/first-email.md#first-email-bash). Its run ID, inbox and matched message variables are used below.

<a id="bodies"></a>



<a id="read-the-matched-message-body"></a>

## Read the matched message body

Run after a match in the same terminal. The key remains in your environment.

```bash
if [ -n "$MESSAGE_ID" ]; then
  curl --fail-with-body --silent --show-error "$INBOXSPEC_API_URL/v1/messages/$MESSAGE_ID/body?format=text" \
    -H "Authorization: Bearer $INBOXSPEC_API_KEY"
else
  printf '%s\n' 'A matched message is required; inspect the wait outcome.' >&2
  false
fi
```

If the InboxSpec CLI is already installed, it uses the same API address and key environment variables:

```bash
if [ -n "$MESSAGE_ID" ]; then
  inboxspec messages body "$MESSAGE_ID" --format text
else
  printf '%s\n' 'A matched message is required; inspect the wait outcome.' >&2
  false
fi
```

A message without a text part returns `unsupported_format`; use a format listed in that error. [The API reference](https://api.inboxspec.com/docs) also covers HTML, links and attachments.
