API Support in Jelastic Cloud: Automate the Processes of Your Application Lifecycle

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Jelastic Cloud API lets developers automate a set of actions required for an application’s lifecycle and extend our platform functionality, by combining other services. Using our API, you can programmatically create environments, deploy apps and perform other tasks that could be earlier accomplished only via Jelastic’s dashboard, but not limited to them.api

Jelastic API follows REST principles. REST API determines a set of functions which can be requested by a developer, who then receives a response. The interaction is performed via HTTP protocol. The advantage of such method is a wide extension of the HTTP protocol. That’s why REST API can be used with almost any programming language.

Jelastic API Request

All requests of API methods are GET or POST HTTP-requests to the URL with a set of parameters:


The type of the URL which should be used, is stated in the description of each method (REST field).

rest link

The data of the request can be sent as a query string (after the “?” sign) while using the GET method, or in the body of the POST request. Remember, that in the case of a GET request, the parameters must be percent encoded (URL encoding).

Currently, Jelastic API does not differentiate GET and POST requests. As a reminder, there is a limitation on the length of the URL request – 2048 characters. That is why we recommend using:

  • GET request for receiving the information which easily fits within the length limitation
  • POST request for changing the data (creating environment, changing config files etc.)

In such a way, you won’t be restricted with the request length. Also, such usage is more relevant for the HTTP protocol specification.

Every request should contain a set of the mandatory parameters. There are some additional parameters required for a particular function. Such parameters are stated in the documentation about this function.

Each request includes the mandatory appid parameter identifying the requested environment. If the request is not connected with the environment as an appid parameter, the system value 1dd8d191d38fff45e62564fcf67fdcd6 should be used.

The text value of the parameters should be provided in UTF-8 code. The sequence of the parameters in the request is not important.

Jelastic API Response

The request response is UTF-8 encoded. The response for all API functions is given in JSON format. An example of the result is described in the documentation of the method.signin method

Jelastic API in Action

To start automation of the required processes with Jelastic API you have to adhere to the following requirements:

If you are using Maven, add the following dependency to pom.xml


To call any API function, you need to be authenticated. The parameter “session” is responsible for authentication, i.e. identifying the user with the request. The session is achieved by calling the Users > Authentication > Signin method.



  • appid is a system value (1dd8d191d38fff45e62564fcf67fdcd6)
  • login and password are the credentials of your Jelastic account

The further calling of the API functions should be performed with the received session value.

To complete the working session with API, call the Users > Authentication > Signout method.


With the help of Jelastic’s Java Client Library, you can automate various actions connected with your application lifecycle management, for example: creating an environment, changing its status, deleting, restarting nodes, deploying applications, etc.

Let’s examine how to create an environment with your custom topology and settings using Jelastic Client Library.

Create Environment

A full version of the example on environment creation can be found in Jelastic’s API documentation (Jelastic Java Samples tab). And here is some step-by-step explanation of the main points:

1. Declare a new CreateEnvironment public class, which will include all of the following blocks and parameters. The first parameter’s block should contain the next strings:

    private final static String PLATFORM_APPID = "1dd8d191d38fff45e62564fcf67fdcd6";
    private final static String HOSTER_URL = "<hoster-url>"; 
    private final static String USER_EMAIL = "<email>";
    private final static String USER_PASSWORD = "<password>"; 
    private final static String ENV_NAME = "test-api-environment-" + new Random().nextInt(100);


  • <hoster-url> – URL of your hosting provider (Hoster’s URL / API column in this document)
  • <email> – your Jelastic account’s email (login)
  • <password> – your Jelastic account’s password

2. Then the authentication is configured, which will use the login and password you’ve specified above.

 public static void main(String[] args) {         

        System.out.println("Authenticate user...");
        AuthenticationResponse authenticationResponse = authenticationService.signin(USER_EMAIL, USER_PASSWORD);
        System.out.println("Signin response: " + authenticationResponse);
        if (!authenticationResponse.isOK()) {
        final String session = authenticationResponse.getSession();

After authentication, a new unique session is created. It will be used for performing the necessary operations within a user’s account. All the further API function calls should be performed within this session, which remains valid until Signout method calling.

3. The next step is getting the list of engines available for the specified <engine_type> (can be java, php, ruby, js etc).

        System.out.println("Getting list of engines...");
        ArrayResponse arrayResponse = environmentService.getEngineList(PLATFORM_APPID, session, "<engine_type>");
        System.out.println("GetEngineList response: " + arrayResponse);
        if (!arrayResponse.isOK()) {

4. After that, get the list of available node templates according to the specified <templates_type>, which can be:

  • ALL – all available at platform templates, i.e. native and cartridges
  • NATIVE – default node templates
  • CARTRIDGE – custom templates, that were added to the platform as cartridges by hosting provider
        System.out.println("Getting list of templates...");
        arrayResponse = environmentService.getTemplates(PLATFORM_APPID, session, "<templates_type>", false);
        System.out.println("GetTemplates response: " + arrayResponse);
        if (!arrayResponse.isOK()) {

5. The next block is devoted to the custom configurations and settings of your new environment and the servers it will contain. More details on JSON parameters, used in Jelastic manifests for defining environment’s topology, can be seen here.

        JSONObject env = new JSONObject()
                .put("ishaenabled", false)
                .put("engine", "php5.5")
                .put("shortdomain", ENV_NAME);
        JSONObject apacheNode = new JSONObject()
                .put("nodeType", "apache2")
                .put("extip", false)
                .put("count", 1)
                .put("fixedCloudlets", 1)
                .put("flexibleCloudlets", 4);
        JSONObject mysqlNode = new JSONObject()
                .put("nodeType", "mysql5")
                .put("extip", false)
                .put("fixedCloudlets", 1)
                .put("flexibleCloudlets", 4);
        JSONObject memcachedNode = new JSONObject()
                .put("nodeType", "memcached");
        JSONArray nodes = new JSONArray()

6. Finally, initiate the creation of a new environment with all the specified settings:

System.out.println("Creating environment...");
        ScriptEvalResponse scriptEvalResponse = environmentService.createEnvironment(PLATFORM_APPID, session, 
        "createenv", env.toString(), nodes.toString());
        System.out.println("CreateEnvironment response: " + scriptEvalResponse);

That’s all. By following such steps you can automate the creation of various environments. Find a full version of this example in Jelastic API docs > Jelastic Java Samples > CreateEnvironment. Also, among those Jelastic Java Samples you can find other examples of Jelastic Client Library usage for automating different actions pertaining to your application lifecycle management. Start now and enjoy development with Jelastic!

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates