Pentests
Start an AI pentest, follow it, read its findings and see what it cost.
An API pentest is the same run you would start from the dashboard:
same levels, same prices, same report.
Before the first run:
- Verify the target in the dashboard, the same way as for any pentest.
- Turn on API runs for it under your API keys in Settings.
- Copy the target's verification id from the same targets table, in the Verification id column. You pass it as
verificationIdwhen you start a run.
Proving you control the target
We only test hosts you can prove are yours. There are three ways, and the dialog offers the ones that can work for the host you typed.
| Method | What you publish | When to pick it |
|---|---|---|
| DNS TXT record | A _barrion-challenge TXT record | You run the DNS zone. Verifying acme.com covers every subdomain at once |
| File or GET endpoint | The value at a path on the host, /.well-known/barrion-verify.txt by default | You can serve a path on the host. The usual choice |
| HTML meta tag | A <meta> tag in the home page's <head> | You can edit the page but not DNS or the served paths |
File or GET endpoint is one method with the path prefilled and editable, because serving a file and answering a GET are the same thing to us: we fetch the path over HTTPS and look for the value in the body. It passes if the response is the value, or includes it as one part of the body, so a static file, a route of your own and an edge function all work, and a route that already answers JSON or HTML is fine with the value somewhere inside it.
Keep the prefilled path unless your host cannot serve it. The usual case for
changing it is a host a platform hands you whole and keeps the root of:
<project-ref>.supabase.co, us-central1-<project>.cloudfunctions.net,
<id>.execute-api.<region>.amazonaws.com and the like. The gateway routes only
its own prefixes, so /.well-known/ never reaches you; the domain is the
platform's, so there is no zone for a TXT record; and a JSON API has no home
page for a meta tag. There you say where the value is served instead - a
Supabase edge function at /functions/v1/barrion-verify, a public storage
object at /storage/v1/object/public/<bucket>/barrion-verify.txt, a function
route of your own. The field is editable on any host, so the same applies to an
API route on your own domain that has no /.well-known/ to serve.
Two things worth knowing before you change the path:
- The path has to be on the host you are verifying. Not another host, and not a redirect to one. Anything else is refused.
- Pick a path only your own server can answer. Verifying a target is what
authorizes us to attack it, and a path you choose is only proof if nobody else
could have put the value there. A page anyone visiting the site can post to, a
public upload directory, a shared paste route: none of those say anything
about who runs the host. The default
/.well-known/path is reserved for whoever operates the host, which is why it needs no thought. We also refuse a path that contains the value itself, because a great many hosts answer any address by printing it back, and that would look like a pass without proving anything.
If you verify the same host again later - setting up a schedule, or a new pentest - the field comes back prefilled with the path you used last time, so you do not retype it. It is only a suggestion: change it, or use the default path, whichever is right this time.
Types
Every pentest endpoint answers with these shapes.
type PentestStatus =
| "QUEUED"
| "VERIFYING" | "RECON" | "ENUMERATION" | "WEB_TEST" | "API_TEST" | "ANALYSIS" | "REPORTING"
| "COMPLETED" | "FAILED" | "CANCELLED" // only these three mean the run is over
// Only on runs started from the dashboard; the API never creates them:
| "AWAITING_PAYMENT" // waiting for a checkout to be paid
| "PAUSED"; // ran out of credits partway; can be resumed from the dashboard
type Pentest = {
id: string;
targetUrl: string;
status: PentestStatus;
depth: "LEAD" | "STANDARD" | "DEEP" | "EXTENDED" | "MAXIMUM"; // a run started from the API is one of the first three
apiKeyId: string | null; // the key that started it, null for a dashboard run
createdAt: string; // ISO 8601
startedAt: string | null;
completedAt: string | null;
reportReleased: boolean; // whether you may read its findings yet, see "Read the findings"
assurance: "AUTOMATED" | "EXPERT_REVIEWED"; // whether an engineer reviewed it, see "Expert review"
inconclusive: boolean; // true when a COMPLETED run could not reach the target, see "Read the findings"
credits: PentestCredits;
};
type PentestCredits = {
state: "RESERVED" | "CHARGED" | "RETURNED" | "NOT_CREDIT_FUNDED" | "AWAITING_PAYMENT";
reserved: number | null; // credits held at start
charged: number | null; // null until the run is settled
returned: number | null; // null until the run is settled
};
type PentestFinding = {
id: string;
title: string;
description: string | null;
severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
confidence: "CONFIRMED" | "FIRM" | "TENTATIVE";
affectedUrl: string | null;
remediation: string | null;
cvssScore: string | null;
cweId: string | null;
};Start a pentest
POST /v1/pentests · permission pentests:write · requires an Idempotency-Key header
Starts a run and holds its level's credits. Answers 201 with the run's id, which is how you follow it.
Request body
Prop
Type
Any other field is refused rather than ignored, so a typo fails loudly. The run's budget, duration and model come from the level and cannot be set.
Other domains in scope
targetUrl's host and every subdomain of it are tested already, so neither needs a row. Everything else the app touches goes in scopeDomains, one row per host, each saying what the run does with that host.
type ScopeDomain = {
domain: string; // a hostname, no scheme, port or path
intent: "TEST" | "REACH" | "SIGN_IN";
};intent | What the run does | Proof of ownership |
|---|---|---|
TEST | Tested in full, in the attack scope beside the target, and reported on. | Required |
REACH | Reached, not tested: read-only checks, crafted headers included, nothing that changes data or state. Findings on it are reported. | Required |
SIGN_IN | Signed in through and nothing else. Navigation scope only, and findings on it are dropped. | None: it is usually an identity provider you do not own |
A row covers that host and every subdomain of it, matched on a dot boundary, at the same intent. So one row for acme.io speaks for api.acme.io too, and acmeio.com is untouched by it.
Where a row needs proof of ownership, the host must be the verified target, a subdomain of it, or another domain you have verified. Unproven, the request is refused with a 400.
A REACH or SIGN_IN row for a host under the target takes that host back out of attack scope, which is how you spare a status page or an IdP subdomain the target would otherwise cover.
List each host once. One host on two rows is a 400, because the two rows would ask for different things and the run can only do one of them.
allowlistedDomains and loginProviderDomains are the older way to say the same thing and are still accepted. Sending scopeDomains together with either of them is a 400: there is no precedence rule, because picking one would silently run a scope you did not ask for.
type LoginProvider = { domain: string; mode: "LOGIN" | "TEST" }; // LOGIN is SIGN_INAPI specifications
An OpenAPI, Swagger, Postman or HAR file tells the agent what endpoints exist, so it tests the ones your crawl would never reach. Send one entry per file in apiSpecs.
type ApiSpec = {
format: "openapi" | "swagger" | "postman" | "har";
source: "inline" | "url";
content?: string; // the file itself, when source is "inline"
url?: string; // where to fetch it, when source is "url"
baseUrl?: string; // the API's base URL, if the file does not state it
};Exactly one of content and url is required, matched to source. A url spec is fetched by the run, in scope.
Several files is the normal case: a login API and an admin API are usually separate documents, and both get tested. Up to 5 files, and up to 1 MB of inline content across the whole list rather than per file, so five 200 KB specs fit where one 1 MB spec fits. Over either limit the request is a 400 naming which; for a file larger than the inline budget, host it and send source: "url".
apiSpec, the single specification, is still accepted and unchanged. If a request sends both, apiSpecs is what runs and apiSpec is ignored, so moving to the list is one edit and no coordination.
The specification is read for every applicationType, not only BACKEND_API: a web app's REST backend is worth seeding too.
Example
curl -X POST https://api.barrion.io/v1/pentests \
-H "Authorization: Bearer $BARRION_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: release-2026-09-28" \
-d '{
"targetUrl": "https://staging.example.com",
"verificationId": "6aca3f16-78aa-4e04-a77a-425a8b3d67ad",
"depth": "LEAD"
}'Response 201
type StartPentestResponse = { id: string; status: PentestStatus };{ "id": "3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c", "status": "QUEUED" }A retry with the same Idempotency-Key and body answers the same run, with the header Idempotent-Replayed: true, and starts nothing. See Idempotency.
Errors
| Status | Code | Why | What to do |
|---|---|---|---|
| 400 | VALIDATION_ERROR | A field is missing or invalid; field names it | Fix the request |
| 400 | VALIDATION_ERROR | humanSignedReport is true on a level below DEEP | Start the run at DEEP, or leave the flag off |
| 402 | INSUFFICIENT_CREDITS | Your balance does not cover the whole level | Top up, or pick a lighter level |
| 403 | TARGET_API_RUNS_DISABLED | API runs are off for this target | Turn them on in Settings |
| 403 | API_KEY_CAP_EXCEEDED | The run would take this key past its budget | Raise the key's budget |
| 403 | ORG_CREDIT_CAP_EXCEEDED | The run would take you past your allowance in the organization | Ask an organization admin |
| 403 | FORBIDDEN | The target's verification is not complete, has expired, or does not cover targetUrl | Re-verify the target in the dashboard |
| 403 | FORBIDDEN | In an organization, targetUrl is not one of the pentest targets assigned to you | Ask an organization admin for access |
| 404 | NOT_FOUND | No target verification with this verificationId in your account | Copy the id from the targets table under API keys |
| 409 | IDEMPOTENCY_IN_PROGRESS | The first request with this key is still running | Retry the same request shortly |
| 409 | CONFLICT | A pentest of yours is paused, and an account may hold one | Continue or stop it in the dashboard |
| 413 | PAYLOAD_TOO_LARGE | The body is over 100 KB | Shorten the notes, or pass a spec by URL instead of inline |
| 422 | IDEMPOTENCY_KEY_REUSED | This key was already used with a different body | Use a new key for a new run |
| 429 | PENTEST_CONCURRENCY_EXCEEDED | You already have as many pentests running as your account allows | Wait for one to finish |
| 429 | RATE_LIMITED | Too many starts in a minute, or three of your runs are parked waiting for payment | Wait for Retry-After; without that header, clear a parked run in the dashboard |
| 500 | INTERNAL_ERROR | The run could not be dispatched | Retry with the same Idempotency-Key |
A pentest is only started when your balance covers its whole level. The dashboard can start a run on part of a level and let you top up to continue; the API never does, because a pipeline cannot top up halfway through.
Authenticated runs
To test behind a login, pass test accounts in credentials, taken from your CI secret store on every run.
type Credential = {
name: string; // unique within the run; letters, digits, _ and -
kind?: "FORM_LOGIN" | "BEARER_TOKEN" | "BASIC_AUTH" | "COOKIE" | "API_KEY"; // default FORM_LOGIN
user: string; // username, or the header or parameter name for API_KEY
pass: string; // password, token or key value
totpSecret?: string; // authenticator-app secret, if the login needs one
instructions?: string; // non-secret guidance, e.g. "after login, open /profile"
mode?: "auto" | "json" | "form" | "browser"; // FORM_LOGIN: how the login is submitted; default auto
location?: "header" | "query"; // API_KEY: where the key is sent; default header
tokenUrl?: string; // BEARER_TOKEN: OAuth2 token URL for the client-credentials flow
scope?: string; // BEARER_TOKEN with tokenUrl: scope to request
audience?: string; // BEARER_TOKEN with tokenUrl: audience to request
};For BEARER_TOKEN without tokenUrl, pass is the token itself. With tokenUrl, user is the client id and pass the client secret, and Barrion requests the token and refreshes it during the run.
authHint tells the agent how the login works, so it does not have to find out. Nothing in it is a secret, and every field is optional:
type AuthHint = {
loginUrl?: string; // the sign-in page, if it is not where the agent would look
mode?: "auto" | "json" | "form" | "browser"; // how the form submits; default auto
userField?: string; // the username input's name, when it is not guessable
passField?: string; // the password input's name
extra?: Record<string, string>; // other fields the form needs, e.g. a tenant or realm
};Credentials are encrypted as they arrive and are never shown back to you or written to logs. They stay stored, encrypted, so Barrion's reviewers can verify findings behind the login and a retest of the same run can reuse them. A daily cleanup deletes them once they are 30 days old. Use dedicated test accounts, not real users' logins.
Get a pentest
GET /v1/pentests/{id} · permission pentests:read
The run's status and what it has cost so far. This is what a pipeline polls.
curl https://api.barrion.io/v1/pentests/3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c \
-H "Authorization: Bearer $BARRION_API_KEY"Response 200: Pentest
{
"id": "3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c",
"targetUrl": "https://staging.example.com",
"status": "WEB_TEST",
"depth": "LEAD",
"apiKeyId": "b81d4f0e-2c3a-4b5d-8e9f-0a1b2c3d4e5f",
"createdAt": "2026-09-28T10:02:11.000Z",
"startedAt": "2026-09-28T10:04:40.000Z",
"completedAt": null,
"reportReleased": true,
"inconclusive": false,
"credits": { "state": "RESERVED", "reserved": 400, "charged": null, "returned": null }
}A run can wait in QUEUED for a while before it starts: it is waiting for a free slot. FAILED runs are not charged, and CANCELLED ones only for the work they got through.
credits.state:
| State | Meaning |
|---|---|
RESERVED | Some of the run's credits are still held. charged and returned are null until all of them are settled |
CHARGED | Settled. charged credits were spent and returned went back to your balance |
RETURNED | Failed, cancelled before it started, or inconclusive. Everything reserved went back |
NOT_CREDIT_FUNDED | Paid for another way, for example included in your plan |
AWAITING_PAYMENT | A dashboard run waiting for its checkout. Nothing is reserved yet |
A run can be COMPLETED and still read RESERVED, for two reasons. Settling a finished run takes up to a minute or so. And on Standard and Deep, the part of the credits that pays for the expert review stays held until a reviewer signs the report off. See Credits.
Turning expert review off does not change what a run costs. The same credits are reserved and the same credits are charged; the part that pays for the review is still charged, because the level's price does not move with the setting. What you get for turning it off is the report at completion instead of after a reviewer has been through it.
Errors
404 NOT_FOUND when there is no such run in this account. Retests are not in the API, so a retest's id is also a 404.
List pentests
GET /v1/pentests · permission pentests:read
Your runs, newest first.
Prop
Type
curl "https://api.barrion.io/v1/pentests?limit=20" \
-H "Authorization: Bearer $BARRION_API_KEY"Response 200
type ListPentestsResponse = {
pentests: Pentest[];
nextOffset: number | null; // null on the last page
};Read the findings
GET /v1/pentests/{id}/findings · permission pentests:read
Prop
Type
curl "https://api.barrion.io/v1/pentests/3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c/findings?severity=critical,high" \
-H "Authorization: Bearer $BARRION_API_KEY"Response 200
type PentestFindingsResponse = {
id: string;
reportReleased: boolean;
total: number | null; // null while the report is not released
nextOffset: number | null;
findings: PentestFinding[]; // worst first; empty while the report is not released
};{
"id": "3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c",
"reportReleased": true,
"total": 1,
"nextOffset": null,
"findings": [
{
"id": "c1d0e2f3-4a5b-6c7d-8e9f-0a1b2c3d4e5f",
"title": "SQL injection in the search parameter",
"description": "...",
"severity": "CRITICAL",
"confidence": "CONFIRMED",
"affectedUrl": "https://staging.example.com/search?q=",
"remediation": "...",
"cvssScore": "9.8",
"cweId": "CWE-89"
}
]
}Findings follow the same release rule as the dashboard, and reportReleased says whether you may see them yet. It is not the same as the run being finished:
- Light includes no expert review, so its findings are released as soon as the run is paid for, and fill in while it runs.
reportReleasedistruebefore the run isCOMPLETED. - Standard and Deep include an expert review, unless you started the run with
expertReview: false. With the review on, nothing is released until a Barrion reviewer has signed the report off, which can be some time after the run reachesCOMPLETED. With it off, the findings are released as soon as the run finishes, the same as Light. - A run that ended
FAILEDorCANCELLEDshows whatever it found, without review.
A run started with humanSignedReport is signed after that review is approved: the engineer who issues the certificate and the client report is the one whose name they carry. Approving the review is not itself the signature, and the two documents are not served over the API - you collect them from the run in the dashboard.
So to judge a run, wait for both: status is COMPLETED and reportReleased is true. Only findings that made it into the report are listed.
A COMPLETED run with inconclusive: true never reached the target: it was down, blocked the agent (a firewall or WAF), or needed a VPN. Zero findings from such a run is not a pass, so treat it as a failed check in a pipeline. It is not charged, its credits are returned, and it has no report. Fix access to the target and start a new run.
If a reviewer rejects a Standard or Deep report, reportReleased stays false, and the API cannot yet tell that apart from a review still in progress. If a report is not released within a few days of the run completing, check the run in the dashboard.
Expert review
assurance says who stands behind a run's results, and it is the field to read rather than inferring it from depth:
assurance | Meaning |
|---|---|
EXPERT_REVIEWED | A Barrion engineer decided on every finding before the report was released. A released run that reads this really was reviewed, because the report cannot be released until the review is signed off |
AUTOMATED | Nobody reviewed it. The engine found and verified the findings on its own |
A run is AUTOMATED in two cases: it ran at LEAD (Light), which is sold with no expert review, or it was started with expertReview: false.
Two things worth knowing if you are building on this:
depthstopped answering this question. BeforeexpertReviewexisted, Standard and above always meant reviewed. A pipeline that still readsdepthto decide whether a human looked at a report will now be wrong for any run started with the review off. Readassurance.- An
AUTOMATEDrun that is finished and not released is waiting on nothing. Its report is released on completion, so ifreportReleasedisfalsethe report has not been unlocked, and polling will not change that. AnEXPERT_REVIEWEDrun is the one worth waiting on.
The certificate a run can be issued carries the same two values, so a document and the run it came from always agree: an unreviewed run gets the certificate that names no signer, never an engineer's signed attestation.
Cancel a pentest
POST /v1/pentests/{id}/cancel · permission pentests:write
curl -X POST https://api.barrion.io/v1/pentests/3f9e2c7a-1b4d-4e8f-9a2c-5d6e7f8a9b0c/cancel \
-H "Authorization: Bearer $BARRION_API_KEY" \
-d ''The request has no body, but it must still send Content-Length: 0, which -d '' does. Without it the load balancer answers 411 Length Required.
Response 200
type CancelPentestResponse = {
success: true;
status: "COMPLETED" | "FAILED" | "CANCELLED"; // the run's status after the call
};A cancelled run is charged only for the work it got through, and nothing if it had not started. Cancelling a run that has already ended is not an error: it answers { "success": true, "status": "COMPLETED" } and changes nothing, so a pipeline's cleanup step can always call it.