Authentication and paging
How requests are authenticated and authorised, how to keep keys out of your code, and how to page through large lists reliably.
The Authorization header#
Every request except /v1/health and /v1/openapi.json needs your personal API key as a bearer token:
GET /v1/findings HTTP/1.1
Host: api.pentesys.io
Authorization: Bearer pts_YOUR_KEY
Accept: application/json
There is no sign-in flow, cookie or OAuth for the API or the MCP connector: the key is the only credential. A missing or malformed key gets 401 with a WWW-Authenticate: Bearer realm="Pentesys" header:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="Pentesys"
{"error":{"code":"missing_api_key","message":"Send your API key: Authorization: Bearer pts_… (create one in Pentesys Enterprise under Account → API keys)."}}
What is checked on every request#
- Format:
pts_followed by exactly 40 letters and digits. Anything else isinvalid_api_key. - The key: it exists, has not expired and has not been revoked; your organisation still allows API keys (
api_keys_disabledotherwise). - You: your membership is Active and you are still in the organisation, and your sign-in account is enabled (
account_disabledotherwise). - The key's access: a read-only key can only use
GET(read_only_keyotherwise). - Your permission: re-read from your current role profiles, for example
findings.triageto change a finding's status (forbiddenotherwise). - Your scope: records outside your organisation or asset groups are reported as
404 not_found, exactly as if they did not exist.
Your role is re-read on every call, so a change made by your administrator applies to your next request.
Keeping keys out of code#
# ~/.bashrc or a local .env file that is never committed
export PENTESYS_API_KEY="pts_YOUR_KEY"
curl -s https://api.pentesys.io/v1/me -H "Authorization: Bearer $PENTESYS_API_KEY"
# Store the key as a repository or environment secret named PENTESYS_API_KEY
jobs:
export:
runs-on: ubuntu-latest
steps:
- name: Export overdue remediation
env:
PENTESYS_API_KEY: ${{ secrets.PENTESYS_API_KEY }}
run: |
curl -sf "https://api.pentesys.io/v1/remediation?sla=Overdue&per_page=100" \
-H "Authorization: Bearer $PENTESYS_API_KEY" > overdue.json
import os, requests
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['PENTESYS_API_KEY']}"
me = session.get("https://api.pentesys.io/v1/me", timeout=30).json()
print(me["organisation"]["name"], me["permissions"])
- Use a separate key per integration, and a read-only key unless it must write.
- Never log the
Authorizationheader. Most HTTP libraries do not, but debugging proxies and verbose modes (curl -v) do. - Rotate before expiry: create the new key, update the secret, check Last used on the new key, then revoke the old one.
Paging#
Every list endpoint is paged. Send page (from 1) and per_page (1 to 100, default 25). The response has data and a meta block:
GET /v1/remediation?sla=Overdue&page=2&per_page=50
{
"data": [
{ "code": "REM-FND-1042", "title": "SQL injection in product search", "owner": "Platform team",
"severity": "Critical", "status": "In progress", "due_date": "2026-11-20", "source": "Validate", "ticket": "PLAT-381" }
],
"meta": { "page": 2, "per_page": 50, "total": 51, "last_page": 2 }
}
page- The page returned.
per_page- Rows per page.
total- Rows matching your filters (and visible to you).
last_page- The final page number. Stop when
pagereaches it.
A per_page above 100, or a page below 1, is rejected with 422 validation_failed.
Walking every page#
def all_rows(session, path, **params):
page = 1
while True:
r = session.get(f"https://api.pentesys.io/v1{path}",
params={**params, "page": page, "per_page": 100}, timeout=30)
r.raise_for_status()
body = r.json()
yield from body["data"]
if page >= body["meta"]["last_page"]:
return
page += 1
for finding in all_rows(session, "/findings", status="open"):
print(finding["code"], finding["severity"], finding["title"])
async function* allRows(path, params = {}) {
for (let page = 1; ; page++) {
const qs = new URLSearchParams({ ...params, page, per_page: 100 });
const res = await fetch(`https://api.pentesys.io/v1${path}?${qs}`, {
headers: { Authorization: `Bearer ${process.env.PENTESYS_API_KEY}` },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const body = await res.json();
yield* body.data;
if (page >= body.meta.last_page) return;
}
}
for await (const f of allRows("/findings", { status: "open" })) console.log(f.code, f.title);
Data is read live, so rows can move between pages if records change while you page. For an exact snapshot, filter narrowly (for example by severity or status) and page quickly, or re-run the export.
Filters and sorting#
- Filters are query parameters, combined with AND:
?status=open&severity=High. - Values are case-sensitive and must be one of the documented values, for example
severity=Criticalnotcritical. Spaces are URL-encoded:status=In%20progress. qis a free-text search (up to 100 characters).- Unknown parameters are ignored; invalid values for known parameters are rejected with
422. - Only
/assetstakessort(exposure,name,observed); other lists have a fixed order.