Skip to main content

Create a Test Environment (API)

Create a named test environment in a Jira space and use it when recording Test Runs from your automation tools.

Create a test environment, such as UAT or Staging, in a Jira space. Your automation can then use that name when recording Test Runs.

Endpoints

Action

Method

Endpoint

Create a test environment

POST

/api/v2/properties/environment

Confirm and use the environment

GET

/api/v2/properties/environments

Add the endpoint path to your Vansah base URL.

Before you begin

  • Create a Vansah API token with Jira access configured for your workspace.

  • The token account needs Jira administrator or Jira space administrator permission for this operation.

  • Choose a name not already used by an active environment in that Jira space. You can list existing environments first.

This create endpoint rejects a new environment when the Jira space already has 50 active environment records.

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 example name and Jira space key with your own values.

1. Prepare the JSON request

Endpoint: POST /api/v2/properties/environment

Save this complete body as environment.json to create UAT in the DEMO Jira space:

{
"name": "UAT",
"project": {
"key": "DEMO"
}
}

Parent object

JSON field

Type

Example value

Use

Request body

name

String

"UAT"

Required. A nonempty name of 1–255 characters. Use a meaningful plain-text name.

project

key

String

"DEMO"

The destination Jira space key. Include it in the request as shown.

JSON path project.key refers to the Jira space key. Use the key inside the project object as shown. Avoid the placeholder name -, which is excluded from environment-list results.

2. Create the environment

Endpoint: POST /api/v2/properties/environment

curl --request POST \
--url "$VANSAH_URL/api/v2/properties/environment" \
--header "Authorization: $VANSAH_TOKEN" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data-binary @environment.json

Header

Value

Authorization

Your Vansah API token directly, without a Bearer prefix.

Content-Type

application/json

Accept

application/json

Run the command from the directory containing environment.json. This create request does not use pagination or filtering parameters.

3. Read the response

Endpoint: POST /api/v2/properties/environment

A successful creation returns HTTP 200. The response message is Updated successfully:

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

Response JSON path

How to use it

data.name

The saved environment name. Use it in Test Run requests that accept an environment name.

data.identifier

Save this returned value if you later follow an operation that requires an environment identifier, such as renaming the environment.

The identifier shown is synthetic; use the value returned by your own request if it is needed later.

4. Confirm and use the environment

Endpoint: GET /api/v2/properties/environments

Look up the environment in the same Jira space:

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"

Find UAT in the returned names. See List Test Environments for the response and pagination.

Use that name in the environment property when you create a Test Run. To change it later, follow Update an Environment.

Errors and troubleshooting

An existing active name returns HTTP 400, for example:

{
"success": false,
"errorCode": 1390,
"message": "Duplicate environment(UAT)",
"data": []
}

HTTP status

Meaning

400

Invalid or missing name/space, duplicate name, 50-record creation limit, or a creation failure.

401

Missing, invalid, expired, or inactive token, missing Jira authorization, or a Jira permission lookup that rejects authentication.

403

The account is blocked or lacks administrator permission.

503

The Jira permission lookup is temporarily unavailable. This error uses errorCode 1400.

Message or issue

What to check

One or more validation errors found.

Read JSON path data.errors. Send a nonempty string name of 1–255 characters.

Duplicate environment(UAT)

Reuse the existing environment or choose another name. Duplicate errors use errorCode 1390.

Cannot create more than 50 Case Environments per space.

Review active environments in the Jira space before adding another.

Please provide space information

Include the correct Jira space key in the project object.

You don't have permission to access this resource

Check Jira administrator or Jira space administrator permission for the token account.

Something went wrong while Creating Environment.

Check the environment list before retrying. If the failure continues, contact Vansah Support with the request and response after removing the token.

Validation responses can include an errors array without an error code. A successful retry may not be needed if the environment already appears in the list.

Did this answer your question?