Docs
/
/
Platform
Manage your account
Managing assets

Managing assets

Learn how to upload and manage assets for use in your notification templates.

Overview

#

Assets are files that you upload to Knock for use in your notification templates. You can upload images to be hosted by Knock and reference them via URL in your templates. This is useful for including logos, icons, and other visual elements in your notifications.

Account owners, admins, and members can manage assets from the Assets page under Content in the Knock dashboard sidebar. You can also manage assets with the Management API or the Knock CLI.

Assets are account-wide. An asset you upload is available in every environment.

Uploading assets

#

To upload a new asset:

  1. Navigate to Content > Assets in your dashboard sidebar.
  2. Click the "Upload image" button.
  3. Select one or more image files from your computer. You can upload up to 20 files at a time.

File requirements

#

Keep the following requirements in mind when uploading assets:

  • File size. Each image must be 5 MB or less.
  • File type. Only image files are supported. The dashboard accepts JPEG, PNG, GIF, and SVG files. The Management API and the CLI accept JPEG, PNG, and GIF files.

You can upload as many images as you need to your Knock account.

You can also upload an asset from the command line with knock asset upload.

Using assets in templates

#

Once you've uploaded an asset, you can copy its URL and use it in your notification templates. To copy the URL:

  1. Navigate to Content > Assets in the Knock dashboard.
  2. Find the asset you want to use.
  3. Click the copy button to copy the asset URL to your clipboard.

You can then paste this URL into your notification templates wherever you need to reference the image, such as in email templates or in-app notifications.

Deleting assets

#

To delete an asset:

  1. Navigate to Content > Assets in the Knock dashboard.
  2. Find the asset you want to delete.
  3. Click the delete button to remove the asset.

Managing assets with the Management API

#

The Management API enables you to upload, list, and archive image assets programmatically. The API accepts JPEG, PNG, and GIF files up to 5 MB.

Uploading an asset

#

Knock doesn't accept file bytes on the Management API itself. Instead, you upload the file directly to storage with a signed URL, then tell Knock to create the asset. Uploading an asset takes three requests:

1

Request an upload

Call the request an asset upload endpoint with the file's mime_type and its size in bytes as content_length. Knock returns an upload_url, a storage key, and an expires_in value. The upload URL expires after 300 seconds.

2

Upload the file

Send a PUT request with the file bytes to the upload_url. The URL's signature covers the Content-Type and Content-Length headers, so they must match the mime_type and content_length values from the response.

3

Create the asset

Call the create an asset endpoint with the key from the first request and a filename. Knock returns the asset, including its hosted url, which you can reference in your templates.

Listing assets

#

Use the list assets endpoint to retrieve a paginated list of the active assets in your account. Each entry includes the asset's id, filename, mime_type, and hosted url.

Archiving an asset

#

Use the archive an asset endpoint to archive an asset by its id. As with deleting an asset in the dashboard, you should update any templates that reference the asset before you archive it.

Frequently asked questions

#

Only image files are supported. The dashboard accepts JPEG, PNG, GIF, and SVG files. The Management API and the CLI accept JPEG, PNG, and GIF files.

There is no limit to the number of assets you can upload to your Knock account.

Each image file must be 5 MB or less.

Account owners, admins, and members can upload and manage assets.

New chat