> ## Documentation Index
> Fetch the complete documentation index at: https://ampersand-24eb5c1a-rajatspawar-eng-4130-outpost-queues-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Cloud Pub/Sub destinations

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={null}
specVersion: 1.0.0
integrations:
  - name: salesforceToPubSub
    displayName: Salesforce to Pub/Sub
    provider: salesforce
    read:
      objects:
        - objectName: account
          destination: ampersandPubSub
        - objectName: contact
          destination: ampersandPubSub
```
