Manage Environment Parameters Using REST API in Testsigma

Manage Environments Using REST APIs


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.


Prerequisites

Before you begin, ensure you have an API Key from Testsigma application.


Get an Environment

This endpoint retrieves details for a specific Environment.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/environments/<ENV_ID>
Response Body (Sample)
{
"id": 10,
"name": "Test environment1",
"description": "Test Environment",
"createdById": 2,
"updatedById": 2,
"createdDate": 1732176819137,
"updatedDate": 1732176819137,
"createdAtEpoch": 1732176819137,
"updatedAtEpoch": 1732176819137,
"variables": [
{
"id": 8,
"key": "Url",
"value": "https://google.com",
"isEncrypted": false,
"projectId": 9,
"isDefault": null,
"createdDate": 1732176819179,
"updatedDate": 1732176819179,
"createdAtEpoch": 1732176819179,
"updatedAtEpoch": 1732176819179
}
]
}

The <ENV_ID> can be found in the URL of the Environment details page. Refer to the screenshot below: Env ID

NOTE:

To retrieve all environments, use this endpoint with the same method.

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

Update an Environment

Request Type PUT
Endpoint https://app.testsigma.com/api/v1/environments/<ENV_ID>
Authorization Bearer <API_Token>
Request Body Type JSON
Request Body
{
"name": "Test environment1",
"description": "Test Environment",
"createdById": 1,
"updatedById": 3,
"createdDate": 1731915641765,
"updatedDate": 1731915964126,
"createdAtEpoch": 1731915641765,
"updatedAtEpoch": 1731915964126,
"id": 10,
"projectId": 9,
"variables": [
{
"id": "8",
"key": "Url",
"value": "https://youtube.com",
"isEncrypted": false,
"projectId": 9,
"isDefault": null,
"createdDate": 1731915669291,
"updatedDate": 1731915669291,
"createdAtEpoch": 1731915669291,
"updatedAtEpoch": 1731915669291
}
]
}

Request Fields:

  • name: This is the environment name.
  • description: This is a description of the environment.
  • createdById: This identifies the user who created the environment.
  • updatedById: This identifies the user updating the environment.
  • createdDate: This is the date and time the environment was created.
  • updatedDate: This is the date and time the environment was last updated.
  • createdAtEpoch: This shows the epoch timestamp when the environment was created.
  • updatedAtEpoch: This shows the epoch timestamp when the environment was last updated.
  • projectId: Id of the associated project.
NOTE:

The Request Body should include only the fields that are being updated or created.


Create an Environment

Request Type POST
Endpoint https://app.testsigma.com/api/v1/environments
Authorization Bearer <API_Token>
Request Body Type JSON
Request Body

{
"name": "Test environment1",
"description": "Test Environment",
"createdById": 1,
"updatedById": 3,
"createdDate": 1731915641765,
"updatedDate": 1731915964126,
"createdAtEpoch": 1731915641765,
"updatedAtEpoch": 1731915964126,
"projectId": 9,
"variables": [
{
"key": "Url",
"value": "https://youtube.com",
"isEncrypted": false,
"projectId": 9,
"isDefault": null,
"createdDate": 1731915669291,
"updatedDate": 1731915669291,
"createdAtEpoch": 1731915669291,
"updatedAtEpoch": 1731915669291
}
]
}

Request Fields:

  • name: This is the environment name.
  • description: This is a description of the environment.
  • createdById: This identifies the user who created the environment.
  • updatedById: This identifies the user updating the environment.
  • createdDate: This is the date and time the environment was created.
  • updatedDate: This is the date and time the environment was last updated.
  • createdAtEpoch: This shows the epoch timestamp when the environment was created.
  • updatedAtEpoch: This shows the epoch timestamp when the environment was last updated.
  • projectId: Id of the associated project.