---
title: Upload asset
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Pages](https://developers.cloudflare.com/api/go/resources/pages)

[Assets](https://developers.cloudflare.com/api/go/resources/pages/subresources/assets)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Upload asset

client.Pages.Assets.Upload(ctx, body) (\*[AssetUploadResponse](<https://developers.cloudflare.com/api/go/resources/pages#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)>), error)

POST/pages/assets/upload

Upload one or more files to the Pages asset store. Each file is identified by its content hash and is uploaded using the same JSON shape as the Cloudflare KV bulk write API. Used as part of the Pages Direct Upload workflow.

Authenticate with the JWT obtained from the upload-token endpoint: GET /accounts/{account\_id}/pages/projects/{project\_name}/upload-token

##### Security

##### ParametersExpand Collapse

<details>

<summary>

body AssetUploadParams

</summary>

<details>

<summary>

Body param.Field\[\[]AssetUploadParamsBody]

</summary>

Base64 bool

Whether value is base64 encoded.

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20base64">Link to this property</a>

Key string

File content hash used as the object key in the Pages asset store.

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20key">Link to this property</a>

<details>

<summary>

Metadata AssetUploadParamsBodyMetadata

</summary>

ContentType string

MIME type for the uploaded file.

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20metadata%20%3E%20(property)%20contentType">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20metadata">Link to this property</a>

Value string

File content. When base64 is true, this value is base64 encoded.

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20value">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default%20%3E%20(param)%20body">Link to this property</a>

</details>

[Link to this property](<#(resource)%20pages.assets%20%3E%20(method)%20upload%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type AssetUploadResponse struct{…}

</summary>

<details>

<summary>

Errors \[]AssetUploadResponseError

</summary>

Code int64

minimum1000

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors%20%3E%20(items)%20%3E%20(property)%20code">Link to this property</a>

Message string

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors%20%3E%20(items)%20%3E%20(property)%20message">Link to this property</a>

DocumentationURL stringOptional

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors%20%3E%20(items)%20%3E%20(property)%20documentation_url">Link to this property</a>

<details>

<summary>

Source AssetUploadResponseErrorsSourceOptional

</summary>

Pointer stringOptional

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors%20%3E%20(items)%20%3E%20(property)%20source%20%3E%20(property)%20pointer">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors%20%3E%20(items)%20%3E%20(property)%20source">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20errors">Link to this property</a>

<details>

<summary>

Messages \[]AssetUploadResponseMessage

</summary>

Code int64

minimum1000

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20code">Link to this property</a>

Message string

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20message">Link to this property</a>

DocumentationURL stringOptional

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20documentation_url">Link to this property</a>

<details>

<summary>

Source AssetUploadResponseMessagesSourceOptional

</summary>

Pointer stringOptional

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20source%20%3E%20(property)%20pointer">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20source">Link to this property</a>

</details>

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20messages">Link to this property</a>

Success AssetUploadResponseSuccess

Whether the API call was successful.

<a href="#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)%20%3E%20(property)%20success">Link to this property</a>

</details>

[Link to this property](<#(resource)%20pages.assets%20%3E%20(model)%20AssetUploadResponse%20%3E%20(schema)>)

### Upload asset

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/pages"
)

func main() {
  client := cloudflare.NewClient(

  )
  response, err := client.Pages.Assets.Upload(context.TODO(), pages.AssetUploadParams{
    Body: []pages.AssetUploadParamsBody{pages.AssetUploadParamsBody{
      Base64: cloudflare.F(true),
      Key: cloudflare.F("b026324c6904b2a9cb4b88d6d61c81d1"),
      Metadata: cloudflare.F(pages.AssetUploadParamsBodyMetadata{
        ContentType: cloudflare.F("text/plain"),
      }),
      Value: cloudflare.F("SGVsbG8sIFdvcmxkIQ=="),
    }},
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Errors)
}
```

200 example

```
{
  "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
}
```

##### Returns Examples

200 example

```
{
  "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
}
```