API Reference
Types and Errors
Polling options, shared unions, and typed SDK errors.
All public SDK types are exported from @zeroleaks/sdk.
Polling
interface WaitOptions<T> {
pollIntervalMs?: number;
timeoutMs?: number;
signal?: AbortSignal;
onPoll?: (value: T) => void | Promise<void>;
}Attack surfaces
type AttackSurface =
| "direct_chat"
| "indirect_content"
| "tool_calling"
| "mcp"
| "repo_ci"
| "rag_vector"
| "multi_turn";Report unions
Exported by @zeroleaks/sdk 0.3.0 or later.
type SecretLeakClass =
| "credential"
| "planted_canary"
| "authorization_rule"
| "internal_endpoint"
| "tool_schema"
| "instruction_text";
type EvidenceStrength =
| "semantic"
| "indicator"
| "observed_tool_call"
| "deterministic_effect";
type FindingSeverity = "critical" | "high" | "medium" | "low" | "informational";Errors
| Error | Meaning |
|---|---|
ZeroLeaksError | Base API, validation, authentication, or network error |
ZeroLeaksTimeoutError | Request, polling, or runtime relay timed out |
ZeroLeaksAbortError | The supplied abort signal was triggered |
ZeroLeaksScanError | A scan reached a non-success terminal state or the runtime target failed |
Every error extends ZeroLeaksError, which includes status, code, details (the response body or scan result), and requestId. It also includes retryAfterMs when the response provides a Retry-After header. ZeroLeaksScanError adds scanId.
code | Source |
|---|---|
MISSING_API_KEY, INVALID_API_KEY | Client constructor |
MISSING_FETCH | No fetch implementation available |
NETWORK_ERROR | The API could not be reached |
TIMEOUT, ABORTED | ZeroLeaksTimeoutError, ZeroLeaksAbortError |
SCAN_FAILED | ZeroLeaksScanError |
INVALID_TARGET_RESPONSE | A runtime target returned something without text; arrives as the details of a ZeroLeaksScanError |
SUBSCRIPTION_LIMIT | API 403: no scan access on the current plan or workspace |
SCAN_CONCURRENCY_LIMIT, SCAN_HOURLY_LIMIT | API 429: plan throughput cap |
PROMPT_SCANS_RETIRED | API 410 from scans.create and scans.run: hosted prompt scans are retired. Do not retry. |
import { ZeroLeaksScanError } from "@zeroleaks/sdk";
try {
await zeroleaks.runtimeScans.run(target);
} catch (error) {
if (error instanceof ZeroLeaksScanError) {
console.error(error.scanId, error.details);
}
}