Skip to main content
On-Demand Code Scans are currently in beta. The API is available for early CLI, IDE, pre-commit, and custom integration workflows, but behavior, limits, and response fields may change before general availability.

Overview

On-Demand Code Scans let you submit small units of code to ZeroPath for security analysis without starting a full repository scan. Use them when you want fast feedback from a CLI, IDE integration, pre-commit hook, CI job, or custom tool. You can submit:
  • A Git diff
  • A single file
  • Multiple files
  • One or more code snippets
The scan runs asynchronously. Submit a job, poll its status, then fetch the results.
On-Demand Code Scans are not full repository scans. They analyze only the code you submit. Results are returned through the async code scan API and expire after 7 days.

Target Modes

Every scan request includes a target. The target controls whether ZeroPath uses repository context or treats the submitted code as standalone. When a repository is resolved, ZeroPath can use persisted repository, application, and threat-model context to improve analysis. Standalone scans use only the submitted code, optional target metadata, and optional supplemental context.

Submit a Scan

Call POST /api/v2/async-code-scans/submit with your code input and target.
Successful submissions return 202 Accepted:

Poll Status

Call POST /api/v2/async-code-scans/status with the returned jobId.
The public statuses are:
  • queued
  • running
  • completed
  • failed
Repository-backed jobs require repository view access. Standalone jobs can be viewed only by the same submitting API token or same submitting user.

Fetch Results

Call POST /api/v2/async-code-scans/results after the job completes.
Results include structured vulnerabilities with file location, severity, confidence, CWE identifiers, and an optional fix:
On-Demand Code Scan results are temporary and are meant to be consumed from the API response for the submitted job.

Input Shapes

Use exactly one input shape per request.

Diff

File

Files

Snippets

Supplemental Context

Use additionalContext for background information that can help the scanner interpret the submitted code.
ZeroPath treats supplemental context as untrusted background information, not as scanner instructions.

CLI Usage

The ZeroPath CLI includes scan-code for On-Demand Code Scans.
By default, the CLI uses target.kind = "auto" and includes your Git remote URL when available. Use --repository-id to require linked repository context, or --standalone to force a scan without repository context.

Limits

Requests over these limits return 413.

Authentication

On-Demand Code Scans use the same API token headers as the rest of the ZeroPath API.
For repository targets, the caller must be able to start scans on the target repository. For auto targets, ZeroPath uses repository context only when the submitted remote URL resolves to exactly one accessible repository. For standalone targets, the caller only needs authenticated organization context.