> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ampersand.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Cloud Pub/Sub destinations

> Publish Read and Subscribe Action payloads as JSON to a Google Cloud Pub/Sub topic using a project ID, topic ID, and a Pub/Sub Publisher service account.

For more information on destinations, see the [Destinations](/destinations) page.

When new data is read from a SaaS instance via a [Read Action](/read-actions) or [Subscribe Action](/subscribe-actions), Ampersand publishes the payload as messages to your Google Cloud Pub/Sub topic.

## Prerequisites

Before setting up a Pub/Sub destination, ensure that you have:

* A Google Cloud project with a Pub/Sub topic
* A service account with the `Pub/Sub Publisher` role (or `pubsub.topics.publish` permission) on that topic, and a JSON key for it

## Data format

Ampersand publishes each read or subscribe message to your topic as JSON. The full payload schema is defined in [webhook.yaml](https://github.com/amp-labs/openapi/blob/main/webhook/webhook.yaml).

## Create a Pub/Sub destination

Go to the [Destinations page](https://dashboard.withampersand.com/projects/_/destinations) in the Ampersand Dashboard and create a new Pub/Sub destination.

You'll need to provide:

| Field | Type | Required | Example | Description |
| - | - | - | - | - |
| **Destination name** | string | Yes | `ampersandPubSub` | Alias to reference in your `amp.yaml` file |
| **Project ID** | string | Yes | `my-gcp-project` | Google Cloud project ID |
| **Topic ID** | string | Yes | `ampersand-events` | Pub/Sub topic ID |
| **Service account credentials** | string | Yes | | Service account key JSON with publish access to the topic |

## Refer to the destination in your integration

After creating your Pub/Sub destination, reference it in your `amp.yaml` file:

```yaml theme={"dark"}
specVersion: 1.0.0
integrations:
  - name: salesforceToPubSub
    displayName: Salesforce to Pub/Sub
    provider: salesforce
    read:
      objects:
        - objectName: account
          destination: ampersandPubSub
        - objectName: contact
          destination: ampersandPubSub
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.