Skip to content
Start here

Delete Spend Policy

client.Billing.SpendPolicies.Delete(ctx, policyID, params) (*SpendPolicyDeleteResponse, error)
DELETE/accounts/{account_id}/billing/spend-policies/{policy_id}

Soft-deletes the spend policy. The policy is disabled and no longer appears in list, get or audit responses. The If-Match header must equal the policy’s current version.

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
ParametersExpand Collapse
policyID string

The unique identifier of the spend policy.

formatuuid
params SpendPolicyDeleteParams
AccountID param.Field[string]

Path param: Represents a Cloudflare resource identifier tag.

maxLength32
IfMatch param.Field[string]

Header param: The policy version the change is based on, as returned in ETag. Quoted ("3") and bare (3) values are both accepted. Weak ETags (W/"3") and * are not.

ReturnsExpand Collapse
type SpendPolicyDeleteResponse struct{…}
ID string

The unique identifier of the spend policy.

formatuuid

Delete Spend Policy

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"),
  )
  spendPolicy, err := client.Billing.SpendPolicies.Delete(
    context.TODO(),
    "6f1c2b8e-3d4a-4f5b-9c6d-7e8f9a0b1c2d",
    billing.SpendPolicyDeleteParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      IfMatch: cloudflare.F(`"3"`),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", spendPolicy.ID)
}
{
  "errors": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "messages": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "result": {
    "id": "6f1c2b8e-3d4a-4f5b-9c6d-7e8f9a0b1c2d"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "messages": [
    {
      "message": "message",
      "code": 0
    }
  ],
  "result": {
    "id": "6f1c2b8e-3d4a-4f5b-9c6d-7e8f9a0b1c2d"
  },
  "success": true
}