Test-Lab.aiDocs
API Reference

Run Tests

POST /api/v1/run - Trigger test plan execution

Run Tests

Trigger one or more test plans programmatically.

POST https://test-lab.ai/api/v1/run

Authentication

Authorization: Bearer tl_xxxxx

Request Body

FieldTypeRequiredDescription
testPlanIdnumberOne of theseRun a single test plan
testPlanIdsnumber[] | stringOne of theseRun multiple test plans
projectIdnumberOne of theseRun all test plans for a project
testTypestringNo"quickTest" or "deepTest" (default: plan's default)
buildIdstringNoCI build/commit identifier (max 100 chars)
cookiesarrayNoAuthentication cookies to inject (see below)

Exactly one of testPlanId, testPlanIds, or projectId must be provided.

FieldTypeRequiredDescription
namestringYesCookie name
valuestringYesCookie value
domainstringYesDomain (e.g. .example.com)

Cookies can also be configured at the project or test plan level in the dashboard. Runtime cookies override stored cookies.

Examples

Single Test Plan

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "testPlanId": YOUR_TEST_PLAN_ID,
    "testType": "quickTest"
  }'

Response:

{
  "jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "running",
  "testPlanId": YOUR_TEST_PLAN_ID,
  "testType": "quickTest"
}

Multiple Test Plans

Using an array:

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "testPlanIds": [ID_1, ID_2, ID_3],
    "testType": "deepTest"
  }'

Using a comma-separated string:

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "testPlanIds": "ID_1,ID_2,ID_3"
  }'

Response (multiple plans):

{
  "jobs": [
    {
      "jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "status": "running",
      "testPlanId": YOUR_TEST_PLAN_ID,
      "testPlanName": "Login Flow",
      "testType": "deepTest"
    },
    {
      "jobId": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
      "status": "running",
      "testPlanId": ID_2,
      "testPlanName": "Signup Flow",
      "testType": "deepTest"
    }
  ],
  "triggered": 2,
  "failed": 0
}

All Plans for a Project

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "projectId": YOUR_PROJECT_ID
  }'

With Build ID (CI Integration)

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "testPlanId": YOUR_TEST_PLAN_ID,
    "buildId": "abc123"
  }'

Response with buildId:

With Authentication Cookies

curl -X POST https://test-lab.ai/api/v1/run \
  -H "Authorization: Bearer tl_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "testPlanId": YOUR_TEST_PLAN_ID,
    "cookies": [
      { "name": "session", "value": "abc123xyz", "domain": ".myapp.com" }
    ]
  }'

Response:

{
  "jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "running",
  "testPlanId": YOUR_TEST_PLAN_ID,
  "testType": "quickTest",
  "buildId": "abc123"
}

Response Fields

Single Plan Response

FieldTypeDescription
jobIdstringUUID of the created job
statusstring"running", "queued", or "pending"
testPlanIdnumberID of the test plan
testTypestringTest mode used
buildIdstringBuild ID if provided

Multiple Plans Response

FieldTypeDescription
jobsarrayArray of job objects
jobs[].jobIdstringUUID of each job
jobs[].statusstringStatus of each job
jobs[].testPlanIdnumberTest plan ID
jobs[].testPlanNamestringTest plan name
jobs[].testTypestringTest mode
jobs[].errorstringError if job failed to start
triggerednumberCount of successfully triggered jobs
failednumberCount of failed jobs
buildIdstringBuild ID if provided

Error Responses

Invalid API Key

{
  "error": "Invalid API key"
}

Status: 401

Insufficient Credits

{
  "error": "Insufficient credits. Please top up to continue running tests."
}

Status: 402

Test Plan Not Found

{
  "error": "No test plans found"
}

Status: 404

Invalid Parameters

{
  "error": "One of testPlanId, testPlanIds, or projectId is required"
}

Status: 400

Code Examples

JavaScript/Node.js

const response = await fetch('https://test-lab.ai/api/v1/run', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.TESTLAB_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    testPlanId: YOUR_TEST_PLAN_ID,
    testType: 'quickTest',
    buildId: process.env.GITHUB_SHA,
  }),
});

const data = await response.json();
console.log('Job started:', data.jobId);

Python

import requests
import os

response = requests.post(
    'https://test-lab.ai/api/v1/run',
    headers={
        'Authorization': f'Bearer {os.environ["TESTLAB_API_KEY"]}',
        'Content-Type': 'application/json',
    },
    json={
        'testPlanId': YOUR_TEST_PLAN_ID,
        'testType': 'quickTest',
        'buildId': os.environ.get('GITHUB_SHA'),
    }
)

data = response.json()
print(f'Job started: {data["jobId"]}')

Next Steps

On this page