Gmail Webhook for New Emails, 4 Ways Compared
Try it now: extract email data to Excel, CSV, or JSON
Connect a Gmail or IMAP mailbox to parse new mail automatically, or paste an email below to test the converter now.
Create a free account to download. No credit card required.
Gmail has no built-in webhook. Nothing in Gmail settings posts a new email to a URL. To get a webhook for new Gmail messages you pick one of four routes: the Gmail API with Google Cloud Pub/Sub, a Google Apps Script on a timer, a Zapier Gmail trigger with a Webhooks step, or an email parser that reads the mailbox over IMAP and posts each message as JSON. The right one depends on whether you want a notification, the raw message, or the values inside it.
This comparison is for the developer, ops lead or RevOps admin who has a Gmail or Google Workspace inbox full of orders, leads, invoices or alerts and needs each new one to land in their own system without someone copying it across.
Want the values inside the email at your endpoint, not a notification?
Connect Gmail to the email to webhook feature, name the fields you need, and every new message is posted to your URL as signed JSON.
Gmail webhook options side by side
| Route | What your URL receives | Build effort | Best for |
|---|---|---|---|
| Gmail API + Cloud Pub/Sub | A notification with the mailbox address and a history ID. You fetch and parse the message yourself. | High: Cloud project, OAuth, topic, watch renewal, receiver, parser | Products that integrate deeply with many users' Gmail |
| Apps Script on a time trigger | Whatever your script builds, usually subject, sender and a regex match or two | Medium: a script you own and debug | One mailbox, simple senders, someone who likes JavaScript |
| Zapier: Gmail trigger + Webhooks by Zapier | The Gmail fields Zapier exposes, mapped by hand into the POST body | Low to set up, per-task cost as volume grows | Teams already running their automations in Zapier |
| Email parser over IMAP (MailParse) | A parsed record: headers, your named fields, table rows as line_items, signed | Low: connect the mailbox, name fields, add a URL | Getting business values from templated mail into your system |
Based on each product's public documentation as of September 2026. Plans and limits change, so confirm the current details before you build.
How do I get a webhook when a new email arrives in Gmail?
Use the Gmail API's watch method with a Cloud Pub/Sub topic if you are building an app, or connect the mailbox to a service that watches it for you and posts each message to your URL. Gmail itself only notifies Pub/Sub, never an arbitrary webhook, so every other route is a service polling or watching the inbox on your behalf.
Route 1, the Gmail API with Cloud Pub/Sub
This is Google's official push mechanism. You create a Google Cloud project, enable the Gmail API, create a Pub/Sub topic, grant Gmail's service account permission to publish to it, and call users.watch for each mailbox. When the mailbox changes, Pub/Sub delivers a message to your push endpoint.
The catch is what that message contains: the email address and a historyId, not the email. Your receiver then calls users.history.list to find what changed and users.messages.get to fetch the message, then decodes the MIME parts and extracts whatever you need. Google also expires the watch, so you re-call users.watch at least every seven days (Google recommends daily). Add OAuth consent, token refresh, and verification for restricted Gmail scopes if the app is used outside your own organization.
It is the right answer for a product that connects thousands of customer mailboxes. For one operations inbox it is a small software project, and the part that takes the longest, turning a body into fields, is still yours to write.
Route 2, Google Apps Script on a timer
Apps Script runs inside Google Workspace and can read Gmail directly. A typical script searches for unread messages with a label, reads the subject and plain body, runs a few regular expressions, posts the result with UrlFetchApp.fetch, and marks the thread read. A time-driven trigger runs it every few minutes.
It costs nothing extra and it is fine for one sender with a stable template. It gets fragile when there are many senders, HTML tables, or templates that change. Apps Script also has daily quotas on runtime and URL fetches, and when the script fails at 2 a.m. nobody knows until someone asks where yesterday's orders went.
Route 3, Zapier Gmail trigger with Webhooks by Zapier
Zapier's "New Email" or "New Email Matching Search" trigger watches Gmail, and the Webhooks by Zapier action sends a POST with whatever fields you map. Setup takes minutes. Webhooks by Zapier is a premium app, so it needs a paid Zapier plan, and each email that runs through the Zap counts as tasks.
The limitation is the same as the other two routes: Zapier passes the email's fields, not the values inside the body. To get an order total or a list of products you add a parsing step, write a Formatter or Code step, or bolt on a separate parser. For more on that trade-off see our Zapier email parser alternative page.
Route 4, an email parser that posts to your webhook
An email parser inverts the order of work. It reads the mailbox, parses each message into fields first, and only then calls your URL. With MailParse you connect Gmail over IMAP (an app password on an account with 2-Step Verification), parse a sample email, and name the values your system needs, for example order_id, total and ship_to. Then you paste your https endpoint on the Mailboxes screen.
From then on each new message produces a record.parsed POST. The body carries the standard headers (from, to, cc, date, subject), the new reply text and the quoted thread as separate fields, every custom field you named, and any HTML table as a line_items array. It is the same JSON the email parser API returns, so a record you receive by webhook and one you fetch later are identical.
The trade-off is speed. Connected mailboxes sync every 15 minutes. If a few minutes of delay would hurt, forward the Gmail label to your MailParse forwarding address instead, which is checked every 5 minutes. If you need a response within seconds, a raw inbound email service that you point an MX record at is faster, and you write the parser yourself.
How do I verify the webhook came from MailParse?
Check the MailParse-Signature header on every request. It looks like t=1759140000,v1=5f2b.... Compute an HMAC-SHA256 over the timestamp, a period and the raw request body with your signing secret, compare the result to v1 in constant time, and reject requests with an old timestamp. It is the same scheme Stripe uses, so most frameworks already have a helper you can adapt.
Once the signature checks out, treat the content as untrusted anyway. Email is written by outsiders. If the parsed records go on to an AI agent that can call tools, put a guard in front of it that blocks prompt injection and enforces tool permissions, because an email body is one of the easiest places to plant instructions.
Which Gmail webhook route should I pick?
Pick by what you need at the endpoint. If you are building a product on top of other people's Gmail, use the Gmail API with Pub/Sub and budget for the parser. If you have one simple sender and time to maintain a script, Apps Script is enough. If everything already runs in Zapier and the fields you need are the subject and sender, stay there.
If the value is inside the email (the amount on an invoice notification, the line items on an order confirmation, the phone number in a lead alert) and you want it at your endpoint as a clean key without writing a parser, use an email parser. Our longer walkthrough on sending parsed email data to a webhook shows a receiver end to end, and the IMAP email parser page covers mailboxes other than Gmail.
Frequently asked questions
Does Gmail have webhooks?
No. Gmail cannot post to a webhook URL on its own. The Gmail API can publish change notifications to a Google Cloud Pub/Sub topic, and Pub/Sub can push those to an endpoint, but the notification holds only a mailbox address and a history ID. You still fetch and parse the message yourself, or use a service that does that for you.
How often does the Gmail watch need to be renewed?
A Gmail API watch expires, and Google's documentation says to call users.watch again at least every seven days, recommending once a day. If the renewal job stops, notifications stop silently, so production integrations usually renew on a schedule and alert when a mailbox has gone quiet for too long.
Can I send only some Gmail messages to a webhook?
Yes. With the Gmail API you filter by label in the watch request. In Apps Script and Zapier you use a search query. With MailParse you connect the mailbox and choose the folder or label, or create a Gmail filter that forwards only matching senders to your forwarding address, so only those messages are parsed and posted.
Can I send Gmail to a webhook as JSON?
Yes. All four routes end in a JSON POST, but the content differs. The Gmail API gives you the raw message to decode, Apps Script and Zapier give you the fields you map by hand, and an email parser gives you a structured record with named fields and table rows. Pick the one that matches what your receiver needs to store.