GCP Pub/Sub

Publish events to a Google Cloud Pub/Sub topic.

Creating a Pub/Sub Destination

curl 'https://api.outpost.hookdeck.com/2025-07-01/tenants/<TENANT_ID>/destinations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_KEY>' \
--data '{
  "type": "gcp_pubsub",
  "topics": ["orders"],
  "config": {
    "project_id": "my-gcp-project",
    "topic": "my-pubsub-topic"
  },
  "credentials": {
    "service_account_json": "{\"type\": \"service_account\", ...}"
  }
}'

Configuration

Config

FieldTypeRequiredDescription
config.project_idstringYesGCP project ID
config.topicstringYesPub/Sub topic name
config.endpointstringNoCustom endpoint for the Pub/Sub emulator

Credentials

FieldTypeRequiredDescription
credentials.service_account_jsonstringYes*Service account JSON key file contents

*Not required when using the Pub/Sub emulator.

Message Format

Events are published as Pub/Sub messages:

  • Data: The event's data field as JSON
  • Attributes: System metadata (event-id, topic, timestamp) plus any event metadata from the published event

Example

Publishing this event:

{
  "topic": "orders",
  "data": { "order_id": "123", "status": "created" },
  "metadata": { "source": "checkout-service" }
}

Results in a Pub/Sub message with:

Data:

{"order_id": "123", "status": "created"}

Attributes:

AttributeValue
event-idevt_123
topicorders
timestamp1704067200
sourcecheckout-service

Creating a Service Account

  1. In the GCP Console, navigate to IAM & Admin > Service Accounts
  2. Click Create Service Account
  3. Grant the Pub/Sub Publisher role (roles/pubsub.publisher)
  4. Create a JSON key and download it
  5. Use the JSON file contents as credentials.service_account_json

Local Development with the Pub/Sub Emulator

{
  "type": "gcp_pubsub",
  "topics": ["orders"],
  "config": {
    "project_id": "test-project",
    "topic": "test-topic",
    "endpoint": "localhost:8085"
  }
}

When using the emulator, service_account_json is not required.