Skip to content
Start here

Get PayGo Account Billable Usage Info (Version 1, Alpha)

client.Billing.Usage.PaygoInfo(ctx, query) (*UsagePaygoInfoResponse, error)
GET/accounts/{account_id}/paygo-usage-info

Returns high-level usage information for the account, including coverage, and subscription metadata.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Billing Read
ParametersExpand Collapse
query UsagePaygoInfoParams
AccountID param.Field[string]

Represents a Cloudflare resource identifier tag.

maxLength32
ReturnsExpand Collapse
type UsagePaygoInfoResponse struct{…}

Contains the paygo usage info.

Covered bool

Indicates whether the account is covered.

Subscriptions []UsagePaygoInfoResponseSubscription

List of subscriptions for the account.

ID string

The identifier for the Cloudflare subscription.

BillingCycleAnchorTimestamp Time

The subscription billing cycle anchor timestamp.

formatdate-time
StartTimestamp Time

The subscription start timestamp.

formatdate-time
EndTimestamp TimeOptional

The subscription end timestamp. Omitted for active subscriptions; present only when the subscription has been cancelled.

formatdate-time

Get PayGo Account Billable Usage Info (Version 1, Alpha)

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/billing"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.Billing.Usage.PaygoInfo(context.TODO(), billing.UsagePaygoInfoParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Covered)
}
{
  "errors": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "messages": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "result": {
    "covered": true,
    "subscriptions": [
      {
        "id": "3F3CD4CQ6N7FXO7IK6NVFJBOYA",
        "billing_cycle_anchor_timestamp": "2023-01-01T00:00:00Z",
        "start_timestamp": "2023-01-01T00:00:00Z",
        "end_timestamp": "2023-12-31T23:59:59Z"
      }
    ]
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "messages": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "result": {
    "covered": true,
    "subscriptions": [
      {
        "id": "3F3CD4CQ6N7FXO7IK6NVFJBOYA",
        "billing_cycle_anchor_timestamp": "2023-01-01T00:00:00Z",
        "start_timestamp": "2023-01-01T00:00:00Z",
        "end_timestamp": "2023-12-31T23:59:59Z"
      }
    ]
  },
  "success": true
}