# Hostname Associations ## List Hostname Associations `client.CertificateAuthorities.HostnameAssociations.Get(ctx, params) (*HostnameAssociationGetResponse, error)` **get** `/zones/{zone_id}/certificate_authorities/hostname_associations` List Hostname Associations ### Parameters - `params HostnameAssociationGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `MTLSCertificateID param.Field[string]` Query param: The UUID to match against for a certificate that was uploaded to the mTLS Certificate Management endpoint. If no mtls_certificate_id is given, the results will be the hostnames associated to your active Cloudflare Managed CA. ### Returns - `type HostnameAssociationGetResponse struct{…}` - `Hostnames []HostnameAssociation` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/certificate_authorities" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameAssociation, err := client.CertificateAuthorities.HostnameAssociations.Get(context.TODO(), certificate_authorities.HostnameAssociationGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameAssociation.Hostnames) } ``` #### 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": { "hostnames": [ "api.example.com" ] } } ``` ## Replace Hostname Associations `client.CertificateAuthorities.HostnameAssociations.Update(ctx, params) (*HostnameAssociationUpdateResponse, error)` **put** `/zones/{zone_id}/certificate_authorities/hostname_associations` Replace Hostname Associations ### Parameters - `params HostnameAssociationUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `TLSHostnameAssociation param.Field[TLSHostnameAssociation]` Body param ### Returns - `type HostnameAssociationUpdateResponse struct{…}` - `Hostnames []HostnameAssociation` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/certificate_authorities" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hostnameAssociation, err := client.CertificateAuthorities.HostnameAssociations.Update(context.TODO(), certificate_authorities.HostnameAssociationUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), TLSHostnameAssociation: certificate_authorities.TLSHostnameAssociationParam{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hostnameAssociation.Hostnames) } ``` #### 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": { "hostnames": [ "api.example.com" ] } } ``` ## Domain Types ### Hostname Association - `type HostnameAssociation string` ### TLS Hostname Association - `type TLSHostnameAssociation struct{…}` - `Hostnames []HostnameAssociation` - `MTLSCertificateID string` The UUID for a certificate that was uploaded to the mTLS Certificate Management endpoint. If no mtls_certificate_id is given, the hostnames will be associated to your active Cloudflare Managed CA.