Skip to main content

Exporting Test Cases and Test Runs with the API

Download Test Cases, scripts, execution results, and history using the Vansah API, with JSON examples and pagination guidance.

Retrieve Test Case definitions, test scripts, Test Runs, and change history from the Vansah API for reporting or integration with another system. Save each response as JSON and combine the records using their identifiers.

Before you begin

  • Create a Vansah API token with an account that can access the Jira spaces and testing data you need.

  • Copy your workspace’s API Connect URL.

  • Choose the Jira space key. API fields such as projectKey and project.key refer to the Jira space key.

The Bash examples below use curl. Replace these placeholders with your own values:

VANSAH_BASE_URL="https://YOUR-API-CONNECT-HOST"
VANSAH_TOKEN="YOUR_VANSAH_API_TOKEN"
SPACE_KEY="DEMO"

Every request uses Authorization: YOUR_VANSAH_API_TOKEN, without a Bearer prefix. Use the copied base URL without a trailing slash.

1. Retrieve the Test Cases

Request the first page of Test Cases in your Jira space:

curl --get "$VANSAH_BASE_URL/api/v2/testCases" \
--header "Authorization: $VANSAH_TOKEN" \
--data-urlencode "projectKey=$SPACE_KEY" \
--data-urlencode "startAt=0" \
--data-urlencode "limit=50" \
--data-urlencode "sortBy=caseKey" \
--data-urlencode "sortOrder=asc" \
--output test-cases-0.json

Example response excerpt:

{
"success": true,
"data": {
"pagination": { "total": 1, "startAt": 0, "limit": 50 },
"data": [
{
"caseIdentifier": "11111111-1111-4111-8111-111111111111",
"caseKey": "DEMO-C1",
"testCaseVersion": 1,
"headline": "Valid login"
}
]
}
}

Keep each caseIdentifier, caseKey, and testCaseVersion. You will use them to request scripts and history and match executions to their definitions.

Useful optional filters include caseKey for one exact key, testFolderIdentifier for a folder UUID, issueKey for linked Jira work items, and updatedStartDate / updatedEndDate in YYYY-MM-DD format. See List Test Cases (API) for more filters.

2. Retrieve the test scripts

Use the Test Case key from the response. Set testCaseVersion to the version you want to keep with the exported definition.

curl --get "$VANSAH_BASE_URL/api/v2/testCase/list/testScripts" \
--header "Authorization: $VANSAH_TOKEN" \
--data-urlencode "projectKey=$SPACE_KEY" \
--data-urlencode "caseKey=DEMO-C1" \
--data-urlencode "testCaseVersion=1" \
--output demo-c1-scripts.json

The response groups scripts under applicable keys such as steps, plainText, bdd, and automation. Omit type to retrieve the applicable script types, or set it to steps, plainText, bdd, or automation.

caseKey is required for this endpoint and can contain comma-separated Test Case keys. It does not use startAt or limit; send manageable batches of keys. Request historical versions explicitly when your export needs them.

3. Retrieve individual Test Runs

Use format=detail and type=testCaseRuns to retrieve individual executions, including executions associated with Test Plans.

curl --get "$VANSAH_BASE_URL/api/v2/runs" \
--header "Authorization: $VANSAH_TOKEN" \
--data-urlencode "projectKey=$SPACE_KEY" \
--data-urlencode "format=detail" \
--data-urlencode "type=testCaseRuns" \
--data-urlencode "startAt=0" \
--data-urlencode "limit=50" \
--output test-runs-0.json

Example response excerpt:

{
"success": true,
"pagination": { "total": 1, "startAt": 0, "limit": 50 },
"data": [
{
"caseKey": "DEMO-C1",
"testRunIdentifier": "22222222-2222-4222-8222-222222222222",
"testCaseVersion": 1,
"resultName": "PASSED"
}
]
}

The full rows also include execution context, timestamps, result information, and Test Run properties. Keep testRunIdentifier for the next step. Do not use the displayed numeric testRunKey in an endpoint that requires a UUID.

To narrow this request, use caseKey or caseIdentifier, testCaseVersion, issueKey, testFolderIdentifier, environmentIdentifier, releaseJiraID, sprintJiraID, or resultID as appropriate. The default type=misc groups runs by Test Case, so keep type=testCaseRuns when exporting individual executions.

4. Retrieve execution details and history

Replace RUN_UUID with a returned testRunIdentifier.

RUN_UUID="22222222-2222-4222-8222-222222222222"

curl --get "$VANSAH_BASE_URL/api/v2/run/$RUN_UUID/details" \
--header "Authorization: $VANSAH_TOKEN" \
--data-urlencode "autoCreateLogs=0" \
--data-urlencode "iterationNumber=1" \
--output run-details.json

curl "$VANSAH_BASE_URL/api/v2/run/$RUN_UUID/history?sortOrder=ASC" \
--header "Authorization: $VANSAH_TOKEN" \
--output run-history.json

Details are returned in data.run and include saved execution logs and results. Keep autoCreateLogs=0 when exporting so the request does not create missing execution logs.

For Test Runs with Test Data Collection iterations, read data.run.iteration.nums, then request details for each returned number using iterationNumber. This parameter selects the Test Run’s data iteration; it does not select a different Test Plan iteration.

The history response returns change entries in data.run. Change history records updates to a run; the list from Step 3 supplies the individual executions.

To retrieve a Test Case’s change history, use its caseIdentifier:

CASE_UUID="11111111-1111-4111-8111-111111111111"

curl "$VANSAH_BASE_URL/api/v2/testCase/$CASE_UUID/history?sortOrder=ASC" \
--header "Authorization: $VANSAH_TOKEN" \
--output test-case-history.json

Both history endpoints accept sortOrder=ASC or DESC. They return the matching history without startAt / limit pagination.

Retrieve every page

Test Case and Test Run list requests default to 50 records. Repeat the request with startAt=50, then 100, and so on, using a new output filename for each page.

Endpoint

Records

Pagination

GET /testCases

data.data

data.pagination

GET /runs?format=detail&type=testCaseRuns

data

pagination

Use the returned page size to calculate the next offset. Stop when you have reached the reported total or a page returns no records. Check success and any error message before treating an empty response as the end.

Keep the same filters throughout the export. If data changes while you are retrieving pages, records can move between pages; check identifiers for duplicates and reconcile counts when the export finishes.

Retrieve folder and Test Plan structure

Use these GET requests with projectKey to keep the relationships and organization alongside your Test Cases and runs.

Request path

What it returns

/testFolders?type=list

Test Folders as a paginated list. Use type=tree for a nested hierarchy.

/testFolders?type=issue

Jira work items represented in Vansah’s testing context.

/testFolders?type=plannedtestrun

Test Plans in the Jira space.

/testplan/folders?type=list

Folders used to organize Test Plans. Use type=tree for their hierarchy.

These endpoints require type. List requests support startAt and limit and default to 1,000 records. Follow their returned pagination rather than assuming the first response includes every folder or plan.

Retrieve settings used to interpret the data

GET request path

Use it to retrieve

/projects

Jira spaces accessible to the token account. Supports startAt, limit, and an exact key filter.

/category/caseTypes?projectKey=DEMO

Test Case type names and identifiers.

/category/testCaseStatuses?projectKey=DEMO

Test Case status names and identifiers.

/project/testResultSettings?projectKey=DEMO

The Jira space’s result settings and Test Result names.

/project/miscSettings?projectKey=DEMO

The Jira space’s Vansah configuration.

Append the paths to VANSAH_BASE_URL/api/v2 and use the same Authorization header. Replace DEMO with your Jira space key. Category lists support startAt / limit and default to 100 records.

Check the exported files

  • Match definitions and runs using the Test Case key and version, and keep the UUIDs for further API requests.

  • Confirm that every required page and data iteration was retrieved.

  • Keep original JSON alongside any CSV or reporting tables you build, so nested fields remain available.

  • Attachment entries or links in JSON are references. They do not make the JSON file a copy of the attachment files.

  • These requests export the selected records and settings. Plan separately for any additional data required by a migration or backup.

Troubleshooting

Problem

What to check

The runs request reports a validation error

Include format=detail and a valid type. Check the returned field errors.

Run details or history says the identifier is invalid

Use the UUID from testRunIdentifier, rather than the numeric Test Run key.

Only 50 cases or runs were exported

Retrieve the remaining pages with startAt and limit.

Data is missing or access is denied

Check token validity, the copied API Connect URL, Jira space access, and your request filters.

Historical values do not match the current Test Case

Match the run’s testCaseVersion to the definition and script version you request.

For help with an export, contact Vansah support with the request path and error response, excluding tokens and sensitive data.

Did this answer your question?