Dataset
Gmail business email thread datasets for AI training
A Gmail dataset is the mail in a business's Google Workspace mailboxes: Messages with their full headers and MIME parts, the Threads Gmail assembled from them, the system and user Labels on every message, Drafts, Attachments and the Filters that filed mail by rule. SourceX sources it to a buyer's spec from established businesses that run Gmail, scoped to named mailboxes, labels and a date range. How outside correspondents, personal mail and privileged mail are treated is agreed per order. Each dataset is de-identified and licensed for an agreed permitted use.
Dataset manifest
Sourced to your spec- What it is
- One business's Gmail mailboxes as messages with headers, MIME parts, thread IDs and the labels on each message
- Typical systems
- Gmail under Google Workspace: user and delegated mailboxes, send-as aliases and filters; Google Groups archives and Google Vault exports on request
- Typical history
- Specified by the buyer; limited by each mailbox's age, the retention rules in force and what staff deleted
- Modality
- RFC 822 messages with plain text and HTML bodies; labels and thread IDs as structured fields; attachments as files
- Delivery formats
- Agreed per order; commonly JSONL per message keyed by mailbox and thread, plus the original MBOX files
- Preparation
- Correspondents pseudonymized in headers, bodies, signatures and quoted text; screened mail removed
- Licensing
- Rights reviewed against the employer's policies, third-party correspondence and Google's terms; permitted use set in the license
- Availability
- Sourced to your spec from businesses that run Gmail; supply is not guaranteed
What a delivery contains
Fields vary by source system and are fixed per order. A typical delivery includes:
| Field | Type | What it holds |
|---|---|---|
| mailbox_ref | string | Pseudonymous ID of the mailbox this copy of the Message came from, with the Send-as alias used where there was one. |
| message_id | string | The Message's id, a hexadecimal string unique only inside its own mailbox. |
| thread_id | string | The Message's threadId for the Thread Gmail assembled in this mailbox, which an MBOX carries as X-GM-THRID. |
| rfc822_message_id | string | The Message-ID from the Headers, identical on every mailbox's copy of the message. |
| labels | array | The Labels on this Message, each with ID, name and system or user type from the mailbox's Labels list. |
| label_source | enum | For each user Label, whether replaying the mailbox's Filters explains it: filter, unexplained or filters not delivered. |
| headers | object | The Message's Headers, including From, To, Cc, Subject, Date, In-Reply-To and References, with addresses pseudonymized. |
| internal_date | datetime | The Message's internalDate, the time Gmail accepted it, as distinct from the sender-written Date header. |
| payload_parts | array | The Message payload's tree of MIME parts, each with partId, mimeType and filename. |
| body_text | string | The decoded text/plain part, or text converted from text/html, with the quoted earlier Messages cut and marked. |
| attachments | array | Attachment parts with filename, mimeType and size, each marked delivered, withheld or link only. |
| draft | object | For a Message under the DRAFT label, its Draft ID. Gmail replaces the Message on every save, so earlier wording is not kept. |
| history | array | History records for the Message, such as labelsAdded and labelsRemoved, where the supplier captured them. |
Field names from the table above; values are masked placeholders.
Example record
{
"mailbox_ref": "mbx_0412",
"message_id": "18f3a9c2d7e4b061",
"thread_id": "18f39b70c1a2e9d4",
"x_gm_thrid": "1797951584838281684",
"rfc822_message_id": "<m-7f21c9e0@mail.ext-org-12.invalid>",
"internal_date": "2025-03-11T14:25:21Z",
"labels": [
{ "id": "INBOX", "name": "Inbox", "type": "system" },
{ "id": "IMPORTANT", "name": "Important", "type": "system" },
{ "id": "Label_27", "name": "Clients/[CLIENT_17]", "type": "user", "label_source": "filter" },
{ "id": "Label_41", "name": "Needs reply", "type": "user", "label_source": "unexplained" }
],
"headers": {
"from": "[PERSON_88] <p88@ext-org-12.invalid>",
"to": ["ap@supplier-co.invalid"],
"subject": "Re: PO 4471 short shipment",
"in_reply_to": "<m-66b0d412@mail.supplier-co.invalid>",
"references": ["<m-5e01aa97@mail.ext-org-12.invalid>", "<m-66b0d412@mail.supplier-co.invalid>"]
},
"payload_parts": [
{ "part_id": "0", "mime_type": "multipart/alternative" },
{ "part_id": "0.0", "mime_type": "text/plain" },
{ "part_id": "0.1", "mime_type": "text/html" },
{ "part_id": "1", "mime_type": "application/pdf", "filename": "credit_note_4471.pdf" }
],
"body_text": "Hi [PERSON_3], we counted 38 cartons against 42 on the packing list. Credit note attached. Can you confirm before Friday's payment run?",
"quoted_text_removed": true,
"attachments": [
{ "part_id": "1", "filename": "credit_note_4471.pdf", "size": 48211, "delivery": "delivered" }
],
"draft": null,
"export_basis": { "route": "takeout_mbox", "filters_delivered": true }
}Synthetic record for illustration. Field names, structure and format are agreed per order.
What AI teams use it for
Multi-label mail triage
Message-level label sets train classifiers that assign several labels at once instead of choosing one folder.
Reply drafting in thread context
A thread cut before a Sent message gives the context a staff member had and the reply that person wrote.
Writing mail rules from intent
Stored Filters pair criteria with label actions, worked examples for agents that turn a described intent into a rule.
Inbox agents that act on state
Archive, star, read and trash are label changes in Gmail, so an agent's actions map onto label operations.
Held-out triage evaluation
Hold out a mailbox's later months and score predicted labels and replies against what its owner did.
Use-case guides: Enterprise and computer-use agents, Customer support agents, Sales agents, Private evaluation sets
What makes this data valuable
Labels resolved
Every label ID or X-Gmail-Labels name maps to one row in a delivered Labels table.
Thread IDs present
Each message carries its mailbox's thread ID, and the reply headers agree with it.
Label source stated
User labels are split into filter-explained and unexplained by replaying the Filters.
Copies reconciled
Copies of one message in several mailboxes share a Message-ID and one pseudonym map.
Parts accounted for
Each MIME part is delivered, withheld with a reason or marked as a Drive link.
Sent mail included
Sent messages are present, so threads hold both sides.
Document stack
Gmail dataset
Labels sit on messages, and nothing records who applied them
Gmail files nothing in folders. A label is attached to a message, a message can carry any number of them, and Inbox, Sent, Unread, Starred and Trash are labels too. Archiving removes INBOX and opening a message removes UNREAD. A thread is a grouping Gmail builds itself from the reply headers and a matching subject, and the conversation view lists a thread under a label when any one of its messages carries it. The same thread can sit under Inbox, a client label and a project label at once, which gives multi-label supervision that a folder-based mailbox cannot. Labeling a conversation marks its messages, not the thread, so test on the sample whether replies that arrived later carry the label before reading it as a judgment on each message.
Nothing on the message says who applied a label or when. The record is a set of label IDs. Gmail sets system labels such as Sent and Draft, its classifiers set the category tabs, Important and Spam unless someone overrules them, a Filter adds user labels by rule, and a person adds the rest. Filters are stored apart from the mail, as criteria with label actions, in their current state only. To read labels as human judgment, replay the mailbox's Filters over the headers and treat what no rule explains as a person's choice or unknown. A nested label is one name with slashes in it.
Gmail keeps current state and little history. History records list labels and messages added and removed, but only for a limited recent period, so when a thread was archived or starred is usually gone. A draft is overwritten on each save, and sending it creates a new message under a new ID, so the path from first draft to sent text is lost. Thread IDs are local to a mailbox, so two colleagues on one conversation hold two thread IDs, and only the Message-ID header joins them.
What a Gmail MBOX and the Gmail API return, and how to test a sample
A Takeout export delivers a mailbox as an MBOX file of raw messages. Labels and thread membership survive only as two headers Gmail adds: X-Gmail-Labels, a comma-separated list of label names, and X-GM-THRID, the thread ID as a decimal number. The API returns the same thread ID in hexadecimal, so the two routes join only after conversion. A pipeline that reads only bodies loses the thread structure and every label a person applied. A Google Vault export is MBOX or PST with separate metadata files, and Google documents a Labels column in the metadata CSV, so ask for those files with the mail.
The API returns a message as nested MIME parts under a payload, with labelIds, threadId and internalDate beside it. Body data is base64url encoded, an attachment is a stub with an attachment ID that needs a second request, and the format requested decides whether bodies were captured at all. Many messages carry the same content twice, as text/plain and text/html, and each reply quotes the mail before it. Mail composed in Gmail typically wraps the quote in a gmail_quote element, and other mail clients mark it their own way. Unless quotes are cut, the first message of a long thread is counted once per reply.
Test a sample in this order. Count messages that lack X-GM-THRID or labels. Group by thread ID and check that In-Reply-To values resolve inside the group. Pick a nested label and one with a comma or non-ASCII characters, and confirm the parser returns the name staff see. Find one message held in two mailboxes and check that both copies share a Message-ID and the same pseudonyms. Check that a body line starting with From did not split a message in two.
What to check before licensing
- Ask which route produced the archive: Takeout, the Admin console's Data Export tool, Google Vault or the Gmail API. In an MBOX sample, check every message for X-Gmail-Labels and X-GM-THRID, and for a Vault export ask for its metadata files.
- Check how third parties who wrote to the business are handled. Every thread holds the words and addresses of people outside the supplier, so ask what basis the data owner relies on and test that one outside sender maps to one pseudonym in every mailbox.
- Confirm that personal mail and privileged legal correspondence were screened out, and how: by label, by correspondent domain or by review. Ask for a marker wherever a message was withheld inside a thread.
- Have counsel for the buyer and for the data owner each read Google's current Workspace terms and Gmail API policies on exported data and API use, and confirm they allow the intended use.
- Ask for each mailbox's Filters and Labels list as of export day. Without the Filters, labels a rule applied cannot be separated from labels a person chose.
- Ask whether each shared address was a delegated mailbox, a send-as alias or a Google Group, whose archive is held outside any Gmail mailbox.
- Count attachment parts against delivered files and list messages whose only attachment is a Drive link. Ask whether Spam, Trash and Drafts are in scope.
Delivery No files move before a signed license. A listing or a request grants no files by itself.
How licensing works through SourceX
- 1
Define
Send the domain, modality, volume, format, timeline and permitted use you need.
- 2
Source
SourceX identifies businesses that hold matching data and are open to licensing it.
- 3
Qualify
Fit, rights and quality are checked, and you review samples before committing.
- 4
License
Scope, permitted use, exclusivity, price and obligations are agreed in writing.
- 5
Deliver
Approved data is prepared, de-identified where required and transferred securely.
Questions Acquisition Partners ask
Do Gmail labels survive an export?
Yes, but only where the pipeline looks for them. A Takeout MBOX writes each message's label names into an X-Gmail-Labels header, system labels beside the names staff created. The Gmail API returns label IDs that resolve against a separate Labels list. A parser that keeps only bodies loses both, so ask for labels as a field on every message.
How are Gmail threads rebuilt when several mailboxes are licensed?
By joining on the Message-ID header, not on Gmail's thread ID. Gmail builds threads separately in each mailbox, so one conversation has a different thread ID in every account, and each account holds only the messages that reached it. Ask for a delivery that keeps each mailbox's own thread ID and adds a cross-mailbox conversation key built from Message-ID, In-Reply-To and References.
Can we tell labels a person applied from labels a filter applied?
Only partly. A message stores a set of label IDs with no record of who added each one or when. Replaying the mailbox's stored Filters over message headers marks the labels a current rule explains. A filter acts on mail as it arrives, so ask when each rule was created, and a label from a filter that was later deleted cannot be told apart from a person's choice.
Are attachments and Drive-linked files included?
Attachments can be, linked files usually are not. An attachment is a MIME part of the message, so it sits inside the MBOX and is fetched through the API by its attachment ID. A file shared from Google Drive is only a link in the body, and the file stays in Drive. Ask for each part to be marked delivered, withheld or link only.
How are outside correspondents and personal mail handled?
That is agreed per order and is yours to verify. Every thread contains the words and addresses of people outside the supplier, so headers, signatures and quoted text all need pseudonymizing, and counsel should confirm the basis for licensing that correspondence. Ask how personal mail and privileged legal threads were removed, and test the sample for both.
Is SourceX affiliated with Google?
Gmail is named to identify the system the records come from. That does not imply a partnership with or endorsement by Google. The records belong to the business that runs Gmail, which licenses them under a signed agreement, and a request does not guarantee a matching dataset. Buyers should still confirm with counsel that the vendor's terms allow the intended use of exported data.
Related datasets
- Approved workplace email and chat exports
Approved, de-identified exports of team email threads and chat channels
- Shared inbox and customer email threads with outcomes
Team mailbox threads with external emails, assignment trail, internal comments, saved replies and an outcome per thread
- Google Workspace company records
One tenant's mail, files, calendar events, Chat messages and Meet artifacts, joined by its user accounts and groups
- Outlook and Exchange mailbox records
One business's Exchange mailboxes as messages with folder paths, conversation IDs, categories, flags and inbox rules
- Google Calendar scheduling records
One business's Google Calendar events with recurrence rules, exception instances, attendee responses and room bookings
Evaluating this data for procurement?
Diligence packets are prepared per dataset. Rights, privacy processing and quality differ between datasets.
Request dataset diligenceTell us what your models need
Send your spec — domain, volume, format, timeline and permitted use — and SourceX will match it against partner data and come back with what can be licensed.
Updated 26 November 2026.