List messages
cooper_list_messagesUse this when you need to check an inbox for new or recent mail (sent and received), for example after sending a message and waiting for a reply. Read-only; requires auth. Inputs: inbox_id (optional; inbox id, username, or email — omit to use the account's newest inbox), limit (optional, default 50, max 200), labels (optional; the message must have every label, for example ["unread"]), unread (optional boolean; true keeps only unread mail, false drops it), before (optional ISO-8601 exclusive upper bound on created_at), after (optional ISO-8601 exclusive lower bound on created_at), from (optional case-insensitive substring of From), to (optional case-insensitive substring of To or Cc), subject (optional case-insensitive substring), direction (optional inbound or outbound), thread_id (optional), ascending (optional; true returns oldest first), page_token (optional cursor), wait_seconds (optional integer from 0 to 55; when set, hold until unread mail arrives and return object inbox_wait with timed_out). Filters run on the server before limit. Returns {object:"list", inbox_id, data:[{id, thread_id, direction, status, from, to, subject, preview, created_at, labels, folder, attachments?}], next_page_token}, newest first unless ascending is true. Each message includes folder from its thread. Omit folder to list inbox and archive only. When wait_seconds is set, returns unread mail immediately if any is already stored, including mail in spam or trash. page_token is the base64url of created_at and id. Previews only, not full bodies: call cooper_get_message to read one message. Mark one read with cooper_update_message. Fails with 400 invalid_date, invalid_direction, invalid_ascending, invalid_page_token, invalid_label, invalid_unread, invalid_folder, or label_conflict, or 404 inbox_not_found.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Case-insensitive substring of To or Cc. % and _ match those characters. | |
| from | No | Case-insensitive substring of From. % and _ match those characters. | |
| after | No | ISO-8601 exclusive lower bound on created_at. A bad value returns invalid_date. | |
| limit | No | Max messages to return (default 50, max 200) | |
| before | No | ISO-8601 exclusive upper bound on created_at. A bad value returns invalid_date. | |
| folder | No | inbox, archive, spam, trash, or all. Omit to list inbox and archive only. Ignored when wait_seconds is set. A bad value returns invalid_folder. | |
| labels | No | Keep messages that have every one of these labels. Example: ["unread"]. | |
| unread | No | true lists only messages labeled unread. false omits them. | |
| subject | No | Case-insensitive substring of the subject. % and _ match those characters. | |
| inbox_id | No | Inbox id, username, or email. Omit to use the newest inbox. | |
| ascending | No | true lists oldest first. false, the default, lists newest first. | |
| direction | No | inbound or outbound. Anything else returns invalid_direction. | |
| thread_id | No | Only messages on this thread (thr_…). | |
| page_token | No | Cursor from next_page_token. A bad token returns invalid_page_token. | |
| wait_seconds | No | Optional. When set, hold until unread mail arrives, from 0 to 55 seconds. Returns immediately when unread mail is already stored. At most 5 waits can run at once for this key. The result is object inbox_wait with timed_out. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Message previews. Call cooper_get_message for a full body. | |
| object | No | Object type name, such as list, message, or thread. | |
| inbox_id | No | Inbox id (inb_…) this object belongs to. Null when it applies to every inbox. | |
| timed_out | No | True when the wait ended without a match. | |
| next_page_token | No | Cursor for the next page, or null when this is the last page. Pass it back as page_token. |