# Prefixes ## List Prefixes `client.Addressing.Prefixes.List(ctx, query) (*SinglePage[Prefix], error)` **get** `/accounts/{account_id}/addressing/prefixes` List all prefixes owned by the account. ### Parameters - `query PrefixListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type Prefix struct{…}` - `ID string` Identifier of an IP Prefix. - `AccountID string` Identifier of a Cloudflare account. - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `Approved string` Approval state of the prefix (P = pending, V = active). - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegateLOACreation bool` Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description string` Description of the prefix. - `IrrValidationState string` State of one kind of validation for an IP prefix. - `LOADocumentID string` Identifier for the uploaded LOA document. - `ModifiedAt Time` - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether advertisement status of the prefix is locked, meaning it cannot be changed. - `OwnershipValidationState string` State of one kind of validation for an IP prefix. - `OwnershipValidationToken string` Token provided to demonstrate ownership of the prefix. - `RPKIValidationState string` State of one kind of validation for an IP prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Addressing.Prefixes.List(context.TODO(), addressing.PrefixListParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "2af39739cc4e3b5910c918468bb89828", "account_id": "258def64c72dae45f3e4c8516e2111f2", "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "approved": "P", "asn": 13335, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegate_loa_creation": true, "description": "Internal test prefix", "irr_validation_state": "pending", "loa_document_id": "d933b1530bc56c9953cf8ce166da8004", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false, "ownership_validation_state": "pending", "ownership_validation_token": "1234a5b6-1234-1abc-12a3-1234a5b6789c", "rpki_validation_state": "pending" } ] } ``` ## Prefix Details `client.Addressing.Prefixes.Get(ctx, prefixID, query) (*Prefix, error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}` List a particular prefix owned by the account. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `query PrefixGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type Prefix struct{…}` - `ID string` Identifier of an IP Prefix. - `AccountID string` Identifier of a Cloudflare account. - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `Approved string` Approval state of the prefix (P = pending, V = active). - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegateLOACreation bool` Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description string` Description of the prefix. - `IrrValidationState string` State of one kind of validation for an IP prefix. - `LOADocumentID string` Identifier for the uploaded LOA document. - `ModifiedAt Time` - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether advertisement status of the prefix is locked, meaning it cannot be changed. - `OwnershipValidationState string` State of one kind of validation for an IP prefix. - `OwnershipValidationToken string` Token provided to demonstrate ownership of the prefix. - `RPKIValidationState string` State of one kind of validation for an IP prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) prefix, err := client.Addressing.Prefixes.Get( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", prefix.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" } } ], "success": true, "result": { "id": "2af39739cc4e3b5910c918468bb89828", "account_id": "258def64c72dae45f3e4c8516e2111f2", "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "approved": "P", "asn": 13335, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegate_loa_creation": true, "description": "Internal test prefix", "irr_validation_state": "pending", "loa_document_id": "d933b1530bc56c9953cf8ce166da8004", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false, "ownership_validation_state": "pending", "ownership_validation_token": "1234a5b6-1234-1abc-12a3-1234a5b6789c", "rpki_validation_state": "pending" } } ``` ## Add Prefix `client.Addressing.Prefixes.New(ctx, params) (*Prefix, error)` **post** `/accounts/{account_id}/addressing/prefixes` Add a new prefix under the account. ### Parameters - `params PrefixNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `ASN param.Field[int64]` Body param: Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR param.Field[string]` Body param: IP Prefix in Classless Inter-Domain Routing format. - `DelegateLOACreation param.Field[bool]` Body param: Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description param.Field[string]` Body param: Description of the prefix. - `LOADocumentID param.Field[string]` Body param: Identifier for the uploaded LOA document. ### Returns - `type Prefix struct{…}` - `ID string` Identifier of an IP Prefix. - `AccountID string` Identifier of a Cloudflare account. - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `Approved string` Approval state of the prefix (P = pending, V = active). - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegateLOACreation bool` Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description string` Description of the prefix. - `IrrValidationState string` State of one kind of validation for an IP prefix. - `LOADocumentID string` Identifier for the uploaded LOA document. - `ModifiedAt Time` - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether advertisement status of the prefix is locked, meaning it cannot be changed. - `OwnershipValidationState string` State of one kind of validation for an IP prefix. - `OwnershipValidationToken string` Token provided to demonstrate ownership of the prefix. - `RPKIValidationState string` State of one kind of validation for an IP prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) prefix, err := client.Addressing.Prefixes.New(context.TODO(), addressing.PrefixNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), ASN: cloudflare.F(int64(13335)), CIDR: cloudflare.F("192.0.2.0/24"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", prefix.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" } } ], "success": true, "result": { "id": "2af39739cc4e3b5910c918468bb89828", "account_id": "258def64c72dae45f3e4c8516e2111f2", "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "approved": "P", "asn": 13335, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegate_loa_creation": true, "description": "Internal test prefix", "irr_validation_state": "pending", "loa_document_id": "d933b1530bc56c9953cf8ce166da8004", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false, "ownership_validation_state": "pending", "ownership_validation_token": "1234a5b6-1234-1abc-12a3-1234a5b6789c", "rpki_validation_state": "pending" } } ``` ## Update Prefix Description `client.Addressing.Prefixes.Edit(ctx, prefixID, params) (*Prefix, error)` **patch** `/accounts/{account_id}/addressing/prefixes/{prefix_id}` Modify the description for a prefix owned by the account. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `params PrefixEditParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Description param.Field[string]` Body param: Description of the prefix. ### Returns - `type Prefix struct{…}` - `ID string` Identifier of an IP Prefix. - `AccountID string` Identifier of a Cloudflare account. - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `Approved string` Approval state of the prefix (P = pending, V = active). - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegateLOACreation bool` Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description string` Description of the prefix. - `IrrValidationState string` State of one kind of validation for an IP prefix. - `LOADocumentID string` Identifier for the uploaded LOA document. - `ModifiedAt Time` - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether advertisement status of the prefix is locked, meaning it cannot be changed. - `OwnershipValidationState string` State of one kind of validation for an IP prefix. - `OwnershipValidationToken string` Token provided to demonstrate ownership of the prefix. - `RPKIValidationState string` State of one kind of validation for an IP prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) prefix, err := client.Addressing.Prefixes.Edit( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixEditParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), Description: cloudflare.F("Internal test prefix"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", prefix.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" } } ], "success": true, "result": { "id": "2af39739cc4e3b5910c918468bb89828", "account_id": "258def64c72dae45f3e4c8516e2111f2", "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "approved": "P", "asn": 13335, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegate_loa_creation": true, "description": "Internal test prefix", "irr_validation_state": "pending", "loa_document_id": "d933b1530bc56c9953cf8ce166da8004", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false, "ownership_validation_state": "pending", "ownership_validation_token": "1234a5b6-1234-1abc-12a3-1234a5b6789c", "rpki_validation_state": "pending" } } ``` ## Delete Prefix `client.Addressing.Prefixes.Delete(ctx, prefixID, body) (*PrefixDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/prefixes/{prefix_id}` Delete an unapproved prefix owned by the account. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `body PrefixDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type PrefixDeleteResponse struct{…}` - `Errors []PrefixDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source PrefixDeleteResponseErrorsSource` - `Pointer string` - `Messages []PrefixDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source PrefixDeleteResponseMessagesSource` - `Pointer string` - `Success PrefixDeleteResponseSuccess` Whether the API call was successful. - `const PrefixDeleteResponseSuccessTrue PrefixDeleteResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) prefix, err := client.Addressing.Prefixes.Delete( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", prefix.Errors) } ``` #### 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" } } ], "success": true } ``` ## Domain Types ### Prefix - `type Prefix struct{…}` - `ID string` Identifier of an IP Prefix. - `AccountID string` Identifier of a Cloudflare account. - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `Approved string` Approval state of the prefix (P = pending, V = active). - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegateLOACreation bool` Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner. - `Description string` Description of the prefix. - `IrrValidationState string` State of one kind of validation for an IP prefix. - `LOADocumentID string` Identifier for the uploaded LOA document. - `ModifiedAt Time` - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether advertisement status of the prefix is locked, meaning it cannot be changed. - `OwnershipValidationState string` State of one kind of validation for an IP prefix. - `OwnershipValidationToken string` Token provided to demonstrate ownership of the prefix. - `RPKIValidationState string` State of one kind of validation for an IP prefix. # Service Bindings ## List Service Bindings `client.Addressing.Prefixes.ServiceBindings.List(ctx, prefixID, query) (*SinglePage[ServiceBinding], error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings` List the Cloudflare services this prefix is currently bound to. Traffic sent to an address within an IP prefix will be routed to the Cloudflare service of the most-specific Service Binding matching the address. **Example:** binding `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other IPs in the prefix to Cloudflare Magic Transit. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `query PrefixServiceBindingListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type ServiceBinding struct{…}` - `ID string` Identifier of a Service Binding. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `Provisioning ServiceBindingProvisioning` Status of a Service Binding's deployment to the Cloudflare network - `State ServiceBindingProvisioningState` When a binding has been deployed to a majority of Cloudflare datacenters, the binding will become active and can be used with its associated service. - `const ServiceBindingProvisioningStateProvisioning ServiceBindingProvisioningState = "provisioning"` - `const ServiceBindingProvisioningStateActive ServiceBindingProvisioningState = "active"` - `ServiceID string` Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. - `ServiceName string` Name of a service running on the Cloudflare network ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Addressing.Prefixes.ServiceBindings.List( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixServiceBindingListParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "0429b49b6a5155297b78e75a44b09e14", "cidr": "192.0.2.0/24", "provisioning": { "state": "provisioning" }, "service_id": "2db684ee7ca04e159946fd05b99e1bcd", "service_name": "Magic Transit" } ] } ``` ## Get Service Binding `client.Addressing.Prefixes.ServiceBindings.Get(ctx, prefixID, bindingID, query) (*ServiceBinding, error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}` Fetch a single Service Binding ### Parameters - `prefixID string` Identifier of an IP Prefix. - `bindingID string` Identifier of a Service Binding. - `query PrefixServiceBindingGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type ServiceBinding struct{…}` - `ID string` Identifier of a Service Binding. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `Provisioning ServiceBindingProvisioning` Status of a Service Binding's deployment to the Cloudflare network - `State ServiceBindingProvisioningState` When a binding has been deployed to a majority of Cloudflare datacenters, the binding will become active and can be used with its associated service. - `const ServiceBindingProvisioningStateProvisioning ServiceBindingProvisioningState = "provisioning"` - `const ServiceBindingProvisioningStateActive ServiceBindingProvisioningState = "active"` - `ServiceID string` Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. - `ServiceName string` Name of a service running on the Cloudflare network ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) serviceBinding, err := client.Addressing.Prefixes.ServiceBindings.Get( context.TODO(), "2af39739cc4e3b5910c918468bb89828", "0429b49b6a5155297b78e75a44b09e14", addressing.PrefixServiceBindingGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", serviceBinding.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" } } ], "success": true, "result": { "id": "0429b49b6a5155297b78e75a44b09e14", "cidr": "192.0.2.0/24", "provisioning": { "state": "provisioning" }, "service_id": "2db684ee7ca04e159946fd05b99e1bcd", "service_name": "Magic Transit" } } ``` ## Create Service Binding `client.Addressing.Prefixes.ServiceBindings.New(ctx, prefixID, params) (*ServiceBinding, error)` **post** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings` Creates a new Service Binding, routing traffic to IPs within the given CIDR to a service running on Cloudflare's network. **NOTE:** The first Service Binding created for an IP Prefix must exactly match the IP Prefix's CIDR. Subsequent Service Bindings may be created with a more-specific CIDR. Refer to the [Service Bindings Documentation](https://developers.cloudflare.com/byoip/service-bindings/) for compatibility details. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `params PrefixServiceBindingNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `CIDR param.Field[string]` Body param: IP Prefix in Classless Inter-Domain Routing format. - `ServiceID param.Field[string]` Body param: Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. ### Returns - `type ServiceBinding struct{…}` - `ID string` Identifier of a Service Binding. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `Provisioning ServiceBindingProvisioning` Status of a Service Binding's deployment to the Cloudflare network - `State ServiceBindingProvisioningState` When a binding has been deployed to a majority of Cloudflare datacenters, the binding will become active and can be used with its associated service. - `const ServiceBindingProvisioningStateProvisioning ServiceBindingProvisioningState = "provisioning"` - `const ServiceBindingProvisioningStateActive ServiceBindingProvisioningState = "active"` - `ServiceID string` Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. - `ServiceName string` Name of a service running on the Cloudflare network ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) serviceBinding, err := client.Addressing.Prefixes.ServiceBindings.New( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixServiceBindingNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), CIDR: cloudflare.F("192.0.2.0/24"), ServiceID: cloudflare.F("2db684ee7ca04e159946fd05b99e1bcd"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", serviceBinding.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" } } ], "success": true, "result": { "id": "0429b49b6a5155297b78e75a44b09e14", "cidr": "192.0.2.0/24", "provisioning": { "state": "provisioning" }, "service_id": "2db684ee7ca04e159946fd05b99e1bcd", "service_name": "Magic Transit" } } ``` ## Delete Service Binding `client.Addressing.Prefixes.ServiceBindings.Delete(ctx, prefixID, bindingID, body) (*PrefixServiceBindingDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}` Delete a Service Binding ### Parameters - `prefixID string` Identifier of an IP Prefix. - `bindingID string` Identifier of a Service Binding. - `body PrefixServiceBindingDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type PrefixServiceBindingDeleteResponse struct{…}` - `Errors []PrefixServiceBindingDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source PrefixServiceBindingDeleteResponseErrorsSource` - `Pointer string` - `Messages []PrefixServiceBindingDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source PrefixServiceBindingDeleteResponseMessagesSource` - `Pointer string` - `Success PrefixServiceBindingDeleteResponseSuccess` Whether the API call was successful. - `const PrefixServiceBindingDeleteResponseSuccessTrue PrefixServiceBindingDeleteResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) serviceBinding, err := client.Addressing.Prefixes.ServiceBindings.Delete( context.TODO(), "2af39739cc4e3b5910c918468bb89828", "0429b49b6a5155297b78e75a44b09e14", addressing.PrefixServiceBindingDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", serviceBinding.Errors) } ``` #### 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" } } ], "success": true } ``` ## Domain Types ### Service Binding - `type ServiceBinding struct{…}` - `ID string` Identifier of a Service Binding. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `Provisioning ServiceBindingProvisioning` Status of a Service Binding's deployment to the Cloudflare network - `State ServiceBindingProvisioningState` When a binding has been deployed to a majority of Cloudflare datacenters, the binding will become active and can be used with its associated service. - `const ServiceBindingProvisioningStateProvisioning ServiceBindingProvisioningState = "provisioning"` - `const ServiceBindingProvisioningStateActive ServiceBindingProvisioningState = "active"` - `ServiceID string` Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. - `ServiceName string` Name of a service running on the Cloudflare network # BGP Prefixes ## List BGP Prefixes `client.Addressing.Prefixes.BGPPrefixes.List(ctx, prefixID, query) (*SinglePage[BGPPrefix], error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes` List all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to control which specific subnets are advertised to the Internet. It is possible to advertise subnets more specific than an IP Prefix by creating more specific BGP Prefixes. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `query PrefixBGPPrefixListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type BGPPrefix struct{…}` - `ID string` Identifier of BGP Prefix. - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `ASNPrependCount int64` Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw bool` Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `BGPSignalOpts BGPPrefixBGPSignalOpts` - `Enabled bool` Whether control of advertisement of the prefix to the Internet is enabled to be performed via BGP signal - `ModifiedAt Time` Last time BGP signaling control was toggled. This field is null if BGP signaling has never been enabled. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `ModifiedAt Time` - `OnDemand BGPPrefixOnDemand` - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether the advertisement status of the prefix is locked, meaning it cannot be changed. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Addressing.Prefixes.BGPPrefixes.List( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixBGPPrefixListParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "7009ba364c7a5760798ceb430e603b74", "asn": 13335, "asn_prepend_count": 2, "auto_advertise_withdraw": true, "bgp_signal_opts": { "enabled": false, "modified_at": "2014-01-01T05:20:00.12345Z" }, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false } } ] } ``` ## Fetch BGP Prefix `client.Addressing.Prefixes.BGPPrefixes.Get(ctx, prefixID, bgpPrefixID, query) (*BGPPrefix, error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}` Retrieve a single BGP Prefix according to its identifier ### Parameters - `prefixID string` Identifier of an IP Prefix. - `bgpPrefixID string` Identifier of BGP Prefix. - `query PrefixBGPPrefixGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type BGPPrefix struct{…}` - `ID string` Identifier of BGP Prefix. - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `ASNPrependCount int64` Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw bool` Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `BGPSignalOpts BGPPrefixBGPSignalOpts` - `Enabled bool` Whether control of advertisement of the prefix to the Internet is enabled to be performed via BGP signal - `ModifiedAt Time` Last time BGP signaling control was toggled. This field is null if BGP signaling has never been enabled. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `ModifiedAt Time` - `OnDemand BGPPrefixOnDemand` - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether the advertisement status of the prefix is locked, meaning it cannot be changed. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) bgpPrefix, err := client.Addressing.Prefixes.BGPPrefixes.Get( context.TODO(), "2af39739cc4e3b5910c918468bb89828", "7009ba364c7a5760798ceb430e603b74", addressing.PrefixBGPPrefixGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bgpPrefix.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" } } ], "success": true, "result": { "id": "7009ba364c7a5760798ceb430e603b74", "asn": 13335, "asn_prepend_count": 2, "auto_advertise_withdraw": true, "bgp_signal_opts": { "enabled": false, "modified_at": "2014-01-01T05:20:00.12345Z" }, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false } } } ``` ## Create BGP Prefix `client.Addressing.Prefixes.BGPPrefixes.New(ctx, prefixID, params) (*BGPPrefix, error)` **post** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes` Create a BGP prefix, controlling the BGP advertisement status of a specific subnet. When created, BGP prefixes are initially withdrawn, and can be advertised with the Update BGP Prefix API. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `params PrefixBGPPrefixNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `CIDR param.Field[string]` Body param: IP Prefix in Classless Inter-Domain Routing format. ### Returns - `type BGPPrefix struct{…}` - `ID string` Identifier of BGP Prefix. - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `ASNPrependCount int64` Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw bool` Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `BGPSignalOpts BGPPrefixBGPSignalOpts` - `Enabled bool` Whether control of advertisement of the prefix to the Internet is enabled to be performed via BGP signal - `ModifiedAt Time` Last time BGP signaling control was toggled. This field is null if BGP signaling has never been enabled. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `ModifiedAt Time` - `OnDemand BGPPrefixOnDemand` - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether the advertisement status of the prefix is locked, meaning it cannot be changed. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) bgpPrefix, err := client.Addressing.Prefixes.BGPPrefixes.New( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixBGPPrefixNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), CIDR: cloudflare.F("192.0.2.0/24"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bgpPrefix.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" } } ], "success": true, "result": { "id": "7009ba364c7a5760798ceb430e603b74", "asn": 13335, "asn_prepend_count": 2, "auto_advertise_withdraw": true, "bgp_signal_opts": { "enabled": false, "modified_at": "2014-01-01T05:20:00.12345Z" }, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false } } } ``` ## Update BGP Prefix `client.Addressing.Prefixes.BGPPrefixes.Edit(ctx, prefixID, bgpPrefixID, params) (*BGPPrefix, error)` **patch** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}` Update the properties of a BGP Prefix, such as the on demand advertisement status (advertised or withdrawn). ### Parameters - `prefixID string` Identifier of an IP Prefix. - `bgpPrefixID string` Identifier of BGP Prefix. - `params PrefixBGPPrefixEditParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `ASNPrependCount param.Field[int64]` Body param: Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw param.Field[bool]` Body param: Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `OnDemand param.Field[PrefixBGPPrefixEditParamsOnDemand]` Body param - `Advertised bool` ### Returns - `type BGPPrefix struct{…}` - `ID string` Identifier of BGP Prefix. - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `ASNPrependCount int64` Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw bool` Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `BGPSignalOpts BGPPrefixBGPSignalOpts` - `Enabled bool` Whether control of advertisement of the prefix to the Internet is enabled to be performed via BGP signal - `ModifiedAt Time` Last time BGP signaling control was toggled. This field is null if BGP signaling has never been enabled. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `ModifiedAt Time` - `OnDemand BGPPrefixOnDemand` - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether the advertisement status of the prefix is locked, meaning it cannot be changed. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) bgpPrefix, err := client.Addressing.Prefixes.BGPPrefixes.Edit( context.TODO(), "2af39739cc4e3b5910c918468bb89828", "7009ba364c7a5760798ceb430e603b74", addressing.PrefixBGPPrefixEditParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bgpPrefix.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" } } ], "success": true, "result": { "id": "7009ba364c7a5760798ceb430e603b74", "asn": 13335, "asn_prepend_count": 2, "auto_advertise_withdraw": true, "bgp_signal_opts": { "enabled": false, "modified_at": "2014-01-01T05:20:00.12345Z" }, "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "modified_at": "2014-01-01T05:20:00.12345Z", "on_demand": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z", "on_demand_enabled": true, "on_demand_locked": false } } } ``` ## Domain Types ### BGP Prefix - `type BGPPrefix struct{…}` - `ID string` Identifier of BGP Prefix. - `ASN int64` Autonomous System Number (ASN) the prefix will be advertised under. - `ASNPrependCount int64` Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute - `AutoAdvertiseWithdraw bool` Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route. - `BGPSignalOpts BGPPrefixBGPSignalOpts` - `Enabled bool` Whether control of advertisement of the prefix to the Internet is enabled to be performed via BGP signal - `ModifiedAt Time` Last time BGP signaling control was toggled. This field is null if BGP signaling has never been enabled. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `ModifiedAt Time` - `OnDemand BGPPrefixOnDemand` - `Advertised bool` Prefix advertisement status to the Internet. This field is only not 'null' if on demand is enabled. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. - `OnDemandEnabled bool` Whether advertisement of the prefix to the Internet may be dynamically enabled or disabled. - `OnDemandLocked bool` Whether the advertisement status of the prefix is locked, meaning it cannot be changed. # Advertisement Status ## Get Advertisement Status `client.Addressing.Prefixes.AdvertisementStatus.Get(ctx, prefixID, query) (*PrefixAdvertisementStatusGetResponse, error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status` View the current advertisement state for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `query PrefixAdvertisementStatusGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type PrefixAdvertisementStatusGetResponse struct{…}` - `Advertised bool` Advertisement status of the prefix. If `true`, the BGP route for the prefix is advertised to the Internet. If `false`, the BGP route is withdrawn. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) advertisementStatus, err := client.Addressing.Prefixes.AdvertisementStatus.Get( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixAdvertisementStatusGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", advertisementStatus.Advertised) } ``` #### 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" } } ], "success": true, "result": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z" } } ``` ## Update Prefix Dynamic Advertisement Status `client.Addressing.Prefixes.AdvertisementStatus.Edit(ctx, prefixID, params) (*PrefixAdvertisementStatusEditResponse, error)` **patch** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status` Advertise or withdraw the BGP route for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `params PrefixAdvertisementStatusEditParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Advertised param.Field[bool]` Body param: Advertisement status of the prefix. If `true`, the BGP route for the prefix is advertised to the Internet. If `false`, the BGP route is withdrawn. ### Returns - `type PrefixAdvertisementStatusEditResponse struct{…}` - `Advertised bool` Advertisement status of the prefix. If `true`, the BGP route for the prefix is advertised to the Internet. If `false`, the BGP route is withdrawn. - `AdvertisedModifiedAt Time` Last time the advertisement status was changed. This field is only not 'null' if on demand is enabled. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) response, err := client.Addressing.Prefixes.AdvertisementStatus.Edit( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixAdvertisementStatusEditParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), Advertised: cloudflare.F(true), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Advertised) } ``` #### 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" } } ], "success": true, "result": { "advertised": true, "advertised_modified_at": "2014-01-01T05:20:00.12345Z" } } ``` # Delegations ## List Prefix Delegations `client.Addressing.Prefixes.Delegations.List(ctx, prefixID, query) (*SinglePage[Delegations], error)` **get** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations` List all delegations for a given account IP prefix. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `query PrefixDelegationListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type Delegations struct{…}` - `ID string` Identifier of a Delegation. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegatedAccountID string` Account identifier for the account to which prefix is being delegated. - `ModifiedAt Time` - `ParentPrefixID string` Identifier of an IP Prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.Addressing.Prefixes.Delegations.List( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixDelegationListParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "d933b1530bc56c9953cf8ce166da8004", "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegated_account_id": "b1946ac92492d2347c6235b4d2611184", "modified_at": "2014-01-01T05:20:00.12345Z", "parent_prefix_id": "2af39739cc4e3b5910c918468bb89828" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Create Prefix Delegation `client.Addressing.Prefixes.Delegations.New(ctx, prefixID, params) (*Delegations, error)` **post** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations` Create a new account delegation for a given IP prefix. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `params PrefixDelegationNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `CIDR param.Field[string]` Body param: IP Prefix in Classless Inter-Domain Routing format. - `DelegatedAccountID param.Field[string]` Body param: Account identifier for the account to which prefix is being delegated. ### Returns - `type Delegations struct{…}` - `ID string` Identifier of a Delegation. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegatedAccountID string` Account identifier for the account to which prefix is being delegated. - `ModifiedAt Time` - `ParentPrefixID string` Identifier of an IP Prefix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) delegations, err := client.Addressing.Prefixes.Delegations.New( context.TODO(), "2af39739cc4e3b5910c918468bb89828", addressing.PrefixDelegationNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), CIDR: cloudflare.F("192.0.2.0/24"), DelegatedAccountID: cloudflare.F("b1946ac92492d2347c6235b4d2611184"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", delegations.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" } } ], "success": true, "result": { "id": "d933b1530bc56c9953cf8ce166da8004", "cidr": "192.0.2.0/24", "created_at": "2014-01-01T05:20:00.12345Z", "delegated_account_id": "b1946ac92492d2347c6235b4d2611184", "modified_at": "2014-01-01T05:20:00.12345Z", "parent_prefix_id": "2af39739cc4e3b5910c918468bb89828" } } ``` ## Delete Prefix Delegation `client.Addressing.Prefixes.Delegations.Delete(ctx, prefixID, delegationID, body) (*PrefixDelegationDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/prefixes/{prefix_id}/delegations/{delegation_id}` Delete an account delegation for a given IP prefix. ### Parameters - `prefixID string` Identifier of an IP Prefix. - `delegationID string` Identifier of a Delegation. - `body PrefixDelegationDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type PrefixDelegationDeleteResponse struct{…}` - `ID string` Identifier of a Delegation. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/addressing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) delegation, err := client.Addressing.Prefixes.Delegations.Delete( context.TODO(), "2af39739cc4e3b5910c918468bb89828", "d933b1530bc56c9953cf8ce166da8004", addressing.PrefixDelegationDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", delegation.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" } } ], "success": true, "result": { "id": "d933b1530bc56c9953cf8ce166da8004" } } ``` ## Domain Types ### Delegations - `type Delegations struct{…}` - `ID string` Identifier of a Delegation. - `CIDR string` IP Prefix in Classless Inter-Domain Routing format. - `CreatedAt Time` - `DelegatedAccountID string` Account identifier for the account to which prefix is being delegated. - `ModifiedAt Time` - `ParentPrefixID string` Identifier of an IP Prefix.