> For the complete documentation index, see [llms.txt](https://docs.aurinko.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurinko.io/unified-apis/webhooks-api/configuring-pub-sub-for-gmail-api-webhooks.md).

# Configuring Pub/Sub for Gmail API Webhooks

This guide explains how to set up Google Cloud Pub/Sub (Pub/Sub) for Aurinko to receive push notifications from the Gmail API. Using Pub/Sub eliminates the need for constant polling of your Gmail inbox for updates, improving efficiency.

To get started, head over to [https://console.developers.google.com](https://console.developers.google.com/). You will be prompted to log in with a Google account if you're not already logged in with one.

Select your project, or create a new one. Refer to [this article](/authentication/google-oauth-setup.md) if creating a new project, the Gmail API needs to be enabled!

### Pub/Sub topic setup

***

1. Head over to the Pub/Sub page

<div data-full-width="true"><figure><img src="/files/w61wScyaJsA3KhAUyS6O" alt=""><figcaption></figcaption></figure></div>

2. Create a new topic. The default options will do:

<div data-full-width="true"><figure><img src="/files/LbuzVyVtY5C6N3qehpZZ" alt=""><figcaption></figcaption></figure></div>

3. Copy the topic name and enter it in your Aurinko app settings:

<div data-full-width="true"><figure><img src="/files/K1eSo5VLTFGh3Q4OaPjj" alt=""><figcaption></figcaption></figure></div>

4. Back in the Google Developer console, edit the default subscription that was created for your new topic. Make it a Push subscription with the following 'Endpoint URL': <mark style="color:red;">`https://api.aurinko.io/push/google/email/{clientId}`</mark>

<div data-full-width="true"><figure><img src="/files/bkAPT0mvID6G9bg1NBM1" alt=""><figcaption></figcaption></figure></div>

Also, change the retry policy and save:

<div data-full-width="true"><figure><img src="/files/7ZCKRmbZcioqkNXKEre2" alt=""><figcaption></figcaption></figure></div>

5. Go back to the **'Topics'** menu and click **'View permissions'** for your new topic.

<div data-full-width="true"><figure><img src="/files/rulRyX40eGBeBm4P2iUk" alt=""><figcaption></figcaption></figure></div>

6. Now, let's grant Gmail privileges to publish notifications to your topic.

Click '**ADD PRINCIPLE'** and grant publish privileges to <mark style="color:red;">`gmail-api-push@system.gserviceaccount.com`</mark>:

<div data-full-width="true"><figure><img src="/files/c8zOkblKBIFnvyxbJHvh" alt=""><figcaption></figcaption></figure></div>

**You are done!**
