Skip to content

Get test results with an API key

Use a read-only project key when a script needs to answer “Did our latest run pass?” You’ll need a project with at least one reported run and a terminal with Bash, curl, and jq.

As a workspace owner or admin, open Project settings → API keys. Under Public API keys, choose Create key, name it (for example, ci-status), select Read only, and create it. Copy the key while it’s visible.

Paste it at the prompt in your terminal. Bash hides what you type.

Terminal window
read -rs -p 'Public API key: ' TESTPERCH_READ_KEY
echo

Use the key to look up its project ID, then request one run from that project.

Terminal window
api=https://testperch.com/api/public/v1
project_id=$(curl -fsS -H "X-API-Key: $TESTPERCH_READ_KEY" "$api/context" | jq -er '.project_restriction.id')
curl -fsS -H "X-API-Key: $TESTPERCH_READ_KEY" "$api/projects/$project_id/runs?first=1" |
jq '.edges[].node | {status, branch, started_at, web_url}'

Look for status in the output. A finished run may show passed or failed. A run still in progress shows running. Open web_url to see the individual tests. Compare the branch and start time with the latest entry in Runs.

To send the same request from your browser, open Try the API and choose List whole runs. Enter your read-only key for X-API-Key, use the same project_id, and set first to 1.

See the runs API reference for the filters you can use to find a particular CI build and the fields returned for each run.