For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
      • Create an Asset
      • Get All Assets
      • Get Asset by ID
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • webflow.createAsset(fileBlob)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Errors
  • Designer ability
  • Limits
  • MIME types
AssetsCreating & Retrieving Assets

Create an Asset

Was this page helpful?
Previous

Get All Assets

Next
Built with

webflow.createAsset(fileBlob)

Create a new asset on your Webflow site.

This method is specifically for creating new assets - if you need to update an existing asset, use the set asset file method instead. Be sure to review the limits and MIME types sections to ensure your files meet the requirements.

Adding assets to pages

To add an asset to a page:

  1. Create an asset
  2. Create an image element
  3. Use the element.setAsset(asset) method to set the asset

Syntax

1webflow.createAsset(fileBlob:File): Promise<Asset>

Parameters

  • fileBlob:File - Represents a valid File to upload. Refer to the examples below for guidance on uploading an asset from a remote source and directly from a file picker.

Returns

Promise<Asset>

A Promise that resolves to the new Asset.

Example

Remote File
Direct Upload
1// Fetch image from remote source and build a Blob object
2 const response = await fetch(url)
3 const blob = await response.blob()
4 const file = new File([blob], fileName, {
5 type: 'image/png',
6 })
7
8 // Create and upload the asset to webflow
9 const asset = await webflow.createAsset(file);
10 console.log(asset)

Try this example

Errors

If the method fails to create an asset, the method will return an error with the following cause and message.

TagMessage
ResourceCreationFailedFailed to create asset for ${File.name}

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canManageAssetsanyanyanyany

Limits

Uploaded assets must adhere to specific size limitations:

  • Images must not exceed 4MB
  • Documents must not exceed 10MB

MIME types

Refer to the accepted MIME types listed below for compatibility. Pass Lottie files as application/json MIME types.

MIME Types
'image/jpeg'
'image/jpg'
'image/png'
'image/gif'
'image/svg+xml'
'image/bmp'
'image/webp'
'application/pdf'
'application/msword'
'application/vnd.ms-excel'
'application/vnd.ms-powerpoint'
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
'text/plain'
'text/csv'
'application/vnd.oasis.opendocument.text'
'application/vnd.oasis.opendocument.spreadsheet'
'application/vnd.oasis.opendocument.presentation'
'application/json'