Docs
/
/

Assets mAPI reference

Complete reference documentation for the Assets resource.

Assets

#

Assets are files you upload to Knock for use in your notification templates. Assets are account-wide and are not scoped to an environment.

List assets

#

Returns a paginated list of active account assets. Assets are account-wide and do not require an environment parameter.

Endpoint

GET/v1/assets

Query parameters

after
string

The cursor to fetch entries after.

before
string

The cursor to fetch entries before.

limit
integer

The number of entries to fetch per-page.

Returns

PaginatedAssetResponse

A paginated list of Asset. Contains a list of entries and page information.

entries

A list of entries.

asset_type
string
Required

The type of asset.

created_at
string(date-time)
Required

The timestamp of when this asset was created.

filename
string

The human-readable filename for this asset.

id
string(uuid)
Required

The unique ID for this asset.

mime_type
string
Required

The MIME type for this asset.

updated_at
string(date-time)
Required

The timestamp of when this asset was last updated.

url
string
Required

The public URL for this asset.

page_info

The information about a paginated result.

after
string

The cursor to fetch entries after. Will only be present if there are more entries to fetch.

before
string

The cursor to fetch entries before. Will only be present if there are more entries to fetch before the current page.

page_size
integer

The number of entries to fetch per-page.

Archive an asset

#

Archives a library or template image asset by id. The stored file remains at its URL. Other asset types, unknown ids, and already archived assets are not found. Assets are account-wide and do not require an environment parameter.

Endpoint

DELETE/v1/assets/{asset_id}

Path parameters

asset_id
string(uuid)

The id of the asset to archive.

Returns

ArchiveAssetResponse

The response from archiving an asset.

result
string

The result of the archive operation.

Create an asset

#

Records a library asset after the file has been uploaded to the key from an upload request. The asset is always a library asset. Assets are account-wide and do not require an environment parameter.

Endpoint

POST/v1/assets

Request body

filename
string
Required

The display name for this asset.

key
string
Required

The storage key from the upload request. The file must already be uploaded.

Returns

An uploaded asset file for an account.

asset_type
string

The type of asset.

created_at
string(date-time)

The timestamp of when this asset was created.

filename
string

The human-readable filename for this asset.

id
string(uuid)

The unique ID for this asset.

mime_type
string

The MIME type for this asset.

updated_at
string(date-time)

The timestamp of when this asset was last updated.

url
string

The public URL for this asset.

Request an asset upload

#

Returns a time-limited URL for uploading an asset file. PUT the file bytes to upload_url with Content-Type and Content-Length from this response, then create the asset with the returned key. This request does not store an asset. Assets are account-wide and do not require an environment parameter.

Endpoint

POST/v1/assets/uploads

Request body

content_length
integer
Required

The file size in bytes. Maximum is 5 MB. The upload URL is signed for this length.

filename
string

The display name to echo back. The upload request does not store it. Send it again when creating the asset.

mime_type
string
Required

The MIME type of the file. One of image/jpeg, image/png, or image/gif.

Returns

AssetUpload

A time-limited permission to upload an asset file directly to storage.

content_length
integer

The byte length the PUT must send as Content-Length.

expires_in
integer

Seconds until the upload URL expires.

filename
string

The filename from the request, when one was sent.

key
string

The storage key to send when creating the asset.

mime_type
string

The MIME type the PUT must send as Content-Type.

upload_url
string

The URL to PUT the file bytes to. The signature covers Content-Type and Content-Length, and the PUT must send both.

Asset

#

An uploaded asset file for an account.

Attributes

asset_type
string

The type of asset.

created_at
string(date-time)

The timestamp of when this asset was created.

filename
string

The human-readable filename for this asset.

id
string(uuid)

The unique ID for this asset.

mime_type
string

The MIME type for this asset.

updated_at
string(date-time)

The timestamp of when this asset was last updated.

url
string

The public URL for this asset.

New chat