Skip to content

API discoveries and app knowledge

A discovery tries the interactions on a page of your app and records what changes (see Component Discovery). You want a script to start one, wait for it and use what it found. The commands assume the variables from Tickets and ticket runs. A discovery or crawl that is not yours is 404 not_found.

Terminal window
curl "$BASE/crawls/42/discoveries" -H "Authorization: Bearer $INSIGHTJET_API_KEY"

The discovery agents of the crawl with their status and progress, as an array. A crawl that is not yours lists none. The field names are not confirmed.

Expected result: status 200 and an array, empty if there is none.

Terminal window
curl -X POST "$BASE/crawls/42/discoveries" \
-H "Authorization: Bearer $INSIGHTJET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Login form discovery", "targetUrl": "https://shop.example.com/login", "maxScenarios": 20}'
{ "agentId": 9, "status": "queued", "queuePosition": 1 }

Queues a discovery agent that analyzes component interactions on the page, runs scenarios and, by default, generates test cases when it is done. Those test cases are merged into the page-object suite, which can replace a page object’s code. It runs for a while: the answer comes at once and Location is /api/v1/discoveries/9. A start uses agent-hours.

The body:

FieldTypeRequiredWhat it is
namestringYesA name for the agent, 1 to 200 characters
targetUrlstringYesThe address to discover on, up to 2,048 characters; it must not contain a login
targetComponentIdsstring[]NoComponent ids to focus on, up to 200
autoGenerateTestCasesbooleanNoGenerate test cases when done; true by default
maxScenariosnumberNoAt most this many scenarios, 1 to 1,000; unlimited by default

No other field is accepted.

Expected result: status 202, status: "queued", an agentId and a queuePosition. Failures: 400 address_has_login, 402 out_of_hours, 429 all_agents_working.

Terminal window
curl "$BASE/discoveries/9" -H "Authorization: Bearer $INSIGHTJET_API_KEY"
curl "$BASE/discoveries/9/results" -H "Authorization: Bearer $INSIGHTJET_API_KEY"

The first answers the status and progress of the agent, including one still running; ask again until it has finished. The second answers the full results: scenarios, mutations and how many test cases it generated. The field names and the status values are not confirmed, except that a finished discovery is completed.

Expected result: status 200 for each.

Terminal window
curl -X POST "$BASE/discoveries/9/test-cases" -H "Authorization: Bearer $INSIGHTJET_API_KEY"
{ "agentId": 9, "testCasesGenerated": 6, "insightjetLink": "https://insightjet.ai/..." }

Generates test cases from a completed discovery’s scenarios and mutations. Each is merged into the page-object suite, which can replace a page object’s code.

Expected result: status 200 and testCasesGenerated. A discovery that is not completed is 409 discovery_not_completed with details.status; 502 generation_failed when generation failed.

Terminal window
curl "$BASE/app-knowledge?url=https://shop.example.com/" -H "Authorization: Bearer $INSIGHTJET_API_KEY"

The features runs have exercised on one of your applications, with the evidence and when each was last confirmed. It answers only for an address on the site, and first path part, of one of your own crawls; any other address is 404 not_found and the crawler is not asked. An entry is marked observed (a run saw it) or inferred (a model wrote it); the mark is always kept. The answer says its state: features, recorded-nothing or no-features-yet. An address with a login in it is 400 address_has_login. The rest of the answer’s field names are not confirmed.

Expected result: status 200 and a state. 502 app_knowledge_unavailable when it could not be read just now.