> For the complete documentation index, see [llms.txt](https://herd-security.gitbook.io/herd-security-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/email-providers/gmail.md). Agents can also search and read this documentation through its [MCP server](https://herd-security.gitbook.io/herd-security-docs/~gitbook/mcp).

# Detecting Phishing Reports From Gmail

Enable Herd to credit users who report a phishing simulation using Gmail's Report phishing button, by reusing your Google Workspace service account and granting one additional read-only Gmail scope.

When users report a Herd phishing simulation using Gmail's built-in **Report phishing** (or **Report spam**) button, Herd can credit them with reporting the simulation in your campaign results. This guide enables that detection by reusing the Google Workspace service account you set up for directory sync and granting it one additional read-only Gmail scope.

{% hint style="warning" %}
**Prerequisites**

* You have already completed [Google Workspace](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/google-workspace.md) directory-sync setup. This guide builds on that integration and reuses the same service account.
* You are a Google Workspace **super admin** (required to edit domain-wide delegation entries in [admin.google.com](http://admin.google.com)).
* You are a Herd admin with Integrations permissions.
  {% endhint %}

## How it works

After Herd sends a phishing simulation, it periodically checks each recipient's Gmail mailbox to see what happened to that specific message: whether it was opened, forwarded, or reported as phishing or moved to spam.

When a user clicks Gmail's **Report phishing** button, Gmail moves the message out of the inbox into spam. Herd detects that change on its next polling cycle and marks the simulation as **Reported** for that user.

Detection has these limits:

* Read-only. Herd only reads message metadata (labels and a small set of forwarding-related headers). It cannot read general message bodies, send mail, modify labels, or delete messages.
* Latency is typically within 5 minutes. Polling runs every 5 minutes; allow up to \~30 minutes for orgs with very large recent campaign volume.
* Recent campaigns only. Herd polls mailboxes for simulations sent in the last 30 days. Older campaigns are not re-checked.
* Reports require user action. A simulation is only credited as reported when the user moves it to spam, whether with Report phishing, Report spam, or by dragging it there. If Gmail's spam filter auto-classifies a message before the user ever sees it, that is not counted as a report.
* Backfill is automatic. Once you turn polling on, every simulation in the last 30 days becomes pollable on the next cycle, including any reports users had already filed before you enabled this.
* Recipients must be in your domain. Polling impersonates each recipient via domain-wide delegation, so external recipients are not polled.

## What Herd reads from Gmail

The `gmail.readonly` scope is the narrowest read scope Google offers, but the access Herd actually uses is narrower still:

* Labels on the specific simulation messages it sent, to determine inbox/spam placement and read state.
* A small set of forwarding-related headers (`X-Forwarded-To`, `Resent-From`, `Resent-To`) on those same messages.

Herd never reads message bodies, never inspects unrelated mail, and never modifies or deletes anything. Access runs through the domain-wide delegation entry you control, and you can revoke it at any time by removing the `gmail.readonly` scope from that entry, or by removing the entry entirely.

## Step 1: Add the Gmail scope to domain-wide delegation

You will edit the existing Herd entry under domain-wide delegation in the Google Admin console and add one additional OAuth scope.

1. Sign in to the Google Admin console as a super admin: **`https://admin.google.com`**.
2. From the left navigation, select **Security → Access and data control → API controls**.
3. Scroll to the **Domain-wide delegation** section and click **Manage Domain Wide Delegation**.
4. In the **API clients** list, find the row whose **Client ID** matches the Herd service account you created during directory-sync setup. Click that row to open it.
5. Click **Edit** (or **Edit OAuth scopes**).
6. Add the following scope on its own line, alongside the three existing directory scopes:
   * `https://www.googleapis.com/auth/gmail.readonly`
7. Click **Authorize**.

Your Herd entry should now show four scopes total:

* `https://www.googleapis.com/auth/admin.directory.user.readonly`
* `https://www.googleapis.com/auth/admin.directory.group.readonly`
* `https://www.googleapis.com/auth/admin.directory.customer.readonly`
* `https://www.googleapis.com/auth/gmail.readonly`

{% hint style="info" %}
The `gmail.readonly` scope grants read-only access to Gmail. Herd uses it only to check what happened to messages it sent as part of your phishing simulations, and never to read general user mail.
{% endhint %}

## Step 2: Enable the Gmail API in your Google Cloud project

The domain-wide delegation scope alone is not enough. The Gmail API itself must be enabled in the same Google Cloud project that hosts your Herd service account. Without this, every Gmail call from Herd will fail with `accessNotConfigured`.

1. Open the Google Cloud Console: **`https://console.cloud.google.com`**.
2. On the top toolbar, confirm the project picker shows the **Herd Integration** project you created during directory-sync setup. If a different project is selected, switch to the Herd one.
3. Open the hamburger menu → **APIs & Services → Library**.
4. In the search box, type **Gmail API**.
5. Click the **Gmail API** result, then click **Enable**.

The API is enabled immediately, but Google's edge cache can take a few minutes to pick it up.

## Step 3: Enable Gmail report detection in Herd

Herd needs no additional credentials. It reuses the service account from your directory-sync setup, so you only turn the feature on.

1. Sign in to your Herd admin console.
2. Open **Settings** and choose **Integrations** in the Settings sidebar.
3. Open the **Gmail** card in the **Email** section.
4. Expand the **Gmail (Google Workspace)** tile.
5. Click **Enable polling**.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2Fgit-blob-11c69da7799628ed309b1c502d1178d5cf187633%2Femail-integrations-section.png?alt=media" alt="The Email section of Herd Settings → Integrations, with the Gmail, Microsoft Outlook and Security Alert Automations cards"><figcaption><p>Settings → Integrations → Email</p></figcaption></figure>

Herd will begin polling recipient mailboxes on the next polling cycle (typically within 5 minutes), and will retroactively check every simulation sent in the last 30 days.

## Step 4: Verify the integration

Before relying on the integration in production, confirm a report flows through end-to-end. The simplest way is [Test your report button](#test-your-report-button). To check by hand instead, send yourself a test simulation:

1. In the Herd admin console, send a phishing simulation campaign that includes your own email address.
2. Open the simulation email in Gmail.
3. Click the Gmail overflow menu (**⋮**) and select **Report phishing**.
   * Confirm the report when prompted by Gmail.
4. Wait \~5 minutes for the next polling cycle (allow up to 30 minutes if your org has very large recent campaign volume).
5. In the Herd admin console, open the campaign results for your test simulation.
6. Your row should now show as **Reported**, with a report timestamp set to roughly when Herd's polling cycle detected it.

If the report does not appear after 30 minutes, see [Troubleshooting](#troubleshooting) below.

## Test your report button

On the Gmail integration (**Settings → Integrations → Gmail**), open **Test your report button**, click **Send me a test**, report the test with **Report phishing**, then choose **Gmail's Report phishing option** (or **A third-party add-in (Mimecast, KnowBe4 or another)**) under **Which button did you use?** and click **I've reported it**. Within a few minutes the card shows **Credited** or **Not credited** with the reason. A credited Gmail report completes the **Test your report button** step of the [Get Started checklist](https://herd-security.gitbook.io/herd-security-docs/getting-started/quickstart.md#the-get-started-checklist).

If the result is **Herd didn't check for reports during the test**, click **Enable polling** on the Gmail integration, then send another test. If your people report with a third-party add-in such as Mimecast or KnowBe4, forward its reporting mailbox to the **Herd forwarding address** shown on the card; see [Detecting Phishing Reports From a Reporting Mailbox](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/email-providers/reporting-mailbox-forwarding.md), which has the Google Workspace routing rule. For the other reasons, which report buttons Herd credits and the test's limits, see [Test your report button](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/email-providers/outlook.md#test-your-report-button) on the Outlook page.

## Outlook / Microsoft 365

If your org also uses Microsoft 365, see [Detecting Phishing Reports From Outlook](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/email-providers/outlook.md) for the equivalent setup. Both providers can be enabled side by side; Herd polls each user's mailbox via the appropriate integration.

## Troubleshooting

<details>

<summary>No reports are appearing, even after the next polling cycle.</summary>

Check each of the following:

1. **Domain-wide delegation scope.** In [**admin.google.com**](http://admin.google.com) **→ Security → API controls → Domain-wide Delegation**, open the Herd service account row and confirm `https://www.googleapis.com/auth/gmail.readonly` is listed. A typo or missing scope is the most common cause.
2. **Gmail API is enabled in your Google Cloud project.** In the [Google Cloud Console](https://console.cloud.google.com) for your **Herd Integration** project, go to **APIs & Services → Enabled APIs & services** and confirm **Gmail API** is in the list. If it's missing, see Step 2 above. Adding the DwD scope without enabling the API will fail with `accessNotConfigured` on every poll.
3. **Gmail tile is enabled.** In the **Gmail** card under **Settings → Integrations**, confirm the tile shows **Polling: Enabled**. If it shows **Disabled**, click **Enable polling**.
4. **Directory sync is healthy.** If your underlying Workspace integration has been disabled or the service account has been disabled in Google Cloud, Gmail polling will not run. Confirm directory sync is still completing successfully.
5. **Campaign age.** Herd only polls mailboxes for simulations sent in the last 30 days. Older campaigns will not pick up new reports.
6. **The recipient's mailbox is in your domain.** Polling impersonates each recipient via domain-wide delegation, so the recipient must be a user in the Workspace domain you connected. External recipients are not polled.

</details>

<details>

<summary>The user opened the simulation but did not click Report phishing. Should it still show as reported?</summary>

No. A simulation is only credited as reported when the message is moved out of the inbox into spam, which Gmail does automatically when a user clicks Report phishing or Report spam. If the user opened the email and ignored it, the simulation will be marked as **Opened** but not **Reported**.

Manually dragging the message to spam also counts. Auto-classification by Gmail's spam filter (where the user never saw the message in their inbox) does not count. Herd only credits user actions.

</details>

<details>

<summary>Can I disable Gmail report detection without removing the directory-sync integration?</summary>

Yes. In the **Gmail** card under **Settings → Integrations**, click **Disable polling**. Directory sync (users and groups) will continue to run normally; only mailbox polling is disabled. To re-enable later, click **Enable polling**. No additional setup is required.

</details>

<details>

<summary>What permissions does Herd actually have on user mailboxes?</summary>

Read-only access via the `gmail.readonly` scope, though Herd uses less than the scope allows. It reads only the labels and a small set of forwarding-related headers (`X-Forwarded-To`, `Resent-From`, `Resent-To`) on the specific messages it sent as phishing simulations. Herd does not read general message bodies, send mail, modify labels, or delete messages. The scope is granted only to the Herd service account, only for users in your Workspace domain, and only via the domain-wide delegation entry you control. You can revoke access at any time by removing the `gmail.readonly` scope from the delegation entry, or by removing the entry entirely.

</details>
