---
title: "How to Send Webhooks to Google Cloud Pub/Sub | WebhookRelay"
meta:
  "og:description": "Publish incoming webhooks straight to a Google Cloud Pub/Sub topic with Webhook Relay Service Connections — no Cloud Function to write. Build event-driven pipelines from any webhook."
  "og:title": "How to Send Webhooks to Google Cloud Pub/Sub"
  description: "Publish incoming webhooks straight to a Google Cloud Pub/Sub topic with Webhook Relay Service Connections — no Cloud Function to write. Build event-driven pipelines from any webhook."
---

![Stripes](https://webhookrelay.com/blog/webhook-to-pubsub/images/stripes.svg)

# **How to Send Webhooks to Google Cloud Pub/Sub**

Publish incoming webhooks straight to a Google Cloud Pub/Sub topic with Webhook Relay Service Connections — no Cloud Function to write. Build event-driven pipelines from any webhook.

![How to Send Webhooks to Google Cloud Pub/Sub](https://webhookrelay.com/blog/webhook-to-pubsub/images/blog/heroes/route.jpg)

[Google Cloud Pub/Sub](https://cloud.google.com/pubsub) is the backbone of a lot of event-driven systems on GCP — publish a message, and any number of subscribers (Cloud Functions, Dataflow, BigQuery, your own services) react to it. The friction is getting an external **webhook** onto a topic in the first place, which usually means writing a Cloud Function just to call `publish`. Webhook Relay [Service Connections](https://webhookrelay.com/blog/webhook-to-pubsub/blog/introducing_service_connections/) let webhooks publish to Pub/Sub directly.

## [How it works](#how-it-works)

Webhook Relay has **service connections** (your cloud credentials) and **outputs** (where to send data). Attach a Pub/Sub output to a bucket, and every webhook that arrives is published to your topic:

```
Provider --> Webhook Relay bucket --> Pub/Sub output --> your topic --> subscribers
```

No HTTP-triggered Cloud Function in the middle. Your existing subscribers do the work.

## [1. Create a GCP service connection](#_1-create-a-gcp-service-connection)

Create a service account in your GCP project, grant it the **Pub/Sub Publisher** role (`roles/pubsub.publisher`) on the target topic, and create a JSON key. In Webhook Relay, add a **service connection** for GCP with your project ID and the full JSON key contents. The key is encrypted at rest and never returned in full by the API.

## [2. Create the topic and attach a Pub/Sub output](#_2-create-the-topic-and-attach-a-pubsub-output)

Make sure the topic exists (Webhook Relay publishes to it but doesn't create it):

```
gcloud pubsub topics create webhooks
```

Then add a **Pub/Sub output** to your bucket with the topic name (`webhooks`). From now on, every webhook delivered to the bucket is published to that topic, with the request body as the message data and headers carried as attributes.

## [3. Point your provider at the bucket URL](#_3-point-your-provider-at-the-bucket-url)

Use the bucket's public Webhook Relay endpoint as the webhook URL in your provider, and test it:

```
curl -X POST https://your-webhook-relay-endpoint \
  -H 'Content-Type: application/json' \
  -d '{"event":"build.finished","status":"success"}'
```

A message lands on your Pub/Sub topic, and your subscribers fire.

## [Why publish webhooks to Pub/Sub](#why-publish-webhooks-to-pubsub)

- **Decouple producers from consumers.** Webhooks become events many services can subscribe to independently.
- **Scale and buffer.** Pub/Sub absorbs spikes and delivers at the rate your subscribers can handle.
- **Fan-out on GCP.** One webhook → many subscribers (a Cloud Function, a BigQuery pipeline, an alerting service).

## [Going further](#going-further)

- Add a [transformation](https://webhookrelay.com/blog/webhook-to-pubsub/features/transform-webhooks/) to reshape the payload before publishing.
- [Filter](https://webhookrelay.com/blog/webhook-to-pubsub/features/forwarding-rules/) so only relevant events are published.
- Deliver to [multiple destinations](https://webhookrelay.com/blog/webhook-to-pubsub/features/webhook-multiple-destinations/) at once.
- On AWS instead? See [sending webhooks to SQS](https://webhookrelay.com/blog/webhook-to-pubsub/blog/webhook-to-sqs/).

[Inspect a webhook first](https://webhookrelay.com/blog/webhook-to-pubsub/webhook-bin/) or [create a free account](https://my.webhookrelay.com/register) to set up the Pub/Sub output.