This guide covers the Google Cloud Pub/Sub configuration needed for real-time inbox sync when using Private Infrastructure (OAuth) for Gmail. This is a one-time setup inside your own GCP project. Smartlead handles everything else from there.
You'll create two Pub/Sub topics and two subscriptions in your own Google Cloud project:
Resource | Name | Purpose |
Topic |
| Main topic — Gmail publishes change notifications here |
Topic |
| Dead-letter topic — failed deliveries land here |
Subscription |
| Push subscription → Smartlead's webhook endpoint |
Subscription |
| Pull subscription on the DLQ for inspection/replay |
Replace <customer-id> with the unique ID Smartlead gives you during onboarding. It keeps your resources identifiable and distinct from every other customer's setup.
Your Smartlead onboarding team will provide three values:
Placeholder | Example | Where You Use It |
| 47291 | In every topic/subscription name, and in the push URL (customer=) |
| 8 | In the push endpoint URL (region=) |
| (issued separately) | In the push endpoint URL (secret=) |
Final push endpoint (used in Step 5):
https://prod.slrealtime.com/api/v1/webhooks/gmail/resourceNotifications?region=<region-code>&secret=<secret>&customer=<customer-id>A Google Cloud project with billing enabled.
An account with Pub/Sub Admin (or Owner/Editor) role on that project.
Your customer-id, region-code, and secret from Smartlead.
The same Google account used to log into Gmail must own the project, or have Pub/Sub Editor on it — Google enforces this when notifications are enabled on the mailbox.
Open Google Cloud Console at console.cloud.google.com.
Select your project from the project picker.
Go to APIs & Services → Library.
Search Cloud Pub/Sub API, click it, then click Enable.
Go to Pub/Sub → Topics → Create topic.
Fill in: Topic ID: smartlead-gmail-pubsub-<customer-id>; Encryption: Google-managed encryption key (default); Add a default subscription: uncheck (you'll create subscriptions manually in Step 5); Schema: none; Message retention: leave default.
Click Create.
Repeat Step 2 with one change: Topic ID: smartlead-gmail-pubsub-<customer-id>-dlq.
Pub/Sub retries failed pushes with exponential backoff. After 5 failed attempts, a message is dead-lettered here instead of lost, so it can be inspected or replayed later.
Gmail publishes notifications via a Google-managed service account. Grant it Pub/Sub Publisher on the main topic only — not the DLQ.
Pub/Sub → Topics → click your main topic.
Open the info panel → Permissions tab → Add principal.
Fill in: New principals: [email protected]; Role: Pub/Sub Publisher.
Click Save.
⚠ Important: do not add this on the DLQ topic — only Pub/Sub itself writes there.
Pub/Sub → Subscriptions → Create subscription.
Field | Value |
Subscription ID |
|
Cloud Pub/Sub topic | your main topic (not the DLQ) |
Delivery type | Push |
Endpoint URL |
|
Enable authentication | Off |
Enable payload unwrapping | Off |
Subscription expiration | Never expire |
Acknowledgement deadline | 10 seconds |
Message retention duration | 1 day |
Retain acknowledged messages | Off |
Exactly once delivery | Off |
Message ordering | Off |
Expand Dead lettering and enable it:
Field | Value |
Dead-letter topic | your -dlq topic |
Maximum delivery attempts | 5 |
Expand Retry policy:
Field | Value |
Retry policy | Retry after exponential backoff delay |
Minimum backoff | 10 seconds |
Maximum backoff | 600 seconds |
Click Create.
ℹ When you enable dead-lettering, Google Cloud will prompt you to auto-grant the Pub/Sub service account Pub/Sub Publisher on the DLQ topic and Pub/Sub Subscriber on this subscription. Click Grant if prompted.
Pub/Sub → Subscriptions → Create subscription.
Field | Value |
Subscription ID |
|
Cloud Pub/Sub topic | your -dlq topic (not the main topic) |
Delivery type | Pull |
Subscription expiration | Never expire |
Acknowledgement deadline | 10 seconds |
Message retention duration | 7 days |
Retain acknowledged messages | Off |
Exactly once delivery | Off |
Message ordering | Off |
Dead lettering | Off |
Retry policy | Retry immediately |
Click Create.
Before notifying Smartlead you're ready, confirm:
Both topics exist (main and -dlq).
Main topic has Pub/Sub Publisher for [email protected].
Main subscription is Push, points to the main topic, endpoint URL has your correct region/secret/customer values, dead-letter topic is the -dlq topic, max delivery attempts = 5.
DLQ subscription is Pull, points to the -dlq topic, retention = 7 days.
Then share with Smartlead onboarding: your GCP project ID, your customer-id, the Gmail account email being connected, and confirmation you used the assigned values in the push URL.
Symptom | Likely Cause | Fix |
"Topic not found" during onboarding | Topic name mismatch or wrong project | Double-check topic ID and project ID |
"User not authorized" during onboarding | Gmail service account missing Pub/Sub Publisher on main topic | Re-add [email protected] as Publisher |
"Unacked messages" keeps climbing | Smartlead's endpoint is rejecting pushes | Confirm customer-id, region-code, secret in the push URL exactly match what Smartlead gave you |
Messages landing in the DLQ | Pushes failed 5x in a row | Inspect via DLQ subscription → Messages → Pull, and share the messageId with Smartlead support |
"Push permission denied" warning | Pub/Sub service account missing publisher rights on DLQ | Re-toggle Dead lettering on the main subscription and accept the auto-grant banner |
MAIN TOPIC: smartlead-gmail-pubsub-<customer-id>
DLQ TOPIC: smartlead-gmail-pubsub-<customer-id>-dlq
MAIN SUB: smartlead-gmail-pubsub-<customer-id>-sub (Push)
DLQ SUB: smartlead-gmail-pubsub-<customer-id>-dlq-sub (Pull)
GMAIL PUBLISHER: [email protected] (main topic only)