Shared Preconditions
How to work with shared preconditions using the public API
The shared preconditions endpoints allow you to manage reusable test preconditions that can be referenced across multiple test cases. Shared preconditions consist of a title and text content that describes the initial state or setup required before executing test cases.
About Shared Preconditions
Shared preconditions are reusable precondition templates that can be used in multiple test cases. They consist of:
- Title: A descriptive name for the shared precondition (required, minimum 1 character)
- Text: The actual precondition content in HTML format (required, minimum 1 character)
When a shared precondition is used in a test case, it provides consistent setup instructions. Updates to a shared precondition automatically propagate to all test cases that reference it.
- Shared preconditions must have both a title and text content
- The title of a shared precondition must be unique within a project
- Shared preconditions are versioned - updates create new versions while preserving old ones
- Deleted shared preconditions are no longer returned by these endpoints, but test case versions that reference them still return them, with
deletedAtset
List Shared Preconditions
/paginated endpoints are transitional. In API v1, the base paths will return paginated responses and the /paginated suffix will be removed.
Retrieves all shared preconditions within a project, optionally sorted and with additional fields included.
Path Parameters
project_id: The project identifier (can be either the project code or UUID)
Query Parameters
| Parameter | Type | Description | Default | Example |
|---|---|---|---|---|
offset | number | Number of items to skip. | 0 | offset=10 |
limit | number | Maximum number of items to return. Accepted range: 0–1,000. | 100 | limit=20 |
sortField | string | Field to sort by: created_at or title. | title | sortField=title |
sortOrder | string | Sort direction for sortField: asc or desc. | asc | sortOrder=asc |
include | string | Include additional fields omitted by default. Accepted value: tcaseCount. | None | include=tcaseCount |
- Use
include=tcaseCountto see how many test cases reference each shared precondition - Sorting by
created_atshows the most recently created preconditions first (withdesc) or oldest first (withasc) - Sorting by
titleprovides alphabetical ordering - If no
sortFieldis specified, the default sort is bytitlein ascending order
Example Request
Fetch all shared preconditions
curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/paginatedFetch all shared preconditions sorted by title in ascending order
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/paginated?sortField=title&sortOrder=asc"Fetch all shared preconditions sorted by creation date (newest first)
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/paginated?sortField=created_at&sortOrder=desc"Fetch all shared preconditions with test case count included
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/paginated?include=tcaseCount"Response Fields
{
total: number // Number of matching shared preconditions across all pages
offset: number // Offset applied to this response
limit: number // Limit applied to this response
data: Array<{ // Shared preconditions in this page
projectId: string // ID of the project the precondition belongs to
id: number // Shared precondition ID
version: number // Version of the shared precondition
title: string // Title of the shared precondition
type: string // Type of the precondition (always `shared` for shared preconditions)
text: html // Text of the precondition
isLatest: boolean // Whether this is the latest version of the precondition
createdAt: datetime // Time the shared precondition was first created
updatedAt: datetime // Time this version was created
tcaseCount?: number // Number of test cases using this shared precondition; only with `include=tcaseCount`
}>
}Example Response
{
"total": 3,
"offset": 0,
"limit": 100,
"data": [
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 1,
"version": 2,
"title": "User is logged in",
"type": "shared",
"text": "<p>The user has valid credentials and is authenticated in the system</p>",
"isLatest": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-20T14:45:00.000Z",
"tcaseCount": 15
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 2,
"version": 1,
"title": "Application is running",
"type": "shared",
"text": "<p>The application server is running and accessible</p>",
"isLatest": true,
"createdAt": "2025-01-16T09:15:00.000Z",
"updatedAt": "2025-01-16T09:15:00.000Z",
"tcaseCount": 15
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 3,
"version": 1,
"title": "Database is initialized",
"type": "shared",
"text": "<p>The database contains the required test data</p>",
"isLatest": true,
"createdAt": "2025-01-17T11:20:00.000Z",
"updatedAt": "2025-01-17T11:20:00.000Z",
"tcaseCount": 3
}
]
}List Shared Preconditions (Deprecated)
Deprecated
This endpoint is deprecated. Use List Shared Preconditions (GET /api/public/v0/project/{project_id}/shared-precondition/paginated) instead.
Retrieves all shared preconditions within a project, optionally sorted and with additional fields included.
Path Parameters
project_id: The project identifier (can be either the project code or UUID)
Query Parameters
All query parameters are optional.
| Parameter | Type | Description | Default | Example |
|---|---|---|---|---|
sortField | string | Field to sort by: created_at or title. | title | sortField=title |
sortOrder | string | Sort direction for sortField: asc or desc. | asc | sortOrder=asc |
include | string | Include additional fields omitted by default. Accepted value: tcaseCount. | None | include=tcaseCount |
- Use
include=tcaseCountto see how many test cases reference each shared precondition - Sorting by
created_atshows the most recently created preconditions first (withdesc) or oldest first (withasc) - Sorting by
titleprovides alphabetical ordering - If no
sortFieldis specified, the default sort is bytitlein ascending order
Example Request
Fetch all shared preconditions
curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-preconditionFetch all shared preconditions sorted by title in ascending order
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?sortField=title&sortOrder=asc"Fetch all shared preconditions sorted by creation date (newest first)
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?sortField=created_at&sortOrder=desc"Fetch all shared preconditions with test case count included
curl \
-H "Authorization: ApiKey your.api.key.here" \
"https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?include=tcaseCount"Response Fields
Array<{ // List of shared precondition objects
projectId: string // ID of the project the precondition belongs to
id: number // Shared precondition ID
version: number // Version of the shared precondition
title: string // Title of the shared precondition
type: string // Type of the precondition (always `shared` for shared preconditions)
text: html // Text of the precondition
isLatest: boolean // Whether this is the latest version of the precondition
createdAt: datetime // Time the shared precondition was first created
updatedAt: datetime // Time this version was created
tcaseCount?: number // Number of test cases using this shared precondition; only with `include=tcaseCount`
}>Unlike the other deprecated lists, the array isn't wrapped in an object, and a project without shared preconditions returns null rather than [].
Example Response
[
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 1,
"version": 2,
"title": "User is logged in",
"type": "shared",
"text": "<p>The user has valid credentials and is authenticated in the system</p>",
"isLatest": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-20T14:45:00.000Z",
"tcaseCount": 15
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 2,
"version": 1,
"title": "Application is running",
"type": "shared",
"text": "<p>The application server is running and accessible</p>",
"isLatest": true,
"createdAt": "2025-01-16T09:15:00.000Z",
"updatedAt": "2025-01-16T09:15:00.000Z",
"tcaseCount": 15
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 3,
"version": 1,
"title": "Database is initialized",
"type": "shared",
"text": "<p>The database contains the required test data</p>",
"isLatest": true,
"createdAt": "2025-01-17T11:20:00.000Z",
"updatedAt": "2025-01-17T11:20:00.000Z",
"tcaseCount": 3
}
]Get Shared Precondition
Get details of a single shared precondition using its ID.
Path Parameters
project_id: The project identifier (can be either the project code or UUID)shared_precondition_id: The shared precondition identifier (numeric ID)
Example Request
curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/1Response Fields
{
projectId: string // ID of the project the precondition belongs to
id: number // Shared precondition ID
version: number // Version of the shared precondition
title: string // Title of the shared precondition
type: string // Type of the precondition (always `shared` for shared preconditions)
text: html // Text of the precondition
isLatest: boolean // Whether this is the latest version of the precondition
createdAt: datetime // Time the shared precondition was first created
updatedAt: datetime // Time this version was created
tcaseCount: number // Number of test cases using this shared precondition
}Example Response
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 1,
"version": 2,
"title": "User is logged in",
"type": "shared",
"text": "<p>The user has valid credentials and is authenticated in the system</p>",
"isLatest": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-20T14:45:00.000Z",
"tcaseCount": 15
}Create Shared Precondition
Creates a shared precondition. Test cases use it by its ID, through precondition.sharedPreconditionId.
Request Body
{
title: string // Title (1–255 characters), unique in the project
text: html // Text of the precondition
}Response
Status: 201 Created
The created shared precondition, as Get Shared Precondition returns it.
Errors
| Status Code | Description |
|---|---|
| 409 | A shared precondition with the same title exists |
Update Shared Precondition
Changes the title or the text of a shared precondition.
Every test case that uses the shared precondition gets a new version, and open runs get the new versions, like after any test case update.
Request Body
{
title?: string // New title (1–255 characters), unique in the project
text?: html // New text
}Omitted fields are left unchanged. A request that changes nothing returns the shared precondition as it is, without a new version.
Response
Status: 200 OK
The updated shared precondition, as Get Shared Precondition returns it.
Errors
| Status Code | Description |
|---|---|
| 409 | A shared precondition with the same title exists |
Delete Shared Precondition
Deletes a shared precondition.
Irreversible
Deleted shared preconditions don't go to the trash and can't be restored. Every test case that uses the shared precondition gets a new version with its text copied in as a standalone precondition, so it can't be linked to the shared precondition again.
Response
Status: 200 OK
{
message: string
}