Skip to main content

Page last updated 29 July 2026

Call the entries.createAsset() method to create an entry representing a new asset, uploading the file and creating the entry in a single operation.

Call signatures

TypeScript
createAsset(asset: Entry, assetFilePath: string, parentNodePath: string): Promise<Entry>

Parameters

NameTypeDescription
assetEntryThe entry that represents the asset, with a sys.dataFormat of "asset"
assetFilePathstringThe local file path of the asset to upload
parentNodePathstringThe node path in the project's file store where the asset will be placed

Returns

A Promise that will resolve with the created Entry

Remarks

The file is uploaded before the entry is created. A temporary fileId is returned from the upload and used as a file reference in the sysAssetFile field of the entry.

Throws any error that is returned by the API for an unsuccessful request echoing the HTTP status returned from the API.

Example

Create a new asset entry, providing the entry object with the required details and use it along with the local file path for the asset to upload
TypeScript
// Using TypeScript, or ES Module await syntax
const newAsset = {
  title: "Batman Returns",
  sys: {
    projectId: "movieDb",
    dataFormat: "asset",
  },
};

const asset = await client.entries.createAsset(
  newAsset,
  "./posters/batman-returns.jpg",
  "/image-library/movie-posters"
);

console.log(asset.sys.id);
console.log(asset.sysAssetFile?.fileId);
Create a new asset entry, providing the entry object with the required details and use it along with the local file path for the asset to upload
JavaScript
// Using Common JS promise callback syntax
const newAsset = {
  title: "Batman Returns",
  sys: {
    projectId: "movieDb",
    dataFormat: "asset",
  },
};

client.entries
  .createAsset(
    newAsset,
    "./posters/batman-returns.jpg",
    "/image-library/movie-posters"
  )
  .then(function (asset) {
    console.log(asset.sys.id);
    console.log(asset.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