Purchase a spend-based commitment

You can purchase offers by using the Cloud Commerce Consumer Procurement API, an API for making Cloud Marketplace purchases.

Today, only spend-based commitments for selected products can be purchased via the API. This how-to describes how to purchase a spend-based commitment.

Before you begin

Identify the Offer you want to purchase

To purchase a spend-based commitment, you use an Offer name which indicates the product you're purchasing and the discount term.

The following Offers are available for purchase:

Product Term Offer name
AlloyDB for PostgreSQL 1 year services/alloydb.googleapis.com/standardOffers/adbca020-a973-48c9-b9b6-f5d70527790c
AlloyDB for PostgreSQL 3 years services/alloydb.googleapis.com/standardOffers/56e5948f-f1ed-45ce-84d6-a8408092e7d5
Backup for GKE 1 year services/gkebackup.googleapis.com/standardOffers/89852607-f073-4696-94cc-de7ed85f27c7
Backup for GKE 3 years services/gkebackup.googleapis.com/standardOffers/25d2877b-2868-4312-b54e-880896a119c5
Backup and DR 1 year services/backupdr.googleapis.com/standardOffers/30c7e770-724f-4a7d-8369-b726a397b53a
Backup and DR 3 years services/backupdr.googleapis.com/standardOffers/6748e93c-4114-4fa2-bf3e-cb4d3534bb48
Bigtable 1 year services/bigtable.googleapis.com/standardOffers/5a0a5567-1552-445e-9f1b-f1ac69fb0f39
Bigtable 3 years services/bigtable.googleapis.com/standardOffers/26e8485e-acef-4e73-9a13-f0b2109befff
Cloud Run 1 year services/run.googleapis.com/standardOffers/55435965-baf5-485f-baea-3fde53566e5e
Cloud Run 3 years services/run.googleapis.com/standardOffers/a8b22b6c-2992-48d3-9b73-98fc7a47d61c
Compute Engine flexible commitment 1 year services/compute.googleapis.com/standardOffers/ffe0f6a3-2f98-437e-8d49-fc443a05d3c2
Compute Engine flexible commitment 3 years services/compute.googleapis.com/standardOffers/062a285d-8989-4ce7-8f9a-bed8d183236f
Google Kubernetes Engine 1 year services/container.googleapis.com/standardOffers/ae2672e6-47a8-41dc-9448-6956d7f4fbc1
Google Kubernetes Engine 3 years services/container.googleapis.com/standardOffers/fcf378c1-fbe0-4aaa-b05e-9597f8b45578
Dataflow 1 year services/dataflow.googleapis.com/standardOffers/42ae4415-0361-404f-8bc5-1e7c041c2d82
Dataflow 3 years services/dataflow.googleapis.com/standardOffers/cac998b8-3d49-4672-ae5b-e5b3c56e05f2
Managed Service for Apache Kafka 1 year services/managedkafka.googleapis.com/standardOffers/e1636f7d-1a29-4d53-a89e-c1f60e8dadcf
Managed Service for Apache Kafka 3 years services/managedkafka.googleapis.com/standardOffers/31d79333-0c0e-4208-9b20-c6e4f27e5d1d
Memorystore 1 year services/redis.googleapis.com/standardOffers/fe93270a-f338-4a76-b303-c323608a9d37
Memorystore 3 years services/redis.googleapis.com/standardOffers/8f20579e-7630-4592-8fa6-0d7d3b749354
NetApp Volumes 1 year services/netapp.googleapis.com/standardOffers/90520cfa-14b6-42ae-92b9-129671bf2aca
NetApp Volumes 3 years services/netapp.googleapis.com/standardOffers/c852fef8-e699-4524-90f4-e7b89edeb33c
Spanner 1 year services/spanner.googleapis.com/standardOffers/29829e5f-681c-4810-a471-8e4611a8042b
Spanner 3 years services/spanner.googleapis.com/standardOffers/709f6c69-8a49-4032-97f7-ce21fe340603
Cloud SQL 1 year services/cloudsql.googleapis.com/standardOffers/266e6a8c-2a0d-4b92-af9c-5795760f1fc9
Cloud SQL 3 years services/cloudsql.googleapis.com/standardOffers/4998bf0a-51dd-4ce0-8405-aa529dd86d33

Identify the Offer parameters

Commitments have two parameters:

  • Commitment amount (hourly_commit): The credit applied to your Cloud Billing account each hour after you purchase this commitment.
  • Region (region): The region for which this commitment's credits apply.

When you purchase a commitment, you must specify both parameters.

Purchase the Offer

To purchase an Offer, call billingAccounts.orders.place, and supply the following parameters:

  • The hourly_commit indicating the dollar value of the commitment.

  • The region to purchase the commitment for.

To place an order, run the following command:

curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/billingAccounts/BILLING_ACCOUNT_ID/orders:place' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer ACCESS_TOKEN' \
    --header 'X-Goog-User-Project: CONSUMER_PROJECT_ID' \
    -d '@-' <<EOF
    {
    "displayName": "DISPLAY_NAME",
    "lineItemInfo": [{
        "parameters": [{
        "name": "hourly_commit",
        "value": {
            "doubleValue": HOURLY_COMMIT
        }
        }, {
        "name": "region",
        "value": {
            "stringValue": "REGION"
        }
        }],
        "offer": "OFFER_NAME"
    }]
    }
EOF

This returns the name of a long-running operation:

{
    "name": "OPERATION_NAME"
}

To verify that the returned long-running operation completed successfully, run the following command:

curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/OPERATION_NAME' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer ACCESS_TOKEN' \
    --header 'X-Goog-User-Project: CONSUMER_PROJECT_ID'

The long-running operation should complete in less than one second.

View your Order

You can view the current state of a commitment directly in Google Cloud console, or by calling billingAccounts.orders.get. The name field of the created Order specifies the Order name.

cURL

To view an order, run the following command:

curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/ORDER_NAME' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer ACCESS_TOKEN' \
    --header 'X-Goog-User-Project: CONSUMER_PROJECT_ID'

Console

  1. Navigate to https://console.cloud.google.com/billing.
  2. Select your Cloud Billing account.
  3. Select Commitments from the sidebar.
  4. Your purchased commitment is visible in the displayed table.