API test cases
You want a script to find the tests InsightJet made for your app, read their code, and run them, for example after a deploy. You reach only your own test cases: one that is someone else’s is 404 not_found, the same as one that does not exist. The commands assume the variables from Tickets and ticket runs:
export INSIGHTJET_API_KEY="<your key>"BASE=https://insightjet.ai/api/v1List test cases
Section titled “List test cases”curl "$BASE/crawls/42/test-cases?page=1&limit=50" -H "Authorization: Bearer $INSIGHTJET_API_KEY"{ "total": 120, "page": 1, "limit": 50, "testCases": [ { "...": "..." } ] }The current version of each test case across all the application’s crawls (one per lineage, the highest version), as the Test Cases list in the app shows them, with version and lineageId. The code fields are left out; read one test case for them. page starts at 1; limit is up to 200 (50 by default). The fields of each entry are not listed here: not confirmed beyond version and lineageId.
Expected result: status 200 with total, page, limit and a testCases array.
Read a test case
Section titled “Read a test case”curl "$BASE/test-cases/301" -H "Authorization: Bearer $INSIGHTJET_API_KEY"The full test case: name, description, feature, scenario, version, lineageId, Gherkin steps, Playwright code, JSON steps, page-object code, factory code and tags. The exact field names are not confirmed.
Expected result: status 200 and the test case with its code.
Read its history
Section titled “Read its history”curl "$BASE/test-cases/301/history" -H "Authorization: Bearer $INSIGHTJET_API_KEY"{ "testCaseId": 301, "currentVersion": 3, "lineageId": "...", "history": [ { "...": "..." } ] }Earlier versions with their changeset diffs, newest first. A re-crawl that changes a test case moves the old content here.
Expected result: status 200, currentVersion and a history array.
Run a test case
Section titled “Run a test case”curl -X POST "$BASE/test-cases/301/runs" \ -H "Authorization: Bearer $INSIGHTJET_API_KEY" \ -H "Content-Type: application/json" \ -d '{"targetUrl": "https://staging.shop.example.com/"}'Runs the test on the crawler’s Playwright runner and waits for the result, up to five minutes. The body is optional: targetUrl runs the test against another address (staging, a preview) instead of the crawl’s, and must not contain a login. The answer describes the result: pass or fail, step counts, duration, a video address and an error. Its exact field names are not confirmed. A run uses agent-hours.
Expected result: status 200 and the result of the run. Failures: 409 no_executable_code (no Playwright code), 402 out_of_hours, 429 all_agents_working, 502 run_failed (the crawler did not run it), 400 address_has_login.
Run it as a page-object test
Section titled “Run it as a page-object test”curl -X POST "$BASE/test-cases/301/pom-runs" -H "Authorization: Bearer $INSIGHTJET_API_KEY"{ "suiteRunId": 88, "testCaseId": 301, "status": "running", "insightjetLink": "https://insightjet.ai/..." }Runs the test case as a page-object spec. The answer comes at once; Location is /api/v1/pom-suite-runs/88, where you read the result. The application’s login must be saved in InsightJet’s Settings: the API never takes one.
Expected result: status 202, status: "running" and a suiteRunId. If there is no saved login the answer is 409 needs_app_credentials and details.missing names the values it lacks. A test case that is not a runnable page-object spec is 409 not_runnable_pom_spec.
Test reports
Section titled “Test reports”curl "$BASE/test-reports?timeRange=30d" -H "Authorization: Bearer $INSIGHTJET_API_KEY"Pass and fail rates, run counts and the average duration of your test runs in a range, and the ten newest runs. timeRange is 1d, 7d, 30d or all (7d by default). The field names are not confirmed.
Expected result: status 200 and the report.
Test run history of a crawl
Section titled “Test run history of a crawl”curl "$BASE/crawls/42/test-runs?testCaseId=301&limit=10" -H "Authorization: Bearer $INSIGHTJET_API_KEY"Test runs with per-spec detail: status, step counts, duration, error and video address. With testCaseId, that test’s runs; without it, a summary of every test of the crawl. limit is up to 50 (10 by default). A crawl that is not yours is 404 not_found.
Expected result: status 200 and the runs.
Test flows
Section titled “Test flows”curl "$BASE/test-flows?crawlId=42" -H "Authorization: Bearer $INSIGHTJET_API_KEY"Your saved test flows, newest change first; crawlId is optional and limits them to one crawl. The answer is an array.
Expected result: status 200 and an array of flows, empty if you have none.