Skip to content
Start here

Update Zone Subscription

client.Zones.Subscriptions.Update(ctx, params) (*SubscriptionUpdateResponse, error)
PUT/zones/{zone_id}/subscription

Updates zone subscriptions, either plan or add-ons.

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 Write
ParametersExpand Collapse
params SubscriptionUpdateParams
ZoneID param.Field[string]

Path param: Identifier

maxLength32
Subscription param.Field[Subscription]

Body param

ReturnsExpand Collapse
type SubscriptionUpdateResponse struct{…}
ID stringoptional

Subscription identifier tag.

maxLength32
Currency stringoptional

The monetary unit in which pricing information is displayed.

CurrentPeriodEnd Timeoptional

The end of the current period and also when the next billing is due.

formatdate-time
CurrentPeriodStart Timeoptional

When the current billing period started. May match initial_period_start if this is the first period.

formatdate-time
Frequency SubscriptionUpdateResponseFrequencyoptional

How often the subscription is renewed automatically.

One of the following:
const SubscriptionUpdateResponseFrequencyWeekly SubscriptionUpdateResponseFrequency = "weekly"
const SubscriptionUpdateResponseFrequencyMonthly SubscriptionUpdateResponseFrequency = "monthly"
const SubscriptionUpdateResponseFrequencyQuarterly SubscriptionUpdateResponseFrequency = "quarterly"
const SubscriptionUpdateResponseFrequencyYearly SubscriptionUpdateResponseFrequency = "yearly"
const SubscriptionUpdateResponseFrequencyNotApplicable SubscriptionUpdateResponseFrequency = "not-applicable"
Price float64optional

The price of the subscription that will be billed, in US dollars.

RatePlan RatePlanoptional

The rate plan applied to the subscription.

ID RatePlanIDoptional

The ID of the rate plan.

One of the following:
const RatePlanIDFree RatePlanID = "free"
const RatePlanIDLite RatePlanID = "lite"
const RatePlanIDPro RatePlanID = "pro"
const RatePlanIDProPlus RatePlanID = "pro_plus"
const RatePlanIDBusiness RatePlanID = "business"
const RatePlanIDEnterprise RatePlanID = "enterprise"
const RatePlanIDPartnersFree RatePlanID = "partners_free"
const RatePlanIDPartnersPro RatePlanID = "partners_pro"
const RatePlanIDPartnersBusiness RatePlanID = "partners_business"
const RatePlanIDPartnersEnterprise RatePlanID = "partners_enterprise"
Currency stringoptional

The currency applied to the rate plan subscription.

ExternallyManaged booloptional

Whether this rate plan is managed externally from Cloudflare.

IsContract booloptional

Whether a rate plan is enterprise-based (or newly adopted term contract).

PublicName stringoptional

The full name of the rate plan.

Scope stringoptional

The scope that this rate plan applies to.

Sets []stringoptional

The list of sets this rate plan applies to. Returns array of strings.

State SubscriptionUpdateResponseStateoptional

The state that the subscription is in.

One of the following:
const SubscriptionUpdateResponseStateTrial SubscriptionUpdateResponseState = "Trial"
const SubscriptionUpdateResponseStateProvisioned SubscriptionUpdateResponseState = "Provisioned"
const SubscriptionUpdateResponseStatePaid SubscriptionUpdateResponseState = "Paid"
const SubscriptionUpdateResponseStateAwaitingPayment SubscriptionUpdateResponseState = "AwaitingPayment"
const SubscriptionUpdateResponseStateCancelled SubscriptionUpdateResponseState = "Cancelled"
const SubscriptionUpdateResponseStateFailed SubscriptionUpdateResponseState = "Failed"
const SubscriptionUpdateResponseStateExpired SubscriptionUpdateResponseState = "Expired"

Update Zone Subscription

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/shared"
  "github.com/cloudflare/cloudflare-go/zones"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  subscription, err := client.Zones.Subscriptions.Update(context.TODO(), zones.SubscriptionUpdateParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Subscription: shared.SubscriptionParam{

    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", subscription.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "506e3185e9c882d175a2d0cb0093d9f2",
    "currency": "USD",
    "current_period_end": "2014-03-31T12:20:00Z",
    "current_period_start": "2014-05-11T12:20:00Z",
    "frequency": "monthly",
    "price": 20,
    "rate_plan": {
      "id": "free",
      "currency": "USD",
      "externally_managed": false,
      "is_contract": false,
      "public_name": "Business Plan",
      "scope": "zone",
      "sets": [
        "string"
      ]
    },
    "state": "Paid"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "506e3185e9c882d175a2d0cb0093d9f2",
    "currency": "USD",
    "current_period_end": "2014-03-31T12:20:00Z",
    "current_period_start": "2014-05-11T12:20:00Z",
    "frequency": "monthly",
    "price": 20,
    "rate_plan": {
      "id": "free",
      "currency": "USD",
      "externally_managed": false,
      "is_contract": false,
      "public_name": "Business Plan",
      "scope": "zone",
      "sets": [
        "string"
      ]
    },
    "state": "Paid"
  },
  "success": true
}