# Addressing # Regional Hostnames ## List Regional Hostnames `client.Addressing.RegionalHostnames.List(ctx, query) (*SinglePage[RegionalHostnameListResponse], error)` **get** `/zones/{zone_id}/addressing/regional_hostnames` List all Regional Hostnames within a zone. ### Parameters - `query RegionalHostnameListParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameListResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Addressing.RegionalHostnames.List(context.TODO(), addressing.RegionalHostnameListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) 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": [ { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Fetch Regional Hostname `client.Addressing.RegionalHostnames.Get(ctx, hostname, query) (*RegionalHostnameGetResponse, error)` **get** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Fetch the configuration for a specific Regional Hostname, within a zone. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `query RegionalHostnameGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameGetResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.Get( context.TODO(), "foo.example.com", addressing.RegionalHostnameGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.CreatedOn) } ``` #### 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": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Create Regional Hostname `client.Addressing.RegionalHostnames.New(ctx, params) (*RegionalHostnameNewResponse, error)` **post** `/zones/{zone_id}/addressing/regional_hostnames` Create a new Regional Hostname entry. Cloudflare will only use data centers that are physically located within the chosen region to decrypt and service HTTPS traffic. Learn more about [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). ### Parameters - `params RegionalHostnameNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Hostname param.Field[string]` Body param: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey param.Field[string]` Body param: Identifying key for the region - `Routing param.Field[string]` Body param: Configure which routing method to use for the regional hostname ### Returns - `type RegionalHostnameNewResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.New(context.TODO(), addressing.RegionalHostnameNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Hostname: cloudflare.F("foo.example.com"), RegionKey: cloudflare.F("ca"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.CreatedOn) } ``` #### 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": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Update Regional Hostname `client.Addressing.RegionalHostnames.Edit(ctx, hostname, params) (*RegionalHostnameEditResponse, error)` **patch** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Update the configuration for a specific Regional Hostname. Only the region_key of a hostname is mutable. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `params RegionalHostnameEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `RegionKey param.Field[string]` Body param: Identifying key for the region ### Returns - `type RegionalHostnameEditResponse struct{…}` - `CreatedOn Time` When the regional hostname was created - `Hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `RegionKey string` Identifying key for the region - `Routing string` Configure which routing method to use for the regional hostname ### 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Addressing.RegionalHostnames.Edit( context.TODO(), "foo.example.com", addressing.RegionalHostnameEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), RegionKey: cloudflare.F("ca"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.CreatedOn) } ``` #### 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": { "created_on": "2014-01-01T05:20:00.12345Z", "hostname": "foo.example.com", "region_key": "ca", "routing": "dns" } } ``` ## Delete Regional Hostname `client.Addressing.RegionalHostnames.Delete(ctx, hostname, body) (*RegionalHostnameDeleteResponse, error)` **delete** `/zones/{zone_id}/addressing/regional_hostnames/{hostname}` Delete the region configuration for a specific Regional Hostname. ### Parameters - `hostname string` DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` - `body RegionalHostnameDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameDeleteResponse struct{…}` - `Errors []RegionalHostnameDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source RegionalHostnameDeleteResponseErrorsSource` - `Pointer string` - `Messages []RegionalHostnameDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source RegionalHostnameDeleteResponseMessagesSource` - `Pointer string` - `Success RegionalHostnameDeleteResponseSuccess` Whether the API call was successful. - `const RegionalHostnameDeleteResponseSuccessTrue RegionalHostnameDeleteResponseSuccess = 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalHostname, err := client.Addressing.RegionalHostnames.Delete( context.TODO(), "foo.example.com", addressing.RegionalHostnameDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalHostname.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 } ``` # Regions ## List Regions `client.Addressing.RegionalHostnames.Regions.List(ctx, query) (*SinglePage[RegionalHostnameRegionListResponse], error)` **get** `/accounts/{account_id}/addressing/regional_hostnames/regions` List all Regional Services regions available for use by this account. ### Parameters - `query RegionalHostnameRegionListParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type RegionalHostnameRegionListResponse struct{…}` - `Key string` Identifying key for the region - `Label string` Human-readable text label for the region ### 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.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Addressing.RegionalHostnames.Regions.List(context.TODO(), addressing.RegionalHostnameRegionListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) 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": [ { "key": "ca", "label": "Canada" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` # Services ## List Services `client.Addressing.Services.List(ctx, query) (*SinglePage[ServiceListResponse], error)` **get** `/accounts/{account_id}/addressing/services` Bring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a service running on the Cloudflare network to enable a Cloudflare product on the IP addresses. This endpoint can be used as a reference of available services on the Cloudflare network, and their service IDs. ### Parameters - `query ServiceListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type ServiceListResponse struct{…}` - `ID string` Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the **List Services** endpoint. - `Name 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.Services.List(context.TODO(), addressing.ServiceListParams{ 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": "2db684ee7ca04e159946fd05b99e1bcd", "name": "Magic Transit" } ] } ``` # Address Maps ## List Address Maps `client.Addressing.AddressMaps.List(ctx, query) (*SinglePage[AddressMap], error)` **get** `/accounts/{account_id}/addressing/address_maps` List all address maps owned by the account. ### Parameters - `query AddressMapListParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMap struct{…}` - `ID string` Identifier of an Address Map. - `CanDelete bool` If set to false, then the Address Map cannot be deleted via API. This is true for Cloudflare-managed maps. - `CanModifyIPs bool` If set to false, then the IPs on the Address Map cannot be modified via the API. This is true for Cloudflare-managed maps. - `CreatedAt Time` - `DefaultSNI string` If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description string` An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled bool` Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `ModifiedAt Time` ### 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.AddressMaps.List(context.TODO(), addressing.AddressMapListParams{ 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": "055817b111884e0227e1be16a0be6ee0", "can_delete": true, "can_modify_ips": true, "created_at": "2014-01-01T05:20:00.12345Z", "default_sni": "*.example.com", "description": "My Ecommerce zones", "enabled": true, "modified_at": "2014-01-01T05:20:00.12345Z" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Address Map Details `client.Addressing.AddressMaps.Get(ctx, addressMapID, query) (*AddressMapGetResponse, error)` **get** `/accounts/{account_id}/addressing/address_maps/{address_map_id}` Show a particular address map owned by the account. ### Parameters - `addressMapID string` Identifier of an Address Map. - `query AddressMapGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMapGetResponse struct{…}` - `ID string` Identifier of an Address Map. - `CanDelete bool` If set to false, then the Address Map cannot be deleted via API. This is true for Cloudflare-managed maps. - `CanModifyIPs bool` If set to false, then the IPs on the Address Map cannot be modified via the API. This is true for Cloudflare-managed maps. - `CreatedAt Time` - `DefaultSNI string` If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description string` An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled bool` Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `IPs IPs` The set of IPs on the Address Map. - `CreatedAt Time` - `IP string` An IPv4 or IPv6 address. - `Memberships []AddressMapGetResponseMembership` Zones and Accounts which will be assigned IPs on this Address Map. A zone membership will take priority over an account membership. - `CanDelete bool` Controls whether the membership can be deleted via the API or not. - `CreatedAt Time` - `Identifier string` The identifier for the membership (eg. a zone or account tag). - `Kind Kind` The type of the membership. - `const KindZone Kind = "zone"` - `const KindAccount Kind = "account"` - `ModifiedAt Time` ### 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"), ) addressMap, err := client.Addressing.AddressMaps.Get( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", addressMap.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": "055817b111884e0227e1be16a0be6ee0", "can_delete": true, "can_modify_ips": true, "created_at": "2014-01-01T05:20:00.12345Z", "default_sni": "*.example.com", "description": "My Ecommerce zones", "enabled": true, "ips": [ { "created_at": "2014-01-01T05:20:00.12345Z", "ip": "192.0.2.1" } ], "memberships": [ { "can_delete": true, "created_at": "2014-01-01T05:20:00.12345Z", "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone" } ], "modified_at": "2014-01-01T05:20:00.12345Z" } } ``` ## Create Address Map `client.Addressing.AddressMaps.New(ctx, params) (*AddressMapNewResponse, error)` **post** `/accounts/{account_id}/addressing/address_maps` Create a new address map under the account. ### Parameters - `params AddressMapNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Description param.Field[string]` Body param: An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled param.Field[bool]` Body param: Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `IPs param.Field[[]string]` Body param - `Memberships param.Field[[]AddressMapNewParamsMembership]` Body param: Zones and Accounts which will be assigned IPs on this Address Map. A zone membership will take priority over an account membership. - `Identifier string` The identifier for the membership (eg. a zone or account tag). - `Kind Kind` The type of the membership. - `const KindZone Kind = "zone"` - `const KindAccount Kind = "account"` ### Returns - `type AddressMapNewResponse struct{…}` - `ID string` Identifier of an Address Map. - `CanDelete bool` If set to false, then the Address Map cannot be deleted via API. This is true for Cloudflare-managed maps. - `CanModifyIPs bool` If set to false, then the IPs on the Address Map cannot be modified via the API. This is true for Cloudflare-managed maps. - `CreatedAt Time` - `DefaultSNI string` If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description string` An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled bool` Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `IPs IPs` The set of IPs on the Address Map. - `CreatedAt Time` - `IP string` An IPv4 or IPv6 address. - `Memberships []AddressMapNewResponseMembership` Zones and Accounts which will be assigned IPs on this Address Map. A zone membership will take priority over an account membership. - `CanDelete bool` Controls whether the membership can be deleted via the API or not. - `CreatedAt Time` - `Identifier string` The identifier for the membership (eg. a zone or account tag). - `Kind Kind` The type of the membership. - `const KindZone Kind = "zone"` - `const KindAccount Kind = "account"` - `ModifiedAt Time` ### 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"), ) addressMap, err := client.Addressing.AddressMaps.New(context.TODO(), addressing.AddressMapNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", addressMap.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": "055817b111884e0227e1be16a0be6ee0", "can_delete": true, "can_modify_ips": true, "created_at": "2014-01-01T05:20:00.12345Z", "default_sni": "*.example.com", "description": "My Ecommerce zones", "enabled": true, "ips": [ { "created_at": "2014-01-01T05:20:00.12345Z", "ip": "192.0.2.1" } ], "memberships": [ { "can_delete": true, "created_at": "2014-01-01T05:20:00.12345Z", "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone" } ], "modified_at": "2014-01-01T05:20:00.12345Z" } } ``` ## Update Address Map `client.Addressing.AddressMaps.Edit(ctx, addressMapID, params) (*AddressMap, error)` **patch** `/accounts/{account_id}/addressing/address_maps/{address_map_id}` Modify properties of an address map owned by the account. ### Parameters - `addressMapID string` Identifier of an Address Map. - `params AddressMapEditParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `DefaultSNI param.Field[string]` Body param: If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description param.Field[string]` Body param: An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled param.Field[bool]` Body param: Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. ### Returns - `type AddressMap struct{…}` - `ID string` Identifier of an Address Map. - `CanDelete bool` If set to false, then the Address Map cannot be deleted via API. This is true for Cloudflare-managed maps. - `CanModifyIPs bool` If set to false, then the IPs on the Address Map cannot be modified via the API. This is true for Cloudflare-managed maps. - `CreatedAt Time` - `DefaultSNI string` If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description string` An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled bool` Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `ModifiedAt Time` ### 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"), ) addressMap, err := client.Addressing.AddressMaps.Edit( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapEditParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", addressMap.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": "055817b111884e0227e1be16a0be6ee0", "can_delete": true, "can_modify_ips": true, "created_at": "2014-01-01T05:20:00.12345Z", "default_sni": "*.example.com", "description": "My Ecommerce zones", "enabled": true, "modified_at": "2014-01-01T05:20:00.12345Z" } } ``` ## Delete Address Map `client.Addressing.AddressMaps.Delete(ctx, addressMapID, body) (*AddressMapDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/address_maps/{address_map_id}` Delete a particular address map owned by the account. An Address Map must be disabled before it can be deleted. ### Parameters - `addressMapID string` Identifier of an Address Map. - `body AddressMapDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMapDeleteResponse struct{…}` - `Errors []AddressMapDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapDeleteResponseErrorsSource` - `Pointer string` - `Messages []AddressMapDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapDeleteResponseMessagesSource` - `Pointer string` - `Success AddressMapDeleteResponseSuccess` Whether the API call was successful. - `const AddressMapDeleteResponseSuccessTrue AddressMapDeleteResponseSuccess = true` - `ResultInfo AddressMapDeleteResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) addressMap, err := client.Addressing.AddressMaps.Delete( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", addressMap.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Address Map - `type AddressMap struct{…}` - `ID string` Identifier of an Address Map. - `CanDelete bool` If set to false, then the Address Map cannot be deleted via API. This is true for Cloudflare-managed maps. - `CanModifyIPs bool` If set to false, then the IPs on the Address Map cannot be modified via the API. This is true for Cloudflare-managed maps. - `CreatedAt Time` - `DefaultSNI string` If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account. - `Description string` An optional description field which may be used to describe the types of IPs or zones on the map. - `Enabled bool` Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. - `ModifiedAt Time` ### Kind - `type Kind string` The type of the membership. - `const KindZone Kind = "zone"` - `const KindAccount Kind = "account"` # Accounts ## Add an account membership to an Address Map `client.Addressing.AddressMaps.Accounts.Update(ctx, addressMapID, params) (*AddressMapAccountUpdateResponse, error)` **put** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}` Add an account as a member of a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `params AddressMapAccountUpdateParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Body param.Field[unknown]` Body param ### Returns - `type AddressMapAccountUpdateResponse struct{…}` - `Errors []AddressMapAccountUpdateResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapAccountUpdateResponseErrorsSource` - `Pointer string` - `Messages []AddressMapAccountUpdateResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapAccountUpdateResponseMessagesSource` - `Pointer string` - `Success AddressMapAccountUpdateResponseSuccess` Whether the API call was successful. - `const AddressMapAccountUpdateResponseSuccessTrue AddressMapAccountUpdateResponseSuccess = true` - `ResultInfo AddressMapAccountUpdateResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) account, err := client.Addressing.AddressMaps.Accounts.Update( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapAccountUpdateParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), Body: map[string]interface{}{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Remove an account membership from an Address Map `client.Addressing.AddressMaps.Accounts.Delete(ctx, addressMapID, body) (*AddressMapAccountDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}` Remove an account as a member of a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `body AddressMapAccountDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMapAccountDeleteResponse struct{…}` - `Errors []AddressMapAccountDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapAccountDeleteResponseErrorsSource` - `Pointer string` - `Messages []AddressMapAccountDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapAccountDeleteResponseMessagesSource` - `Pointer string` - `Success AddressMapAccountDeleteResponseSuccess` Whether the API call was successful. - `const AddressMapAccountDeleteResponseSuccessTrue AddressMapAccountDeleteResponseSuccess = true` - `ResultInfo AddressMapAccountDeleteResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) account, err := client.Addressing.AddressMaps.Accounts.Delete( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapAccountDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", account.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # IPs ## Add an IP to an Address Map `client.Addressing.AddressMaps.IPs.Update(ctx, addressMapID, ipAddress, params) (*AddressMapIPUpdateResponse, error)` **put** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}` Add an IP from a prefix owned by the account to a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `ipAddress string` An IPv4 or IPv6 address. - `params AddressMapIPUpdateParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Body param.Field[unknown]` Body param ### Returns - `type AddressMapIPUpdateResponse struct{…}` - `Errors []AddressMapIPUpdateResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapIPUpdateResponseErrorsSource` - `Pointer string` - `Messages []AddressMapIPUpdateResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapIPUpdateResponseMessagesSource` - `Pointer string` - `Success AddressMapIPUpdateResponseSuccess` Whether the API call was successful. - `const AddressMapIPUpdateResponseSuccessTrue AddressMapIPUpdateResponseSuccess = true` - `ResultInfo AddressMapIPUpdateResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) ip, err := client.Addressing.AddressMaps.IPs.Update( context.TODO(), "055817b111884e0227e1be16a0be6ee0", "192.0.2.1", addressing.AddressMapIPUpdateParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), Body: map[string]interface{}{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", ip.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Remove an IP from an Address Map `client.Addressing.AddressMaps.IPs.Delete(ctx, addressMapID, ipAddress, body) (*AddressMapIPDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}` Remove an IP from a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `ipAddress string` An IPv4 or IPv6 address. - `body AddressMapIPDeleteParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMapIPDeleteResponse struct{…}` - `Errors []AddressMapIPDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapIPDeleteResponseErrorsSource` - `Pointer string` - `Messages []AddressMapIPDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapIPDeleteResponseMessagesSource` - `Pointer string` - `Success AddressMapIPDeleteResponseSuccess` Whether the API call was successful. - `const AddressMapIPDeleteResponseSuccessTrue AddressMapIPDeleteResponseSuccess = true` - `ResultInfo AddressMapIPDeleteResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) ip, err := client.Addressing.AddressMaps.IPs.Delete( context.TODO(), "055817b111884e0227e1be16a0be6ee0", "192.0.2.1", addressing.AddressMapIPDeleteParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", ip.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # Zones ## Add a zone membership to an Address Map `client.Addressing.AddressMaps.Zones.Update(ctx, addressMapID, params) (*AddressMapZoneUpdateResponse, error)` **put** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}` Add a zone as a member of a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `params AddressMapZoneUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier of a zone. - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `Body param.Field[unknown]` Body param ### Returns - `type AddressMapZoneUpdateResponse struct{…}` - `Errors []AddressMapZoneUpdateResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapZoneUpdateResponseErrorsSource` - `Pointer string` - `Messages []AddressMapZoneUpdateResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapZoneUpdateResponseMessagesSource` - `Pointer string` - `Success AddressMapZoneUpdateResponseSuccess` Whether the API call was successful. - `const AddressMapZoneUpdateResponseSuccessTrue AddressMapZoneUpdateResponseSuccess = true` - `ResultInfo AddressMapZoneUpdateResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) zone, err := client.Addressing.AddressMaps.Zones.Update( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapZoneUpdateParams{ ZoneID: cloudflare.F("8ac8489932db6327334c9b6d58544cfe"), AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), Body: map[string]interface{}{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", zone.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Remove a zone membership from an Address Map `client.Addressing.AddressMaps.Zones.Delete(ctx, addressMapID, body) (*AddressMapZoneDeleteResponse, error)` **delete** `/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}` Remove a zone as a member of a particular address map. ### Parameters - `addressMapID string` Identifier of an Address Map. - `body AddressMapZoneDeleteParams` - `ZoneID param.Field[string]` Identifier of a zone. - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type AddressMapZoneDeleteResponse struct{…}` - `Errors []AddressMapZoneDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapZoneDeleteResponseErrorsSource` - `Pointer string` - `Messages []AddressMapZoneDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source AddressMapZoneDeleteResponseMessagesSource` - `Pointer string` - `Success AddressMapZoneDeleteResponseSuccess` Whether the API call was successful. - `const AddressMapZoneDeleteResponseSuccessTrue AddressMapZoneDeleteResponseSuccess = true` - `ResultInfo AddressMapZoneDeleteResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. ### 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"), ) zone, err := client.Addressing.AddressMaps.Zones.Delete( context.TODO(), "055817b111884e0227e1be16a0be6ee0", addressing.AddressMapZoneDeleteParams{ ZoneID: cloudflare.F("8ac8489932db6327334c9b6d58544cfe"), AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", zone.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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # LOA Documents ## Download LOA Document `client.Addressing.LOADocuments.Get(ctx, loaDocumentID, query) (*Response, error)` **get** `/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download` Download specified LOA document under the account. ### Parameters - `loaDocumentID string` Identifier for the uploaded LOA document. - `query LOADocumentGetParams` - `AccountID param.Field[string]` Identifier of a Cloudflare account. ### Returns - `type LOADocumentGetResponse interface{…}` ### 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"), ) loaDocument, err := client.Addressing.LOADocuments.Get( context.TODO(), "d933b1530bc56c9953cf8ce166da8004", addressing.LOADocumentGetParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", loaDocument) } ``` ## Upload LOA Document `client.Addressing.LOADocuments.New(ctx, params) (*LOADocumentNewResponse, error)` **post** `/accounts/{account_id}/addressing/loa_documents` Submit LOA document (pdf format) under the account. ### Parameters - `params LOADocumentNewParams` - `AccountID param.Field[string]` Path param: Identifier of a Cloudflare account. - `LOADocument param.Field[string]` Body param: LOA document to upload. ### Returns - `type LOADocumentNewResponse struct{…}` - `ID string` Identifier for the uploaded LOA document. - `AccountID string` Identifier of a Cloudflare account. - `AutoGenerated bool` Whether the LOA has been auto-generated for the prefix owner by Cloudflare. - `Created Time` - `Filename string` Name of LOA document. Max file size 10MB, and supported filetype is pdf. - `SizeBytes int64` File size of the uploaded LOA document. - `Verified bool` Whether the LOA has been verified by Cloudflare staff. - `VerifiedAt Time` Timestamp of the moment the LOA was marked as validated. ### 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"), ) loaDocument, err := client.Addressing.LOADocuments.New(context.TODO(), addressing.LOADocumentNewParams{ AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), LOADocument: cloudflare.F("@document.pdf"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", loaDocument.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", "account_id": "258def64c72dae45f3e4c8516e2111f2", "auto_generated": true, "created": "2014-01-01T05:20:00.12345Z", "filename": "site_loa_doc.pdf", "size_bytes": 444, "verified": true, "verified_at": "2019-12-27T18:11:19.117Z" } } ``` # 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.