# Fallback Origin ## Get Fallback Origin for Custom Hostnames `client.CustomHostnames.FallbackOrigin.Get(ctx, query) (*FallbackOriginGetResponse, error)` **get** `/zones/{zone_id}/custom_hostnames/fallback_origin` Retrieves the current fallback origin configuration for custom hostnames on a zone. The fallback origin handles traffic when specific custom hostname origins are unavailable. ### Parameters - `query FallbackOriginGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type FallbackOriginGetResponse struct{…}` - `CreatedAt Time` This is the time the fallback origin was created. - `Errors []string` These are errors that were encountered while trying to activate a fallback origin. - `Origin string` Your origin hostname that requests to your custom hostnames will be sent to. - `Status FallbackOriginGetResponseStatus` Status of the fallback origin's activation. - `const FallbackOriginGetResponseStatusInitializing FallbackOriginGetResponseStatus = "initializing"` - `const FallbackOriginGetResponseStatusPendingDeployment FallbackOriginGetResponseStatus = "pending_deployment"` - `const FallbackOriginGetResponseStatusPendingDeletion FallbackOriginGetResponseStatus = "pending_deletion"` - `const FallbackOriginGetResponseStatusActive FallbackOriginGetResponseStatus = "active"` - `const FallbackOriginGetResponseStatusDeploymentTimedOut FallbackOriginGetResponseStatus = "deployment_timed_out"` - `const FallbackOriginGetResponseStatusDeletionTimedOut FallbackOriginGetResponseStatus = "deletion_timed_out"` - `UpdatedAt Time` This is the time the fallback origin was updated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_hostnames" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) fallbackOrigin, err := client.CustomHostnames.FallbackOrigin.Get(context.TODO(), custom_hostnames.FallbackOriginGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", fallbackOrigin.CreatedAt) } ``` #### 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_at": "2019-10-28T18:11:23.37411Z", "errors": [ "DNS records are not setup correctly. Origin should be a proxied A/AAAA/CNAME dns record" ], "origin": "fallback.example.com", "status": "pending_deployment", "updated_at": "2020-03-16T18:11:23.531995Z" } } ``` ## Update Fallback Origin for Custom Hostnames `client.CustomHostnames.FallbackOrigin.Update(ctx, params) (*FallbackOriginUpdateResponse, error)` **put** `/zones/{zone_id}/custom_hostnames/fallback_origin` Updates the fallback origin configuration for custom hostnames on a zone. Sets the default origin server for custom hostname traffic. ### Parameters - `params FallbackOriginUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Origin param.Field[string]` Body param: Your origin hostname that requests to your custom hostnames will be sent to. ### Returns - `type FallbackOriginUpdateResponse struct{…}` - `CreatedAt Time` This is the time the fallback origin was created. - `Errors []string` These are errors that were encountered while trying to activate a fallback origin. - `Origin string` Your origin hostname that requests to your custom hostnames will be sent to. - `Status FallbackOriginUpdateResponseStatus` Status of the fallback origin's activation. - `const FallbackOriginUpdateResponseStatusInitializing FallbackOriginUpdateResponseStatus = "initializing"` - `const FallbackOriginUpdateResponseStatusPendingDeployment FallbackOriginUpdateResponseStatus = "pending_deployment"` - `const FallbackOriginUpdateResponseStatusPendingDeletion FallbackOriginUpdateResponseStatus = "pending_deletion"` - `const FallbackOriginUpdateResponseStatusActive FallbackOriginUpdateResponseStatus = "active"` - `const FallbackOriginUpdateResponseStatusDeploymentTimedOut FallbackOriginUpdateResponseStatus = "deployment_timed_out"` - `const FallbackOriginUpdateResponseStatusDeletionTimedOut FallbackOriginUpdateResponseStatus = "deletion_timed_out"` - `UpdatedAt Time` This is the time the fallback origin was updated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_hostnames" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) fallbackOrigin, err := client.CustomHostnames.FallbackOrigin.Update(context.TODO(), custom_hostnames.FallbackOriginUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Origin: cloudflare.F("fallback.example.com"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", fallbackOrigin.CreatedAt) } ``` #### 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_at": "2019-10-28T18:11:23.37411Z", "errors": [ "DNS records are not setup correctly. Origin should be a proxied A/AAAA/CNAME dns record" ], "origin": "fallback.example.com", "status": "pending_deployment", "updated_at": "2020-03-16T18:11:23.531995Z" } } ``` ## Delete Fallback Origin for Custom Hostnames `client.CustomHostnames.FallbackOrigin.Delete(ctx, body) (*FallbackOriginDeleteResponse, error)` **delete** `/zones/{zone_id}/custom_hostnames/fallback_origin` Removes the fallback origin configuration for custom hostnames on a zone. Custom hostnames without specific origins will no longer have a fallback. ### Parameters - `body FallbackOriginDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type FallbackOriginDeleteResponse struct{…}` - `CreatedAt Time` This is the time the fallback origin was created. - `Errors []string` These are errors that were encountered while trying to activate a fallback origin. - `Origin string` Your origin hostname that requests to your custom hostnames will be sent to. - `Status FallbackOriginDeleteResponseStatus` Status of the fallback origin's activation. - `const FallbackOriginDeleteResponseStatusInitializing FallbackOriginDeleteResponseStatus = "initializing"` - `const FallbackOriginDeleteResponseStatusPendingDeployment FallbackOriginDeleteResponseStatus = "pending_deployment"` - `const FallbackOriginDeleteResponseStatusPendingDeletion FallbackOriginDeleteResponseStatus = "pending_deletion"` - `const FallbackOriginDeleteResponseStatusActive FallbackOriginDeleteResponseStatus = "active"` - `const FallbackOriginDeleteResponseStatusDeploymentTimedOut FallbackOriginDeleteResponseStatus = "deployment_timed_out"` - `const FallbackOriginDeleteResponseStatusDeletionTimedOut FallbackOriginDeleteResponseStatus = "deletion_timed_out"` - `UpdatedAt Time` This is the time the fallback origin was updated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_hostnames" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) fallbackOrigin, err := client.CustomHostnames.FallbackOrigin.Delete(context.TODO(), custom_hostnames.FallbackOriginDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", fallbackOrigin.CreatedAt) } ``` #### 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_at": "2019-10-28T18:11:23.37411Z", "errors": [ "DNS records are not setup correctly. Origin should be a proxied A/AAAA/CNAME dns record" ], "origin": "fallback.example.com", "status": "pending_deployment", "updated_at": "2020-03-16T18:11:23.531995Z" } } ```