Before you start
- See Authentication for the keys each operation accepts and Conventions for base URLs, pagination, errors, and rate limits. The Deep Scan and Bug Scan findings exports are export and user-management operations. The other Security operations are product operations.
- The curl examples read the key from
CODERABBIT_API_KEY. The upload steps read SARIF files withjq.
Choose an operation
Export Deep Scan code findings
-
Call List or download Deep Scan code findings. By default, it returns open findings from the latest completed scan of each repository in the keyâs scope. Its reference lists the filters for one repository, an earlier scan, and the finding state. With a workspace token,
org_idselects one organization. -
While
next_cursorisnâtnull, request the next page withcursorset to that value and the same filters. -
To download the whole inventory instead, add
format=csvorformat=sarif. A download holds every finding that matches the filters, up to 50,000 findings and 16 MiB; larger results return413, so narrow them withrepo_idorscan_id. The CLI prints JSON only, so download CSV and SARIF with curl.
- JSON:
descriptionand thereachability_call_stackarray. - CSV: the
descriptioncolumn, and the call stack as a JSON-encoded array in thereachability_call_stackcolumn. - SARIF:
runs[].results[].message.textfor the explanation andruns[].results[].properties.reachabilityCallStackfor the call stack.
Upload Deep Scan findings to GitHub code scanning
Code scanning keeps results per repository and commit, so upload one SARIF file per repository.- Get the repository IDs from List repositories on GitHub Cloud, or from List organization repositories on the Enterprise plan.
-
Download a SARIF file for each repository with
repo_id. Pause between requests; see Rate limits.--failmakes curl report an error response, such as413for an export thatâs too large, instead of saving it as a SARIF file, so only successful downloads leave a file.--retryretries a429after theRetry-Afterinterval. Before you upload, delete the SARIF files of earlier runs, so a failed download canât leave an old file in place. -
Read the scanned commit from the file. Without
scan_id, a download holds the repositoryâs latest completed scan, and each result names the scan inproperties.scanProvenance.scanIdand its commit inproperties.scanProvenance.scope.primary.revision.If the command prints nothing, the file has no findings or the scan recorded no commit; skip it. Skipping the upload doesnât replace the previous GitHub analysis, so earlier results can remain visible. If you take the commit from a JSON call instead, pass that rowâsscan_provenance.scanIdasscan_idwhen you download, so both describe the same scan even when a newer one completes in between. -
Upload each file to its repository with the
github/codeql-action/upload-sarifaction. Setshato the scanned commit andrefto the full reference of the scanned branch, such asrefs/heads/main. Otherwise, GitHub attaches the results to the commit of the workflow that uploads them.
partialFingerprints, which code scanning uses to recognize the same alert across uploads. The upload-sarif action computes them from the source files, so run it in a checkout of the scanned commit. The code scanning REST API doesnât compute them, so uploads through it can create duplicate alerts.
GitHub rejects a SARIF file larger than 10 MB after gzip compression. It accepts up to 25,000 results per run and keeps the 5,000 most severe. See SARIF support for code scanning for the other limits.
Export Bug Scan findings
-
Call List or download Bug Scan findings with
repo_id, the repositoryâs Git provider ID. For a Bitbucket Cloud repository, use its UUID in braces. The operation reads the latest completed scan unless you passscan_id, and you can filter by severity. -
Read
scanfor the scanâsid,head_commit,completed_at, andpartial_coverage. When the repository has no completed scan,scanisnullanddatais empty. Findings come in the scanâs rank order, and each has astateofopen,fixed, ordismissed. -
While
next_cursorisnâtnull, request the next page withcursorset to that value. A cursor stays on the scan it came from, even after a newer scan completes. Sending a differentscan_idwith it returns400 INVALID_CURSOR. -
To download every finding of the scan, add
format=csvorformat=sarif. Downloads are limited to 50,000 findings and 16 MiB; larger results return413, so filter byseverity.
state isnât a filter, and sending it returns 400. With a workspace token, a repository ID that more than one organization holds returns 400 AMBIGUOUS_REPOSITORY; pass org_id to pick the organization. An organization without Bug Scan gets 403 BUG_SCAN_NOT_ENABLED.
repo_id is required, so to cover every repository, call the operation once per repository. Take the IDs from List repositories or List organization repositories, as for Deep Scan, and pause between calls. Skip a repository whose scan is null: it has no completed scan.
Upload Bug Scan findings to GitHub code scanning
A Bug Scan SARIF file names its scan inruns[0].properties.scanId and the scanned commit in runs[0].properties.headCommit. Read the commit from the file you upload, so it always matches the findings in it:
headCommit is null, the scan recorded no commit; skip the file. If you read scan.head_commit from a JSON call instead, pass its scan.id as scan_id when you download.
Upload the file with the github/codeql-action/upload-sarif action or the code scanning REST API. Set the commit SHA of the upload to the scanned commit and its ref to the full reference of the scanned branch, such as refs/heads/main. Otherwise, GitHub attaches the results to the commit of the workflow that uploads them. Each result carries a stable fingerprint in partialFingerprints, so code scanning tracks a finding across uploads. GitHubâs size limits from the Deep Scan upload apply too.
Work with findings through the Security operations
These operations work for GitHub Cloud organizations. They use the same access rules as the CodeRabbit app: reading needs Security read access, and starting scans, requesting fixes, and changing a findingâs state follow the rules in Access and billing.List and read findings
- List code and secret findings returns vulnerabilities and secrets together. Set
finding_kindto get only one kind. - List secret scanner findings returns secrets only, with filters for confidence and verification status.
- List vulnerable dependencies lists dependencies with known advisories.
- Read a code security finding, Read a secret finding, and Read a dependency and its advisories return one item each.
Export a software bill of materials
List software bill of materials components pages through components. Export a software bill of materials downloads it as CycloneDX, SPDX, or CSV. Both can be limited to specific repositories.Start a scan
- Estimate the cost with Estimate an AI Deep Scan. Its
freshfield tells you whether the estimate is current. An estimate doesnât start a scan. - Call Request security scans for installed repositories with the repositories, the targets to scan, and the scan mode. A
scan_modeofdeepwith thecodetarget runs a Deep Scan. To cap the spend, setspend_limit_cents. - Check
resultsfor each repository.triggeredmeans CodeRabbit accepted the scan, not that it finished.blockedcomes with ablockedReasonand can includeblockedRetryAfterSeconds. - Follow progress with List security scan activity or Read a security scan.
paid_usage_confirmation with the estimate in estimateCents and the credit amount in creditCents. Only a Deep Scan can be confirmed this way. For how Deep Scan billing works, see Deep Scan estimates and billing.
Fix, dismiss, or reopen a finding
- Request an AI fix for a security finding with the findingâs kind in
finding_kind. A202response means CodeRabbit accepted the request, not that the fix is done. To follow the fix and find the resulting task or pull request, read the finding with the reader for its kind: Read a code security finding for a vulnerability, Read a secret finding for a secret, or Read a dependency and its advisories for a dependency. If you arenât sure whether a fix request went through, read the finding before you send it again. - Dismiss a security finding with the same
finding_kindvalues. - Reopen a code security finding returns a code finding to the open state. It doesnât apply to secrets or dependencies.
Read runtime validation results
- Call Read runtime validation availability for a finding. This call doesnât start a validation.
- If
availableistrue, pass itsfindingIdentityIdasfinding_identity_idto List runtime validation attempts for a finding. - Read an attempt with Read a runtime validation result.
Handle errors
For response formats and other codes, see Errors and Rate limits.
Whatâs next
CodeRabbit Security
Learn how Deep Scan works, what it reports, and how to triage findings in the app.
Runtime verification
Reproduce Deep Scan findings in a test environment before you fix them.
Authenticate requests
Pick the API key type each security operation accepts.