Tech Topics

Automate Elastic Cloud workflows using an SDK and Elasticsearch Service API

We recently announced the general availability of our Elasticsearch Service API. APIs help to automate tasks such as creating and scaling deployments, integrating with existing workflows, and testing. 

The Elasticsearch Service API supports the Open API Specification, which allows you to use tools like Swagger to generate software development kits (SDKs) in any programming language. You can import the API spec onto Postman and create a Postman Collection to create a test suite.

In this blog post, we’ll generate an SDK using Swagger and demonstrate how you can perform operations using the Elasticsearch Service API. 

Generating an SDK

Note: If you don’t want to generate an SDK, you can skip this step and use the ESS Java Client SDK

As mentioned above, the Elasticsearch Service API follows the Open API Specification. Here, we’ll be using Swagger Generator to generate respective language SDK. 

  1. First, copy the API specification from this link.
  2. Open
  3. Paste the API spec in the above link and accept the prompt to convert to YAML.
  4. Go to Generate Client > Java (we’ll select Java for this tutorial, but you can use the programming language of your choice).

Using Swagger Generator to generate the SDK

We’ve generated a Java Client SDK and compiled a JAR to use it further as a dependency in our sample application. 

Creating an API key

To perform any of the API calls, we need an API key to talk to Elasticsearch Service securely. This requires an Elastic Cloud account. Visit this link to spin up an extended 30-day free trial of Elastic Cloud.

Now you’ll need to create an API key using the Elastic Cloud console. You can do this under the Account section:

Create a API key from the Elastic Cloud console

Note: API keys are sensitive and tied to your account, and they grant privileges to create, list, and destroy resources in Elasticsearch Service. Please keep your keys safe.

Performing operations using the Elasticsearch Service API and SDK

The Elasticsearch Service API contains multiple operation APIs to manage your deployments. 

For example, we can use the SDK to automate essential workflows. I’m using Intellij and a sample Java project to use the SDK jar that we generated earlier. You can also use other editors to do the same thing.

Elastic Cloud API as a Postman Collection

Here are some operations you can perform with the Elasticsearch Service API SDK:

  • Create an Elasticsearch Service deployment

Code for Creating a Elasticsearch Deployment on Elastic Cloud

  • List Elasticsearch Service deployments

Code snippet to list Elastic Cloud deployments

You can also see the API request equivalent to what you’ve configured in the user interface after selecting the required deployment specifications along with the cloud platform and region.

Equivalent REST API request for the selected Cloud Platform and Region in Elastic Cloud Console

To see the list of available regions, refer to the available regions page in our documentation. 

Further reading

Thanks for following along! The code for this project is available in this GitHub repository.

If you have any further questions, please do not hesitate to reach out on our community Slack channel #dev-cloud-api (request an invite here) or drop a question on our forums.