# Subscriptions ## Zone Subscription Details `client.Zones.Subscriptions.Get(ctx, query) (*SubscriptionGetResponse, error)` **get** `/zones/{zone_id}/subscription` Lists zone subscription details. ### Parameters - `query SubscriptionGetParams` - `ZoneID param.Field[string]` Identifier ### Returns - `type SubscriptionGetResponse struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionGetResponseFrequency` How often the subscription is renewed automatically. - `const SubscriptionGetResponseFrequencyWeekly SubscriptionGetResponseFrequency = "weekly"` - `const SubscriptionGetResponseFrequencyMonthly SubscriptionGetResponseFrequency = "monthly"` - `const SubscriptionGetResponseFrequencyQuarterly SubscriptionGetResponseFrequency = "quarterly"` - `const SubscriptionGetResponseFrequencyYearly SubscriptionGetResponseFrequency = "yearly"` - `const SubscriptionGetResponseFrequencyNotApplicable SubscriptionGetResponseFrequency = "not-applicable"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `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 string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionGetResponseState` The state that the subscription is in. - `const SubscriptionGetResponseStateTrial SubscriptionGetResponseState = "Trial"` - `const SubscriptionGetResponseStateProvisioned SubscriptionGetResponseState = "Provisioned"` - `const SubscriptionGetResponseStatePaid SubscriptionGetResponseState = "Paid"` - `const SubscriptionGetResponseStateAwaitingPayment SubscriptionGetResponseState = "AwaitingPayment"` - `const SubscriptionGetResponseStateCancelled SubscriptionGetResponseState = "Cancelled"` - `const SubscriptionGetResponseStateFailed SubscriptionGetResponseState = "Failed"` - `const SubscriptionGetResponseStateExpired SubscriptionGetResponseState = "Expired"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) subscription, err := client.Zones.Subscriptions.Get(context.TODO(), zones.SubscriptionGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subscription.ID) } ``` #### Response ```json { "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 } ``` ## Create Zone Subscription `client.Zones.Subscriptions.New(ctx, params) (*SubscriptionNewResponse, error)` **post** `/zones/{zone_id}/subscription` Create a zone subscription, either plan or add-ons. ### Parameters - `params SubscriptionNewParams` - `ZoneID param.Field[string]` Path param: Identifier - `Subscription param.Field[Subscription]` Body param ### Returns - `type SubscriptionNewResponse struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionNewResponseFrequency` How often the subscription is renewed automatically. - `const SubscriptionNewResponseFrequencyWeekly SubscriptionNewResponseFrequency = "weekly"` - `const SubscriptionNewResponseFrequencyMonthly SubscriptionNewResponseFrequency = "monthly"` - `const SubscriptionNewResponseFrequencyQuarterly SubscriptionNewResponseFrequency = "quarterly"` - `const SubscriptionNewResponseFrequencyYearly SubscriptionNewResponseFrequency = "yearly"` - `const SubscriptionNewResponseFrequencyNotApplicable SubscriptionNewResponseFrequency = "not-applicable"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `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 string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionNewResponseState` The state that the subscription is in. - `const SubscriptionNewResponseStateTrial SubscriptionNewResponseState = "Trial"` - `const SubscriptionNewResponseStateProvisioned SubscriptionNewResponseState = "Provisioned"` - `const SubscriptionNewResponseStatePaid SubscriptionNewResponseState = "Paid"` - `const SubscriptionNewResponseStateAwaitingPayment SubscriptionNewResponseState = "AwaitingPayment"` - `const SubscriptionNewResponseStateCancelled SubscriptionNewResponseState = "Cancelled"` - `const SubscriptionNewResponseStateFailed SubscriptionNewResponseState = "Failed"` - `const SubscriptionNewResponseStateExpired SubscriptionNewResponseState = "Expired"` ### Example ```go 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.New(context.TODO(), zones.SubscriptionNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Subscription: shared.SubscriptionParam{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subscription.ID) } ``` #### Response ```json { "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 } ``` ## Update Zone Subscription `client.Zones.Subscriptions.Update(ctx, params) (*SubscriptionUpdateResponse, error)` **put** `/zones/{zone_id}/subscription` Updates zone subscriptions, either plan or add-ons. ### Parameters - `params SubscriptionUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier - `Subscription param.Field[Subscription]` Body param ### Returns - `type SubscriptionUpdateResponse struct{…}` - `ID string` Subscription identifier tag. - `Currency string` The monetary unit in which pricing information is displayed. - `CurrentPeriodEnd Time` The end of the current period and also when the next billing is due. - `CurrentPeriodStart Time` When the current billing period started. May match initial_period_start if this is the first period. - `Frequency SubscriptionUpdateResponseFrequency` How often the subscription is renewed automatically. - `const SubscriptionUpdateResponseFrequencyWeekly SubscriptionUpdateResponseFrequency = "weekly"` - `const SubscriptionUpdateResponseFrequencyMonthly SubscriptionUpdateResponseFrequency = "monthly"` - `const SubscriptionUpdateResponseFrequencyQuarterly SubscriptionUpdateResponseFrequency = "quarterly"` - `const SubscriptionUpdateResponseFrequencyYearly SubscriptionUpdateResponseFrequency = "yearly"` - `const SubscriptionUpdateResponseFrequencyNotApplicable SubscriptionUpdateResponseFrequency = "not-applicable"` - `Price float64` The price of the subscription that will be billed, in US dollars. - `RatePlan RatePlan` The rate plan applied to the subscription. - `ID RatePlanID` The ID of the rate plan. - `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 string` The currency applied to the rate plan subscription. - `ExternallyManaged bool` Whether this rate plan is managed externally from Cloudflare. - `IsContract bool` Whether a rate plan is enterprise-based (or newly adopted term contract). - `PublicName string` The full name of the rate plan. - `Scope string` The scope that this rate plan applies to. - `Sets []string` The list of sets this rate plan applies to. Returns array of strings. - `State SubscriptionUpdateResponseState` The state that the subscription is in. - `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"` ### Example ```go 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) } ``` #### Response ```json { "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 } ```