Secret Scanner API
Scan text, a file, a diff or a ZIP of a repo for leaked API keys, tokens, private keys and passwords with the 220+ gitleaks rules. Secrets are masked.
Send text (text or a raw body) or a file: a single source file, a .gz, a unified diff (only added lines are scanned, with line numbers of the new file) or a .zip of a repository. The scanner applies the default gitleaks rule set (220+ rules: AWS, GitHub, GitLab, Stripe, Slack, Google, OpenAI and Anthropic keys, private keys, JWTs and many more), converted from Go RE2 to JavaScript and refreshed weekly, plus our own rule for passwords inside connection-string URLs (postgres://user:pass@host). As in gitleaks, each rule has keywords, an optional secret group, a Shannon entropy threshold and allowlists (placeholders like ${VAR}, changeme, example keys, node_modules, lock files, images).
Each finding gives rule_id, description, file, line / column (1-based) and end position, the masked secret and masked match, the entropy and a confidence (low for the generic key rule). entropy=true also reports long high-entropy strings that no rule matched. rules restricts the scan to some rule ids. Regexes run only on windows around keyword hits, with a total time budget, so a pathological input cannot run forever; the response flags timed_out or slow_rules if that happens.
Privacy: the content is scanned in memory and is never stored or logged, and secrets are masked in the response. Still, a key that has been pasted anywhere should be rotated. Limits: 5 million characters in total, files in a ZIP up to 2 MB each, 10,000 files.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body | string | no | Text, code or a unified diff to scan (or send a raw text body). | |
file | body | file | no | A text file, .gz, diff or .zip of a repository (multipart, or file_base64). | |
filename | body | string | no | Path of the text, for path-based rules and allowlists (e.g. config/.env). | |
diff | body | boolean | no | Treat the text as a unified diff (auto-detected). | |
entropy | body | boolean | no | false | Also report high-entropy strings not matched by a rule. |
rules | body | string | no | Comma-separated rule ids to run (default: all). | |
limit | body | number | no | 1000 | Maximum findings returned (1–5000). |
Example
curl -X POST "https://apibox.io.vn/v1/secret-scan" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"AWS_ACCESS_KEY_ID=AKIAQWERTYUIOPASDFGH\nDATABASE_URL=postgres://admin:S3cr3tP4ssw0rd!@db.example.com:5432/app\n","filename":".env"}'const res = await fetch('https://apibox.io.vn/v1/secret-scan', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "AWS_ACCESS_KEY_ID=AKIAQWERTYUIOPASDFGH\nDATABASE_URL=postgres://admin:S3cr3tP4ssw0rd!@db.example.com:5432/app\n",
"filename": ".env"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/secret-scan",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"text": "AWS_ACCESS_KEY_ID=AKIAQWERTYUIOPASDFGH\nDATABASE_URL=postgres://admin:S3cr3tP4ssw0rd!@db.example.com:5432/app\n", "filename": ".env"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/secret-scan');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"text":"AWS_ACCESS_KEY_ID=AKIAQWERTYUIOPASDFGH\\nDATABASE_URL=postgres://admin:S3cr3tP4ssw0rd!@db.example.com:5432/app\\n","filename":".env"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"leaks_found": true,
"count": 2,
"files_scanned": 1,
"characters_scanned": 109,
"by_rule": {
"aws-access-token": 1,
"url-credentials": 1
},
"findings": [
{
"rule_id": "aws-access-token",
"description": "Identified a pattern that may indicate AWS credentials, risking unauthorized cloud resource access and data breaches on AWS platforms.",
"file": ".env",
"line": 1,
"column": 19,
"end_line": 1,
"end_column": 38,
"secret_masked": "AKIA**************GH",
"match_masked": "AKIA**************GH",
"entropy": 3.984,
"confidence": "high",
"fingerprint": ".env:aws-access-token:1"
},
{
"rule_id": "url-credentials",
"description": "Password inside a URL / connection string (database, broker, FTP, HTTP basic auth).",
"file": ".env",
"line": 2,
"column": 31,
"end_line": 2,
"end_column": 45,
"secret_masked": "S3***********d!",
"match_masked": "postgres://admin:S3***********d!@db.example.com:5432",
"entropy": 3.507,
"confidence": "high",
"fingerprint": ".env:url-credentials:2"
}
],
"truncated": false,
"rules": {
"count": 222,
"source": "gitleaks default config (MIT)",
"dropped": 0
},
"ms": 5,
"privacy": "The text is scanned in memory and not stored or logged; secrets are masked in the response."
}
Use cases
- Check logs or a support ticket for keys before pasting them into an LLM
- Light pre-commit or CI check on a diff without installing a scanner
- Audit a ZIP of a project handed over by a contractor
- Catch database passwords left in .env or config files
FAQ
Is my code stored?
No. The request is processed in memory, nothing is written to storage or logs, and the response only contains masked secrets.
Is this the same as running gitleaks?
It uses the same default rules, keywords, entropy thresholds and allowlists. A rule that cannot be converted from RE2 is dropped and counted in rules.dropped (none at the moment). Git history is not scanned, only the files you send.
Why is a finding marked low confidence?
The generic-api-key rule matches any key = "long random value" assignment, so it finds real secrets that have no known format but also some false positives. Provider-specific rules are marked high.
Related APIs
Hash Generator
Compute MD5, SHA-1, SHA-256, SHA-384, SHA-512 and CRC32 of text or files in one call, as hex or base64, with optional HMAC signing.
B64Encode / Decode
Encode or decode text as Base64, Base64URL, hex, URL encoding, HTML entities, Unicode escapes, ROT13 or binary with one simple API call.
***Password Generator
Generate cryptographically secure random passwords (4–256 chars, up to 100 at once) or check a password’s strength, entropy and estimated crack time.