Connect source to your GCP project

Connects a Google Cloud project to an existing gcp source, so we can discover metrics, manage log sinks, and enrich your Google Cloud resources.

This is the API equivalent of the Connect your GCP project step in the source's Ingest tab.

Create the source first with Create a source and "platform": "gcp", deploy the Google Cloud components as described in Google Cloud, then send the project ID and project number back with the request below.

Where do the project ID and number come from?

Both are produced by the Better Stack setup script and by the Terraform module, which output project_id and project_number. In the Google Cloud console you find them on the project's dashboard, or with gcloud projects describe PROJECT_ID.

PATCH https://telemetry.betterstack.com/api/v1/sources/{source_id}

URL parameters

id
required string

Headers

Authorization
required string

Body parameters

gcp_project_id
string
gcp_project_number
string
gcp_account_id
string
200

Response body

{
  "data": {
    "id": "96",
    "type": "source",
    "attributes": {
      "source_group_id": 573,
      "team_id": 123,
      "team_name": "Test team",
      "name": "GCP production",
      "platform": "gcp",
      "table_name": "gcp_production",
      "token": "FczKcxEhjEDE58dBX7XaeX1q",
      "ingesting_paused": false,
      "ingesting_host": "s96.eu-nbg-2.betterstackdata.com",
      "created_at": "2026-05-27T12:30:41.695Z",
      "updated_at": "2026-06-11T14:00:50.756Z",
      "logs_retention": 7,
      "metrics_retention": 14,
      "data_region": "eu-nbg-2"
    }
  }
}
404

Response body

{
  "errors": "Resource with provided ID was not found"
}
422

Response body

{
  "errors": "Both Project ID and Project Number are required.",
  "invalid_attributes": []
}
422

Response body

{
  "errors": "GCP credentials validation failed: Permission denied on resource project my-gcp-project.",
  "invalid_attributes": []
}

Example cURL

Connect a Google Cloud project
curl --request PATCH \
  --url https://telemetry.betterstack.com/api/v1/sources/96 \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "gcp_project_id": "my-gcp-project",
    "gcp_project_number": "587153488274"
  }'


Metric discovery starts right after the project is connected. Available metrics appear in the source's Ingest tab within a few minutes.

Getting a validation error?

Better Stack authenticates through Workload Identity Federation configured by the setup script or the Terraform module. Re-run it against the project if validation fails, and check that the project number matches the project ID.