API Documentation

Programmatic access to BrainyLion website audits. This API is designed for both human developers and AI coding agents.

Quick Start

  1. Get an API key from your admin at /admin/api-keys
  2. Submit an audit with POST /api/v1/audits
  3. Poll for results with GET /api/v1/audits/:id
  4. Or provide a callback_url and we'll POST results to you when ready

Authentication

All /api/v1/* endpoints require a valid API key passed as a Bearer token in the Authorization header.

Authorization: Bearer bl_live_your_api_key_here

API keys are created by admins through the API Keys dashboard. Keys start with bl_live_ and are shown only once at creation — store them securely.

Error Responses
StatusMeaning
401Missing or invalid API key
403API key doesn't have access to this resource

Submit an Audit

POST/api/v1/audits

Submits a website URL for auditing. Returns immediately with the audit ID and a pending status. The audit runs asynchronously in the background (typically 30–50 seconds).

Request Body (JSON)
FieldTypeRequiredDescription
urlstringYesThe website URL to audit. https:// is added automatically if missing.
audit_typestringNo One of: basic (default, 10 questions), advanced (26 questions), dental (dental-specific), restoration-seo (SEO with metadata analysis).
callback_urlstringNoURL to receive a POST with results when the audit completes. See Webhooks.
model_overridestringNoOverride the AI model used for analysis (e.g. gpt-5.4). Defaults to gpt-5.4-mini.
Example Request
curl -X POST https://brainylion.com/api/v1/audits \
  -H "Authorization: Bearer bl_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example-restoration.com",
    "audit_type": "basic",
    "callback_url": "https://your-server.com/webhook"
  }'
Response 201 Created
{
  "id": 1623,
  "status": "pending",
  "website": "https://example-restoration.com",
  "audit_type": "basic",
  "callback_url": "https://your-server.com/webhook",
  "created_at": "2026-03-25T18:23:05.000Z"
}

Get Audit Status & Results

GET/api/v1/audits/:id

Retrieve the status and results of a specific audit. Poll this endpoint until status is completed or failed.

Query Parameters
ParamTypeDescription
includestringSet to screenshot to include the base64-encoded screenshot (large). Omitted by default.
Status Values
StatusMeaning
pendingAudit is queued and waiting to start
processingAudit is actively running (screenshot + AI analysis)
completedAudit finished successfully — results are available
failedAudit failed — see error_message for details
Example Request
curl https://brainylion.com/api/v1/audits/1623 \
  -H "Authorization: Bearer bl_live_your_key"
Response (Completed)
{
  "id": 1623,
  "status": "completed",
  "website": "https://example-restoration.com",
  "audit_type": "basic",
  "overall_grade": "B",
  "runtime_ms": 34200,
  "created_at": "2026-03-25T18:23:05.000Z",
  "error_message": null,
  "scores": [
    {
      "question": "Is there a clearly visible phone number in the header?",
      "score": 1,
      "reason": "A phone number (555-123-4567) is prominently displayed in the top navigation bar."
    },
    {
      "question": "Does the website have a clear call-to-action above the fold?",
      "score": 0,
      "reason": "No clear CTA button is visible in the initial viewport. The first CTA appears below the fold."
    }
  ],
  "technical_seo_scores": [
    {
      "metric": "https",
      "passed": true,
      "value": "true",
      "recommendation": "Your site uses HTTPS. Great for security and SEO."
    },
    {
      "metric": "page_speed",
      "passed": true,
      "value": "1.2",
      "recommendation": "Excellent! Your page loads in 1.2 seconds."
    },
    {
      "metric": "title_tag",
      "passed": true,
      "value": "Example Restoration - Water Damage Experts",
      "recommendation": "Good! Your title tag is present and has appropriate length."
    }
  ]
}

List Your Audits

GET/api/v1/audits

Returns a paginated list of all audits submitted with your API key.

Query Parameters
ParamTypeDefaultDescription
limitinteger20Number of results per page (max 100)
offsetinteger0Number of results to skip
statusstringFilter by status: pending, processing, completed, failed
Example Request
curl "https://brainylion.com/api/v1/audits?status=completed&limit=5" \
  -H "Authorization: Bearer bl_live_your_key"
Response
{
  "audits": [
    {
      "id": 1623,
      "website": "https://example-restoration.com",
      "status": "completed",
      "audit_type": "basic",
      "overall_grade": "B",
      "runtime": 34200,
      "created_at": "2026-03-25T18:23:05.000Z",
      "error_message": null
    }
  ],
  "pagination": {
    "total": 42,
    "limit": 5,
    "offset": 0,
    "has_more": true
  }
}

Webhooks

When you provide a callback_url in your audit submission, we'll POST the results to that URL when the audit completes (or fails).

Delivery Details
  • Method: POST
  • Content-Type: application/json
  • Retries: 3 attempts with exponential backoff (1s, 4s, 16s)
  • Timeout: 10 seconds per attempt
  • 4xx responses are not retried (considered permanent failures)
Headers
HeaderDescription
X-BrainyLion-SignatureHMAC-SHA256 hex digest of the request body (for verifying authenticity)
X-BrainyLion-Eventaudit.completed or audit.failed
X-BrainyLion-DeliveryUnique delivery ID for deduplication
Webhook Payload
{
  "event": "audit.completed",
  "audit": {
    "id": 1623,
    "status": "completed",
    "website": "https://example-restoration.com",
    "audit_type": "basic",
    "overall_grade": "B",
    "runtime_ms": 34200,
    "created_at": "2026-03-25T18:23:05.000Z",
    "error_message": null,
    "scores": [ ... ],
    "technical_seo_scores": [ ... ]
  }
}

Recommended Polling Pattern

If not using webhooks, poll GET /api/v1/audits/:id with increasing intervals:

# Pseudocode for polling
response = POST /api/v1/audits { url: "https://example.com" }
audit_id = response.id

loop:
  wait 5 seconds
  result = GET /api/v1/audits/{audit_id}

  if result.status == "completed":
    # Use result.scores, result.overall_grade, etc.
    break

  if result.status == "failed":
    # Check result.error_message
    break

  # Still pending/processing — keep polling
  # Increase wait to 10s after first few attempts

Typical audit time is 30–50 seconds. We recommend starting with 5-second polling intervals and backing off to 10 seconds after 30 seconds.

Audit Types

TypeQuestionsDescription
basic10Standard website audit — checks phone number visibility, CTAs, trust signals, and basic UX. Best for quick assessments.
advanced26Comprehensive audit covering all basic checks plus mobile optimization, content quality, social proof, and conversion optimization.
dental~15Specialized audit for dental practice websites with industry-specific criteria.
restoration-seo~20SEO-focused audit for restoration companies. Includes technical metadata extraction (title tags, H1s, internal links, schema markup, word count) and SEO-specific scoring.

Grading Scale

Each question is scored 0 (fail) or 1 (pass). The overall grade is calculated from the percentage of questions passed:

GradeScore
A90–100%
B80–89%
C70–79%
D60–69%
FBelow 60%

Rate Limits & Concurrency

The API processes up to 3 audits concurrently. Additional requests are queued and processed in order. Each audit requires a Puppeteer browser instance and an OpenAI API call, so this limit protects upstream service availability.

There are no per-key rate limits at this time, but excessive usage may be throttled.

Error Reference

StatusMeaningAction
400Bad request (invalid URL, bad audit_type, etc.)Check request body format
401Missing or invalid API keyCheck your Authorization header
403API key doesn't own this auditYou can only access audits you created
404Audit not foundCheck the audit ID