Create or Delete an Environment
Create an environment
Provisions a new Jahia Cloud environment. This is typically the first step of an automated pipeline.
Endpoint
POST <CLOUD_URL>/modules/cloudAction/createJahiaEnv.do
Example
CLOUD_URL="https://jahia.cloud" # Base URL of your Jahia Cloud instance
CLOUD_ENVNAME="my-env" # Must be unique across your organization, must be LOWERCASE and can only contain lowercase letters, numbers and hyphens
CLOUD_ORG="jahiacloud" # Assigned to your organization by Jahia, used to construct the shortDomain
CLOUD_SHORTDOMAIN="${CLOUD_ENVNAME}-${CLOUD_ORG}" # Short domain for the new environment
CLOUD_JAHIA_VERSION="8.2.3.0" # Jahia version to deploy
SUPER_USER_PASSWORD="VerySecuredPassword987" # Root password for the new environment
CLOUD_SUBSCRIPTIONITEMID="122" # Found by calling the getContext endpoint
CLOUD_REGIONID="aws-eu-west-1" # Found by calling the getContext endpoint
CLOUD_BANDID="1" # Found by calling the getContext endpoint
CLOUD_PAT="PRIVATE_TOKEN" # Cloud Perstonal API Token generated from the Jahia Cloud UI.
curl -i "${CLOUD_URL}/modules/cloudAction/createJahiaEnv.do" \
-X POST \
-H "Authorization: APIToken ${CLOUD_PAT}" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
--data-raw "orgName=${CLOUD_ORG}&envName=${CLOUD_ENVNAME}&shortDomain=${CLOUD_SHORTDOMAIN}&productVersion=${CLOUD_JAHIA_VERSION}&rootPassword=${SUPER_USER_PASSWORD}&subscriptionItemId=${CLOUD_SUBSCRIPTIONITEMID}®ionId=${CLOUD_REGIONID}&bandId=${CLOUD_BANDID}"
Expected result
HTTP 200 on success. Any other status code means the environment creation failed.
Environment creation is asynchronous. After receiving a 200, poll the Jahia healthcheck endpoint until the environment reports a GREEN status before proceeding with provisioning.
Waiting for the environment to be ready
After the environment is created, you will typically need to wait until it is fully started before performing further operations (such as applying Basic Authentication or deploying content). The following bash function polls the Jahia healthcheck until the environment reports a GREEN status:
SUPER_USER_PASSWORD="VerySecuredPassword987" # The rootPassword you set when creating the environment
healthcheck () {
HEALTHCHECK=$(curl -sS -u root:${SUPER_USER_PASSWORD} ${JAHIA_URL}/modules/graphql \
-H "Origin: ${JAHIA_URL}" \
-H 'content-type: application/json' \
--data-raw '{"query":"\t\nquery {\n admin {\n jahia {\n healthCheck(severity: CRITICAL) { # Your minimum severity to return\n status { # Highest reported status across all probes\n health # GREEN, YELLOW or RED\n message # Explanation for the health level\n }\n }\n }\n }\n}"}' 2>&1)
if jq -e . >/dev/null 2>&1 <<<"$HEALTHCHECK"; then
HEALTH=$(jq -r '.data.admin.jahia.healthCheck.status.health' <<< "$HEALTHCHECK")
MESSAGE=$(jq -r '.data.admin.jahia.healthCheck.status.message' <<< "$HEALTHCHECK")
if [[ "$HEALTH" == "GREEN" ]]; then
echo "$(date +'%d %B %Y - %k:%M:%S') HealthCheck: Jahia has started and its status is GREEN ($MESSAGE) - ${JAHIA_URL}"
env_started="true"
else
echo "$(date +'%d %B %Y - %k:%M:%S') HealthCheck: Jahia is still starting (SAM Status => $HEALTH : $MESSAGE) - ${JAHIA_URL}"
fi
else
echo "$(date +'%d %B %Y - %k:%M:%S') HealthCheck: Invalid response - Jahia and SAM have not started yet. - ${JAHIA_URL}"
fi
}
And then inside a bash script:
MAX_START_TIME=1200 # Time in seconds to wait before considering the environment failed to start (20 minutes in this example)
START_TIME=$SECONDS
while true; do
healthcheck
if [[ "$env_started" == "true" ]]; then
break
fi
ELAPSED_TIME=$(($SECONDS - $START_TIME))
if [[ $ELAPSED_TIME -gt $MAX_START_TIME ]]; then
echo "$(date +'%d %B %Y - %k:%M:%S') Jahia took more than $MAX_START_TIME seconds to start, exiting... "
exit 1
fi
sleep 5
done
Delete an environment
Deletes an existing Jahia Cloud environment. Commonly used at the end of CI/CD pipelines to clean up temporary environments.
This action is irreversible. The environment and all of its data will be permanently destroyed.
Endpoint
POST <CLOUD_URL>/modules/cloudAction/deleteEnv.do
Example
CLOUD_URL="https://jahia.cloud" # Base URL of your Jahia Cloud instance
CLOUD_ENVNAME="my-env" # Must be unique across your organization, and can only contain lowercase letters, numbers and hyphens
CLOUD_ORG="jahiacloud" # Assigned to your organization by Jahia, used to construct the shortDomain
CLOUD_SHORTDOMAIN="${CLOUD_ENVNAME}-${CLOUD_ORG}" # Short domain for the new environment
CLOUD_PAT="PRIVATE_TOKEN" # Cloud Perstonal API Token generated from the Jahia Cloud UI.
curl -i "${CLOUD_URL}/modules/cloudAction/deleteEnv.do" \
-X POST \
-H "Authorization: APIToken ${CLOUD_PAT}" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
--data-raw "orgName=${CLOUD_ORG}&shortDomain=${CLOUD_SHORTDOMAIN}"
Expected result
HTTP 200 on success. The environment deletion is triggered immediately.