Contentstack
Contentstack
Java Management SDK Interact with the Content Management APIs and allow you to create, update, delete, and fetch content from your Contentstack account.
organisation
The organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources, and users. The organization allows easy management of projects as well as users within the Organization.
| Name | Type | Description |
|---|---|---|
| organizationUid | String |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Organisation organisation = contentstack.organisation();
//OR
Organisation organisation = contentstack.organisation("organisationId");user
All accounts registered with Contentstack are known as Users. A stack can have many users with varying permissions and roles
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); User user = contentstack.user();
stack
A Stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project.
| Name | Type | Description |
|---|---|---|
| apiKey | String | The apiKey for the stack |
| managementToken | String | The authorization for the stack |
| branch | String | The branch that include branching in the response |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Stack stack = contentstack.stack();
or
Stack stack = contentstack.stack("apiKey");
or
Stack stack = contentstack.stack("apiKey", "managementToken", "branch");login
Before executing any calls, retrieve the authtoken by authenticating yourself via the login call of User Session. The authtoken is returned to the 'Response' body of the login call and is mandatory in all the calls.
| Name | Type | Description |
|---|---|---|
| emailId (required) | String | The email id of the user |
| password (required) | String | The password of the contentstack user |
| tfaToken | String | The tfa token |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
.
LoginDetails login = contentstack.login("emailId", "password");
LoginDetails login = contentstack.login("emailId", "password", "tfaToken");earlyAccess
With the earlyAccess header support, you can access features that are part of the early access program.
String[] eaMembers = {"Taxonomy", "Teams", "Others"};
Contentstack contentstack = new Contentstack.Builder().earlyAccess(eaMembers).build();setHost
The setHost method specifies the API endpoint for your Contentstack region. This method ensures that your requests are routed to the appropriate regional host enabling optimal performance and compliance with regional data policies.
For a complete list of supported regions and their base URLs, refer to the Content Management API documentation.
The following code snippet demonstrates how to initialize the Contentstack client and set the regional host (for example, for Australia):
import Contentstack;
// Initialize the Contentstack client and set the regional host (e.g., for Australia)
Contentstack client = new Contentstack.Builder()
.setAuthtoken(TestClient.AUTHTOKEN)
.setHost("au-api.contentstack.com")
.build();
// Get the entry instance from the specified content type and entry UID
Entry entry = client.stack("apiKey").contentType("contentType").entry("entry_uid");
// Fetch the entry from the specified region
Response<ResponseBody> response = entry.fetch();