Acquia CLI

Acquia CLI examples

Examples of handling a JSON response

When you execute Acquia CLI commands invoking a Cloud Platform API endpoint, the endpoint returns a machine-readable JSON response.

Acquia recommends you to use the following open source tools to navigate the JSON response:

  • jq: Lightweight and flexible JSON processor. Acquia recommends you to read the manual to discover its possibilities.

  • jid: JSON incremental digger

  • jtbl: Print JSON and JSON Lines data as a table

The following are the examples where Acquia CLI leverages these tools to be more productive and achieve typical use cases:

Finding the last three Cloud events for an application

Use the limit filter in jq to return a subset of the results:

$ acli api:applications:notification-list myapp | jq '[limit(3;.[] | {event, completed_at})]'
    "event": "DatabaseBackupDownloaded",
    "completed_at": "2021-02-24T16:13:37+00:00"
    "event": "RemoteIdeCreatedEvent",
    "completed_at": "2021-02-24T13:22:03+00:00"
    "event": "DatabaseBackupDownloaded",
    "completed_at": "2021-02-23T18:23:29+00:00"

Filtering out application details for an arbitrary sitegroup

Pass the following select query to search for a partial match in the JSON output:

$ acli api:applications:list | jq '.[] | select( | contains ("thomas"))'

The query returns the following output, where <version> refers to the version of your Drupal application:

  "id": 111241,
  "uuid": "da76k877-fc7f-bcf4-2523-c801f469b9dc",
  "name": "thomas",
  "hosting": {
    "type": "ace",
    "id": "prod:thomas"
  "subscription": {
    "uuid": "1054c7fc-8954-4e52-b132-a4f5bc3a7d16",
    "name": "Thomas - Sandbox"
  "organization": {
    "uuid": "d29ej812-7c03-11e4-b588-22000b04072f",
    "name": "My Drupal <version> Application"
  "flags": {
    "remote_admin": false
  "status": "normal",
  "type": "drupal",
  "platform": null,
  "_links": {
    "self": {
      "href": ""
    "parent": {
      "href": ""
  "_embedded": {
    "tags": []

Finding all Cloud environments for an application

Use jq to filter out the JSON response:

$ acli api:applications:environment-list myapp | jq '.[].name'

Interactively drilling down into the JSON response

Use jid to scan through the JSON response until you find the desired result:

Viewing results in a table

Use the following jtbl to improve the readability of the JSON response. If your output is not complex, pipe it to jtbl to view a formatted table:

$ acli api:distributions:list | jq -c '.[] | {title,version}' | jtbl

The command returns the following output, where <major-version> refers to the current major version of your Drupal application, and <specific-version> refers to the specific version of your Drupal application.

title                              version
---------------------------------  ----------
Drupal <major-version>             <specific-version>
Acquia Connector                   8.x-1.9
Apigee Developer Portal Kickstart  8.x-1.7
Commerce Kickstart                 7.x-2.62
DKAN                               7.x-1.15.4
govCMS                             7.x-3.6
Open Atrium                        7.x-2.69
OpenPublic                         7.x-1.9
Thunder                            8.x-2.9
Web Experience Toolkit             7.x-4.9

Waiting for completion of a database backup

After you initiate the process of creating a database backup through Acquia CLI, the system takes some time to complete the process. You cannot deploy your code or perform other tasks until the process is completed. To wait until the system creates the backup, use the app:task-wait command:

acli app:task-wait "$(acli api:environments:database-backup-create my_db)"

Other examples

The following are examples of other operations that you can perform with Acquia CLI:

Creating a new application with Acquia CLI

To create a new Drupal application with the acli new command:

  1. Open Terminal on your local machine.

  2. Run the acli new command.

    The system prompts you to choose a project template.

    See the following example:

    $ acli new
    Acquia recommends most customers use acquia/drupal-recommended-project,
    which includes useful utilities such as Acquia Connector.
    acquia/drupal-minimal-project is the most minimal application that will
    run on Cloud Platform.
    Which starting project would you like to use?
    [0] acquia/drupal-recommended-project
    [1] acquia/drupal-minimal-project
    > 1
    Creating project. This may take a few minutes
    Creating a "acquia/drupal-minimal-project" project at "./drupal"
    New 💧Drupal project created in /tmp/drupal. 🎉

Hooking into Acquia CLI commands

To define a script that runs before, or after any Acquia CLI command, add the script to the root composer.json file. Ensure that you follow the naming pattern (pre|post)-acli-(command name with dashes). For example, pre-acli-push-db or post-acli-pull-files. The script does not run if you name it incorrectly. See the following examples:

"scripts": {
   "pre-acli-pull-db": [
       "echo \"I'm pulling the database now!\""
   "post-acli-pull-db": [
       "echo \"I'm done pulling the database!\""