# Get a Specific Message

{% hint style="info" %}
This is the only GraphQL query that will allow you to get the raw body and the html of the message.
{% endhint %}

## Gets a specific message, by id, from a mailbox.

<mark style="color:green;">`POST`</mark> `https://api.maildrop.cc/graphql`

This GraphQL query takes a mailbox and an id as required parameters. Returns a Message object with valid "data" and "html" fields.

#### Headers

| Name         | Type   | Description      |
| ------------ | ------ | ---------------- |
| Content-Type | String | application/json |

#### Request Body

| Name | Type   | Description                                                                                                        |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------ |
|      | String | '{"query":"query Example { message(mailbox:\\"testing\\", id:\\"AIm59ihdGy\\") { id headerfrom subject date } }"}' |

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong><strong>    "data": {
</strong><strong>        "message": {
</strong><strong>            "id": "AIm59ihdGy",
</strong><strong>            "headerfrom": "Test &#x3C;test@test.com>",
</strong><strong>            "subject": "Testing!",
</strong><strong>            "date": "2023-02-09T23:51:14.411Z"
</strong><strong>        }
</strong><strong>    }
</strong><strong>}
</strong></code></pre>

{% endtab %}
{% endtabs %}

#### See Also

* [GraphQL reference type for a Message](https://docs.maildrop.cc/graphql-types/message)

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl --request POST \
    --header 'content-type: application/json' \
    --url https://api.maildrop.cc/graphql \
    --data '{"query":"query Example {\n  message(mailbox:\"testing\", id:\"AIm59ihdGy\") { id headerfrom subject date }\n}"}'
```

returns:

```json
{"data":{"message":{"id":"AIm59ihdGy","headerfrom":"test@test.com","subject":"Testing!","date":"2023-02-09T23:51:14.411Z"}}}
```

{% endtab %}

{% tab title="React" %}

```tsx
export const GET_MESSAGE = gql`
    query GetMessage($mailbox: String!, $id: String!) {
        message(mailbox: $mailbox, id: $id) {
            id
            subject
            date
            headerfrom
            data
            html
        }
    }
`;

interface QueryReturn {
    message: Message;
}

interface MyComponentProps {
    mailbox: string;
    id: string;
}

const MyComponent = (props: MyComponentProps) => {
    const { loading, error, data } = useQuery<QueryReturn>(GET_MESSAGE, {
        variables: { mailbox: props.mailbox, id: props.id },
    });
    return (
        <div>
            {loading && <div>Loading...</div>}
            {!loading && error && <div>There was an error.</div>}
            {!loading && data?.message && <div>Message: {data.message.subject}</div>}            
        </div>
    );
};
```

{% endtab %}
{% endtabs %}
