Skip to content

API Reference

The middleBrick REST API lets you integrate security scanning into any system: internal tools, Slack bots, dashboards, CI pipelines, or custom automations.

https://api.middlebrick.com/v1

All API requests require an API key passed in the Authorization header:

Authorization: Bearer mb_your_api_key_here

Generate API keys from your dashboard. Keys inherit your plan’s rate limits and scan quotas.


Submit a URL for security scanning.

Request:

Terminal window
curl -X POST https://api.middlebrick.com/v1/scan \
-H "Authorization: Bearer mb_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.example.com/v1/users",
"specUrl": "https://api.example.com/openapi.json",
"context": "financial"
}'

Request body:

FieldTypeRequiredDescription
urlstringYesThe API endpoint URL to scan (must be HTTPS)
specUrlstringNoOpenAPI/Swagger spec URL for deeper analysis
contextstringNoAPI context: financial, medical, public, internal

Response (200):

{
"id": "scan_abc123",
"status": "completed",
"url": "https://api.example.com/v1/users",
"score": 72,
"grade": "C",
"createdAt": "2025-01-15T10:30:00Z",
"completedAt": "2025-01-15T10:30:08Z",
"categories": {
"authentication": {
"score": 85,
"findings": [
{
"severity": "high",
"title": "Auth bypass via HTTP method",
"description": "POST returns 200 without credentials while GET requires auth",
"remediation": "Enforce authentication across all HTTP methods"
}
]
},
"bolaAuthorization": {
"score": 60,
"findings": [...]
},
"bflaAuthorization": { "score": 100, "findings": [] },
"propertyAuthorization": { "score": 90, "findings": [...] },
"inputValidation": { "score": 75, "findings": [...] },
"rateLimiting": { "score": 50, "findings": [...] },
"dataExposure": { "score": 65, "findings": [...] },
"encryption": { "score": 95, "findings": [] },
"ssrf": { "score": 100, "findings": [] },
"inventoryManagement": { "score": 80, "findings": [...] },
"unsafeConsumption": { "score": 100, "findings": [] },
"llmSecurity": { "score": 100, "findings": [] }
},
"findings": [
{
"category": "authentication",
"severity": "high",
"title": "Auth bypass via HTTP method",
"description": "POST returns 200 without credentials while GET requires auth",
"remediation": "Enforce authentication across all HTTP methods"
},
{
"category": "dataExposure",
"severity": "high",
"title": "PII detected in response",
"description": "Email addresses found in response body",
"remediation": "Remove or mask PII from API responses"
}
]
}

Response fields:

FieldTypeDescription
idstringUnique scan identifier
statusstringcompleted, failed, or processing
urlstringThe scanned URL
scorenumberOverall security score (0–100)
gradestringLetter grade: A, B, C, D, or F
createdAtstringISO 8601 timestamp of scan creation
completedAtstringISO 8601 timestamp of scan completion
categoriesobjectPer-category scores and findings
findingsarrayAll findings sorted by severity

Finding object:

FieldTypeDescription
categorystringWhich security check produced this finding
severitystringcritical, high, medium, low, or info
titlestringShort description of the finding
descriptionstringDetailed explanation
remediationstringHow to fix the issue

Retrieve results for a previous scan.

Request:

Terminal window
curl https://api.middlebrick.com/v1/scan/scan_abc123 \
-H "Authorization: Bearer mb_your_api_key_here"

Response: Same format as POST /scan response.

Returns 404 if the scan doesn’t exist or doesn’t belong to your account.


List your scan history, newest first.

Request:

Terminal window
curl "https://api.middlebrick.com/v1/scans?limit=10&offset=0" \
-H "Authorization: Bearer mb_your_api_key_here"

Query parameters:

ParameterTypeDefaultDescription
limitnumber20Results per page (max 100)
offsetnumber0Pagination offset

Response (200):

{
"scans": [
{
"id": "scan_abc123",
"url": "https://api.example.com/v1/users",
"score": 72,
"grade": "C",
"findingsCount": 7,
"createdAt": "2025-01-15T10:30:00Z"
},
{
"id": "scan_def456",
"url": "https://api.example.com/v1/health",
"score": 91,
"grade": "A",
"findingsCount": 2,
"createdAt": "2025-01-14T08:15:00Z"
}
],
"total": 42,
"limit": 20,
"offset": 0
}

Rate limits are enforced per API key:

PlanRequests/minuteScans/month
Free103
Starter3015
Pro60100
EnterpriseCustomUnlimited

When you hit a rate limit, the API returns 429 Too Many Requests with a Retry-After header indicating when you can retry.

Rate limit headers (included in every response):

HeaderDescription
X-RateLimit-LimitRequests allowed per minute
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetUnix timestamp when the window resets

All errors follow this format:

{
"error": {
"code": "rate_limit_exceeded",
"message": "You have exceeded your plan's scan limit"
}
}
CodeHTTP StatusDescription
invalid_url400The provided URL is not valid or not HTTPS
invalid_context400Context must be one of: financial, medical, public, internal
unauthorized401Missing or invalid API key
forbidden403Your plan doesn’t include this feature
not_found404Scan not found or doesn’t belong to your account
rate_limit_exceeded429Plan limit reached (check Retry-After header)
scan_failed500Scan could not complete (target unreachable or returned error)

const response = await fetch('https://api.middlebrick.com/v1/scan', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MIDDLEBRICK_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://api.example.com/v1/users',
context: 'financial',
}),
});
const result = await response.json();
console.log(`Score: ${result.score} (${result.grade})`);
console.log(`Findings: ${result.findings.length}`);
// Show critical findings
result.findings
.filter(f => f.severity === 'critical')
.forEach(f => console.log(`CRITICAL: ${f.title}`));
import os
import requests
response = requests.post(
'https://api.middlebrick.com/v1/scan',
headers={
'Authorization': f'Bearer {os.environ["MIDDLEBRICK_API_KEY"]}',
'Content-Type': 'application/json',
},
json={
'url': 'https://api.example.com/v1/users',
'context': 'financial',
},
)
result = response.json()
print(f'Score: {result["score"]} ({result["grade"]})')
for finding in result['findings']:
if finding['severity'] in ('critical', 'high'):
print(f'[{finding["severity"].upper()}] {finding["title"]}')
Terminal window
# One-liner: scan and show score
curl -s -X POST https://api.middlebrick.com/v1/scan \
-H "Authorization: Bearer $MIDDLEBRICK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://api.example.com/v1/users"}' \
| jq '{score, grade, findings: [.findings[] | {severity, title}]}'