---
title: "Asset"
description: "Asset"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/java/reference/asset"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-06"
---

# Asset

## Asset

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

These are the keys that can be passed for addParam.

Key

Value

Description

include\_fallback

boolean

Enter true to include published localized content from the fallback locale when the specified locale lacks published content.

include\_dimension

boolean

Set to true to include the image dimensions (height and width) in the response. Supported image formats include JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD.

include\_branch

boolean

Set to true to include the \_branch top-level key in the response. This key indicates the unique ID of the branch where the specified Contentstack module resides.

version

number

Enter the latest version number. Providing a draft version number will result in an empty response.

loorelative\_urlsb

string

Enter the language code for which you want to include entries. Only published, localized entries will be displayed.

## getUpdatedBy

Gets UpdatedBy object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getUpdatedBy();
```

## setHeader

Add header using key and value

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.setHeader("key","value");
```

The key you want to remove from the header

Value of the header against the key

## removeHeader

Removes header using key

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.removeHeader("key");
```

Key of the header you want to remove

## sort

Sort assets.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset()
asset.sort(keyOrderBy, ORDERBY.ASCENDING);
```

the key order by

the orderby can be applied using ORDERBY enums

## includeCount

Include count of asset.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset()
asset.includeCount();
```

## includeRelativeUrl

Include relative url asset.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset()
asset.includeRelativeUrl();
```

## includeFallback

Includes Fallback language in the asset response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeFallback();
```

## includeMetadata

Includes asset metadata along with response body.

```
Stack stack = Contentstack.stack("apiKey", "deliveryToken", environment_name);
Asset asset = stack.asset();
asset.includeMetadata();
```

## getCount

Returns list of all assets available in the stack.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset()
asset.getCount()
```

## getAssetUid

Gets AssetUid object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getAssetUid();
}
});
```

## getFileType

Gets FileType object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileType();
}
});
```

## getFileSize

Gets FileSize object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileSize();
}
});
```

## getFileName

Gets FileName object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 String filename = asset.getFileName();
}
});
```

## getUrl

Gets getUrl object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 String url = asset.getUrl();
 System.out.println(url);
}
});
```

## toJSON

Gets JSON object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.toJSON();
}
});
```

## getCreateAt

Gets CreateAt object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreateAt();
}
});
```

## getCreatedBy

Gets CreatedBy object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreatedBy();
}
});
```

## getUpdateAt

Gets UpdateAt object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getUpdateAt();
}
});
```

## getDeleteAt

Gets Deleted At object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getDeleteAt()
```

## getDeletedBy

Gets Deleted by object from the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getDeletedBy()
```

## getTags

Includes Array of tags in the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getTags()
```

## setTags

Includes Tags in the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.setTags()
```

## includeDimension

Inludes Dimension in the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeDimension();
```

## addParam

Add query parameter to the asset request

These are the keys that can be passed for addParam.

Key

Value

Description

include\_fallback

boolean

Enter true to include published localized content from the fallback locale when the specified locale lacks published content.

include\_dimension

boolean

Set to true to include the image dimensions (height and width) in the response. Supported image formats include JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD.

include\_branch

boolean

Set to true to include the \_branch top-level key in the response. This key indicates the unique ID of the branch where the specified Contentstack module resides.

version

number

Enter the latest version number. Providing a draft version number will result in an empty response.

relative\_urls

boolean

Set 'true' to include the relative URL of the asset in the response

include\_path

boolean

Set to true to add a path array to the response, displaying the hierarchical folder structure of the asset or folder.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Asset asset = stack.asset(assetUid).addParam();
```

Key of the header you want to add

Add value to the header against the header key

## includeBranch

Includes Branch in the asset response

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeBranch();
```

## fetch

Fetch all the assets available in the stack

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
  System.out.print(asset);
 }
}
```

callback of the asset response

## setLocale

The setLocale method sets the locale (language) for the asset request. Use before fetch() to request localized asset data.

```
Returns the same Asset instance for chaining (e.g., asset.setLocale("en-us").fetch(callback)).
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Asset asset = stack.asset("<ASSET_UID>");
asset.setLocale("en-us").fetch(new FetchResultCallback() {
    @Override
    public void onCompletion(ResponseType responseType, Error error) {
        if (error != null) return;
        String lang = asset.getLocale();
    }
});
```

## getLocale

The getLocale method returns the locale (language) of the asset. This value is obtained from the response after the asset is fetched and configured.

```
Returns the locale of the asset (for example, en-us). This value returns null if the asset has not been fetched or if the response does not include a locale. The SDK sets this value automatically when it applies the fetch response.
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Asset asset = stack.asset("<ASSET_UID>");
asset.fetch(new FetchResultCallback() {
    @Override
    public void onCompletion(ResponseType responseType, Error error) {
        if (error != null) return;
        String locale = asset.getLocale();
    }
});
```

## assetFields

The assetFields method acts as a filter for the API response, ensuring you get exactly the asset metadata you need. It specifies the asset-related field groups to include in the API response when you fetch a single entry.

**Note:** The assetFields method is supported only in the North America (NA) region.

```
Supported values
user_defined_fields: Custom metadata and other user-defined asset fields for assets included with this entry.embedded: Embedded asset payload for assets referenced from this entryai_suggested: AI-suggested asset metadata where applicable for assets in this entry.visual_markups: Visual markup data for assets referenced from this entry.Behavior:
Multiple calls: The last call overrides previous values.No arguments or null: Omits the asset_fields[] parameter; the API returns default fields.Fetch a single entry with specific asset fields.
Use this when you know the entry UID and want to fetch its assets.
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Entry entry = stack
    .contentType("blog_post")
    .entry("entry_uid")
    .assetFields("user_defined_fields", "embedded", "ai_suggested", "visual_markups");

entry.fetch(new EntryResultCallBack() {
    @Override
    public void onCompletion(ResponseType responseType, Error error) {
        if (error == null) {
            // Use entry data
        } else {
            // Handle error
        }
    }
});Query multiple entries with asset fields
Use this when fetching a list of entries (e.g., a blog feed) to ensure all returned entries include the specified asset metadata.
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Query query = stack
    .contentType("blog_post")
    .query()
    .assetFields("user_defined_fields", "embedded");
query.find(new QueryResultsCallBack() {
    @Override
    public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
        if (error == null) {
            // Use queryResult.getResultObjects() for the list of entries
        } else {
            // Handle error
        }
    }
});
```

One or more asset field groups to include in the response.

## Config

## Asset | Java Delivery SDK | Contentstack

Asset retrieves uploaded files such as images, videos, and PDFs stored in your stack using the Contentstack Java Delivery SDK.