# Custom Pages ## List custom pages `client.CustomPages.List(ctx, query) (*SinglePage[CustomPageListResponse], error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages` Fetches all the custom pages. ### Parameters - `query CustomPageListParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type CustomPageListResponse struct{…}` - `ID string` - `CreatedOn Time` - `Description string` - `ModifiedOn Time` - `PreviewTarget string` - `RequiredTokens []string` - `State CustomPageListResponseState` The custom page state. - `const CustomPageListResponseStateDefault CustomPageListResponseState = "default"` - `const CustomPageListResponseStateCustomized CustomPageListResponseState = "customized"` - `URL string` The URL associated with the custom page. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.CustomPages.List(context.TODO(), custom_pages.CustomPageListParams{ }) 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": "basic_challenge", "created_on": "2014-01-01T05:20:00.12345Z", "description": "Basic Challenge", "modified_on": "2014-01-01T05:20:00.12345Z", "preview_target": "block:basic-sec-captcha", "required_tokens": [ "::CAPTCHA_BOX::" ], "state": "default", "url": "http://www.example.com" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Get a custom page `client.CustomPages.Get(ctx, identifier, query) (*CustomPageGetResponse, error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/{identifier}` Fetches the details of a custom page. ### Parameters - `identifier CustomPageGetParamsIdentifier` Error Page Types - `const CustomPageGetParamsIdentifier1000Errors CustomPageGetParamsIdentifier = "1000_errors"` - `const CustomPageGetParamsIdentifier500Errors CustomPageGetParamsIdentifier = "500_errors"` - `const CustomPageGetParamsIdentifierBasicChallenge CustomPageGetParamsIdentifier = "basic_challenge"` - `const CustomPageGetParamsIdentifierCountryChallenge CustomPageGetParamsIdentifier = "country_challenge"` - `const CustomPageGetParamsIdentifierIPBlock CustomPageGetParamsIdentifier = "ip_block"` - `const CustomPageGetParamsIdentifierManagedChallenge CustomPageGetParamsIdentifier = "managed_challenge"` - `const CustomPageGetParamsIdentifierRatelimitBlock CustomPageGetParamsIdentifier = "ratelimit_block"` - `const CustomPageGetParamsIdentifierUnderAttack CustomPageGetParamsIdentifier = "under_attack"` - `const CustomPageGetParamsIdentifierWAFBlock CustomPageGetParamsIdentifier = "waf_block"` - `const CustomPageGetParamsIdentifierWAFChallenge CustomPageGetParamsIdentifier = "waf_challenge"` - `query CustomPageGetParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type CustomPageGetResponse struct{…}` - `ID string` - `CreatedOn Time` - `Description string` - `ModifiedOn Time` - `PreviewTarget string` - `RequiredTokens []string` - `State CustomPageGetResponseState` The custom page state. - `const CustomPageGetResponseStateDefault CustomPageGetResponseState = "default"` - `const CustomPageGetResponseStateCustomized CustomPageGetResponseState = "customized"` - `URL string` The URL associated with the custom page. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) customPage, err := client.CustomPages.Get( context.TODO(), custom_pages.CustomPageGetParamsIdentifierRatelimitBlock, custom_pages.CustomPageGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", customPage.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": "basic_challenge", "created_on": "2014-01-01T05:20:00.12345Z", "description": "Basic Challenge", "modified_on": "2014-01-01T05:20:00.12345Z", "preview_target": "block:basic-sec-captcha", "required_tokens": [ "::CAPTCHA_BOX::" ], "state": "default", "url": "http://www.example.com" } } ``` ## Update a custom page `client.CustomPages.Update(ctx, identifier, params) (*CustomPageUpdateResponse, error)` **put** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/{identifier}` Updates the configuration of an existing custom page. ### Parameters - `identifier CustomPageUpdateParamsIdentifier` Error Page Types - `const CustomPageUpdateParamsIdentifier1000Errors CustomPageUpdateParamsIdentifier = "1000_errors"` - `const CustomPageUpdateParamsIdentifier500Errors CustomPageUpdateParamsIdentifier = "500_errors"` - `const CustomPageUpdateParamsIdentifierBasicChallenge CustomPageUpdateParamsIdentifier = "basic_challenge"` - `const CustomPageUpdateParamsIdentifierCountryChallenge CustomPageUpdateParamsIdentifier = "country_challenge"` - `const CustomPageUpdateParamsIdentifierIPBlock CustomPageUpdateParamsIdentifier = "ip_block"` - `const CustomPageUpdateParamsIdentifierManagedChallenge CustomPageUpdateParamsIdentifier = "managed_challenge"` - `const CustomPageUpdateParamsIdentifierRatelimitBlock CustomPageUpdateParamsIdentifier = "ratelimit_block"` - `const CustomPageUpdateParamsIdentifierUnderAttack CustomPageUpdateParamsIdentifier = "under_attack"` - `const CustomPageUpdateParamsIdentifierWAFBlock CustomPageUpdateParamsIdentifier = "waf_block"` - `const CustomPageUpdateParamsIdentifierWAFChallenge CustomPageUpdateParamsIdentifier = "waf_challenge"` - `params CustomPageUpdateParams` - `State param.Field[CustomPageUpdateParamsState]` Body param: The custom page state. - `const CustomPageUpdateParamsStateDefault CustomPageUpdateParamsState = "default"` - `const CustomPageUpdateParamsStateCustomized CustomPageUpdateParamsState = "customized"` - `URL param.Field[string]` Body param: The URL associated with the custom page. - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type CustomPageUpdateResponse struct{…}` - `ID string` - `CreatedOn Time` - `Description string` - `ModifiedOn Time` - `PreviewTarget string` - `RequiredTokens []string` - `State CustomPageUpdateResponseState` The custom page state. - `const CustomPageUpdateResponseStateDefault CustomPageUpdateResponseState = "default"` - `const CustomPageUpdateResponseStateCustomized CustomPageUpdateResponseState = "customized"` - `URL string` The URL associated with the custom page. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) customPage, err := client.CustomPages.Update( context.TODO(), custom_pages.CustomPageUpdateParamsIdentifierRatelimitBlock, custom_pages.CustomPageUpdateParams{ State: cloudflare.F(custom_pages.CustomPageUpdateParamsStateDefault), URL: cloudflare.F("http://www.example.com"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", customPage.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": "basic_challenge", "created_on": "2014-01-01T05:20:00.12345Z", "description": "Basic Challenge", "modified_on": "2014-01-01T05:20:00.12345Z", "preview_target": "block:basic-sec-captcha", "required_tokens": [ "::CAPTCHA_BOX::" ], "state": "default", "url": "http://www.example.com" } } ``` # Assets ## List custom assets `client.CustomPages.Assets.List(ctx, params) (*V4PagePaginationArray[AssetListResponse], error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/assets` Fetches all the custom assets. ### Parameters - `params AssetListParams` - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - `Page param.Field[int64]` Query param - `PerPage param.Field[int64]` Query param ### Returns - `type AssetListResponse struct{…}` - `Description string` A short description of the custom asset. - `LastUpdated Time` - `Name string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `SizeBytes int64` The size of the asset content in bytes. - `URL string` The URL where the asset content is fetched from. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.CustomPages.Assets.List(context.TODO(), custom_pages.AssetListParams{ }) 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": [ { "description": "Custom 500 error page", "last_updated": "2014-01-01T05:20:00.12345Z", "name": "my_custom_error_page", "size_bytes": 1024, "url": "https://example.com/error.html" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Get a custom asset `client.CustomPages.Assets.Get(ctx, assetName, query) (*AssetGetResponse, error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/assets/{asset_name}` Fetches the details of a custom asset. ### Parameters - `assetName string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `query AssetGetParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type AssetGetResponse struct{…}` - `Description string` A short description of the custom asset. - `LastUpdated Time` - `Name string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `SizeBytes int64` The size of the asset content in bytes. - `URL string` The URL where the asset content is fetched from. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) asset, err := client.CustomPages.Assets.Get( context.TODO(), "my_custom_error_page", custom_pages.AssetGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", asset.Description) } ``` #### 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": { "description": "Custom 500 error page", "last_updated": "2014-01-01T05:20:00.12345Z", "name": "my_custom_error_page", "size_bytes": 1024, "url": "https://example.com/error.html" } } ``` ## Create a custom asset `client.CustomPages.Assets.New(ctx, params) (*AssetNewResponse, error)` **post** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/assets` Creates a new custom asset. ### Parameters - `params AssetNewParams` - `Description param.Field[string]` Body param: A short description of the custom asset. - `Name param.Field[string]` Body param: The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `URL param.Field[string]` Body param: The URL where the asset content is fetched from. - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type AssetNewResponse struct{…}` - `Description string` A short description of the custom asset. - `LastUpdated Time` - `Name string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `SizeBytes int64` The size of the asset content in bytes. - `URL string` The URL where the asset content is fetched from. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) asset, err := client.CustomPages.Assets.New(context.TODO(), custom_pages.AssetNewParams{ Description: cloudflare.F("Custom 500 error page"), Name: cloudflare.F("my_custom_error_page"), URL: cloudflare.F("https://example.com/error.html"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", asset.Description) } ``` #### 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": { "description": "Custom 500 error page", "last_updated": "2014-01-01T05:20:00.12345Z", "name": "my_custom_error_page", "size_bytes": 1024, "url": "https://example.com/error.html" } } ``` ## Update a custom asset `client.CustomPages.Assets.Update(ctx, assetName, params) (*AssetUpdateResponse, error)` **put** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/assets/{asset_name}` Updates the configuration of an existing custom asset. ### Parameters - `assetName string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `params AssetUpdateParams` - `Description param.Field[string]` Body param: A short description of the custom asset. - `URL param.Field[string]` Body param: The URL where the asset content is fetched from. - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type AssetUpdateResponse struct{…}` - `Description string` A short description of the custom asset. - `LastUpdated Time` - `Name string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `SizeBytes int64` The size of the asset content in bytes. - `URL string` The URL where the asset content is fetched from. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) asset, err := client.CustomPages.Assets.Update( context.TODO(), "my_custom_error_page", custom_pages.AssetUpdateParams{ Description: cloudflare.F("Custom 500 error page"), URL: cloudflare.F("https://example.com/error.html"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", asset.Description) } ``` #### 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": { "description": "Custom 500 error page", "last_updated": "2014-01-01T05:20:00.12345Z", "name": "my_custom_error_page", "size_bytes": 1024, "url": "https://example.com/error.html" } } ``` ## Delete a custom asset `client.CustomPages.Assets.Delete(ctx, assetName, body) error` **delete** `/{accounts_or_zones}/{account_or_zone_id}/custom_pages/assets/{asset_name}` Deletes an existing custom asset. ### Parameters - `assetName string` The unique name of the custom asset. Can only contain letters (A-Z, a-z), numbers (0-9), and underscores (_). - `body AssetDeleteParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/custom_pages" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) err := client.CustomPages.Assets.Delete( context.TODO(), "my_custom_error_page", custom_pages.AssetDeleteParams{ }, ) if err != nil { panic(err.Error()) } } ```