Patchlightdocs

REST API

Endpoints, request shapes, and error codes for the Patchlight API.

Base URL https://api.patchlight.dev. Every /v1/* route expects a workspace API key:

curl https://api.patchlight.dev/v1/balance \
  -H "Authorization: Bearer pl_sk_..."

Create the key in the dashboard under App → API Keys. If TypeScript is where you live, the SDK wraps all of this — including polling, retries, and idempotency — and has no runtime dependencies.

Webhooks (inbound)

Single signature-verified receiver, configured once on your GitHub App (one webhook for all installs).

MethodPathDescription
POST/webhooks/githubVerifies X-Hub-Signature-256, records the event, enqueues a review

Reviews API

Trigger reviews from any CI/CD system — see the SDK & CLI docs for the friendly wrapper. All /v1/* routes are scoped to the API key's workspace: an organization key sees the organization's data, a personal key sees personal data only.

MethodPathDescription
POST/v1/reviewsSubmit a unified diff (+ optional file contents) for review. Returns 202 with { review: { id, status } }
GET/v1/reviews/:idReview status, summary, error, timestamps
GET/v1/reviews/:id/findings{ status, findings } — findings are empty until the review is done

POST /v1/reviews body

FieldRequiredLimitsDescription
repoyes≤256 chars, [\w./@-]Repository name shown in the dashboard
diffyes≤1 MBUnified diff to review
filesno≤100 files, ≤200 KB each, ≤5 MB totalPath → content map for review context
refno≤200 charsReviewed commit sha/branch
baseRefno≤200 charsBase branch of the diff
titleno≤500 charsHuman-readable title

Send an Idempotency-Key header to make the submit replay-safe for 24 hours: repeats with the same key return the original review (200) instead of creating a duplicate.

Error codes

StatuserrorMeaning
400invalid_requestMalformed body — details in message
401missing_api_key / invalid_api_keyAbsent, unknown, or revoked key
402insufficient_fundsBalance below the review cost (body includes balance, required, in USD)
404not_foundReview does not exist in this workspace
413payload_too_largeDiff or file caps exceeded
429too_many_pending_reviewsMore than 10 queued/running API reviews
503queue_unavailable / reviews_not_configuredTransient platform issue — retry later

Review status

queuedrunningdone. Two other statuses are terminal:

  • failed — the worker errored; the reason is in error.
  • skipped — a monthly spend cap or per-repo budget blocked the review before any work started. It never advances, so polling for done will hit your timeout instead.

Security scans API

A scan reads a whole repository rather than a diff, so it requires a connected GitHub repository — repos created implicitly by POST /v1/reviews have no git connection and cannot be scanned. Scans bill per token, so cost scales with repository size.

MethodPathDescription
POST/v1/repos/:id/scanStart a scan. Returns 202 with { scanId, status }
GET/v1/scans/:idScan status, cost, and findingsCount
GET/v1/scans/:id/findings{ status, findings } — empty until the scan is done

:id is a repository id from GET /v1/repos, not an owner/repo name.

Scan error codes

StatuserrorMeaning
400repo_not_scannableRepo has no GitHub connection
402insufficient_fundsBalance below the minimum to start a scan
402spend_cap / repo_budgetMonthly workspace cap or per-repo budget reached
404repo_not_foundRepo does not exist in this workspace
409already_runningThat repo already has a queued or running scan
503scan_runner_not_configuredScan runner unavailable — retry later

Findings API

MethodPathDescription
GET/v1/findingsRecent findings across the workspace's repositories
PATCH/v1/findings/:idTriage a finding — { "status": "open" | "resolved" | "dismissed" }

PATCH /v1/findings/:id accepts both review and scan finding ids; you do not need to know which kind you hold. It returns { finding: { id, status } }, or 404 when the finding is not in the key's workspace.

Every route that returns findings uses one shape. Exactly one of reviewId / scanId is set and the other is null; cwe is only ever populated by scans.

Org-scoped API keys can triage anything in the organization. The dashboard additionally limits members to findings on their own pull requests — an API key resolves to a workspace rather than to a person, so that narrowing has no equivalent here.

Read API

MethodPathDescription
GET/v1/balanceRemaining USD balance of the workspace
GET/v1/reposRepositories in the workspace
GET/v1/reviewsRecent reviews — same fields as GET /v1/reviews/:id
GET/v1/findingsFindings across the workspace's repositories
GET/healthHealth check

Reviews and security scans are billed in USD from your balance.

All timestamps (createdAt, startedAt, completedAt, finishedAt) are ISO-8601 strings, not epoch numbers. Parse them with new Date(value).

On this page