Update Environment parameters using REST API


For some CI/CD pipelines, the URL of the Application Under Test (AUT) changes with every deployment. Manually updating it within the Testsigma App for every build can get tedious at scale. Environments API lets you read and update the URL of the Application under Test (AUT) dynamically after every build in your CI Pipeline.

NOTE:

You need to authenticate these requests with your Testsigma API Key. See How to generate API Keys.


Get An Environment

Request Method: GET

Endpoint: https://app.testsigma.com/api/v1/environments/<ENVIRONMENT_ID>

<ENVIRONMENT_ID> can be found from the Environment details page URL


Get All Environments

Request Method: GET

Endpoint: https://app.testsigma.com/api/v1/environments


Update Environment

Request Type PUT
Endpoint https://app.testsigma.com/api/v1/environments/<ENVIRONMENT_ID>
<ENVIRONMENT_ID> can be found from the Environment details page URL
Authorization Bearer <api_token>
<api_token> is the same as the Testsigma API Key mentioned above.
Request Body Type JSON
Request Body {
 "id": 53,
 "name": "newEnvironment",
 "description": null,
 "createdById": 9,
 "updatedById": 9,
 "parameters": {
  "url": "https://travel.testsigma.com/"
 },
 "passwords": []
}

Request/Response fields

  • id: The unique identifier for the environment. In this case, it's 53.
  • Name: The name of the environment. In this case, it's newEnvironment.
  • Description: The description of the environment. In this case, it's null.
  • createdById: The ID of the user who created the environment. In this case, it's 9.
  • updatedById: The ID of the user who last updated the environment. In this case, it's also 9.
  • Parameters: An object containing the parameters for the environment. In this case, there is only one parameter with the key url and value https://travel.testsigma.com/.
  • Passwords: Passwords is a String array containing the names of parameters that need to be encrypted. In this case, it's an empty array.
NOTE:

Only include the contents that need to be updated and remove the others from the Request Body


Create Environment

Request Type POST
Endpoint https://app.testsigma.com/api/v1/environments
Authorization Bearer <api_token>
<api_token> is the same as the Testsigma API Key mentioned above.
Request Body Type JSON
Request Body {
  "parameters": {
  "url": "https://travel.testsigma.com/"
 },
 "passwords": [],
 "projectId": 191,
 "name": "newEnvironment",
 "description": null,
 "parametersJson": "{\n \"url\": \"https://travel.testsigma.com/\"\n}"
}

Request/Response fields

  • Parameters: An object containing the parameters for the environment. In this case, there is only one parameter with the key url and value https://travel.testsigma.com/.
  • Passwords: Passwords is a String array containing the names of parameters that need to be encrypted. In this case, it's an empty array.
  • ProjectId: The ID of the project that the environment belongs to. In this case, it's 191.
  • Name: The name of the environment. In this case, it's newEnvironment.
  • Description: The description of the environment. In this case, it's null.
  • ParametersJson: A JSON string representation of the parameters object. It's the same as the parameters object.