> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/gcp-billing.md).

# GCP Billing

Read Google Cloud spend, billing accounts, linked projects and budgets. Actual cost comes from the BigQuery billing export, broken down by service, SKU, project or label, with credits reported separately.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector   | Authentication |
| ----------- | -------------- |
| GCP Billing | Credentials    |

#### GCP Billing

Read Google Cloud billing accounts, budgets and actual spend. Spend comes from the BigQuery billing export, so the service account needs both billing and BigQuery read access.

**Set up in GCP Billing**

1. Prepare the GCP Billing account or service that the workflow will access. Grant access to the required resources and operations.
2. Obtain the account, endpoint, and authentication values listed below from the service administrator.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **GCP Billing**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field                     | Required                 | What to enter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| --------------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Project ID                        | Yes                      | The Google Cloud project that runs the BigQuery queries and is billed for the bytes they scan. This is usually the project holding the billing export dataset.                                                                                                                                                                                                                                                                                                                               |
| Service Account JSON              | Yes                      | JSON key for a service account with read-only billing access. Grant roles/billing.viewer on the billing account, plus roles/bigquery.dataViewer on the export dataset and roles/bigquery.jobUser on the project that runs the query. Both halves are needed: the Cloud Billing API returns account metadata and catalog prices, while actual spend is only in the BigQuery billing export. [Provider instructions](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-setup). |
| Billing Export Dataset (Optional) | Optional / as applicable | The BigQuery dataset holding the billing export, such as 'billing\_export'. Setting it here lets the cost actions offer the export tables as a dropdown instead of asking for a full table name.                                                                                                                                                                                                                                                                                             |

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **GCP Billing** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Get Cost

Read Google Cloud spend for a date range, broken down by service, SKU, project or label, with credits shown separately.

**Inputs**

| Field                | Type            | Required | Description                                                                                                                                                                      |
| -------------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Billing Export Table | select (string) | Yes      | The BigQuery table holding your billing export. Set the export dataset on the connection to pick it from a list instead of typing it. Options load from the selected connection. |
| Date Range           | select (string) | No       | Pick a preset window, or choose 'custom' and set Start Date and End Date. Options load from the selected connection. Default: month\_to\_date.                                   |
| Start Date           | string          | No       | First day to include (YYYY-MM-DD). Needed for 'custom'.                                                                                                                          |
| End Date             | string          | No       | Last day to include (YYYY-MM-DD). This day is included. Needed for 'custom'.                                                                                                     |
| Granularity          | select (string) | No       | Size of each time bucket. NONE returns one total per group. Options load from the selected connection. Default: DAILY.                                                           |
| Group By             | select (string) | No       | Break the spend down by service, SKU, project or a label. Choose 'none' for totals only. Options load from the selected connection. Default: none.                               |
| Label Key            | string          | No       | Which label to group by. Required when Group By is 'label'.                                                                                                                      |
| Row Limit            | integer         | No       | How many result rows to return.                                                                                                                                                  |

**Outputs**

| Field           | Type    | Description                                                  |
| --------------- | ------- | ------------------------------------------------------------ |
| Rows            | array   | Spend per bucket and group, with credits applied separately. |
| Total Cost      | number  | Spend before credits, summed across every row.               |
| Total Credits   | number  | Credits applied across every row, as a negative adjustment.  |
| Total Net Cost  | number  | Spend after credits, measured by usage time.                 |
| Group Count     | number  | How many groups the period contains.                         |
| Truncated       | boolean | True when the row limit cut the detail rows short.           |
| Currency        | string  | Currency of the amounts, as recorded in the export.          |
| Bytes Processed | number  | Bytes BigQuery scanned, which is what this query costs you.  |

#### List Billing Export Tables

Find the BigQuery tables holding your Google Cloud billing export, labelled by export type and billing account.

**Inputs**

| Field   | Type   | Required | Description                                                                         |
| ------- | ------ | -------- | ----------------------------------------------------------------------------------- |
| Dataset | string | No       | The BigQuery dataset holding the export. Defaults to the one set on the connection. |

**Outputs**

| Field       | Type    | Description                                            |
| ----------- | ------- | ------------------------------------------------------ |
| Tables      | array   | Billing export tables found in the dataset.            |
| Total Count | number  | Number of export tables found.                         |
| Truncated   | boolean | True when more export tables exist than were returned. |

#### List Billing Accounts

List the Google Cloud billing accounts your service account can read.

**Inputs**

| Field | Type    | Required | Description                                                                     |
| ----- | ------- | -------- | ------------------------------------------------------------------------------- |
| Limit | integer | No       | Maximum records to return (1-1000). Defaults to 200. Minimum: 1. Maximum: 1000. |

**Outputs**

| Field       | Type    | Description                                       |
| ----------- | ------- | ------------------------------------------------- |
| Accounts    | array   | Billing accounts the service account can see.     |
| Total Count | number  | Number of accounts returned.                      |
| Truncated   | boolean | True when more entries remain than were returned. |

#### List Budgets

List the budgets set on a Google Cloud billing account, with their limits and alert thresholds.

**Inputs**

| Field           | Type            | Required | Description                                                                         |
| --------------- | --------------- | -------- | ----------------------------------------------------------------------------------- |
| Billing Account | select (string) | Yes      | Which billing account's budgets to list. Options load from the selected connection. |
| Limit           | integer         | No       | Maximum records to return (1-1000). Defaults to 200. Minimum: 1. Maximum: 1000.     |

**Outputs**

| Field       | Type    | Description                                                       |
| ----------- | ------- | ----------------------------------------------------------------- |
| Budgets     | array   | Budgets on the billing account, with their limits and thresholds. |
| Total Count | number  | Number of budgets returned.                                       |
| Truncated   | boolean | True when more entries remain than were returned.                 |

#### List Project Billing Info

List which Google Cloud projects are billed to an account, and whether billing is enabled for each.

**Inputs**

| Field           | Type            | Required | Description                                                                          |
| --------------- | --------------- | -------- | ------------------------------------------------------------------------------------ |
| Billing Account | select (string) | Yes      | Which billing account's projects to list. Options load from the selected connection. |
| Limit           | integer         | No       | Maximum records to return (1-1000). Defaults to 200. Minimum: 1. Maximum: 1000.      |

**Outputs**

| Field                 | Type    | Description                                       |
| --------------------- | ------- | ------------------------------------------------- |
| Projects              | array   | Projects linked to the billing account.           |
| Billing Enabled Count | number  | How many of the projects have billing enabled.    |
| Total Count           | number  | Number of projects returned.                      |
| Truncated             | boolean | True when more entries remain than were returned. |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/gcp-billing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
