Asset

View as Markdown

Asset

Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use.

Note Unlike entries, assets are not independently localizable via the .NET Management SDK. There is no dedicated asset-localize or asset-unlocalize method. To retrieve locale-specific asset metadata (title, description, alt text), pass a locale key via ParameterCollection when calling Fetch, FetchAsync, or Query.

Create

The Upload asset request uploads an asset file to your stack.

NameTypeDescription
model (required)AssetModel

Asset Model with details.

collectionParameterCollection

Query parameter collection

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

AssetModel model = new AssetModel("ASSET_NAME", "FILE_PATH", "FILE_CONTENT_TYPE");

ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset().Create(model);

CreateAsync

The Upload asset request uploads an asset file to your stack.

NameTypeDescription
model (required)AssetModel

Asset Model with details.

collectionParameterCollection

Query parameter collection

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

AssetModel model = new AssetModel("ASSET_NAME", "FILE_PATH", "FILE_CONTENT_TYPE");

ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset().CreateAsync(model);

Delete

The Delete asset call will delete an existing asset from the stack.

NameTypeDescription
collectionParameterCollection

Query parameter.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Delete();

DeleteAsync

The Delete asset call will delete an existing asset from the stack.

NameTypeDescription
collectionParameterCollection

Query parameter.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").DeleteAsync();

Fetch

The Get an asset call returns comprehensive information about a specific version of an asset of a stack.

Assets are not independently localizable like entries. To retrieve locale-specific asset metadata (title, description, alt text), pass a locale key via ParameterCollection.

NameTypeDescription
collectionParameterCollection

Query parameter.

localestring

Locale code (e.g. en-us, fr-fr) to scope the returned asset metadata to a specific language. Pass this as a key on collection.

include_asset_scan_statusboolean

When true, includes the _asset_scan_status field in the asset response (pending, clean, quarantined, or not_scanned). Opt-in, omitted from the request by default.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;

using Contentstack.Management.Core.Queryable;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");


// Fetch asset (returns master locale metadata)

ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Fetch();


// Fetch asset with a specific locale

ParameterCollection collection = new ParameterCollection();

collection.Add("locale", "en-us");

ContentstackResponse localizedResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Fetch(collection);

FetchAsync

The Get an asset call returns comprehensive information about a specific version of an asset of a stack.

Assets are not independently localizable like entries. To retrieve locale-specific asset metadata (title, description, alt text), pass a locale key via ParameterCollection.

NameTypeDescription
collectionParameterCollection

Query parameter.

localestring

Locale code (e.g. en-us, fr-fr) to scope the returned asset metadata to a specific language. Pass this as a key on collection.

include_asset_scan_statusBoolean

When true, includes the _asset_scan_status field in the asset response (pending, clean, quarantined, or not_scanned). Opt-in, omitted from the request by default.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;

using Contentstack.Management.Core.Queryable;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");


// Fetch asset (returns master locale metadata)

ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").FetchAsync();


// Fetch asset with a specific locale

ParameterCollection collection = new ParameterCollection();

collection.Add("locale", "en-us");

ContentstackResponse localizedResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").FetchAsync(collection);

Folder

The Folder allows to fetch and create folders in assets.

NameTypeDescription
uidstring

Optional folder unique id.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

Folder folder = client.Stack("<API_KEY>").Asset().Folder();

Publish

The Publish an asset call is used to publish a specific version of an asset on the desired environment either immediately or at a later date/time.

NameTypeDescription
details (required)PublishUnpublishDetails

Publish details for publishing asset.

apiVersionstring

API version to pass in headers. Pass the value 3.2 to use latest Publish API.

using Contentstack.Management.Core;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails();
ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Publish(new PublishUnpublishDetails(), apiVersion: "3.2");

 

 


PublishAsync

The Publish an asset call is used to publish a specific version of an asset on the desired environment either immediately or at a later date/time.

NameTypeDescription
details (required)PublishUnpublishDetails

Publish details for publishing asset.

apiVersionstring

API version to pass in headers. Pass the value 3.2 to use latest publish API.

using Contentstack.Management.Core;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails();
ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").PublishAsync(new PublishUnpublishDetails(), apiVersion: "3.2");

Query

The Query on Asset will allow to fetch details of all Assets. Pass a locale key via ParameterCollection to filter results to locale-specific asset metadata.

NameTypeDescription
localestring

Locale code (e.g. en-us, fr-fr) to scope the returned asset metadata to a specific language. Pass this as a key on the ParameterCollection given to Find.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;

using Contentstack.Management.Core.Queryable;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");


// Query all assets

Query query = client.Stack("<API_KEY>").Asset().Query();

ContentstackResponse response = query.Find();


// Query assets with a specific locale

ParameterCollection collection = new ParameterCollection();

collection.Add("locale", "en-us");

ContentstackResponse localizedResponse = query.Find(collection);

References

The References method retrieves the details of the entries and the content types in which the specified asset is referenced.

Example:
using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;



ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");



ContentstackResponse contentstackResponse = client

.Stack("<API_KEY>")

.Asset("<ASSET_UID>")

.References();

ReferencesAsync

The ReferencesAsync method retrieves the details of the entries and the content types in which the specified asset is referenced.

Example:
using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;



ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");



ContentstackResponse contentstackResponse = await client

.Stack("<API_KEY>")

.Asset("<ASSET_UID>")

.ReferencesAsync();

Unpublish

The Unpublish an asset call is used to unpublish a specific version of an asset from a desired environment.

NameTypeDescription
details (required)PublishUnpublishDetails

Publish details for un-publishing asset.

apiVerisonstring

API version to pass in headers. Pass the value 3.2 to use latest Unpublish API.

using Contentstack.Management.Core;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails();
ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Unpublish(new PublishUnpublishDetails(), apiVersion: "3.2");

UnpublishAsync

The Unpublish an asset call is used to unpublish a specific version of an asset from a desired environment.

NameTypeDescription
details (required)PublishUnpublishDetails

Publish details for un-publishing asset.

apiVersionstring

API version to pass in headers. Pass the value 3.2 to use latest Unpublish API.

using Contentstack.Management.Core;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails();
ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").UnpublishAsync(new PublishUnpublishDetails(), apiVersion: "3.2");

Update

The Replace asset call will replace an existing asset with another file on the stack.

NameTypeDescription
model (required)AssetModel

Asset Model with details.

collectionParameterCollection

Query parameter collection

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

AssetModel model = new AssetModel("ASSET_NAME", "FILE_PATH", "FILE_CONTENT_TYPE");

ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Update(model);

UpdateAsync

The Replace asset call will replace an existing asset with another file on the stack.

NameTypeDescription
model (required)AssetModel

Asset Model with details.

collectionParameterCollection

Query parameter collection

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

AssetModel model = new AssetModel("ASSET_NAME", "FILE_PATH", "FILE_CONTENT_TYPE");

ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").UpdateAsync(model);

Version

The Versioning on Asset will allow to fetch all version, delete specific version or naming the asset version.

NameTypeDescription
versionNumberint

Version number for the asset.

using Contentstack.Management.Core;

using Contentstack.Management.Core.Models;


ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

Version version = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").Version();