Update an asset
Log in to add to favouritesPage last updated 29 July 2026
Call the entries.updateAsset() method to update the fields of an existing asset, or to replace the file that an asset represents.
Call signatures
updateAsset(asset: Entry): Promise<Entry>
updateAsset(asset: Entry, assetFilePath: string): Promise<Entry>
Parameters
| Name | Type | Description |
|---|---|---|
| asset | Entry | The entry representing the asset, with the updated fields and the existing sys metadata |
| assetFilePath | string | (optional) The local file path of a new file to upload and attach to the asset. Omit to update metadata only |
Returns
A Promise that will resolve with the updated Entry
Remarks
If assetFilePath is omitted or falsy, only the entry fields (e.g. title, description) are updated and the existing file is kept.
If assetFilePath is provided, the file is uploaded before the entry is updated. A temporary fileId is returned from the upload and set on the sysAssetFile field, replacing the previous file.
Throws any error that is returned by the API for an unsuccessful request echoing the HTTP status returned from the API.
Examples
Update an asset's metadata only
// Using TypeScript, or ES Module await syntax
const existingAsset = await client.entries.get("0484bd0b-86d3-4d26-ac97-67514add802b");
const updatedAsset = await client.entries.updateAsset({
...existingAsset,
title: "Batman Returns",
altText: "Batman Returns release poster",
});
console.log(updatedAsset.title);
// Using Common JS promise callback syntax
client.entries.get("0484bd0b-86d3-4d26-ac97-67514add802b")
.then(function (existingAsset) {
return client.entries.updateAsset({
...existingAsset,
title: "Batman Returns",
altText: "Batman Returns release poster",
});
})
.then(function (updatedAsset) {
console.log(updatedAsset.title);
});
Update an asset's file
// Using TypeScript, or ES Module await syntax
const existingAsset = await client.entries.get("0484bd0b-86d3-4d26-ac97-67514add802b");
const updatedAsset = await client.entries.updateAsset(
existingAsset,
"./posters/batman-returns-v2.jpg"
);
console.log(updatedAsset.sysAssetFile?.fileId);
// Using Common JS promise callback syntax
client.entries.get("0484bd0b-86d3-4d26-ac97-67514add802b")
.then(function (existingAsset) {
return client.entries.updateAsset(
existingAsset,
"./posters/batman-returns-v2.jpg"
);
})
.then(function (updatedAsset) {
console.log(updatedAsset.sysAssetFile?.fileId);
});