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
| Field | Type | Required | Description |
|---|---|---|---|
config.project_id | string | Yes | GCP project ID |
config.topic | string | Yes | Pub/Sub topic name |
config.endpoint | string | No | Custom endpoint for the Pub/Sub emulator |
Credentials
| Field | Type | Required | Description |
|---|---|---|---|
credentials.service_account_json | string | Yes* | 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
datafield 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:
| Attribute | Value |
|---|---|
event-id | evt_123 |
topic | orders |
timestamp | 1704067200 |
source | checkout-service |
Creating a Service Account
- In the GCP Console, navigate to IAM & Admin > Service Accounts
- Click Create Service Account
- Grant the Pub/Sub Publisher role (
roles/pubsub.publisher) - Create a JSON key and download it
- 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.