Skip to main content

Page 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

TypeScript
updateAsset(asset: Entry): Promise<Entry>

updateAsset(asset: Entry, assetFilePath: string): Promise<Entry>

Parameters

NameTypeDescription
assetEntryThe entry representing the asset, with the updated fields and the existing sys metadata
assetFilePathstring(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

Get an existing asset entry and use it in the asset update method, adding new values for title and altText to overwrite existing ones and include in the update
TypeScript
// 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);
Get an existing asset entry and use it in the asset update method, adding new values for title and altText to overwrite existing ones and include in the update
JavaScript
// 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

Get an existing asset entry and use it in the asset update method, adding the local path to the new asset to upload with the update
TypeScript
// 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);
Get an existing asset entry and use it in the asset update method, adding the local path to the new asset to upload with the update
JavaScript
// 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);
  });

Next steps

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request