cs-icon.svg

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&lt;ResponseBody&gt; 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&lt;ResponseBody&gt; 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.

Returns:
Type
Organisation
NameTypeDescription

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

Returns:
Type
User
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.

Returns:
Type
Stack
NameTypeDescription

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.

Returns:
Type
LoginDetails
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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

Sets header for the request
Returns:
Type
Void
NameTypeDescription

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

Sets params for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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:

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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"

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
call
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"

Returns:
Type
call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Folder
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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)

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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)
}

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

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Entry
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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)

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.

Returns:
Type
Call
NameTypeDescription

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"

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Entry
NameTypeDescription

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());
}

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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).

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

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.

Returns:
Type
Call
NameTypeDescription

body (required)

JSONObject

The request body.

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);
}

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Label
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

key (required)

String

Param key for the request.

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
ReleaseItem releaseItem = contentstack.stack().releaseItem();
releaseItem.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.

Returns:
Type
call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Workflow
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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);
}

Returns:
Type
Roles
NameTypeDescription

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.

Returns:
Type
Webhook
NameTypeDescription

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.

Returns:
Type
Stack
NameTypeDescription

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.

Returns:
Type
Stack
NameTypeDescription

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.

Returns:
Type
Stack
NameTypeDescription

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.

Returns:
Type
Stack
NameTypeDescription

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

Returns:
Type
Tokens

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Releases
NameTypeDescription

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.

Returns:
Type
PublishQueue
NameTypeDescription

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

Returns:
Type
Locale
NameTypeDescription

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.

Returns:
Type
Label
NameTypeDescription

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.

Returns:
Type
Instance of Extensions
NameTypeDescription

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.

Returns:
Type
Instance of Extensions
NameTypeDescription

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.

Returns:
Type
Environment
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
ContentType
NameTypeDescription

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.

Returns:
Type
Branch
NameTypeDescription

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.

Returns:
Type
AuditLog
NameTypeDescription

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.

Returns:
Type
Asset
NameTypeDescription

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.
Example:true

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.

Returns:
Type
Call

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.

Returns:
Type
alias
NameTypeDescription

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.

Returns:
Type
the stack
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
DeliveryToken
NameTypeDescription

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.

Returns:
Type
ManagementToken
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Void
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

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call
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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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

Sets header for the request.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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

The Import Webhook section consists of the following two requests that will help you to import new Webhooks or update existing ones by uploading JSON files.
Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Int
import contentstack;
Error error = new Error();
error.getErrorCode();

getErrorMessage

The "GetErrorMessage" method returns the error details.

Returns:
Type
Call
import contentstack;
Error error = new Error();
error.getErrorMessage();

getErrors

The "GetError" method returns the error in JSONObject format.

Returns:
Type
Call
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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
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.

Returns:
Type
Call
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.

Returns:
Type
Call

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Call

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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):

Returns:
Type
Call
NameTypeDescription

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&lt;ResponseBody&gt; 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:

Returns:
Type
Call
NameTypeDescription

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&lt;ResponseBody&gt; 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):

Returns:
Type
Call
NameTypeDescription

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&lt;ResponseBody&gt; 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:

Returns:
Type
Call
NameTypeDescription

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&lt;ResponseBody&gt; 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.

Returns:
Type
Call
NameTypeDescription

body (required)

The request body

The request body.

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; 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.

Returns:
Type
Call

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; 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

Returns:
Type
Call
NameTypeDescription

logUid (required)

String

The log uid.

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();C
all&lt;ResponseBody&gt; 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.

Returns:
Type
Void
NameTypeDescription

shareUid (required)

String

The share uid.

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; 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.

Returns:
Type
Void
NameTypeDescription

body (required)

Object

The request body in JSONObject format.

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; 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.

Returns:
Type
Void

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; 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.

Returns:
Type
Call

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
Call&lt;ResponseBody&gt; response = organisation.fetch().execute();
if (response.isSuccessful){
	System.out.println("Response"+ response)
}

removeParam

Set header for the request.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Void
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Taxonomy
NameTypeDescription

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.

Returns:
Type
Call
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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.

Returns:
Type
Terms
NameTypeDescription

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");