---
title: "Stack"
description: "Stack"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/java/reference/stack"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-13"
---

# Stack

## Stack

A Stack holds the credentials and settings for one [stack](/docs/headless-cms/about-stack) and environment. Every request in the Java Delivery SDK starts from it.

Use this class to

*   create the objects that fetch content, such as a content type, an asset or a taxonomy
*   list the content types of the stack
*   [synchronize](/docs/developers/apis/content-delivery-api/synchronization) the published content of an environment with your app, and fetch later changes only
*   load a draft entry for live preview
*   add or remove request headers
*   build an image transformation URL

## asset

asset creates an [Asset](/docs/developers/sdks/content-delivery-sdk/java/reference/asset) object for one asset, which fetches that asset's details and URL.

```
Returns: Asset. A new asset object.
ValidationThere is no client-side validation. asset accepts null and an empty string, despite the @NotNull annotation.Errors that do occur come from the fetch() call that follows, not from asset(). An unknown UID surfaces as an Error in the callback of Asset.fetch.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. asset sends no request.Each call returns a new Asset. The new object uses the stack's header map, so a header you set on the stack applies to its requests.Asset.fetch calls Get a single asset and fills the same Asset object with the result.Use the assetLibrary method to list several assets.ExampleBasic usage: fetch an asset and print its URLimport com.contentstack.sdk.Asset;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.FetchResultCallback;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

public class FetchAsset {
    public static void main(String[] args) throws IllegalAccessException {
        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) {
                    // The API rejected the request, for example for an unknown UID, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                // fetch fills the same Asset object
                System.out.println(asset.getFileName() + " " + asset.getUrl());
            }
        });
    }
}
```

UID of the asset to fetch.

## assetLibrary

assetLibrary creates an [AssetLibrary](/docs/developers/sdks/content-delivery-sdk/java/reference/assetlibrary) object, which lists the assets published to the environment.

```
Returns: AssetLibrary. A new asset library object.
ValidationThere is no client-side validation, because assetLibrary takes no arguments.Errors that do occur come from the fetchAll() call that follows, not from assetLibrary().Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. assetLibrary sends no request.Each call returns a new AssetLibrary with no filters. The new object uses the stack's header map, so a header you set on the stack applies to its requests.AssetLibrary.fetchAll calls Get all assets. Chain filters such as limit and skip on the result before fetchAll.ExampleBasic usage: list the first ten assetsimport com.contentstack.sdk.Asset;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.FetchAssetsCallback;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

import java.util.List;

public class ListAssets {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.assetLibrary().limit(10).fetchAll(new FetchAssetsCallback() {
            @Override
            public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                for (Asset asset : assets) {
                    System.out.println(asset.getAssetUid() + " " + asset.getFileName());
                }
            }
        });
    }
}
```

## contentType

contentType creates a [ContentType](/docs/developers/sdks/content-delivery-sdk/java/reference/contenttype) object for one content type, which fetches the content type schema or opens its entries.

```
Returns: ContentType. A new content type object.
ValidationThere is no client-side validation. contentType accepts null and an empty string.Errors that do occur come from the request method you call on the result, not from contentType().ContentType.fetch throws IllegalAccessException before any request if contentTypeUid is null or empty, because it fetches one content type by UID.An unknown UID surfaces as an Error in the callback of ContentType.fetch, Entry.fetch or Query.find.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. contentType sends no request.Each call returns a new ContentType. The new object uses the stack's header map, so a header you set on the stack applies to its requests.Call entry("<ENTRY_UID>") on the result to fetch one entry, query() to find entries, or fetch to read the content type schema.ExampleBasic usage: fetch the schema of a content typeimport com.contentstack.sdk.ContentType;
import com.contentstack.sdk.ContentTypesCallback;
import com.contentstack.sdk.ContentTypesModel;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import org.json.JSONObject;

public class FetchContentTypeSchema {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        ContentType contentType = stack.contentType("<CONTENT_TYPE_UID>");

        // fetch throws IllegalAccessException when the content type UID is null or empty
        contentType.fetch(new JSONObject(), new ContentTypesCallback() {
            @Override
            public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
                if (error != null) {
                    // The API rejected the request, for example for an unknown UID, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                JSONObject schema = (JSONObject) contentTypesModel.getResponse();
                System.out.println(schema.optString("title"));
            }
        });
    }
}Find the entries of a content typeimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Entry;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.QueryResult;
import com.contentstack.sdk.QueryResultsCallBack;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

public class FindContentTypeEntries {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.contentType("<CONTENT_TYPE_UID>").query().limit(5).find(new QueryResultsCallBack() {
            @Override
            public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
                if (error != null) { System.out.println(error.getErrorMessage()); return; }
                for (Entry entry : queryresult.getResultObjects()) {
                    System.out.println(entry.getUid() + " " + entry.getTitle());
                }
            }
        });
    }
}
```

UID of the content type to open.

## getApplicationKey

getApplicationKey returns the API key of the stack.

```
Returns: String. The stack's API key.
ValidationThere is no client-side validation, because getApplicationKey takes no arguments and cannot fail.BehaviorClient-side only. getApplicationKey sends no request.getApplicationKey returns the API key you passed to Contentstack.stack. Contentstack.stack removes leading and trailing spaces from this copy of the key.The value does not follow the api_key header. A later setHeader or removeHeader call on api_key changes the requests but not this value.ExampleBasic usage: print the API key of a stackimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Stack;

public class PrintApiKey {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        System.out.println(stack.getApplicationKey());
    }
}
```

## getContentTypes

getContentTypes lists the content types of the stack, with their schemas, and passes them to the callback.

```
Returns: void. The result arrives in the callback.
ValidationThere is no client-side validation of the keys or values in params.getContentTypes throws NullPointerException if params is null, despite the @NotNull annotation, because it reads the keys of the object.getContentTypes sends no request if callback is null.The SDK does not throw on an API rejection. callback receives null for the model and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorgetContentTypes sends one request to Get all content types (GET /content_types).When the stack has an environment header, getContentTypes adds two keys to params before it sends the request:environment, with the value of the header.include_count, with the value true. The API reference lists include_count as required on this request.getContentTypes writes these keys into the JSONObject you pass. Pass a new object on each call if you reuse it for anything else.getContentTypes sends each key of params as a key=value query parameter. The SDK writes each value with toString() and does not URL-encode it. Encode a value that holds a reserved character, such as & or a space.Pass include_global_field_schema set to true in params to return the schema of each Global field inside the content type schema, as the Get all content types reference describes.On success, callback receives a ContentTypesModel.getResultArray() returns a JSONArray with one JSONObject per content type.getResponse() returns the same list as an Object.The model holds only the content_types array. It does not keep count or any other top-level key of the response.ExampleBasic usage: list the content types of the stackimport com.contentstack.sdk.ContentTypesCallback;
import com.contentstack.sdk.ContentTypesModel;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import org.json.JSONArray;
import org.json.JSONObject;

public class ListContentTypes {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.getContentTypes(new JSONObject(), new ContentTypesCallback() {
            @Override
            public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                JSONArray contentTypes = contentTypesModel.getResultArray();
                for (int i = 0; i < contentTypes.length(); i++) {
                    JSONObject contentType = contentTypes.getJSONObject(i);
                    System.out.println(contentType.optString("uid") + " " + contentType.optString("title"));
                }
            }
        });
    }
}All parameters: include Global field schemasimport com.contentstack.sdk.ContentTypesCallback;
import com.contentstack.sdk.ContentTypesModel;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import org.json.JSONObject;

public class ListContentTypesWithSchema {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        JSONObject params = new JSONObject();
        params.put("include_global_field_schema", true);

        stack.getContentTypes(params, new ContentTypesCallback() {
            @Override
            public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
                if (error != null) { System.out.println(error.getErrorMessage()); return; }
                System.out.println("Content types: " + contentTypesModel.getResultArray().length());
            }
        });
    }
}
```

Query parameters to send. Pass an empty object for none.

Receives the content types or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## getDeliveryToken

getDeliveryToken returns the delivery token that the stack sends in the access\_token header.

```
Returns: String. The stack's delivery token.
ValidationThere is no client-side validation, because getDeliveryToken takes no arguments.getDeliveryToken returns null after removeHeader("access_token"), because it reads the current header value.BehaviorClient-side only. getDeliveryToken sends no request.getDeliveryToken reads the access_token header of the stack at the time of the call.It returns the token you passed to Contentstack.stack until you change the header.After setHeader("access_token", ...), it returns the new value.Treat the returned value as a secret. Do not log it or send it to a browser.ExampleBasic usage: check which token the stack sendsimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Stack;

public class CheckDeliveryToken {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        String token = stack.getDeliveryToken();
        // Compare the token instead of printing it
        System.out.println("Token is set: " + (token != null && !token.isEmpty()));
    }
}
```

## globalField

globalField creates a [GlobalField](/docs/developers/sdks/content-delivery-sdk/java/reference/global-fields) object for one global field, or for all the global fields of the stack.

```
Returns: GlobalField. A new global field object.
OverloadsglobalField(String globalFieldUid)globalField(): This overload takes no parameters. Call findAll on the result to list every global field.ValidationThere is no client-side validation. globalField accepts null and an empty string, despite the @NotNull annotation.Errors that do occur come from the request method you call on the result, not from globalField().GlobalField.fetch throws IllegalAccessException before any request if the object holds no UID, because it fetches one global field. A GlobalField from globalField() holds no UID, so call findAll on it instead.An unknown UID surfaces as an Error in the callback of GlobalField.fetch.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. globalField sends no request.Each call returns a new GlobalField. The new object uses the stack's header map, so a header you set on the stack applies to its requests.globalField("<GLOBAL_FIELD_UID>") leads to fetch, which calls Get a single global field.globalField() leads to findAll, which calls Get all global fields.ExampleBasic usage: fetch one global fieldimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.GlobalField;
import com.contentstack.sdk.GlobalFieldsCallback;
import com.contentstack.sdk.GlobalFieldsModel;
import com.contentstack.sdk.Stack;

public class FetchGlobalField {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        GlobalField globalField = stack.globalField("<GLOBAL_FIELD_UID>");

        // fetch throws IllegalAccessException when the global field UID is null or empty
        globalField.fetch(new GlobalFieldsCallback() {
            @Override
            public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
                if (error != null) {
                    // The API rejected the request, for example for an unknown UID, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println(globalFieldsModel.getResponse());
            }
        });
    }
}All overloads: list every global fieldimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.GlobalFieldsCallback;
import com.contentstack.sdk.GlobalFieldsModel;
import com.contentstack.sdk.Stack;

public class ListGlobalFields {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        // globalField() holds no UID, so call findAll on it
        stack.globalField().findAll(new GlobalFieldsCallback() {
            @Override
            public void onCompletion(GlobalFieldsModel globalFieldsModel, Error error) {
                if (error != null) { System.out.println(error.getErrorMessage()); return; }
                System.out.println("Global fields: " + globalFieldsModel.getResultArray().length());
            }
        });
    }
}
```

UID of the global field to fetch.

## imageTransform

imageTransform appends [Image Delivery API](/docs/developers/apis/image-delivery-api/resize-images#resize-image-width) parameters to an image URL, so the URL returns a resized, converted or compressed image.

```
Returns: String. The image URL with the transformation parameters.
ValidationThere is no client-side validation of parameter names or values. imageTransform appends whatever the map holds.imageTransform throws NullPointerException if parameters is null, despite the @NotNull annotation, because it checks whether the map is empty.imageTransform throws NullPointerException if imageUrl is null and parameters is not empty.The Image Delivery API, not the SDK, rejects an invalid value when the app loads the URL. Each parameter section of the Image Delivery API reference lists its accepted values, for example Quality accepts a whole number from 1 to 100.BehaviorClient-side only. imageTransform sends no request. It returns a URL for your app or browser to load.With an empty map, imageTransform returns imageUrl unchanged.Otherwise, it joins the entries as key=value pairs with & and appends them to imageUrl.It starts with ? when imageUrl has no ?, and with & when it already has a query string.It writes each value with toString() and does not URL-encode keys or values. Encode a value that holds a reserved character, such as &, # or a space.The order of the pairs follows the map's iteration order. Use a LinkedHashMap to keep the order you add them in.Common parameters include width and height from Resize Images, format from Convert Formats, and quality.ExampleBasic usage: resize and convert a fetched assetimport com.contentstack.sdk.Asset;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.FetchResultCallback;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

import java.util.LinkedHashMap;
import java.util.Map;

public class ResizeAssetImage {
    public static void main(String[] args) throws IllegalAccessException {
        final Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        final Asset asset = stack.asset("<ASSET_UID>");

        asset.fetch(new FetchResultCallback() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) {
                    // The API rejected the asset request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                Map<String, Object> parameters = new LinkedHashMap<>();
                parameters.put("width", 300);
                parameters.put("format", "webp");
                parameters.put("quality", 80);

                // For example: <asset URL>?width=300&format=webp&quality=80
                System.out.println(stack.imageTransform(asset.getUrl(), parameters));
            }
        });
    }
}Edge case: add parameters to a URL that already has a query stringimport com.contentstack.sdk.Asset;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.FetchResultCallback;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

import java.util.Collections;

public class AppendTransformParameters {
    public static void main(String[] args) throws IllegalAccessException {
        final Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        final Asset asset = stack.asset("<ASSET_UID>");

        asset.fetch(new FetchResultCallback() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) { System.out.println(error.getErrorMessage()); return; }

                // The first call starts the query string with ?
                String resized = stack.imageTransform(asset.getUrl(), Collections.<String, Object>singletonMap("width", 600));
                // The second call sees the ? and appends with &
                String sharpened = stack.imageTransform(resized, Collections.<String, Object>singletonMap("sharpen", "a2,r1000,t2"));
                System.out.println(sharpened);
            }
        });
    }
}
```

URL of the image, such as an asset URL.

Image Delivery API parameter names and values.

## livePreviewQuery

livePreviewQuery fetches the draft entry that a live preview session shows. Later fetches of that entry from the stack return the draft.

```
Returns: Stack. The same stack, for chaining.
ValidationlivePreviewQuery declares throws IOException, a checked exception, so catch it or declare it on the calling method.livePreviewQuery throws IllegalStateException in four cases, because it cannot build or send the preview request:The Config did not enable live preview with enableLivePreview before Contentstack.stack ran.The live preview host is empty.query has no content_type_uid key.The preview request fails with a network error.livePreviewQuery throws java.lang.IllegalAccessError when the live preview host is rest-preview.contentstack.com and the Config holds no preview token. IllegalAccessError is an Error, not an Exception, so a catch (Exception e) block does not catch it. Set the token with setPreviewToken before you call Contentstack.stack.livePreviewQuery throws NullPointerException if query is null, or if you turned live preview on in the Config after Contentstack.stack ran.livePreviewQuery does not report an API rejection. When the preview request returns an error status, it clears the stored draft and returns normally, and later fetches return published content.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorlivePreviewQuery reads five keys from query:content_type_uid and entry_uid name the entry to preview.live_preview holds the preview hash. The SDK sends it in the live_preview header when it is not empty.release_id and preview_timestamp go to the public Config fields releaseId and previewTimestamp, or set them to null when absent. No request in the Java Delivery SDK sends these two values.livePreviewQuery sends one request to https://<live preview host>/v3/content_types/<content_type_uid>/entries/<entry_uid>. The request carries only these headers:api_key from the stack.live_preview with the hash.preview_token when the host is exactly rest-preview.contentstack.com, or authorization with the management token from setManagementToken for any other host.The request does not send the stack's branch or environment headers.When query has no entry_uid key, livePreviewQuery sends the request with null as the entry UID.On success, the SDK stores the draft entry in the Config.A later Entry.fetch for the same content type and entry UID returns the draft without a request.A later entry or query response that holds an entry with the same UID gets the draft in its place.Each livePreviewQuery call replaces the stored draft. Call it again on every preview request.Contentstack.stack builds the preview host once, from the host you set with setLivePreviewHost and the region:For US, the SDK uses the host as given.For any other region, the SDK adds the lowercase region name and a hyphen, for example eu-rest-preview.contentstack.com for EU. Pass the host without a region prefix.Known issue: Outside the US region, the SDK sends the management token instead of the preview token. For AZURE_NA, AZURE_EU, GCP_NA and GCP_EU, the preview host also keeps the underscore, for example azure_na-rest-preview.contentstack.com. Workaround: keep the region US, set both regional hosts in full with setHost and setLivePreviewHost, and use a management token.ExampleBasic usage: load the draft entry and fetch itimport com.contentstack.sdk.Config;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Entry;
import com.contentstack.sdk.EntryResultCallBack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class LoadLivePreview {
    public static void main(String[] args) throws IllegalAccessException, IOException {
        Config config = new Config()
                .enableLivePreview(true)
                .setLivePreviewHost("rest-preview.contentstack.com")
                .setPreviewToken("<PREVIEW_TOKEN>");
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>", config);

        // In a web app, copy these values from the query string of the preview request
        Map<String, String> query = new HashMap<>();
        query.put("live_preview", System.getenv("LIVE_PREVIEW_HASH"));
        query.put("content_type_uid", "<CONTENT_TYPE_UID>");
        query.put("entry_uid", "<ENTRY_UID>");
        stack.livePreviewQuery(query);

        Entry entry = stack.contentType("<CONTENT_TYPE_UID>").entry("<ENTRY_UID>");
        entry.fetch(new EntryResultCallBack() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                // The draft title when the preview request succeeded, else the published title
                System.out.println(entry.getTitle());
            }
        });
    }
}Edge case: preview in the Azure North America region with a management tokenimport com.contentstack.sdk.Config;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Stack;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class LivePreviewAzureNorthAmerica {
    public static void main(String[] args) throws IllegalAccessException, IOException {
        // Keep the region US so the SDK adds no prefix, and set both hosts in full
        Config config = new Config()
                .enableLivePreview(true)
                .setLivePreviewHost(Contentstack.getContentstackEndpoint("azure-na", "preview", true))
                .setManagementToken("<MANAGEMENT_TOKEN>");
        config.setHost(Contentstack.getContentstackEndpoint("azure-na", "contentDelivery", true));
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>", config);

        Map<String, String> query = new HashMap<>();
        query.put("live_preview", System.getenv("LIVE_PREVIEW_HASH"));
        query.put("content_type_uid", "<CONTENT_TYPE_UID>");
        query.put("entry_uid", "<ENTRY_UID>");
        try {
            stack.livePreviewQuery(query);
        } catch (IllegalStateException e) {
            // Thrown for missing live preview settings, a missing content_type_uid, or a network failure
            System.out.println("Live preview failed: " + e.getMessage());
        }
    }
}
```

Query parameters that the preview frame sends to your app.

## removeHeader

removeHeader removes a request header from the stack, so later requests no longer send it.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation. removeHeader does nothing if the stack has no header named headerKey, including for null.Removing a header that the API needs, such as api_key or access_token, does not fail here. The next request returns an Error in its callback.BehaviorClient-side only. removeHeader sends no request.Header names are case-sensitive. removeHeader("Branch") does not remove a header named branch.removeHeader changes the stack's header map, which every object created from the stack also uses. The header disappears from later requests from all of them, including objects you created before the call.Removing environment has two more effects:The sync methods and getContentTypes stop sending the environment query parameter.getContentTypes also stops adding include_count.ExampleBasic usage: stop sending a branch headerimport com.contentstack.sdk.Config;
import com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Entry;
import com.contentstack.sdk.EntryResultCallBack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

public class RemoveBranchHeader {
    public static void main(String[] args) throws IllegalAccessException {
        Config config = new Config();
        config.setBranch("<BRANCH>");
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>", config);

        // Later requests read from the default branch
        stack.removeHeader("branch");

        Entry entry = stack.contentType("<CONTENT_TYPE_UID>").entry("<ENTRY_UID>");
        entry.fetch(new EntryResultCallBack() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println(entry.getTitle());
            }
        });
    }
}
```

Name of the header to remove.

## setHeader

setHeader adds a request header to the stack, or replaces the value of an existing one, for every later request.

```
Returns: void. This method returns nothing.
ValidationsetHeader ignores the call without an error if headerKey or headerValue is an empty string, because it adds a header only when both have a value.setHeader throws NullPointerException if headerKey or headerValue is null, despite the @NotNull annotation, because it checks the length of both.setHeader does not check the header name or value against the API. A wrong value surfaces as an Error in the callback of the next request.BehaviorClient-side only. setHeader sends no request.setHeader writes to the stack's header map, which every object created from the stack also uses. The header applies to later requests from the stack, its content types, entries, queries, assets, asset libraries, global fields and taxonomies, including objects you created before the call.A second call with the same headerKey replaces the value.setHeader can replace the headers that Contentstack.stack set, such as access_token or environment.The sync methods and getContentTypes read the environment header when you call them, so a new value also changes their environment query parameter.Use the removeHeader method to stop sending a header.ExampleBasic usage: send the branch header from codeimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Entry;
import com.contentstack.sdk.EntryResultCallBack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

public class SetBranchHeader {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        stack.setHeader("branch", "<BRANCH>");

        Entry entry = stack.contentType("<CONTENT_TYPE_UID>").entry("<ENTRY_UID>");
        entry.fetch(new EntryResultCallBack() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) {
                    // The API rejected the request, for example for an unknown branch, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println(entry.getTitle());
            }
        });
    }
}Edge case: an empty value does not change the headerimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Stack;

public class EmptyHeaderValue {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        // setHeader ignores an empty value, so the stack keeps the original token
        stack.setHeader("access_token", "");
        System.out.println("Token unchanged: " + "<DELIVERY_TOKEN>".equals(stack.getDeliveryToken()));
    }
}
```

Name of the header to add.

Value to send in the header.

## sync

sync starts an initial sync, which returns the published entries and assets of the environment, either all of them or the ones that match four filters.

```
Returns: void. The result arrives in the callback.
Overloadssync(SyncResultCallBack syncCallBack)sync(String contentType, Date fromDate, String localeCode, Stack.PublishType publishType, SyncResultCallBack syncCallBack)ValidationThere is no client-side validation of the content type UID or the locale code.The five-argument overload throws NullPointerException if fromDate or publishType is null, because it formats the date and reads the enum name before the request.The five-argument overload leaves out the content_type_uid or locale parameter when contentType or localeCode is null. The org.json JSONObject.put method drops a key whose value is null.sync sends no request if syncCallBack is null.The SDK does not throw on an API rejection. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
Behaviorsync sends one request to Initial Sync (GET /stacks/sync) with init=true and the stack's environment value.The five-argument overload adds four query parameters:content_type_uid from contentType.start_from from fromDate, written in UTC as yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example 2026-01-01T00:00:00.000Z.locale from localeCode.type from publishType.Known issue: The five-argument overload sends type in upper case, for example ENTRY_PUBLISHED. The syncPublishType method and the SDK's own documentation use lower case, for example entry_published. To filter by publish type, call syncPublishType and filter the other values in your code.The SDK sends the parameters as key=value pairs without URL encoding.syncCallBack receives a SyncStack. getItems() returns the items in this response, which the API caps at 100.When more items remain, getPaginationToken() returns a token. Pass it to the syncPaginationToken method. The SDK does not request the next page.On the last page, getSyncToken() returns a token. Store it and pass it to the syncToken method later to receive only the changes.Each call replaces the sync parameters that the stack holds. Run one sync at a time on a Stack that several threads share.ExampleBasic usage: sync all published contentimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;
import org.json.JSONObject;

public class InitialSync {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.sync(new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                for (JSONObject item : syncStack.getItems()) {
                    // Each item is one JSON object from the Sync API response
                    System.out.println(item.toString());
                }
                System.out.println("Pagination token: " + syncStack.getPaginationToken());
                System.out.println("Sync token: " + syncStack.getSyncToken());
            }
        });
    }
}All parameters: sync one content type, locale and date rangeimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

import java.time.Instant;
import java.util.Date;

public class FilteredInitialSync {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        Date fromDate = Date.from(Instant.parse("2026-01-01T00:00:00Z"));

        // This overload sends type=ENTRY_PUBLISHED in upper case. See the Known issue above.
        stack.sync("<CONTENT_TYPE_UID>", fromDate, "<LOCALE>", Stack.PublishType.ENTRY_PUBLISHED,
                new SyncResultCallBack() {
                    @Override
                    public void onCompletion(SyncStack syncStack, Error error) {
                        if (error != null) { System.out.println(error.getErrorMessage()); return; }
                        System.out.println("Items: " + syncStack.getItems().size());
                    }
                });
    }
}
```

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

UID of the content type whose entries to sync.

Earliest publish date to sync from.

Locale code to sync, such as "en-us".

Type of item to sync, such as ENTRY\_PUBLISHED.

## syncContentType

syncContentType starts an initial sync of the published entries of one content type.

```
Returns: void. The result arrives in the callback.
ValidationThere is no client-side validation of contentType, despite the @NotNull annotation.When contentType is null, syncContentType sends a sync of all content with no content_type_uid parameter. The org.json JSONObject.put method drops a key whose value is null. Check the UID before you pass it.syncContentType sends no request if syncCallBack is null.The SDK does not throw on an API rejection, such as an unknown content type. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncContentType sends one request to Initial Sync (GET /stacks/sync) with init=true, content_type_uid and the stack's environment value.The result pages like any other sync. Pass getPaginationToken() to the syncPaginationToken method until the last page returns a sync token. The SDK does not request the next page.Use the five-argument sync overload to combine a content type with a date, locale and publish type.ExampleBasic usage: sync the entries of one content typeimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

public class SyncOneContentType {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.syncContentType("<CONTENT_TYPE_UID>", new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Items in this page: " + syncStack.getItems().size());
                System.out.println("Sync token: " + syncStack.getSyncToken());
            }
        });
    }
}
```

UID of the content type whose entries to sync.

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## syncFromDate

syncFromDate starts an initial sync of the entries and assets published on or after a date.

```
Returns: void. The result arrives in the callback.
ValidationsyncFromDate throws NullPointerException if fromDate is null, because it formats the date before the request.syncFromDate does not check the date range. A date in the future sends the request as given.syncFromDate sends no request if syncCallBack is null.The SDK does not throw on an API rejection. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncFromDate sends one request to Initial Sync (GET /stacks/sync) with init=true, start_from and the stack's environment value.syncFromDate writes start_from in UTC as yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example 2026-01-01T00:00:00.000Z, whatever the time zone of the JVM.The result pages like any other sync. Pass getPaginationToken() to the syncPaginationToken method until the last page returns a sync token. The SDK does not request the next page.Use the five-argument sync overload to combine a date with a content type, locale and publish type.ExampleBasic usage: sync content published since a dateimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

import java.time.Instant;
import java.util.Date;

public class SyncFromDate {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        Date fromDate = Date.from(Instant.parse("2026-01-01T00:00:00Z"));

        stack.syncFromDate(fromDate, new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Items in this page: " + syncStack.getItems().size());
                System.out.println("Pagination token: " + syncStack.getPaginationToken());
            }
        });
    }
}
```

Earliest publish date to sync from.

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## syncLocale

syncLocale starts an initial sync of the entries and assets published in one locale.

```
Returns: void. The result arrives in the callback.
ValidationThere is no client-side validation of localeCode.When localeCode is null, syncLocale sends a sync of all content with no locale parameter. The org.json JSONObject.put method drops a key whose value is null. Check the locale code before you pass it.syncLocale sends no request if syncCallBack is null.The SDK does not throw on an API rejection, such as an unknown locale. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncLocale sends one request to Initial Sync (GET /stacks/sync) with init=true, locale and the stack's environment value.The result pages like any other sync. Pass getPaginationToken() to the syncPaginationToken method until the last page returns a sync token. The SDK does not request the next page.Use the five-argument sync overload to combine a locale with a content type, date and publish type.ExampleBasic usage: sync the content of one localeimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

public class SyncOneLocale {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.syncLocale("<LOCALE>", new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Items in this page: " + syncStack.getItems().size());
                System.out.println("Sync token: " + syncStack.getSyncToken());
            }
        });
    }
}
```

Locale code to sync, such as "en-us".

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## syncPaginationToken

syncPaginationToken fetches the next page of an initial or subsequent sync, using the pagination token from the previous page.

```
Returns: void. The result arrives in the callback.
ValidationThere is no client-side validation of paginationToken, despite the @NotNull annotation.When paginationToken is null, syncPaginationToken sends the request without a pagination_token parameter. The org.json JSONObject.put method drops a key whose value is null. The Sync using pagination token reference lists pagination_token as required.syncPaginationToken sends no request if syncCallBack is null.The SDK does not throw on an API rejection, such as an expired token. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncPaginationToken sends one request to Sync using pagination token (GET /stacks/sync) with pagination_token and the stack's environment value.Each call returns one page of at most 100 items. The SDK does not request the following pages.Call syncPaginationToken again with each getPaginationToken() value until getPaginationToken() returns null.The last page returns a sync token in getSyncToken() instead. Store it for the syncToken method.Use a stored pagination token to resume a sync that stopped partway, for example after a network failure.ExampleBasic usage: request every remaining page of a syncimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

public class SyncAllPages {
    public static void main(String[] args) throws IllegalAccessException {
        final Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.syncPaginationToken("<PAGINATION_TOKEN>", new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, for example for an expired token, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Items in this page: " + syncStack.getItems().size());

                if (syncStack.getPaginationToken() != null) {
                    // The SDK does not page on its own, so request the next page with the same callback
                    stack.syncPaginationToken(syncStack.getPaginationToken(), this);
                } else {
                    System.out.println("Sync token: " + syncStack.getSyncToken());
                }
            }
        });
    }
}
```

Pagination token from the previous sync page.

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## syncPublishType

syncPublishType starts an initial sync of one type of item, such as published entries or deleted assets.

```
Returns: void. The result arrives in the callback.
ValidationsyncPublishType throws NullPointerException if publishType is null, because it reads the enum name before the request.Java typing allows only a Stack.PublishType value, so a misspelled type does not compile.syncPublishType sends no request if syncCallBack is null.The SDK does not throw on an API rejection. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncPublishType sends one request to Initial Sync (GET /stacks/sync) with init=true, type and the stack's environment value.syncPublishType sends the enum name in lower case as type. The seven Stack.PublishType values send these strings:ValueSendsASSET_DELETEDasset_deletedASSET_PUBLISHEDasset_publishedASSET_UNPUBLISHEDasset_unpublishedCONTENT_TYPE_DELETEDcontent_type_deletedENTRY_DELETEDentry_deletedENTRY_PUBLISHEDentry_publishedENTRY_UNPUBLISHEDentry_unpublishedsyncPublishType sends one type per call. The Initial Sync reference accepts several comma-separated types, which this method cannot send. Filter the items in your code, or run one sync per type.The result pages like any other sync. Pass getPaginationToken() to the syncPaginationToken method until the last page returns a sync token. The SDK does not request the next page.ExampleBasic usage: sync only the deleted entriesimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

public class SyncDeletedEntries {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        // Sends type=entry_deleted
        stack.syncPublishType(Stack.PublishType.ENTRY_DELETED, new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Deleted entries in this page: " + syncStack.getItems().size());
            }
        });
    }
}
```

Type of item to sync, such as ENTRY\_PUBLISHED.

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## syncToken

syncToken runs a subsequent sync, which returns only the content published, unpublished or deleted since the sync that issued the token.

```
Returns: void. The result arrives in the callback.
ValidationThere is no client-side validation of syncToken.When syncToken is null, syncToken() sends the request without a sync_token parameter. The org.json JSONObject.put method drops a key whose value is null. The Subsequent Sync reference lists sync_token as required.syncToken sends no request if syncCallBack is null.The SDK does not throw on an API rejection, such as an invalid token. syncCallBack receives null for the SyncStack and an Error that holds the API's error code and message.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorsyncToken sends one request to Subsequent Sync (GET /stacks/sync) with sync_token and the stack's environment value.A sync token comes from getSyncToken() on the last page of an earlier sync. Run an initial sync once with sync or a filtered variant, then use syncToken for later runs.When the changes exceed 100 items, the response holds a pagination token instead of a sync token. Pass it to the syncPaginationToken method until a page returns a new sync token. The SDK does not request the next page.Store the new sync token after each completed sync and use it on the next run.ExampleBasic usage: fetch the changes since the last syncimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.SyncResultCallBack;
import com.contentstack.sdk.SyncStack;

public class SubsequentSync {
    public static void main(String[] args) throws IllegalAccessException {
        final Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.syncToken("<SYNC_TOKEN>", new SyncResultCallBack() {
            @Override
            public void onCompletion(SyncStack syncStack, Error error) {
                if (error != null) {
                    // The API rejected the request, for example for an invalid token, or it did not complete
                    System.out.println("Sync failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                System.out.println("Changed items: " + syncStack.getItems().size());

                if (syncStack.getPaginationToken() != null) {
                    // More changes remain on further pages
                    stack.syncPaginationToken(syncStack.getPaginationToken(), this);
                } else {
                    // Store this token for the next run
                    System.out.println("New sync token: " + syncStack.getSyncToken());
                }
            }
        });
    }
}
```

Sync token from the last completed sync.

Receives the sync result or the error. See [Callbacks](/docs/developers/sdks/content-delivery-sdk/java/reference/callbacks).

## taxonomy

taxonomy creates a [Taxonomy](/docs/developers/sdks/content-delivery-sdk/java/reference/taxonomy) object, which finds the entries tagged with taxonomy terms.

```
Returns: Taxonomy. A new taxonomy object.
ValidationThere is no client-side validation, because taxonomy takes no arguments.Errors that do occur come from the find() call that follows, not from taxonomy().Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. taxonomy sends no request.Each call returns a new Taxonomy with an empty query. The new object uses the stack's header map and HTTP client.Chain one or more conditions, such as in or below, then call find. find calls Get all entries with defined taxonomies.ExampleBasic usage: find the entries tagged with a termimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.Stack;
import com.contentstack.sdk.TaxonomyCallback;
import org.json.JSONObject;

import java.util.Collections;

public class FindEntriesByTerm {
    public static void main(String[] args) throws IllegalAccessException {
        Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

        stack.taxonomy()
                .in("taxonomies.<TAXONOMY_UID>", Collections.singletonList("<TERM_UID>"))
                .find(new TaxonomyCallback() {
                    @Override
                    public void onResponse(JSONObject response, Error error) {
                        if (error != null) {
                            // The API rejected the request
                            System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                            return;
                        }
                        System.out.println(response.optJSONArray("entries"));
                    }
                });
    }
}
```

## updateAssetUrl

updateAssetUrl replaces the asset links in an entry's JSON Rich Text Editor fields with the current URLs of the embedded assets.

```
Returns: void. This method returns nothing.
ValidationupdateAssetUrl throws IllegalArgumentException if the entry has no _embedded_items key, because it reads the asset URLs from that key. Chain includeEmbeddedItems() on the entry before fetch.updateAssetUrl throws NullPointerException if entry is null, or if fetch has not yet filled it, because the entry holds no JSON until fetch succeeds.updateAssetUrl throws org.json.JSONException if an embedded item has no _content_type_uid, or an embedded asset has no uid or url.BehaviorClient-side only. updateAssetUrl sends no request. Call it inside the fetch callback, after the entry holds its JSON.updateAssetUrl collects the uid and url of every embedded asset in _embedded_items, which are the items whose _content_type_uid is sys_assets.It then checks each top-level field of the entry that holds a children array. For each direct child with an attrs object that has asset-uid and asset-link, it sets asset-link to the collected URL for that asset-uid.updateAssetUrl changes the entry in place. Read the result from entry.toJSON() or the entry's field getters.LimitationsDoes not update asset links nested below the first level of children, or JSON Rich Text Editor fields inside a group or modular block. Update those links in your code from the _embedded_items values.Does not fetch assets. It uses only the URLs that the entry response already holds in _embedded_items.ExampleBasic usage: refresh asset links in a fetched entryimport com.contentstack.sdk.Contentstack;
import com.contentstack.sdk.Entry;
import com.contentstack.sdk.EntryResultCallBack;
import com.contentstack.sdk.Error;
import com.contentstack.sdk.ResponseType;
import com.contentstack.sdk.Stack;

public class UpdateEmbeddedAssetUrls {
    public static void main(String[] args) throws IllegalAccessException {
        final Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
        final Entry entry = stack.contentType("<CONTENT_TYPE_UID>").entry("<ENTRY_UID>");

        // includeEmbeddedItems adds _embedded_items to the response
        entry.includeEmbeddedItems().fetch(new EntryResultCallBack() {
            @Override
            public void onCompletion(ResponseType responseType, Error error) {
                if (error != null) {
                    // The API rejected the request, or it did not complete
                    System.out.println("Request failed: " + error.getErrorCode() + " " + error.getErrorMessage());
                    return;
                }
                try {
                    stack.updateAssetUrl(entry);
                    System.out.println(entry.toJSON().opt("body"));
                } catch (IllegalArgumentException e) {
                    // Thrown when the entry has no _embedded_items key
                    System.out.println("No embedded items: " + e.getMessage());
                }
            }
        });
    }
}
```

Fetched entry that includes its embedded items.

## Stack | Java Delivery SDK | Contentstack

The Stack class in the Java Delivery SDK holds your credentials and creates the content type, asset, global field and taxonomy objects, and it runs sync and live preview requests.