This topic shows how to send a few simple requests to the Cloud Billing API.

For a full list of methods, see the [REST](https://docs.cloud.google.com/billing/reference/rest) or [RPC](https://docs.cloud.google.com/billing/reference/rpc) reference documentation.

## Before you begin

## Get a list of Cloud Billing Accounts

The API method to list all Cloud Billing Accounts ([REST](https://docs.cloud.google.com/billing/reference/rest/v1/billingAccounts/list), [RPC](https://docs.cloud.google.com/billing/reference/rpc/google.cloud.billing.v1#google.cloud.billing.v1.CloudBilling.google.cloud.billing.v1.CloudBilling.ListBillingAccounts)) is the simpest method in the API, as it has no required parameters, so it's a good place to start. The method simply returns all billing accounts that you have permission to view.

## Protocol

```
GET https://cloudbilling.googleapis.com/v1/billingAccounts
```

## Java

```java
    ListBillingAccountsResponse result = service.billingAccounts().list().execute();
```

## Retrieve a particular Cloud Billing Account

To retrieve a particular billing account ([REST](https://docs.cloud.google.com/billing/reference/rest/v1/billingAccounts/get), [RPC](https://docs.cloud.google.com/billing/reference/rpc/google.cloud.billing.v1#google.cloud.billing.v1.CloudBilling.google.cloud.billing.v1.CloudBilling.GetBillingAccount)), you'll need to know the billing account ID. This example uses the sample ID `012345-567890-ABCDEF`.

## Protocol

```
GET https://cloudbilling.googleapis.com/v1/billingAccounts/012345-567890-ABCDEF
```

## Java

```java
    BillingAccount result = service.billingAccounts()
        .get("billingAccounts/00C5EA-61187E-D842F2").execute();
```

## Enable Cloud Billing on a Google Cloud project

To enable Cloud Billing on a Google Cloud project, you need to call the Cloud Billing API to
associate the Google Cloud project with an existing Cloud Billing Account
([REST](https://docs.cloud.google.com/billing/reference/rest/v1/projects/updateBillingInfo), [RPC](https://docs.cloud.google.com/billing/reference/rpc/google.cloud.billing.v1#google.cloud.billing.v1.CloudBilling.google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo)).
The following sample code associates Google Cloud project `tokyo-rain-123` with
Cloud Billing Account `012345-567890-ABCDEF`. Incidentally, the same API
method can be used to disable Cloud Billing on a Google Cloud project, by setting
`billingAccountName` to empty.

## Protocol

```
PUT https://cloudbilling.googleapis.com/v1/projects/tokyo-rain-123/billingInfo

{
  "billingAccountName": "billingAccounts/012345-567890-ABCDEF"
}
```

## Java

```
    service.projects().updateBillingInfo(
            "projects/tokyo-rain-123",
            new ProjectBillingInfo().setBillingAccountName("billingAccounts/012345-567890-ABCDEF"))
        .execute();
```

## Clean up

> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

1. In the Google Cloud console, go to the **Manage resources** page.

   [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
2. In the project list, select the project that you want to delete, and then click **Delete**.
3. In the dialog, type the project ID, and then click **Shut down** to delete the project.