Test Execution API | Testifly Documentation

Test Execution API Workflow

This guide shows the full flow for starting a new test execution, checking the job that was created, and then loading the final test run report.

1. Start a new test execution

  1. Send a request to POST /api/testExecution/{projId}.
  2. Include your project API key in the x-api-key header.
  3. Pass action: "executeTests" and add the filters that describe what should run.
  4. If you have remote agents connected, you can also pass agentName to route the job to a specific runner.
  5. Save the returned jobId, because you will use it to track the execution job.

The request body below starts a run for a feature. You can swap featureId for testSuiteId, testId, or tests depending on what you want to execute.

{
  "action": "executeTests",
  "featureId": "67f8cb3fe236b8d41b7700ac",
  "agentName": "my-agent"
}

The API response tells you whether the job was accepted and gives you the job identifier.

{
  "success": true,
  "scheduleStatus": "Success",
  "jobId": "6804f1d1d2d4e0a1c1a0d123"
}

What the request fields mean

If the API returns AlreadyExists, the same execution job is already queued, so you should reuse the existing jobId instead of creating a duplicate run.

2. Monitor the job status

  1. Send a request to POST /api/jobs/{projId}.
  2. Pass the jobIds you want to inspect.
  3. Poll this endpoint until the job reaches a terminal state.
  4. Use the returned testRunId to open the final run report.

The request body below checks one job. You can include more job ids in the same array if you want to poll several executions at once. You can also omit the jobIds field to get a list of all active jobs for the project from the last month, but that is not recommended for regular polling because the response will be larger and less efficient to process.

{
  "jobIds": ["6804f1d1d2d4e0a1c1a0d123"]
}

A typical status response contains the current job state, the last update time, and the linked test run id when it becomes available.

{
  "success": true,
  "jobs": [
    {
      "jobId": "6804f1d1d2d4e0a1c1a0d123",
      "status": "InProgress",
      "updatedAt": "2026-04-20T10:15:30.000Z",
      "testRunId": "6804f1e2d2d4e0a1c1a0d456"
    }
  ],
  "missingJobIds": []
}

How to read the job status

3. Monitor the test run status and result

  1. Wait until the job response includes a testRunId.
  2. Send a request to GET /api/testRun/{projId}/{runId}.
  3. Read the overall run summary first, then inspect each test result.
  4. Use the per-test status, timeline, and video link to understand what happened during execution.

The run report response gives you the full result set for the execution.

{
  "runId": "6804f1e2d2d4e0a1c1a0d456",
  "projectId": "67f8cb3fe236b8d41b7700ac",
  "status": "Completed",
  "startTime": "2026-04-20T10:15:31.000Z",
  "testsInProjectCount": 24,
  "title": "Regression run",
  "statuses": [
    {
      "label": "Passed",
      "count": 18
    },
    {
      "label": "Failed",
      "count": 2
    },
    {
      "label": "Skipped",
      "count": 4
    }
  ],
  "tests": [
    {
      "_id": "6804f1f1d2d4e0a1c1a0d789",
      "title": "Login works for valid users",
      "status": "Passed",
      "duration": 1240,
      "hasVideo": true,
      "videoLink": "https://example.com/videos/run-1",
      "startTime": "2026-04-20T10:15:40.000Z",
      "timeline": []
    }
  ]
}

What to look for in the run report

4. Suggested polling flow

  1. Create the execution job.
  2. Poll /api/jobs/{projId} until the job status becomes InProgress or Success and a testRunId is present.
  3. Load /api/testRun/{projId}/{runId} with that testRunId.
  4. Keep refreshing the run report if you want to watch live progress while the job is still running.

5. Authentication and access

All documented endpoints expect the project API key in the x-api-key header.

x-api-key: your_project_api_key

If the key is missing or invalid, the API rejects the request before it reaches the execution or status logic.

6. Quick reference

Use the job response to find the run id, then use the run report to inspect the final result details.