Skip to main content

Remove a Test Environment (API)

Remove an unused test environment from a Jira space and restore it when needed.

Remove an unused test environment from the active list in a Jira space. Start by finding it by name, then use the returned identifier for removal. The API marks the environment as deleted.

Endpoints

Action

Method

Endpoint

Find the environment by name

GET

/api/v2/properties/environments

Remove the selected environment

DELETE

/api/v2/properties/environment/{environmentIdentifier}

Restore a removed environment

PUT

/api/v2/properties/environment/{environmentIdentifier}/restore

Add the endpoint path to your Vansah base URL. Any value in braces, such as {identifier}, is a placeholder; the steps below show how to obtain and supply it.

Before you begin

Create a Vansah API token with Jira access configured for your workspace. The token account needs access to the Jira space and the permission required for the operation:

Operation

Required permission

Remove an environment

Permission to delete Jira work items in the space, or permission to administer the Jira space.

Restore an environment

Jira administrator or Jira space administrator permission.

The examples use Bash and cURL. Set VANSAH_URL to your Vansah base URL without a trailing slash and VANSAH_TOKEN to your API token. Replace the sample Jira space key and environment with your own values.

1. Find the environment by name

Endpoint: GET /api/v2/properties/environments

curl --request GET --get \
--url "$VANSAH_URL/api/v2/properties/environments" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Accept: application/json" \
--data-urlencode "projectKey=DEMO" \
--data-urlencode "startAt=0"

Example response for a Jira space with one environment:

{
"success": true,
"message": "Environments returned successfully",
"pagination": {
"total": 1,
"startAt": 0,
"limit": 50
},
"data": [
{
"identifier": "f94d0e7d-1edb-41ed-bdf2-ae827922bf87",
"name": "UAT"
}
]
}

Find the row named UAT, or the environment you intend to remove. Copy its identifier from the response into this Bash variable:

ENVIRONMENT_IDENTIFIER='f94d0e7d-1edb-41ed-bdf2-ae827922bf87'

Replace the sample value with the one returned for your environment. The removal URL requires that value; it does not accept the environment name. See List Test Environments if you need more pages.

Keep this identifier or the removal response if you may need to restore the environment. It will no longer appear in the active list after removal.

2. Remove the environment

Endpoint: DELETE /api/v2/properties/environment/{environmentIdentifier}

curl --request DELETE \
--url "$VANSAH_URL/api/v2/properties/environment/$ENVIRONMENT_IDENTIFIER?projectKey=DEMO" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Accept: application/json"

Query parameter

Type

Example value

Use

projectKey

String

DEMO

The Jira space key containing the environment. Use the same space as the lookup.

Header

Value

Authorization

Your Vansah API token directly, without a Bearer prefix.

Accept

application/json

The identifier is supplied by the variable from step 1. No JSON request body is needed when the Jira space key is in the URL as shown.

3. Confirm removal

Endpoint: GET /api/v2/properties/environments

A successful removal returns HTTP 200:

{
"success": true,
"message": "Removed Successfully",
"data": {
"identifier": "f94d0e7d-1edb-41ed-bdf2-ae827922bf87",
"name": "UAT"
}
}

List environments in the same Jira space again and confirm the name no longer appears. A second removal of an already deleted environment returns an invalid-identifier error.

Update automation that still uses the removed name. A later Test Run request with that name can create a new environment, which can also prevent restoring the old environment under the same name.

Restore a removed environment

Endpoint: PUT /api/v2/properties/environment/{environmentIdentifier}/restore

Use the saved identifier and the same Jira space. Restoration requires administrator permission and an environment that is currently deleted.

curl --request PUT \
--url "$VANSAH_URL/api/v2/properties/environment/$ENVIRONMENT_IDENTIFIER/restore?projectKey=DEMO" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Accept: application/json"

No JSON request body is needed for this example. A successful restoration returns HTTP 200:

{
"success": true,
"message": "Environment \"UAT\" restored successfully",
"data": {
"identifier": "f94d0e7d-1edb-41ed-bdf2-ae827922bf87",
"name": "UAT"
}
}

Restoration is rejected if another active environment already has the same name. If appropriate, rename the active environment before restoring.

Restoration can also restore deleted test data associated with the environment. It restores associated deleted test data collections, their versions, and variables. Confirm the environment and associated data before using this operation.

List environments again to verify the restored name is active.

Errors and troubleshooting

HTTP status

Meaning

400

Missing or invalid Jira space, environment not found in the required active/deleted state, duplicate active name during restoration, or a processing failure.

401

Missing, invalid, expired, or inactive token, missing Jira authorization, or rejected authentication during permission lookup.

403

The account is blocked or lacks the operation’s required permission.

503

Jira permission lookup is temporarily unavailable; errorCode 1400.

Example response for an invalid or already removed environment:

{
"success": false,
"errorCode": 1390,
"message": "Invalid environment identifier(f94d0e7d-1edb-41ed-bdf2-ae827922bf87)",
"data": []
}

Message or issue

What to check

Invalid environment identifier(...)

Confirm the target belongs to the selected Jira space. It may already be removed.

Environment not found or not deleted

Restoration needs the saved identifier of a deleted environment in that Jira space.

An active environment with the same name already exists

Resolve the active duplicate name before restoring.

Please provide space information

Include the correct projectKey query value. It refers to the Jira space key.

Permission error

Removal and restoration use different permissions. Check the operation’s requirement above.

Processing failure

Read the active list before retrying to check whether the state changed. Contact Vansah Support with the endpoint and response after removing the token if needed.

Missing-environment, duplicate-name and controller errors use errorCode 1390. Check success and message, and include any returned error code when asking Support for help.

Did this answer your question?