# 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()) } } ```