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

# Asset

## Asset

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

## uploadAsset

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

To upload assets from your local system to Contentstack and manage their details, you need to use the following "form-data" parameters:

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.uploadAsset("filePath", "description").execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The file path.

The description of the asset file.

Select the input type as 'File.' Then, browse and select the asset file that you want to import.

If needed, assign a parent folder to your asset by passing the UID of the parent folder.

Enter a title for your uploaded asset.

Assign a specific tag(s) to your uploaded asset.

Set this to 'true' to display the relative URL of the asset.

Set this to 'true' to include the dimensions (height and width) of the image in the response.

## updateDetails​

The "Update asset revision" call upgrades a specified version of an asset as the latest version of that asset.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONObject();
Call<ResponseBody> response = asset.updateDetails(body).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

JSON Request body.

## unpublish

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

In the case of Scheduled Unpublished, add the scheduled\_at key and provide the date/time in the ISO format as its value. Example: "scheduled\_at":"2016-10-07T12:34:36.000Z"

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset.unpublish(body).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

JSON Request body.

## subfolder

The "Get assets and folders of a parent folder" retrieves details of assets and asset subfolders within a specific parent asset folder.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset.subfolder("folderUid", True).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

Folder uid.

Provide true or false.

## setVersionName

The "Set version name for asset" request allows you to assign a name to a specific version of an asset.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset.setVersionName(3, body).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

Asset version number.

The request body of JSONObject.

## rteInformation

The "Get information on RTE assets" call returns comprehensive information on all assets uploaded through the Rich Text Editor field.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.rteInformation().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

## replace

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

Tip: You can try the call manually in any REST API client, such as Postman. Under Body, pass a body parameter named asset\[upload\] and select the input type as 'File'. This will enable you to select the file that you wish to import. You can assign a parent folder to your asset by using the asset\[parent\_uid\] parameter, where you can pass the UID of the parent folder. Additionally, you can pass optional parameters such as asset\[title\] and asset\[description\] which let you enter a title and a description for the uploaded asset, respectively.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.replace("filePath", "description").execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The file path.

The file description.

## getVersionNameDetails

The "Get details of all versions of an asset" request allows you to retrieve the details of all the versions of an asset.

The details returned include the actual version number of the asset; the version name along with details such as the assigned version name, the UID of the user who assigned the name, and the time when the version was assigned a name; and the count of the versions.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset. getVersionNameDetails().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

Enter the maximum number of version details to be returned.

Set to true if you want to retrieve only the named versions of your asset.

Enter 'true' to get the total count of the asset version details.

## getReferences

The "Get asset references" request returns the details of the entries and the content types in which the specified asset is referenced.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset. getReferences().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

## 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.

In case of Scheduled Publishing, add the scheduled\_at key and provide the date/time in the ISO format as its value. Example: "scheduled\_at":"2016-10-07T12:34:36.000Z"

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset.publish(body).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

JSON Request body.

## getPermanentUrl

The "Download an asset with a permanent URL" request displays an asset in the response. The asset returned to the response can be saved to your local storage system. Make sure to specify the unique identifier (slug) in the request URL.

This request will return the most recent version of the asset; however, to download the latest published version of the asset, pass the environment query parameter with the environment name.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.getPermanentUrl("slugUrl").execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The unique identifier of the asset.

## getByType

Based on the query request, "Get either images or videos" retrieves assets that are either image files or video files.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.getByType("assetType").execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

Asset type that you want to retrieve.

\- For images, "images"

\- For videos, "videos"

## generatePermanentUrl

Generate Permanent Asset URL request allows you to generate a permanent URL for an asset. This URL remains constant irrespective of any subsequent updates to the asset.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject body = new JSONBody();
Call<ResponseBody> response = asset.generatePermanentUrl(body).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The JSONObject request body.

## folder

Get folder instance.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.folder("folderUid").execute();
[OR]
Call<ResponseBody> response = asset.folder().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The UID of the folder that you want either to update or move.

## find

The "Get all assets" request returns comprehensive information on all assets available in a stack.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.find().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

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.

## fetch

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

**Tip**: To include the publishing details in the response, use the include\_publish\_details parameter and set its value to ‘true'. This query will return the publishing details of the entry in every environment, along with the version number published in each environment.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.fetch().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

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.

## deleteVersionName

The "Delete Version Name of an Asset" request allows you to delete the name assigned to a specific version of an asset. This request resets the name of the asset version to the version number.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.deleteVersionName(version).execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The asset version.

## delete

Delete asset call deletes an existing asset from the stack.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.delete().execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

## byFolderUid

The "Get assets of a specific folder" retrieves all assets of a specific asset folder; however, it doesn't retrieve the details of sub-folders within it.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
Call<ResponseBody> response = asset.byFolderUid("folderUid").execute();
if (response.isSuccessful){ 
    System.out.println("Response"+ response) 
}
```

The folderUid of a specific folder.

## removeParam

Set header for the request.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset().removeParam("key");
```

Removes query parameter using a key of request.

## addParam

The addParam method adds a query parameter to the Asset request for filtering or configuring the response (e.g., locale, publish details).

```
Value Handling in Requests:
Values are serialized to strings when sent over HTTP.Boolean: true/falseNumber: decimal string (e.g., 10, 3.14)String: sent as it isPass simple types that align with API expectations:String (e.g., "en-us")Boolean (e.g., true)Numeric types (Integer, Long, etc.)The value parameter must not be null.Additional Resource: Refer to the asset method for the complete list of query parameters that could be passed in the key.

Example
import com.contentstack.cms.Contentstack;
import com.contentstack.cms.stack.Asset;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Map<String, Object> headers = new HashMap<>();
headers.put("api_key", "<API_KEY>");
headers.put("authorization", "<MANAGEMENT_TOKEN>");
Contentstack client = new Contentstack.Builder().build();
Asset asset = client.stack(headers).asset("<ASSET_UID>");
asset.addParam("locale", "en-us");
asset.addParam("include_publish_details", true);
try {
    var response = asset.fetch().execute();
    if (response.isSuccessful()) {
        // Use response.body()
    }
} catch (IOException e) {
    // Handle error
}
```

Query parameter name sent with the request (for example, locale or include\_publish\_details). Set when building the request and applied to Asset methods such as find() and fetch().

Value assigned to the query parameter. Determines the behavior or filtering applied to the request (for example, "en-us" for locale, or true for include\_publish\_details).

## addHeader

Sets header for the request.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
asset.addHeader("key", value)
```

Header key for the request.

Header value for the request.

## fetchAsPojo

The fetchAsPojo method fetches a single asset by UID and deserializes it into a POJO.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset("asset_uid");
Response&glt;AssetResponse> response = asset.fetchAsPojo().execute();
if (response.isSuccessful() && response.body() != null) {
    AssetResponse assetResponse = response.body();
    AssetPojo pojo = assetResponse.getAssetPojo();
    System.out.println(" Asset URL: " + pojo.url);
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## findAsPojo

The findAsPojo method fetches multiple assets and deserializes them into POJOs.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Response<AssetListResponse> response = contentstack.stack().asset().findAsPojo().execute();
if (response.isSuccessful() && response.body() != null) {
    AssetListResponse assetListResponse = response.body();
    List<AssetPojo> assets = assetListResponse.getAssets();
    for (AssetPojo asset : assets) {
        System.out.println(" Asset UID: " + asset.uid);
    }
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## byFolderUidAsPojo

The byFolderUidAsPojo method retrieves all assets of a specific asset folder; however, it doesn't retrieve the details of sub-folders within it.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Response<AssetListResponse> response = contentstack.stack().asset().byFolderUidAsPojo("folder_uid").execute();
if (response.isSuccessful() && response.body() != null) {
    AssetListResponse assetListResponse = response.body();
    List<AssetPojo> assets = assetListResponse.getAssets();
    for (AssetPojo asset : assets) {
        System.out.println(" Asset UID: " + asset.uid);
    }
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## subfolderAsPojo

The subfolderAsPojo method retrieves details of assets and asset subfolders within a specific parent asset folder.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Response<AssetListResponse> response = contentstack.stack().asset().subfolderAsPojo("folder_uid", true).execute();
if (response.isSuccessful() && response.body() != null) {
    AssetListResponse assetListResponse = response.body();
    List<AssetPojo> assets = assetListResponse.getAssets();
    for (AssetPojo asset : assets) {
        System.out.println(" Asset Title: " + asset.title);
    }
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## getSingleFolderByNameAsPojo

The getSingleFolderByNameAsPojo method retrieves a folder by name and deserializes into POJOs.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject queryContent = new JSONObject();
        queryContent.put("is_dir", true);
        queryContent.put("name", "sub_folder");
        asset.addParam("query", queryContent);
Response<AssetListResponse> response =
asset.getSingleFolderByNameAsPojo().execute();
if (response.isSuccessful() && response.body() != null) {
    AssetListResponse assetListResponse = response.body();
 if (assetListResponse != null) {
    List<AssetPojo> assetPojos = assetListResponse.getAssets();
     for (AssetPojo assetPojo : assetPojos) {
    System.out.println(" Asset UID: " + assetPojo.uid);
    System.out.println(" Asset Title: " + assetPojo.title);          
        }
    }
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## getSubfolderAsPojo

The getSubfolderAsPojo method fetches all subfolders.

```
import contentstack; 

Contentstack contentstack = new Contentstack.Builder().build();
Asset asset = contentstack.stack().asset();
JSONObject queryContent = new JSONObject();
        queryContent.put("is_dir", true);  
        asset.addParam("folder", "blt4f46298330ee5f99");
        asset.addParam("include_folders", true);    
        asset.addParam("query", queryContent);

Response<AssetListResponse> response = asset.getSubfolderAsPojo().execute();
if (response.isSuccessful() && response.body() != null) {
    AssetListResponse assetListResponse = response.body();
    if (assetListResponse != null) {
    List<AssetPojo> assetPojos = assetListResponse.getAssets();
     for (AssetPojo assetPojo : assetPojos) {
    System.out.println(" Asset UID: " + assetPojo.uid);
    System.out.println(" Asset Title: " + assetPojo.title);          
        }
    }
} else {
    System.out.println("Error: " + response.errorBody().string());
}
```

## Asset | Java Management SDK | Contentstack

Asset refers to media files such as images, videos, PDFs, and audio uploaded to your Contentstack repository in the Java Management SDK.