Skip to main content

Remove a Test Environment (API)

Remove an environment from a Jira space with the Vansah API, find its identifier, handle errors, and restore it when needed.

Remove a test environment, such as an unused UAT environment, from the active environments in a Jira space. The API marks the environment as deleted; it does not delete Test Runs that used it.

Before you begin

  • Have a Vansah API token and your workspace’s Vansah API URL.

  • The token account must be able to access the Jira space and have permission to delete work items (DELETE_ISSUES) or administer that space (ADMINISTER_PROJECTS).

  • Have the Jira space key and the identifier of an active environment in that space.

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 DEMO and the example environment identifier with values from your own Jira space.

Endpoint and headers

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

Header

Value

Authorization

Your Vansah API token, without a Bearer prefix.

Content-Type

application/json

Accept

application/json

1. Find the environment identifier

List the active environments in the Jira space:

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

Find the required environment by its name in data and copy its identifier. Use that identifier in the DELETE URL, rather than the environment name.

The list returns up to 50 environments, sorted by name, and excludes deleted environments and the - placeholder. Use startAt=50, then 100, and so on if more pages are needed; stop when you reach pagination.total. See List Test Environments for the full response and pagination details.

2. Prepare the request

Field

How to use it

environmentIdentifier in the path

Required. The environment UUID returned by the list endpoint. It must identify an active environment in the selected Jira space.

project.key in the JSON body

The Jira space key. Include it as shown below to select the space. You can also supply the space through the projectKey query parameter. Use one space per removal.

project.key and projectKey both refer to the Jira space key. Their API names remain unchanged.

{
"project": {
"key": "DEMO"
}
}

3. Remove the environment

Send the DELETE request with the space details in its JSON body:

curl --request DELETE \
--url "$VANSAH_URL/api/v2/properties/environment/f94d0e7d-1edb-11ed-bdf2-ae827922bf87" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{"project":{"key":"DEMO"}}'

Example successful response:

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

success: true confirms the removal. The response includes the removed environment’s identifier and name. List the environments again to confirm that it no longer appears in the active list.

Repeating the same DELETE request returns an invalid-identifier error because the environment is already deleted. It does not return a second successful removal.

Restore a removed environment

If you need the environment again, send a PUT request to the restore endpoint using its original identifier and the same Jira space:

curl --request PUT \
--url "$VANSAH_URL/api/v2/properties/environment/f94d0e7d-1edb-11ed-bdf2-ae827922bf87/restore" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{"project":{"key":"DEMO"}}'

Restoring requires Jira administrator or Jira space administrator permissions. The environment must be deleted, and there must not be another active environment with the same name.

Troubleshooting

Message or issue

What to check

Invalid environment identifier(...)

Check that the identifier belongs to the selected Jira space. It may be incorrect or already deleted.

Please provide space information or an invalid space key

Include project.key in the JSON body or provide projectKey in the URL. Use the correct Jira space key.

Authentication or permission error

Check the API URL, token, space access, and the token account’s permissions. Delete and restore use different permission checks, as described above.

Something went wrong while Removing Environment

Check the active environment list before retrying, so you can tell whether the removal took effect. Contact Vansah Support if the issue continues.

Restore reports that an active environment has the same name

Resolve the duplicate name before restoring. You can rename an active environment if appropriate.

Example response for an invalid or already removed identifier:

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

Check success and message in the response. When asking Support for help, include the endpoint, Jira space key, and response, without your API token.

You can also view the request in the Vansah API collection in Postman.

Did this answer your question?