Contentstack - Java Management SDK
Java Management SDK for Contentstack
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. All you have to do is build your application frontend, and Contentstack will take care of the rest.
This SDK uses the Content Management API (CMA). The CMA is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the CMA, you will need to authenticate your users with a Management Token or an Authtoken. Read more about it in Authentication.
Note: By using CMA, you can execute GET requests for fetching content. However, we strongly recommend that you always use the Content Delivery API to deliver content to your web or mobile properties.
Prerequisite
You need Java JDK 8 version or above installed on your machine to use the Contentstack Java CMS SDK.
Setup and Installation
Install it via maven:
<dependency> <groupId>com.contentstack.sdk<groupId> <artifactId>cms<artifactId> <version>{version}<version> <dependency>
Install it via Gradle:
implementation 'com.contentstack.sdk:cms:{version}'
Quickstart in 5 mins
Initialising The SDK
To use the Java CMA SDK, you need to first initialize it. To do this, use the following code:
import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().build();
Authentication
To use this SDK, you need to authenticate your users using the Authtoken, credentials, or Management Token (stack-level token).
Login
To Login to Contentstack by using credentials, you can use the following lines of code:
import contentstack Contentstack contentstack = new Contentstack.Builder().build(); contentstack.login("EMAIL","PASSWORD");
Authtoken
An Authtoken is a read-write token used to make authorized CMA requests and a user-specific token.
import contentstack Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
Management Token
Management Tokens are stack-level tokens, with no users attached to them.
import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack("API_KEY","MANAGEMENT_TOKEN");
Fetch Stack Detail
Use the following lines of code to fetch your stack detail using this SDK:
import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build(); Response<ResponseBody> response = contentstack.stack("API_KEY").fetch().execute();
Create Entry
To create an entry in a specific content type of a stack, use the following lines of code:
package com.contentstack.cms.stack; import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build(); Stack stack = contentstack.stack("API_KEY"); // [Create JSONObject Request body to upload] JSONObject jsonBody = new JSONObject() jsonBody.put("key","value"); // [Add Query parameters to the entry] entry.addParam("locale","en-us"); Response<ResponseBody> response = entry.create(jsonBody).execute(); if(response.isSuccessful()){ System.out.println(response.body());} else{ System.out.println(response.errorBody()); }
Create Asset
The following lines of code can be used to upload assets to your stack:
package com.contentstack.cms.stack; import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build(); Asset asset = contentstack.stack("API_KEY").asset(); Response ResponseBody response = asset.uploadAsset("file/path/from/local", "description").execute(); if(response.isSuccessful()){ System.out.println(response.body()); }else{ System.out.println(response.errorBody()); }
Contentstack
Java Management SDK Interact with the Content Management APIs and allow you to create, update, delete, and fetch content from your Contentstack account.
organisation
The organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources, and users. The organization allows easy management of projects as well as users within the Organization.
Name | Type | Description |
---|---|---|
organizationUid | String |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); //OR Organisation organisation = contentstack.organisation("organisationId");
user
All accounts registered with Contentstack are known as Users. A stack can have many users with varying permissions and roles
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); User user = contentstack.user();
stack
A Stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project.
Name | Type | Description |
---|---|---|
apiKey | String | The apiKey for the stack |
managementToken | String | The authorization for the stack |
branch | String | The branch that include branching in the response |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); or Stack stack = contentstack.stack("apiKey"); or Stack stack = contentstack.stack("apiKey", "managementToken", "branch");
login
Before executing any calls, retrieve the authtoken by authenticating yourself via the login call of User Session. The authtoken is returned to the 'Response' body of the login call and is mandatory in all the calls.
Name | Type | Description |
---|---|---|
emailId (required) | String | The email id of the user |
password (required) | String | The password of the contentstack user |
tfaToken | String | The tfa token |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); . LoginDetails login = contentstack.login("emailId", "password"); LoginDetails login = contentstack.login("emailId", "password", "tfaToken");
earlyAccess
With the earlyAccess header support, you can access features that are part of the early access program.
String[] eaMembers = {"Taxonomy", "Teams", "Others"}; Contentstack contentstack = new Contentstack.Builder().earlyAccess(eaMembers).build();
User
All accounts registered with Contentstack are known as Users. A Stack can have many users with varying permissions and roles.
activateAccount
The activate_token a user account call activates the account of a user after signing up.
Name | Type | Description |
---|---|---|
activationToken (required) | String | The activation token is received at the registered email address. You can find the activation token in the activation URL sent to the email address used while signing up. |
body (required) | JSONObject | The body. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); User user = contentstack.user(); Call<ResponseBody> response = user.activateAccount("activationToken", body).execute() if (response.isSuccessful){ System.out.println("Response"+ response) }
getUser
The "Get user" call returns comprehensive information about an existing user account. The information returned includes details of the stacks owned by and shared with the specified user account.
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); User user = contentstack.user(); Call<ResponseBody> response = user.getUser().execute() if (response.isSuccessful){ System.out.println("Response"+ response) }
login
The "login to your account" request is used to sign in to your Contentstack account and obtain the authtoken.
Name | Type | Description |
---|---|---|
email (required) | String | Email id for the user. |
password (required) | String | The password for the user. |
tfaToken | String | The tfa token. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); User user = contentstack.user(); Call<ResponseBody> response = user.login("email", "password", "tfaToken").execute() if (response.isSuccessful){ System.out.println("Response"+ response) }
logout
The "Log out of your account" call is used to sign out the user of the Contentstack account.
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.logout().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
logoutWithAuthtoken
The "Log out of your account" call is used to sign out the user of the Contentstack account.
Name | Type | Description |
---|---|---|
authtoken (required) | String | The authtoken of the user. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.logout("authtoken").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
requestPassword
The "Request for a password" call requests a temporary password to log in to an account if a user has forgotten the login password.
Using this temporary password, you can log in to your account and set a new password for your Contentstack account.
Provide the user's email address in JSON format
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack. requestPassword("body").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
resetPassword
The "Reset password" call sends a request for resetting the password of your Contentstack account.
When executing the call, in the 'Body' section, you need to provide the token that you receive via email, your new password, and password confirmation in JSON format.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.resetPassword("body").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
update
The "Update User" API Request updates the details of an existing user account. Only the information entered here will be updated; the existing data will remain unaffected.
When executing the API call, under the 'Body' section, enter the user's information that you wish to update. This information should be in JSON format.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack= new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.resetPassword("body").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
Alias
An alias acts as a pointer to a particular branch. You can specify the alias ID in your frontend code to pull content from the target branch associated with an alias.
addHeader
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); alias.addHeader("key", value)
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); alias.addParam("key", value);
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameter using a key of request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); alias.removeParam("key");
find
The "Get all aliases" request returns comprehensive information about all the aliases available in a particular stack in your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); Call<ResponseBody> response = alias.find().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
fetch
The "Get a single alias" request returns information about a specific alias.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); Call<ResponseBody> response = alias.fetch().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
update
The "Assign an alias" request creates a new alias in a particular stack of your organization. This alias can point to any existing branch (target branch) of your stack.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body to update the Alias. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); Call<ResponseBody> response = alias.update(body).execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
delete
The "Delete an alias" request deletes an existing alias.
To confirm the deletion of an alias, you need to specify the force=true query parameter.
When executing the API call, in the “URL Parameters” section, provide the UID of your alias.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Alias alias = contentstack.stack().alias(); Call<ResponseBody> response = alias.delete().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
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:
Name | Type | Description |
---|---|---|
filePath (required) | String | The file path. |
description (required) | String | The description of the asset file. |
upload (required) | JPG, GIF, PNG, XML, WebP, BMP, TIFF, SVG, and PSD | Select the input type as 'File.' Then, browse and select the asset file that you want to import. |
parent_uid | String | If needed, assign a parent folder to your asset by passing the UID of the parent folder. |
title | String | Enter a title for your uploaded asset. |
tags | String | Assign a specific tag(s) to your uploaded asset. |
relative_urls | Boolean | Set this to 'true' to display the relative URL of the asset. |
include_dimension | Boolean | Set this to 'true' to include the dimensions (height and width) of the image in the response. |
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) }
updateDetails
The "Update asset revision" call upgrades a specified version of an asset as the latest version of that asset.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | JSON Request body. |
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) }
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"
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | JSON Request body. |
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) }
subfolder
The "Get assets and folders of a parent folder" retrieves details of assets and asset subfolders within a specific parent asset folder.
Name | Type | Description |
---|---|---|
folderUid (required) | String | Folder uid. |
isIncludeFolders (required) | Boolean | Provide true or false. |
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) }
setVersionName
The "Set version name for asset" request allows you to assign a name to a specific version of an asset.
Name | Type | Description |
---|---|---|
versionNumber (required) | Integer | Asset version number. |
requestBody (required) | JSONObject | The request body of JSONObject. |
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) }
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.
Name | Type | Description |
---|---|---|
filePath (required) | String | The file path. |
description (required) | String | The file description. |
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) }
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.
Name | Type | Description |
---|---|---|
limit | Integer | Enter the maximum number of version details to be returned. |
named | Boolean | Set to true if you want to retrieve only the named versions of your asset. |
include_count | Boolean | Enter 'true' to get the total count of the asset version details. |
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) }
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"
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | JSON Request body. |
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) }
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.
Name | Type | Description |
---|---|---|
slugUrl (required) | String | The unique identifier of the asset. |
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) }
getByType
Based on the query request, "Get either images or videos" retrieves assets that are either image files or video files.
Name | Type | Description |
---|---|---|
assetType (required) | String | Asset type that you want to retrieve. - For images, "images" - For videos, "videos" |
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) }
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.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The JSONObject request body. |
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) }
folder
Get folder instance.
Name | Type | Description |
---|---|---|
folderUid | String | The UID of the folder that you want either to update or move. |
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) }
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) }
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) }
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.
Name | Type | Description |
---|---|---|
versionNumber (required) | Integer | The asset version. |
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) }
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.
Name | Type | Description |
---|---|---|
folderUid (required) | String | The folderUid of a specific folder. |
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) }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameter using a key of request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Asset asset = contentstack.stack().asset().removeParam("key");
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Asset asset = contentstack.stack().asset(); asset.addParam("key", value)
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Asset asset = contentstack.stack().asset(); asset.addHeader("key", value)
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()); }
AuditLog
An audit log displays a record of all the activities performed in a stack and helps you track all published items, updates, deletes, and the current status of the existing content.
find
The "Get audit log" request is used to retrieve the audit log of a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); AuditLog auditlog = contentstack.stack().auditLog(); Call<ResponseBody> response = auditlog.find().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
fetch
The "Get audit log item" request is used to retrieve a specific item from the audit log of a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); AuditLog auditlog = contentstack.stack().auditLog(); Call<ResponseBody> response = auditlog.fetch().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | header key for the request |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); AuditLog auditlog = contentstack.stack().auditLog(); response = auditlog.removeParam("key")
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack</span>.Builder().build(); AuditLog auditlog = contentstack.stack().auditLog(); response = auditlog.addParam("key", value)
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); AuditLog auditlog = contentstack.stack().auditLog(); response = auditlog.addHeader("key", value)
Branch
Branches allow you to isolate and easily manage your “in-progress” work from your stable, live work in the production environment. It helps multiple development teams to work in parallel in a more collaborative, organized, and structured manner without impacting each other.
create
The "Create a branch" request creates a new branch in a particular stack of your organization.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); Call<responsebody> response = branch.create("body"); if (response.isSuccessful) { System.out.println("Response" + response) }
fetch
The "Get a single branch" request returns information about a specific branch.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); Call<ResponseBody> response = branch.fetch(); if (response.isSuccessful) { System.out.println("Response" + response) }
find
The "Get all branches" request returns comprehensive information about all the branches available in a particular stack in your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); Call<ResponseBody> response = branch.find(); if (response.isSuccessful) { System.out.println("Response" + response) }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); branch.addParam("key", value);
addHeader
Sets header key for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); branch.addHeader("key", value);
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); branch.removeParam("key");
delete
The "Get assets and folders of a parent folder" retrieves details of both assets and asset subfolders within a specific parent asset folder.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Branch branch = contentstack.stack().branch(); Call<ResponseBody> response = branch.delete().execute(); if (response.isSuccessful){ System.out.println("Response" + response) }
BulkOperation
Use the BulkOperation class to perform actions—such as publishing, unpublishing, deleting, or updating workflows—on multiple entries and assets in a single API request.
create
The create method creates a new release in the stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to create a release. |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Release release = contentstack.stack().releases(); Call<ResponseBody> response = release.create(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Release created successfully."); }
unpublish
The unpublish method removes multiple entries and assets from specific environments and locales.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Data to unpublish multiple items |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.unpublish(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Unpublished successfully"); }
delete
The delete method permanently deletes multiple entries or assets from your stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Data to delete multiple items from stack |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.delete(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Deleted successfully"); }
updateWorkflow
The updateWorkflow method updates the workflow stage for multiple entries in bulk.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to update workflow |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.updateWorkflow(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Workflow updated"); }
addReleaseItems
The addReleaseItems method adds multiple entries or assets to a release in a single request.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Items to be added to the release |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.addReleaseItems(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Items added to release"); }
updateReleaseItems
The updateReleaseItems method updates all items in a release to their latest saved versions.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Configuration to update release items |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.updateReleaseItems(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Release items updated"); }
jobStatus
The jobStatus method allows you to check the status of a bulk job.
Name | Type | Description |
---|---|---|
params.job_id (required) | string | UID of the bulk job |
params.bulk_version | string | The bulk operation version (2.0) |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); BulkOperation bulkOperation = contentstack.stack().bulkOperation(); Call<ResponseBody> response = bulkOperation.jobStatus("jobId").execute(); if (response.isSuccessful()) { System.out.println("Job status retrieved"); }
ContentType
The content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required first to create a content type and then create entries using the content type.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
referenceIncludeGlobalField
The "Get all references of content type" call will fetch all the content types in which a specified content type is referenced.
Note: You must use either the stack's Management Token or the user Authtoken (anyone is mandatory), along with the stack API key, to make a valid Content Management API request. Read more about authentication. You need to use either the stack's Management Token or the user Authtoken (anyone is mandatory), along with the stack API key, to make a valid Content Management API request
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.referenceIncludeGlobalField().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
importOverwrite
The "Import a content type" call imports a content type into a stack by uploading a JSON file.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.importOverwrite().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fieldVisibilityRule
The "Set Field Visibility Rule for Content Type API request" lets you add Field Visibility Rules to existing content types. These rules allow you to show and hide fields based on the state or value of certain fields.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.fieldVisibilityRule("requestBody").execute(); if (response.isSuccessful) { System.out.println(<"Response"> + response) }
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); contentType.addParam("key", value);
entry
An entry is a content created using one of the defined content types.
Name | Type | Description |
---|---|---|
entryUid | String | The entry uid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.entry(entryUid).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create a content type" call creates a new content type in a particular stack of your Contentstack account.
In the Body section, you need to provide the complete schema of the content type.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
reference
The "Get all references of content type" call will fetch all the content types in which a specified content type is referenced.
Note: You must use either the stack's Management Token or the user Authtoken (anyone is mandatory), along with the stack API key, to make a valid Content Management API request. Read more about authentication. You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
Name | Type | Description |
---|---|---|
isIncludeGlobalField (required) | Boolean | Include Global Field true/false |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.reference(isIncludeGlobalField).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
imports
The "Import a content type" call imports a content type into a stack by uploading a JSON file.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.imports().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
export
This call is used to export a specific content type and its schema. The data is exported in JSON format. However, please note that the entries of the specified content type are not exported through this call. The schema of the content type returned will depend on the version number provided.
Note: You must use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.export().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get all content types" call returns comprehensive information on all the content types available in a particular stack in your account.
Note: You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update Content Type" call is used to update the schema of an existing content type.
Note: Whenever you update a content type, it will auto-increment the content type version.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body to update the Alias. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single content type" call returns information about a specific content type.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete Content Type" call deletes an existing content type and all the entries within it. When executing the API call, in the URI Parameters section, provide the UID of your content type.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); Call<ResponseBody> response = contentType.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); contentType.removeParam("key");
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(); contentType.addHeader("key", value)
fetchAsPojo
The fetchAsPojo method fetches a single content type and deserializes the response into a POJO.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ContentType contentType = contentstack.stack().contentType(content_type_uid); Response<ContentTypeResponse> response = contentType.fetchAsPojo().execute(); if (response.isSuccessful() && response.body() != null) { ContentTypeResponse ctResponse = response.body(); System.out.println("ContentType JSON: " + ctResponse.toString()); if (ctResponse != null) { ContentTypePojo ctPojo = ctResponse.getContentPojo(); System.out.println(" Content Type UID: " + ctPojo.uid); System.out.println(" Content Type Title: " + ctPojo.title); } } else { System.out.println("Error: " + response.errorBody().string()); }
findAsPojo
The findAsPojo method fetches a list of content types and deserializes them into POJOs.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Response<ContentTypesResponse> response = contentstack.stack().contentTypes().findAsPojo().execute(); if (response.isSuccessful() && response.body() != null) { ContentTypesResponse ctResponse = response.body(); List<ContentTypePojo> contentTypes = ctResponse.getContentTypes(); for (ContentTypePojo ct : contentTypes) { System.out.println(" Content Type UID: " + ct.uid); System.out.println(" Content Type Title: " + ct.title); } } else { System.out.println("Error: " + response.errorBody().string()); }
Entry
An entry is the actual piece of content created using one of the defined content types.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
versionName
Version naming allows you to assign a name to a version of an entry for easy identification.
Name | Type | Description |
---|---|---|
version (required) | Integer | Enter the version number of the entry to which you want to assign a name. |
requestBody (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.versionName(version, requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
unpublish
The "Unpublish an entry" call will unpublish an entry at once and allow you to do so automatically at a later date/time.
In the 'Body' section, you can specify the locales and environments from which you want to unpublish the entry. These details should be specified in the entry parameter. However, if you do not specify a locale, it will be unpublished from the master locale automatically.
You also need to mention the master locale and the version number of the entry that you want to publish.
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"
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.unpublish(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
unlocalized
The "Unlocalize an entry request" is used to unlocalize an existing entry.
Name | Type | Description |
---|---|---|
localeCode (required) | String | Enter the code of the language to localize the entry of that particular language. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.unLocalize("localeCode").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
publishWithReference
The "Publishing an Entry With References" request allows you to publish an entry with all its references simultaneously.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.publishWithReference(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
publish
The "Publish an entry" request lets you publish an entry either immediately or schedule it for a later date/time.
In the 'Body' section, you can specify the locales and environments to which you want to publish the entry. When you pass locales in the "Body", the following actions take place:
If you have not localized your entry in any of your stack locales, the Master Locale entry gets localized in those locales and is published
If you have localized any or all of your entries in these locales, the existing localized content of those locales will NOT be published. However, if you need to publish them all, you need to perform a Bulk Publish operation.
The locale and environment details should be specified in the entry parameter. However, if you do not specify any source locale(s), it will be published in the master locale automatically.
Along with the above details, you also need to mention the master locale and the version number of the entry that you want to publish.
Name | Type | Description |
---|---|---|
requestBody (required) | String | In the "Body" parameter, you need to provide the content of your entry based on the content type. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.publish(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
localize
The "Localize an entry" request allows you to localize an entry, i.e., the entry will cease to fetch data from its fallback language and possess independent content specific to the selected locale.
Note: This request will only create the localized version of your entry and not publish it. To publish your localized entry, you need to use the Publish an entry request and pass the respective locale code in the locale={locale_code} parameter.
Name | Type | Description |
---|---|---|
requestBody (required) | String | In the "Body" parameter, you need to provide the content of your entry based on the content type. |
localeCode (required) | Object | Enter the code of the language to localize the entry of that particular language. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.localize(requestBody, "localeCode").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
importExisting
The "Import an existing entry" call will import a new version of an existing entry. You can create multiple versions of an entry.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.importExisting().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
getReference
The "Get references of an entry" call returns all the entries of content types that are referenced by a particular entry.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.getReference().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
getLanguage
The "Get languages of an entry" call returns the details of all the languages that an entry exists in.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.getLanguage().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
detailOfAllVersion
The "Get Details of All Versions of an Entry" request allows you to retrieve the details of all the versions of an entry.
The version details returned include the actual version number of the entry; 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 locale of the entry.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.detailOfAllVersion().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
versionNumber
Atomic operations are particularly useful when we do not want content collaborators to overwrite data. Though it works efficiently for singular fields, these operations come in handy, especially in the case of fields that are marked as "Multiple".
Name | Type | Description |
---|---|---|
versionNumber (required) | Integer | Enter the version number of the entry that you want to delete. |
requestBody (required) | JSONObject | Request body for the delete operation. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.versionNumber(versionNumber, requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); entry.removeParam("key");
find
The "Find" call fetches the list of all the entries of a particular content type. It also returns the content of each entry in JSON format. You can also specify the environment and locale where you wish to get the entries.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single entry" request fetches a particular entry of a content type.
The content of the entry is returned in JSON format. You can also specify the environment and locale from which you wish to retrieve the entries.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete an entry" request allows you to delete a specific entry from a content type. This API request also allows you to delete single and/or multiple localized entries.
Name | Type | Description |
---|---|---|
requestBody | You can delete specific localized entries by passing the locale codes in the Request body using the locales key. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.delete(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update an entry" call lets you update the content of an existing entry.
Passing the locale parameter will cause the entry to be localized in the specified locale.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body for the entry update. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.update(requestBody).execute(); if (response.isSuccessful()){ } else System.out.println(response.errorBody().string()); }
export
The "Export an entry" call is used to export an entry. The exported entry data is saved in a downloadable JSON file.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.export().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
imports
The "Import an entry" call is used to import an entry. To import an entry, you need to upload a JSON file that has entry data in the format that fits the schema of the content type it is being imported to.
The Import an existing entry call will import a new version of an existing entry. You can create multiple versions of an entry.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.imports().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create an entry" call creates a new entry for the selected content type.
When executing the API call, in the 'Body' section, you need to provide the content of your entry based on the content type created.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to create/add a single Item. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); Call<ResponseBody> response = entry.create(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Sets header for the request.
Note: Since HashMap does not allow duplicate keys like include[], use the includeReference method to retrieve the entry with reference fields.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); entry.addParam("key", value);
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().entry(); entry.addHeader("Key", value);
includeReference
The includeReference method retrieves the content of the referenced entry.
Name | Type | Description |
---|---|---|
referenceField (required) | String / String[] | Enter the reference_field value |
includeReference with reference_field_uid as String:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack("apiKey").contentType("contentType") .entry("entry_uid"); Response<ResponseBody> response = entry .includeReference("reference_uid_1") .execute(); if (response.isSuccessful()) { System.out.println("Response" + response.body().string()); } else { System.out.println("Error Body" + response.errorBody().string()); }
includeReference with reference_field_uids as an array:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack("apiKey").contentType("contentType") .entry("entry_uid") String[] array = {"reference_uid_1","reference_uid_2"}; Response<ResponseBody> response = entry.includeReference(array).execute(); if (response.isSuccessful()) { System.out.println("Response" + response.body().string()); } else { System.out.println("Error Body" + response.errorBody().string()); }
setWorkflowStage
The setWorkflowStage method allows you to set or update the workflow stage of an entry.
Name | Type | Description |
---|---|---|
workflow (required) | JSONObject | Details for the workflow stage |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); String workflowStagePayload = "{\n" + " \"workflow\": {\n" + " \"workflow_stage\": {\n" + " \"comment\": \"WorkflowComment\",\n" + " \"due_date\": \"Thu Dec 01 2018\",\n" + " \"notify\": false,\n" + " \"uid\": \"workflow_stage_uid\",\n" + " \"assigned_to\": [\n" + " {\n"+ " \"uid\": \"user_uid\",\n" + " \"name\": \"Username\",\n" + " \"email\": \"user_email_id\"\n" + " }\n" + " ],\n" + " \"assigned_by_roles\": [\n" + " {\n" + " \"uid\": \"role_uid\",\n" + " \"name\": \"Rolename\"\n" + " }\n" + " ]\n" + " }\n" + " }\n" + "}"; JSONParser parser = new JSONParser(); JSONObject body = (JSONObject) parser.parse(workflowStagePayload); Entry entry = contentstack.stack(API_KEY,MANAGEMENT_TOKEN).contentType(contenttype).entry(entry_uid); Response<ResponseBody> response = entry.setWorkflowStage(body).execute(); if (response.isSuccessful()) { System.out.println("Response" + response.body().string()); } else { System.out.println("Error Body" + response.errorBody().string()); }
publishRequest
The publishRequest method allows you to either send a publish request or accept/reject a received publish request.
Request Structure
Headers: Include the API Key (stack identifier) and Auth Token (authentication).
Body Parameters:
- uid – Publish rule identifier
- action – "publish", "unpublish", or "both"
- status – 0 (Approval Requested), 1 (Approval Accepted), -1 (Approval Rejected)
- notification_settings – Controls notification triggers
- comment – Optional note for the approver
Name | Type | Description |
---|---|---|
publishing_rule (required) | JSONObject | Details for the publishing rule |
import contentstack Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build(); String publishRequestPayload = "{\n" + " \"workflow\": {\n" + " \"publishing_rule\": {\n" + " \"uid\": \"rule_uid\",\n" + " \"action\": \"publish\",\n" + " \"status\": 1,\n" + " \"notify\": true,\n" + " \"comment\": \"Approve this entry.\"\n" + " }\n" + " }\n" + "}"; JSONParser parser = new JSONParser(); JSONObject body = (JSONObject) parser.parse(publishRequestPayload); Entry entry = contentstack.stack(API_KEY,MANAGEMENT_TOKEN).contentType(contenttype).entry(entry_uid); Response<ResponseBody> response = entry.publishRequest(body).execute(); if (response.isSuccessful()) { System.out.println("Response" + response.body().string()); } else { System.out.println("Error Body" + response.errorBody().string()); }
fetchAsPojo
The fetchAsPojo method fetches a single entry by UID and deserializes it into a POJO.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Entry entry = contentstack.stack().contentType(content_type_uid).entry(entry_uid); Response<EntryResponse> response = entry.fetchAsPojo().execute(); if (response.isSuccessful() && response.body() != null) { EntryResponse entryResponse = response.body(); EntryPojo entrypojo = entryResponse.getEntryPojo(); System.out.println(" Entry Title: " + entrypojo.title); } else { System.out.println("Error: " + response.errorBody().string()); }
findAsPojo
The findAsPojo method fetches multiple entries for a content type and deserializes them into POJOs.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Response<EntryListResponse> response = contentstack.stack().contentType(content_type_uid).entry().findAsPojo().execute(); if (response.isSuccessful() && response.body() != null) { EntryListResponse entryListResponse = response.body(); List<EntryPojo> entries = entryListResponse.getEntries(); for (EntryPojo entry : entries) { System.out.println(" Entry Title: " + entry.title); } } else { System.out.println("Error: " + response.errorBody().string()); }
Environment
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published.
update
The "Update environment" call will update the details of an existing publishing environment for a stack.
When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); Call<ResponseBody> response = environment.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); environment.removeParam("key");
find
The "Get all environments" call fetches the list of all environments available in a stack.
You can add queries to extend the functionality of this API call.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); Call<ResponseBody> response = environment.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single environment" call returns more details about the specified environment of a stack.
When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); Call<ResponseBody> response = environment.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
"Delete environment" call will delete an existing publishing environment from your stack.
When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); Call<ResponseBody> response = environment.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Add an environment call" will add a publishing environment for a stack.
When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); Call<ResponseBody> response = environment.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Environment environment = contentstack.stack().environment(); environment.addParam("key", value);
DeliveryToken
Delivery tokens provide read-only access to the associated environments, while management tokens provide read-write access to the content of your stack. Use these tokens and the stack API key to make authorized API requests.
delete
The "Delete delivery token" request deletes a specific delivery token.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); Call<ResponseBody> response = deliveryToken.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update delivery token" request lets you update the details of a delivery token.
In the Request Body, you need to pass the updated details of the delivery token in JSON format. The details include the updated name, description, and/or the environment of the delivery token.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Thee body should be a JSON Object. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); Call<ResponseBody> response = deliveryToken.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The Create delivery token request creates a delivery token in the stack.
In the Request Body, you need to pass the details of the delivery token in JSON format. The details include the name, description, and environment of the delivery token.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body to create a delivery token. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); Call<ResponseBody> response = deliveryToken.create(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get all delivery tokens" request returns the details of all the delivery tokens created in a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); Call<ResponseBody> response = deliveryToken.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single delivery token" request returns the details of all the delivery tokens created in a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); Call<ResponseBody> response = deliveryToken.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); deliveryToken.addParam("key", value);
removeParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Remove query parameters of request by key. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); deliveryToken.removeParam("key");
addHeader
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack().deliveryToken(); deliveryToken.addHeader("key", value);
Extensions
Extensions let you create custom fields and widgets to customize Contentstack default UI and behavior.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
uploadCustomField
The "Upload a custom field" request is used to upload a custom field to Contentstack.
Name | Type | Description |
---|---|---|
upload | html | Select the HTML file of the custom field that you want to upload. |
title | String | Enter the title of the custom field that you want to upload. |
data_type | String | Enter the data type for the input field of the custom field. |
tags | String | Enter the tags that you want to assign to the custom field. |
multiple | Boolean | Enter ‘true’ if you want your custom field to store multiple values. |
type | String | Enter the type as ‘field’ since this is a custom field extension. |
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contntstack.stack().extensions(); extension.uploadCustomField(body);
update
The "Update Extensions call" will update the details of a custom field.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body to update the Extension. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); Call<ResponseBody> response = extension.update(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); extension.removeParam("key");
find
The "Get all custom fields" request is used to get the information of all custom fields created in a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); Call<ResponseBody> response = extension.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); extension.addParam("key", value);
fetch
The "Fetch" request returns information about a specific extension.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); Call<ResponseBody> response = extension.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete custom field" request deletes a specific custom field.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); Call<ResponseBody> response = extension.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contentstack.stack().extensions(); extension.addHeader("key", value);
Folder
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); folder.addParam("key", value);
delete
The "Delete a folder" call is used to delete an asset folder along with all the assets within that folder.
When executing the API call, provide the parent folder UID.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); Call<ResponseBody> response = folder.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create a folder" call is used to create an asset folder and/or add a parent folder to it (if required).
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body to create a delivery token. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); Call<ResponseBody> response = folder.create(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update or move folder" request can be used either to update the details of a folder or set the parent folder if you want to move a folder under another folder.
When executing the API request, provide the UID of the folder that you want to move/update.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); Call<ResponseBody> response = folder.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); folder.removeParam("key");
fetch
The "Get a single folder" call gets the comprehensive details of a specific asset folder using folder UID.
When executing the API call to search for a subfolder, you will need to provide the parent folder UID.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); Call<ResponseBody> response = folder.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Folder folder = contentstack.stack().folder(); folder.addHeader("key", value);
GlobalFields
A Global field is a reusable field (or group of fields) that you can define once and reuse in any content type within your stack. This eliminates the need (and thereby time and effort) to repeatedly create the same set of fields in multiple content types.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. You can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
A nested global field is a reusable set of sub-fields you can embed within other global fields or content types. It helps manage complex data structures more efficiently across your stack.
Note: To work with nested global fields, set api_version to 3.2 in the request headers. This version is required for all CRUD operations to work correctly.
create
The Create a global field request allows you to create a new global field in a particular stack of your Contentstack account. You can use this global field in any content type within your stack.
Note: Only the stack owner, administrator, and developer can create global fields.
You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request. Read more about authentication.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
Example 1:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.create(body).execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
Example 2:
// For Nested global fields pass api_version param with value 3.2 import com.contentstack.cms.Contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); globalField.addHeader("api_version","3.2"); Response<ResponseBody> response = globalField.create(body).execute(); if(response.isSuccessful) { System.out.println("Response" + response); } else { System.out.println("Error: "+ response.errorBody().string()); }
imports
The "Import global field" call imports global fields into Stack.
Note: You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
Name | Type | Description |
---|---|---|
body (required) | Object | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.imports(body).execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
export
This request is used to export a specific global field and its schema. The data is exported in JSON format.
Name | Type | Description |
---|---|---|
version | Integer | The version of the content type you want to retrieve. If the version number is not specified, you will get the latest version of the content type. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.export().execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update a global field" request allows you to update the schema of an existing global field.
When executing the API call, in the URI Parameters section, provide the unique ID of your global field.
Note: You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.update(requestBody).execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query param using key of request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); globalField.removeParam("key");
find
The "Get all global fields" call returns comprehensive information on all the global fields available in a particular stack in your account
Note: You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request. Read more about authentication.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.find().execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a Single global field" request lets you fetch comprehensive details of a specific global field.
When executing the API call, in the URI Parameters section, provide the unique ID of your global field.
Note: You need to use either the stack's Management Token or the user Authtoken (one of them is mandatory), along with the stack API key, to make a valid Content Management API request.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); GlobalField globalField = contentstack.stack().globalField(); Call<ResponseBody> response = globalField.fetch().execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
Label
Labels allow you to group a collection of content within a stack. Using labels, you can group content types that need to work together.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); response = label.addParam("key", value);
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); label.addHeader("key", value);
addBranch
Enter your branch's unique ID.
Name | Type | Description |
---|---|---|
value (required) | Object | Branch's unique ID. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); response = label.addBranch(value);
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); label.removeParam("key");
delete
The "Delete label" call is used to delete a specific label.
When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); Call<ResponseBody> response = label.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update label" call is used to update an existing label.
When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body to update the Label. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); Call<ResponseBody> response = label.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Find label" call fetches all the existing labels of the stack.
When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
Using addParam(String, Object), you can add queries to extend the functionality of this API call. Under the URI Parameters section, insert a parameter named query and provide a query in JSON format as the value.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); Call<ResponseBody> response = label.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get label" call returns information about a particular label of a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); Call<ResponseBody> response = label.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
This call is used to create a label.
When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Label label = contentstack.stack().label(); Call<ResponseBody> response = label.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
Locale
Contentstack has a sophisticated, multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audiences by serving content in their local language(s).
update
The "Update language" call will let you update the details (such as display name) and the fallback language of an existing language of your stack.
When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | Thee body should be a JSON Object. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.update(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete language" call deletes an existing language from your stack.
When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.delete().execute(); if(response.isSuccessful) { System.out.println("Response" + response); }
find
This call fetches the list of all languages (along with the language codes) available for a stack.
When executing the API call, under the Header section, you need to enter the authtoken that you receive after logging into your account.
You can add queries to extend the functionality of this API call. Under the URI Parameters section, insert a parameter named query and provide a query in JSON format as the value.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale=contentstack.stack().locale(); locale.removeParam("key");
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale ocale = contentstack.stack().locale(); locale.addHeader("key", value);
setFallback
The "Set a fallback" language request allows you to assign a fallback language for an entry in a particular language.
When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging in to your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.setFallback(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
updateFallback
The "Update fallback language" request allows you to update the fallback language for an existing language of your stack.
When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging in to your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.updateFallback(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a language" call returns information about a specific language available on the stack.
When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
This call lets you add a new language to your stack. You can either add a supported language or a custom language of your choice.
When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); Call<ResponseBody> response = locale.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Locale locale = contentstack.stack().locale(); response = locale.addParam("key", value);
ManagementToken
To authenticate Content Management API (CMA) requests over your stack content, you can use Management Tokens.
update
The "Update management token" request lets you update the details of a management token. You can change the name and description of the token, update the stack-level permissions assigned to the token, and change the expiry date of the token (if set).
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); Call<ResponseBody> response = managementToken.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get all management tokens" request returns the details of all the management tokens generated in a stack and NOT the actual management tokens.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); Call<ResponseBody> response = managementToken.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single management token" request returns the details of a specific management token generated in a stack and NOT the actual management token.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); Call<ResponseBody> response = managementToken.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The Delete management token request deletes a specific management token
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); Call<ResponseBody> response = folder.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create management token" request creates a management token in a stack. This token provides you with read-write access to the content of your stack.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | Details of the management token. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); Call<ResponseBody> response = managementToken.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); managementToken.addParam("key", value);
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack().managementToken(); managementToken.addHeader("key", value);
publishQueue
The Publish Queue displays the historical and current details of activities such as publishing, unpublishing, or deleting that can be performed on entries and/or assets. It also shows details of Release deployments. These details include time, entry, content type, version, language, user, environment, and status.
cancelScheduledAction
The "Cancel Scheduled Action" request will allow you to cancel any scheduled publishing or unpublishing activity of entries and/or assets and cancel the deployment of releases.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); Call<ResponseBody> response = publishQueue.cancelScheduledAction().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addHeader
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); publishQueue.addHeader("key", value);
FetchActivity
The "Get publish queue activity" request returns comprehensive information on a specific publish, unpublish, or delete action performed on an entry and/or asset. You can also retrieve details of a specific release deployment.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); Call<ResponseBody> response = publishQueue.fetchActivity().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query param using the key of request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); publishQueue.removeHeader("key");
find
The "Get publish queue" request returns comprehensive information on activities such as publish, unpublish, and delete performed on entries and/or assets. This request also includes the details of the release deployments in the response body.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); Call<ResponseBody> response = publishQueue.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); PublishQueue publishQueue = contentstack.stack().publishQueue(); publishQueue.addParam("key", value);
ReleaseItem
The "Get all items in a Release" request retrieves a list of all items (entries and assets) that are part of a specific Release and perform CRUD operations on it.
createMultiple
The "Add multiple items to a Release" request allows you to add multiple items (entries and/or assets) to a Release.
When executing the API request, you need to provide the Release UID.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to create/add a single Item. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); Call<ResponseBody> response = releaseItem.createMultiple(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update Release items to their latest versions" request let you update all the release items (entries and assets) to their latest versions before deployment
Note: You need to use either the stack's Management Token or the user Authtoken (anyone is mandatory), along with the stack API key, to make a valid Content Management API request.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to create/add a single Item. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); Call<ResponseBody> response = releaseItem.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get all items in a Release request" retrieves a list of all items (entries and assets) that are part of a specific Release.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); Call<ResponseBody> response = releaseItem.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Remove an item from a Release" request removes one or more items (entries and/or assets) from a specific Release.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); Call<ResponseBody> response = releaseItem.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Add a single item to a Release" request allows you to add an item (entry or asset) to a Release.
When executing the API request, you need to provide the Release UID.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The requestBody to create/add a single Item. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); Call<ResponseBody> response = releaseItem.create(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); releaseItem.addParam("key", value);
addHeader
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); releaseItem.addHeader("key", value);
removeParam
Name | Type | Description |
---|---|---|
key (required) | String | Param key for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releaseItem(); releaseItem.removeParam("key");
deleteReleaseItems
The deleteReleaseItems method removes multiple entries or assets from a specific release in a single request.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Data defining the items to be removed |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releases("RELEASE_UID").item(); Call<ResponseBody> response = releaseItem.deleteReleaseItems(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
deleteReleaseItem
The deleteReleaseItem method removes a single entry or asset from a release.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Data defining the item to remove |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releases("RELEASE_UID").item(); Call<ResponseBody> response = releaseItem.deleteReleaseItem(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
move
The move method allows you to move multiple items within a specific release.
Name | Type | Description |
---|---|---|
params.param (required) | object | The data containing the items to be moved. |
params.release_version | string | The release version(2.0) |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ReleaseItem releaseItem = contentstack.stack().releases("RELEASE_UID").item(); Call<ResponseBody> response = releaseItem.move(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
Releases
The Releases class provides methods to create, manage, and deploy content releases that group entries and assets for coordinated publishing across environments.
Note: Pass the release_version parameter as 2.0 in the Headers section if you have the latest release enabled for your organization. Reach out to our support team for more information.
create
The create method creates a new release in the stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to create a release. |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Release release = contentstack.stack().releases(); Call<ResponseBody> response = release.create(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Release created successfully."); }
update
The update method modifies the name, description, or schedule of an existing release.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Request body to update a release |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.stack().releases().update().execute(); if (response.isSuccessful()) { System.out.println("Release updated successfully."); }
fetch
The fetch method retrieves details of a specific release using its UID.
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.stack().releases("RELEASE_UID").fetch().execute(); if (response.isSuccessful()) { System.out.println("Fetched release."); }
clone
The clone method creates a duplicate of an existing release with a new name or description.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Request body to clone a release |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.stack().releases("RELEASE_UID").clone(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Release cloned successfully."); }
delete
The delete method removes a specific release from the stack
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.stack().releases("RELEASE_UID").delete().execute(); if (response.isSuccessful()) { System.out.println("Release deleted successfully."); }
deploy
The deploy method deploys all entries and assets from a release to specified environments and locales.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The requestBody to deploy a release. |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Call<ResponseBody> response = contentstack.stack().releases("RELEASE_UID").deploy(requestBody).execute(); if (response.isSuccessful()) { System.out.println("Release cloned successfully."); }
addParam
The addParam method sets a query parameter for the release request.
Name | Type | Description |
---|---|---|
key (required) | String | Key of the query parameter |
value (required) | Object | Value of the query parameter |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Release release = contentstack.stack().release(); release.addParam("key", value);
addHeader
The addHeader method sets a header for the release request.
Name | Type | Description |
---|---|---|
key (required) | String | Key of the header |
value (required) | Object | Value of the header |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Release release = contentstack.stack().release(); release.addHeader("key", value);
removeParam
The removeParam method removes a previously set query parameter from the release request.
Name | Type | Description |
---|---|---|
key (required) | String | Key of the query parameter to remove |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Release release = contentstack.stack().release(); release.removeParam("key");
Role
A role is a collection of permissions that will be applicable to all the users who are assigned this role.
create
The create role method adds a new role to your stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The body should be of a JSONObject type |
Example:
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); Call<ResponseBody> response = roles.create(requestBody).execute(); if (response.isSuccessful()) { System.out.println(response.body().string()); } else { System.out.println(response.errorBody().string()); }
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); roles.addHeader("key", value);
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); roles.addParam("key", value);
delete
The "Delete role" call deletes an existing role from your stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); Call<ResponseBody> response = roles.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a single role" request returns comprehensive information on a specific role.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); Call<ResponseBody> response = roles.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get all roles" request returns comprehensive information about all roles created in a stack.
You can add queries to extend the functionality of this API request.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); Call<ResponseBody> response = roles.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Update role" request lets you modify an existing role of your stack. However, the pre-existing system roles cannot be modified.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The body should be of a JSONObject type. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); Call<ResponseBody> response = roles.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Roles roles = contentstack.stack().roles(); roles.removeParam("key");
Stack
A stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project.
workflow
A workflow is a tool that allows you to streamline the process of content creation and publishing and lets you manage the content lifecycle of your project smoothly.
Name | Type | Description |
---|---|---|
workflowUid | String | The UID of your workflow that you want to retrieve. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.workflow("workflowUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
roles
A role is a collection of permissions that is applied to all the users who are assigned this role.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The Update User Role API Request updates the roles of an existing user account. This API Request will override the existing roles assigned to a user. For example, we have an existing user with the Developer role, and if you execute this API request with the "Content Manager" role, the user role will lose Developer rights, and the user role be updated to just Content Manager. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.roles(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
Name | Type | Description |
---|---|---|
roleUid | String | The unique ID of the role of which you want to retrieve the details. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.roles("roleUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
webhook
A webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account. Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.
Name | Type | Description |
---|---|---|
webhookUid | String | Enter the unique webhook ID from which you want to retrieve the details. Execute the Get all webhooks call to retrieve the UID of a webhook. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.webhook("webhookUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
updateSetting
The "Add stack settings" request lets you add additional settings for your existing stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.updateSetting(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The Update stack call lets you update the name and description of an existing stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
unshare
The "Unshare stack" removes the user account from the list of collaborators. Once this call is executed, the user will not be able to view the stack in their account.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.unshare(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
transferOwnership
The Transfer stack ownership to other users calls sends the specified user an email invitation for accepting the ownership of a particular stack.
Once the specified user accepts the invitation by clicking on the link provided in the email, the ownership of the stack gets transferred to the new user. Subsequently, the previous owner will no longer have permission on the stack.
Name | Type | Description |
---|---|---|
body (required) | JSONObject | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.transferOwnership(body).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
tokens
Contentstack provides different types of tokens to authorize API requests. You can use Delivery Tokens to authenticate Content Delivery API (CDA) requests and retrieve the published content of an environment. To authenticate Content Management API (CMA) requests over your stack content, you can use Management Tokens.
Delivery tokens provide read-only access to the associated environments, while management tokens provide read-write access to the content of your stack. Use these tokens along with the stack API key to make authorized API requests
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.tokens().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
share
The Share a stack call shares a stack with the specified user to collaborate on the stack.
Name | Type | Description |
---|---|---|
requestBody (required) | String | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.share("requestBody").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
setting
The "Get stack settings" call retrieves the configuration settings of an existing stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.setting().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
resetSetting
The "Reset stack settings" call resets your stack to default settings and, additionally, lets you add parameters to or modify the settings of an existing stack.
Name | Type | Description |
---|---|---|
requestBody (required) | String | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.resetSetting("requestBody").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
releases
You can pin a set of entries and assets (along with the deploy action, i.e., publish/unpublish) to a release, and then deploy this release to an environment. This will publish/unpublish all the items of the release to the specified environment.
Name | Type | Description |
---|---|---|
releaseUid | String | The unique ID of the release of which you want to retrieve the details. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.releases("releaseUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
publishQueue
The Publishing Queue displays the historical and current details of activities such as publishing, unpublishing, or deleting that can be performed on entries and/or assets. It also shows details of Release deployments. These details include time, entry, content type, version, language, user, environment, and status.
Name | Type | Description |
---|---|---|
publishQueueUid | String | The UID of a specific publish queue activity of which you want to retrieve the details. Execute the Get publish queue API request to retrieve the UID of a particular publish queue activity. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.publishQueue("publishQueueUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
locale
Contentstack has a sophisticated, multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audiences by serving content in their local language(s).
Name | Type | Description |
---|---|---|
code | String | The locale code. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.locale("code").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
label
Labels allow you to group a collection of content within a stack. Using labels you can group content types that need to work together.
Name | Type | Description |
---|---|---|
labelUid | String | The label. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.label("labelUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
globalField
A Global field is a reusable field (or group of fields) that you can define once and reuse in any content type within your stack. This eliminates the need (and thereby time and effort) to create the same set of fields repeatedly in multiple content types.
Name | Type | Description |
---|---|---|
globalFiledUid | String | The globalField UID. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.globalField("globalFiledUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
extensions
Extensions let you create custom fields and widgets to customize Contentment's default UI and behavior. Read more about Extensions.
Name | Type | Description |
---|---|---|
customFieldUid | String | The customField Uid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.extensions("customFieldUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
environment
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published.
Name | Type | Description |
---|---|---|
environmentUid (required) | String | The environment UID |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.environment("environmentUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create stack call" creates a new stack in your Contentstack account.
Name | Type | Description |
---|---|---|
organizationUid (required) | String | The organization uid. |
requestBody (required) | JSONObject | The request body should be in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.create("organizationUid", requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
contentType
The ContentType defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.
Name | Type | Description |
---|---|---|
contentTypeUid | String | Enter the unique ID of the content type from which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.contentType("contentTypeUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
branch
Branches allow you to isolate and easily manage your in-progress work from your stable, live work in the production environment. It helps multiple development teams to work in parallel in a more collaborative, organized, and structured manner without impacting each other.
Name | Type | Description |
---|---|---|
branchUid | String | The unique ID of the branch of which you want to retrieve the details. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.branch("branchUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
auditLog
An audit log displays a record of all the activities performed in a stack and helps you track all published items, updates, deletes, and the current status of the existing content.
Name | Type | Description |
---|---|---|
logItemUid | String | The log Item Uid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.auditLog("logItemUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
asset
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use.
Name | Type | Description |
---|---|---|
assetUid (required) | String | The asset Uid. |
folder | String | Enter either the UID of a specific folder to get the assets of that folder or enter ‘cs_root’ to get all assets and their folder details from the root folder. Example:bltd899999999. |
include_folders | Boolean | Set this parameter to ‘true’ to include the details of the created folders along with the details of the assets. Example:true. |
environment | String | Enter the name of the environment to retrieve the assets published on them. You can enter multiple environments. Example: production |
version | Integer | Specify the version number of the asset that you want to retrieve. If the version is not specified, the details of the latest version will be retrieved. Example:1 |
include_publish_details | Boolean | Enter 'true' to include the published details of the entry. |
include_count | Boolean | Set this parameter to 'true' to include the total number of assets available in your stack in the response body. |
relative_urls | Boolean | Set this to 'true' to display the relative URL of the asset. |
asc_field_uid | String | Enter the unique ID of the field for sorting the assets in ascending order by that field. Example:created_at |
desc_field_uid | String | Enter the unique ID of the field for sorting the assets in descending order by that field. Example:file_size |
include_branch | Boolean | Set this to 'true' to include the _branch top-level key in the response. This key states the unique ID of the branch where the concerned Contentstack module resides. Example:false |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Asset asset = contentstack.stack().asset("assetUid");
allUsers
The "Get all users" of a stack call fetches the list of all users of a particular stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.allUsers().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
alias
An alias acts as a pointer to a particular branch. You can specify the alias ID in your frontend code to pull content from the target branch associated with an alias.
Name | Type | Description |
---|---|---|
aliasUid | String | The unique ID of the alias of which you want to retrieve the details. The UID of an alias is unique across a stack. Execute the Get all aliases call to retrieve the UID of an alias |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.alias("aliasUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
acceptOwnership
The "Accept stack owned by another user" call allows a user to accept the ownership of a particular stack via an email invitation.
Once the user accepts the invitation by clicking the link, the ownership is transferred to the new user account. Subsequently, the user who transferred the stack will no longer have any permission on the stack.
Name | Type | Description |
---|---|---|
ownershipToken (required) | String | The ownership token received via email by another user. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.acceptOwnership("ownershipToken").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); stack.addParam("key", value)
find
Find call fetches stack information.
All Stack: auth token is required to fetch all the stacks.
Single Stack: api_key and authtoken is required, and organization_uid is optional.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); Call<ResponseBody> response = stack.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); stack.addHeader("key", value)
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Stack stack = contentstack.stack(); stack.removeParam("key")
Tokens
Contentstack provides different types of tokens to authorize API requests.
deliveryTokens
You can use Delivery Tokens to authenticate Content Delivery API (CDA) requests and retrieve the published content of an environment.
Name | Type | Description |
---|---|---|
tokenUid | String | The UID of the token that you want to retrieve. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); DeliveryToken deliveryToken = contentstack.stack(); Call<ResponseBody> response = deliveryToken.deliveryTokens("tokenUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
managementToken
To authenticate Content Management API (CMA) requests over your stack content, you can use Management Tokens.
Name | Type | Description |
---|---|---|
managementTokenUid | String | The managementTokenUid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); ManagementToken managementToken = contentstack.stack(); Call<ResponseBody> response = managementToken.managementToken("managementTokenUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
Webhook
A webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account. Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.
getExecutionLog
This call will return a comprehensive detail of all the webhooks that were executed at a particular execution cycle.
Name | Type | Description |
---|---|---|
executionUid (required) | String | The execution unique ID of the webhook. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.getExecutionLog("executionUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
GetExecution
The "Get executions of a webhook" request allows you to fetch the execution details of a specific webhook, which includes the execution UID. These details are instrumental in retrieving webhook logs and retrying a failed webhook.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.getExecutions().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
importExisting
The "Import an Existing Webhook" request will allow you to update the details of an existing webhook.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.importExisting().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
export
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.export().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
retry
This call makes a manual attempt to execute a webhook after the webhook has finished executing its automatic attempts.
When executing the API call, in the URI Parameter section, enter the execution UID that you receive when you execute the 'Get executions of webhooks' call.
Name | Type | Description |
---|---|---|
executionUid (required) | String | The execution unique ID of the webhook. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.retry("executionUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); webhook.removeParam("key");
find
The "Get all Webhooks request" returns comprehensive information on all the available webhooks in the specified stack
When executing the API call, under the Header section, you need to enter the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get webhook" request returns comprehensive information on a specific webhook.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete webhook" call deletes an existing webhook from a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); webhook.addParam("key", value);
addHeader
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); webhook.addHeader("key", value);
update
The "Update webhook" request allows you to update the details of an existing webhook in the stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The body should be of a JSONObject type. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
importWebhook
Name | Type | Description |
---|---|---|
fileName (required) | String | the file name |
jsonPath (required) | String | jsonPath like example "/Downloads/import.json" |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Webhook webhook = contentstack.stack().webhook(); Call<ResponseBody> response = webhook.importWebhook("filename","jsonPath").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
Error
getErrorCode
The "GetErrorCode" method returns the error code in integer form.
import contentstack; Error error = new Error(); error.getErrorCode();
getErrorMessage
The "GetErrorMessage" method returns the error details.
import contentstack; Error error = new Error(); error.getErrorMessage();
getErrors
The "GetError" method returns the error in JSONObject format.
import contentstack; Error error = new Error(); error.getError();
Workflow
Workflow is a tool that allows you to streamline the process of content creation and publishing and lets you manage the content lifecycle of your project smoothly.
updatePublishRule
The "Add or Update Publish Rules" request allows you to add a publishing rule or update the details of the existing publishing rules of a workflow.
Name | Type | Description |
---|---|---|
ruleUid (required) | String | The UID of the publishing rule that you want to update. |
requestBody (required) | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.updatePublishRule("ruleUid", requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetchPublishContentType
The "Get Publish Rules by Content Types" request allows you to retrieve details of a Publish Rule applied to a specific content type of your stack.
Name | Type | Description |
---|---|---|
contentTypeUid (required) | String | The UID of the content type of which you want to retrieve the Publishing Rule. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.fetchPublishRuleContentType("contentTypeUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
deletePublishRule
The "Delete Publish Rules" request allows you to delete an existing publish rule.
Name | Type | Description |
---|---|---|
ruleUid (required) | String | The UID of the published rule that you want to delete. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.deletePublishRule("ruleUid").execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
createPublishRule
The "Create Publish Rules" request allows you to create publish rules for the workflow of a stack.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | Specify the unique IDs of the branches for which the publishing rule will be applicable in the schema in the request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.createPublishRule(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetchTasks
The "Get all Tasks" request retrieves a list of all tasks assigned to you.
When executing the API request, in the 'Header' section, you need to provide the API Key of your stack and the authtoken that you receive after logging into your account.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.fetchTasks().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
disable
Disable Workflow request allows you to disable a workflow.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.disable().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
enable
The "Enable Workflow" request allows you to enable a workflow.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.enable().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
update
The "Add or Update Workflow" request allows you to add a workflow stage or update the details of the existing stages of a workflow.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The body should be in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.update(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
create
The "Create a Workflow" request allows you to create a Workflow.
Name | Type | Description |
---|---|---|
requestBody (required) | JSONObject | The details of the workflow in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.create(requestBody).execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
delete
The "Delete webhook" call deletes an existing webhook from a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.delete().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
fetch
The "Get a Single Workflow" request retrieves the comprehensive details of a specific Workflow of a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.fetch().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
find
The "Get a Single Workflow" request retrieves the comprehensive details of a specific Workflow of a stack.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); Call<ResponseBody> response = workflow.find().execute(); if (response.isSuccessful) { System.out.println("Response" + response); }
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Query parameter key for the request. |
value (required) | Object | Query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); workflow.addParam("key", value);
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); workflow.removeParam("key");
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Workflow workflow = contentstack.stack().workflow(); workflow.addHeader("key", value);
Organization
The Organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources and users. The Organization allows easy management of projects and users within the organization.
roles
Gets organization roles.
Below are the parameters to use in the method - addParam(String, Object):
Name | Type | Description |
---|---|---|
limit | Integer | The limit parameter will return a specific number of Organization roles in the output. Example, if there are 10 organization roles, and you wish to fetch only the first 2, you need to specify '2' as the value in this parameter. |
skip | Integer | The 'skip' parameter will skip a specific number of organization roles in the output. For example, if there are 12 organization roles and you want to skip the last 2 to get only the first 10 in the response body, you need to specify '2' here. |
asc | String | The "asc" parameter allows you to sort the list of organization roles in ascending order based on a parameter. |
desc | String | The "desc" parameter allows you to sort the list of organization roles in descending order based on a parameter. |
include_count | Boolean | The "include_count" parameter returns an organization's total number of roles. For example: If you want to know the total number of roles in an organization, you need to put the value as true. |
include_stack_roles | Boolean | The include_stack_roles parameter, when set to true, includes the details of stack-level roles in the Response body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.roles().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
stacks
The "Get all stacks" in an organization call fetches the list of all stacks in an Organization
The query parameters for the method - addParam(String, Object) are as follows:
Name | Type | Description |
---|---|---|
limit | Integer | The 'limit' parameter will return a specific number of sent organization invitations in the output. Example, if 10 invitations were sent out and you wish to fetch only the first 8, you need to specify '2' as the value in this parameter. |
skip | Integer | The 'skip' parameter will skip a specific number of organization roles in the output. Example, if there are 12 organization roles and you want to skip the last 2 to get only the first 10 in the response body, you need to specify '2' here. |
asc | String | The 'asc' parameter allows you to sort the list of organization invitations in ascending order on the basis of a specific parameter. |
desc | String | The 'desc' parameter allows you to sort the list of organization invitations in descending order on the basis of a specific parameter. |
include_count | Boolean | The 'include_count' parameter returns the number of organization invitations sent out. Example: If you wish to know the total number of organization invitations, you need to mention 'true'. |
typeahead | Boolean | The 'typeahead' parameter allows you to perform a name-based search on all the stacks in an organization based on the value provided. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.stacks().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
find
The "Get all organizations" call lists all organizations related to the system user in the order that they were created
Following are the query parameters for the method - addParam(String, Object):
Name | Type | Description |
---|---|---|
limit | Integer | The limit parameter will return a specific number of Organization roles in the output. Example, if there are 10 organization roles, and you wish to fetch only the first 2, you need to specify '2' as the value in this parameter. |
skip | Integer | The 'skip' parameter will skip a specific number of organization roles in the output. For example, if there are 12 organization roles and you want to skip the last 2 to get only the first 10 in the response body, you need to specify '2' here. |
asc | String | The "asc" parameter allows you to sort the list of organization roles in ascending order based on a parameter. |
desc | String | The "desc" parameter allows you to sort the list of organization roles in descending order based on a parameter. |
include_count | Boolean | The "include_count" parameter returns an organization's total number of roles. For example: If you want to know the total number of roles in an organization, you need to put the value as true. |
typehead | Boolean | "contentstack". |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.find().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
allInvitations
The "Get all organization invitations" call gives you a list of all the Organization invitations. Only the owner or the admin of the Organization can resend the invitation to add users to an Organization.
When executing the API call, provide the Organization UID.
The query parameters for addParam(String, Object) are as follows:
Name | Type | Description |
---|---|---|
limit | Integer | The 'limit' parameter will return a specific number of sent organization invitations in the output. Example, if 10 invitations were sent out and you wish to fetch only the first 8, you need to specify '2' as the value in this parameter. |
skip | Integer | The 'skip' parameter will skip a specific number of organization roles in the output. For example, if there are 12 organization roles and you want to skip the last 2 to get only the first 10 in the response body, you need to specify '2' here. |
asc | String | The 'asc' parameter allows you to sort the list of organization invitations in ascending order based on a specific parameter. |
desc | String | The 'desc' parameter allows you to sort the list of organization invitations in descending order on the basis of a specific parameter. |
include_count | Boolean | The 'include_count' parameter returns the total number of organization invitations sent out. Example: If you wish to know the total number of organization invitations, you need to mention 'true'. |
include_roles | String | The 'include_roles' parameter, when set to 'true', will display the details of the roles that are assigned to the user in an organization. |
include_invited_by | Boolean | The 'include_invited_by' parameter, when set to 'true', includes the details of the user who sent out the organization invitation. |
include_user_details | Boolean | The 'include_user_details' parameter, when set to 'true', lets you know whether the user who has been sent the organization invitation has enabled Two-factor Authentication or not. |
typeahead | String |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.allInvitations().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
transferOwnership
The "Transfer organization ownership" call transfers the ownership of an Organization to another user. When the call is executed, an email invitation for accepting the ownership of a particular Organization is sent to the specified user.
Name | Type | Description |
---|---|---|
body (required) | The request body | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.transferOwnership(body).execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
logsDetails
The "Get Organization log details" request is used to retrieve the audit log details of an organization
Tip: This request returns only the first 25 audit log items of the specified organization. If you get more than 25 items in your response, refer to the Pagination section to retrieve all the log items in paginated form.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.logsDetails().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
logItem
The" Get Organization log details" request is used to retrieve the audit log details of an organization
Tip: This request returns only the first 25 audit log items of the specified organization. If you get more than 25 items in your response, refer to the Pagination section to retrieve all the log items in paginated form
Name | Type | Description |
---|---|---|
logUid (required) | String | The log uid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation();C all<ResponseBody> response = organisation.LogItem("logUid").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
resendInvitation
Resend pending organization invitation call allows you to resend Organization invitations to users who have not yet accepted the earlier invitation.
Only the owner or the admin of the Organization can resend the invitation to add users to an Organization.
Name | Type | Description |
---|---|---|
shareUid (required) | String | The share uid. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.resendInvitation("shareUid").execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
removeUsers
The "Remove Users from Organization" request allows you to remove existing users from your organization.
Note: Only the owner or the admin of the organization can remove users.
Name | Type | Description |
---|---|---|
body (required) | Object | The request body in JSONObject format. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.removeUsers(body).execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
inviteUser
The "Add Users to organization" call allows you to send invitations to add users to your organization. Only the owner or the admin of the organization can add users.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.inviteUser(body).execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
fetch
The "Get a single organization" call gets the comprehensive details of a specific organization related to the system user.
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); Call<ResponseBody> response = organisation.fetch().execute(); if (response.isSuccessful){ System.out.println("Response"+ response) }
removeParam
Set header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Removes query parameters using the key of the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); organisation.removeParam("key");
addHeader
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | Header key for the request. |
value (required) | Object | Header value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); organisation.addHeader("key", value);
addParam
Sets header for the request.
Name | Type | Description |
---|---|---|
key (required) | String | The query parameter key for the request. |
value (required) | Object | The query parameter value for the request. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Organisation organisation = contentstack.organisation(); organisation.addParam("key", value);
Taxonomy
Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation, search, and retrieval of information. You can hierarchically organize your web properties based on your requirements, such as their purpose, target audience, or any other aspects of your business.
addParam
The addParam method adds a parameter to a collection using a key-value pair.
Name | Type | Description |
---|---|---|
key (required) | string | The key of the parameter |
value (required) | Object | The value of the parameter |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Taxonomy taxonomy = contentstack.taxonomy (); taxonomy.addParam("key", "value");
addHeader
The addHeader method adds a header with a key-value pair to a request.
Name | Type | Description |
---|---|---|
key (required) | string | The key of the header |
value (required) | String | The value of the header |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Taxonomy taxonomy = contentstack.taxonomy (); taxonomy.addHeader("key", "value");
addHeaders
The addHeaders method adds a headers to a HashMap.
Name | Type | Description |
---|---|---|
headers (required) | HashMap | The key-value pair of the header |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Taxonomy taxonomy = contentstack.taxonomy (); taxonomy.addHeaders("headers");
addParams
The addParams takes a HashMap of String keys and Object values as input and returns a generic type T.
Name | Type | Description |
---|---|---|
params (required) | HashMap | The parameters to be added |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Taxonomy taxonomy = contentstack.taxonomy (); taxonomy.addParams("params");
find
The find method retrieves the list of all taxonomies in the stack.
Name | Type | Description |
---|---|---|
include_terms_count | boolean | Whether to include the count of terms in the response. |
include_referenced_terms_count | boolean | Whether to include the count of referenced terms in the response. |
include_referenced_entries_count | boolean | Whether to include the count of referenced entries in the response. |
include_count | boolean | Whether to include the total count of taxonomies in the response. |
asc or desc | string | Sort order based on the UID field. |
typeahead | string | Search string for typeahead functionality. |
include_deleted | boolean | Whether to include deleted taxonomies in the response. |
skip | number | Number of records to skip in pagination. |
limit | number | Maximum number of records to return |
Response<ResponseBody> response = taxonomy.find().execute();
fetch
The fetch method retrieves the information of a specific taxonomy.
Name | Type | Description |
---|---|---|
include_terms_count | boolean | Whether to include the count of terms in the response. |
include_referenced_terms_count | boolean | Whether to include the count of referenced terms in the response. |
include_referenced_entries_count | boolean | Whether to include the count of referenced entries in the response. |
taxonomyId (required) | string | UID of the taxonomy |
Response<ResponseBody> response = taxonomy.fetch("taxonomyId").execute();
create
The create method lets you add a new taxonomy in the stack.
Name | Type | Description |
---|---|---|
body (required) | JSON Object | The request body to sent in the call. |
JSONObject body = new JSONObject Response<ResponseBody> response = taxonomy.create(body).execute();
update
The update method lets you make changes in the existing taxonomy in the stack.
Name | Type | Description |
---|---|---|
taxonomyId (required) | string | UID of the taxonomy |
JSONObject body = new JSONObject(); JSONObject bodyContent = new JSONObject(); bodyContent.put("name", "Taxonomy 1"); bodyContent.put("description", "Description updated for Taxonomy 1); body.put("taxonomy", bodyContent); Response<ResponseBody> response = taxonomy.update("taxonomyId", body).execute();
delete
The delete method lets you remove an existing taxonomy from the stack.
Name | Type | Description |
---|---|---|
taxonomyId (required) | string | UID of the taxonomy |
Response<ResponseBody> response = taxonomy.delete("taxonomyId").execute();
query
Get an instance of the taxonomy search filter class through which you can query on a taxonomy based on an entry endpoint. Provide the user's email address in JSON format.
Name | Type | Description |
---|---|---|
query (required) | JSONObject | The query of type JSONObject. |
import contentstack; Taxonomy taxonomy = new Contentstack.Builder() .setAuthtoken(TestClient.AUTHTOKEN) .setHost("api.contentstack.io") .build() .stack("apiKey") .taxonomy(); JSONObject query = new JSONObject(); query.put("taxonomies.taxonomy_uid", "{"$in" : ["term_uid1" , "term_uid2" ] }"); Response
terms
The terms method retrieves the information of the terms in the specific taxonomy.
Name | Type | Description |
---|---|---|
taxonomyId (required) | string | UID of the taxonomy |
Term terms = stack("authtoken").taxonomy("taxonomyId").term();
Terms
Terms are the fundamental building blocks in a taxonomy. They are used to create hierarchical structures and are integrated into entries to classify and categorize information systematically.
addParam
The addParam method adds a parameter to a collection using a key-value pair.
Name | Type | Description |
---|---|---|
key (required) | string | The key of the parameter |
value (required) | Object | The value of the parameter |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Terms terms = contentstack.terms(); terms.addParam("key", "value");
addHeader
The addHeader method adds a header with a key-value pair to a request.
Name | Type | Description |
---|---|---|
key (required) | string | The key of the parameter |
value (required) | string | The value of the parameter |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Terms terms = contentstack.terms(); terms.addHeader("key", "value");
addParams
The addParams method takes a HashMap of String keys and Object values as input and returns a generic type T.
Name | Type | Description |
---|---|---|
params (required) | HashMap | Maps String keys to Object values |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Terms terms = contentstack.terms(); terms.addParams("params");
addHeaders
The addHeaders method adds headers to a HashMap.
Name | Type | Description |
---|---|---|
headers (required) | HashMap | A HashMap containing key-value pairs of headers |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Terms terms = contentstack.terms(); terms.addHeaders("headers");
create
The create method lets you add a term to the taxonomy.
Name | Type | Description |
---|---|---|
body (required) | JSON Object | The request body to be sent in the call |
Stack stack = new Contentstack.Builder().build().stack(headers); JSONObject body = new JSONObject(); Term term = stack.taxonomy("taxonomyId").terms().create(body);
find
The find method retrieves th elist of all terms in the taxonomy.
Name | Type | Description |
---|---|---|
taxonomy_uid (required) | string | The UID Of the taxonomy for which we need the terms. |
depth | boolean | Include the terms upto the depth specified if set to a number greater than 0, include all the terms if set to 0, default depth will be set to 1 |
include_children_count | boolean | Include count of number of children under each term |
include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
include_count | boolean | Include count of the documents/nodes that matched the query |
asc|desc | string | Sort the given field in either ascending or descending order |
typeahead | boolean | Used to match the given string in all terms and return the matched result |
deleted | boolean | Used to fetch only the deleted terms |
skip | number | Skip the number of documents/nodes |
limit | number | Limit the result to number of documents/nodes |
Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().addParam("limit", 2).find();
fetch
The fetch method retrieves the information about a specific term in the taxonomy.
Name | Type | Description |
---|---|---|
termUid (required) | string | The UID Of the term |
include_children_count | boolean | Include count of number of children under each term |
include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().find();
descendants
The descendants method retrieves the information about the descendants of a specific term in the taxonomy.
Name | Type | Description |
---|---|---|
termUid (required) | string | The UID Of the term |
depth | boolean | Include the terms upto the depth specified if set to a number greater than 0, include all the terms if set to 0, default depth will be set to 1 |
include_children_count | boolean | Include count of number of children under each term |
include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
include_count | boolean | Include count of the documents/nodes that matched the query |
skip | number | Skip the number of documents/nodes |
limit | number | Limit the result to number of documents/nodes |
Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().descendants("termId");
ancestors
The ancestors method retrieves the information about the ancestors of a specific term in the taxonomy.
Name | Type | Description |
---|---|---|
termUid (required) | string | The UID Of the term |
Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().ancestors("termId");
update
The update method lets you update the details of an existing term in the taxonomy.
Name | Type | Description |
---|---|---|
termUid (required) | string | The UID Of the term |
body (required) | JSONObject | The request body to be sent in the call |
body = new RequestBody{ "term": { "name": "Term 1", "description": "Term 1 Description updated for Taxonomy 1" } } Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().update(body);
search
The search method retrieves the details of different terms in the taxonomy.
Name | Type | Description |
---|---|---|
termString (required) | string | The string of the UIDs/names of the terms |
Stack stack = new Contentstack.Builder().build().stack(headers); Term term = stack.taxonomy("taxonomyId").terms().search("search anything");