# Get a Mailbox Listing

{% hint style="warning" %}
**Please note** that the list of messages in the mailbox will come back with the "**data**" and "**html**" fields set to null. This is for performance reasons - returning 10 messages with 500k of data each would wind up with extremely slow mailbox listings. If you want to retrieve the data and html of a message, get the message id, and then [retrieve the specific message](https://docs.maildrop.cc/api-reference/get-a-specific-message).
{% endhint %}

## Gets an array of messages belonging to 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 an array of Message objects with the "data" and "html" fields set to null.

(GraphQL best practices discourage queries and variable names from being the same, so the query is named "inbox".)

#### Headers

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

#### Request Body

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

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

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

{% endtab %}
{% endtabs %}

#### See Also

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

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

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

returns:

```json
{"data":{"inbox":[{"id":"AIm59ihdGy","headerfrom":"test@heluna.com","subject":"test Thu, 09 Feb 2023 23:51:14 +0000","date":"2023-02-09T23:51:14.411Z"}]}}
```

{% endtab %}

{% tab title="React" %}

```tsx
export const GET_INBOX = gql`
    query GetInbox($mailbox: String!) {
        inbox(mailbox: $mailbox) {
            id
            subject
            date
            headerfrom
        }
    }
`;

interface QueryReturn {
    inbox: Message[];
}

interface MyComponentProps {
    mailbox: string;
}

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maildrop.cc/api-reference/get-a-mailbox-listing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
