Create an asset
Log in to add to favouritesPage 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
createAsset(asset: Entry, assetFilePath: string, parentNodePath: string): Promise<Entry>
Parameters
| Name | Type | Description |
|---|---|---|
| asset | Entry | The entry that represents the asset, with a sys.dataFormat of "asset" |
| assetFilePath | string | The local file path of the asset to upload |
| parentNodePath | string | The 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
// 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);
// 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);
});