API Documentation

Scan websites for cookie compliance violations programmatically. Works in CI/CD pipelines, scripts, and automation.

Quick Start

Get your API key from your account, then scan any URL in seconds.

1

Get your API key

Sign up and your API key is shown immediately. It starts with cg_.

2

Run your first scan

cURL
curl -X POST https://cookieguardos.polsia.app/api/v1/scan \
  -H "Authorization: Bearer cg_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://your-site.com"}'
3

Read the results

The response includes every cookie found plus any compliance violations. A "status": "pass" means you're clean.

Authentication

All API requests require your API key as a Bearer token in the Authorization header.

Authorization: Bearer cg_your_api_key
🔑 Keep your API key secret. Don't commit it to source control — use environment variables or GitHub Secrets.

If your key is invalid, you'll receive a 401 Unauthorized response. Sign up to get a key.

POST /api/v1/scan

POST https://cookieguardos.polsia.app/api/v1/scan

Scans a URL for cookies and checks them against compliance rules (GDPR, ePrivacy). Returns within ~30 seconds.

Request Body

Field Type Required Description
url string Yes Full URL to scan (must include https://)
Request Example
{
  "url": "https://example.com"
}

Response Format

Success Response (200)
{
  "success": true,
  "scan_id": "scan_1234567890_abc123",
  "url": "https://example.com",
  "domain": "example.com",
  "status": "fail",    // "pass" or "fail"
  "duration_ms": 813,
  "cookies": [
    {
      "name": "_ga",
      "domain": "example.com",
      "path": "/",
      "secure": true,
      "httpOnly": false,
      "sameSite": "lax",
      "maxAge": 63072000
    }
  ],
  "violations": [ /* see Violations section */ ],
  "summary": {
    "cookie_count": 4,
    "violation_count": 2,
    "critical": 1,
    "high": 1,
    "medium": 0,
    "low": 0
  }
}

Error Responses

StatusDescription
400Missing or invalid URL
401Invalid or missing API key
422URL unreachable or timed out
500Internal scan error

Violations

Each violation in the violations array describes a compliance issue found.

Violation Object
{
  "rule": "no-tracking-before-consent",
  "severity": "critical",   // critical | high | medium | low
  "type": "consent",           // consent | security | retention
  "description": "Google Analytics cookie '_ga' set without consent...",
  "cookie": "_ga",
  "service": "Google Analytics",
  "category": "analytics"
}

Rules Checked

RuleSeverityDescription
no-tracking-before-consentcritical / highTracking cookies (Google Analytics, Facebook Pixel, etc.) set before user consent
missing-samesitemediumCookie missing SameSite attribute
excessive-lifetimemediumCookie lifetime exceeds GDPR-recommended 13 months
missing-secure-flaglowCookie missing Secure flag on HTTPS site

GitHub Action

Block PRs with cookie compliance violations automatically. Add one workflow file and every pull request gets scanned.

Setup

1

Add your API key as a GitHub Secret

Go to Settings → Secrets → Actions in your repo and add COOKIEGUARD_API_KEY with your key value.

2

Create the workflow file

Create .github/workflows/cookie-compliance.yml:

# Scans every PR for cookie compliance violations
name: Cookie Compliance

on:
  pull_request:
    branches: [main, master]

permissions:
  pull-requests: write

jobs:
  cookie-scan:
    runs-on: ubuntu-latest
    steps:
      - name: Scan for cookie compliance
        uses: Polsia-Inc/cookieguardos/github-action@main
        with:
          url: 'https://your-site.com'
          api-key: ${{ secrets.COOKIEGUARD_API_KEY }}
          fail-on-violations: 'true'
          comment-on-pr: 'true'
3

Open a pull request

The action automatically scans your URL and posts results as a PR comment. Violations block the merge (configurable).

GitHub Action Configuration

Input Required Default Description
url Yes URL to scan (e.g. https://your-site.com)
api-key Yes Your CookieGuard API key
fail-on-violations No true Fail the step if violations are found
comment-on-pr No true Post results as a PR comment

Outputs

OutputDescription
statuspass or fail
violation-countNumber of violations found
cookie-countTotal cookies detected
summaryHuman-readable summary string
💬 Questions or issues? Email support@cookieguard.sh and a human will respond within 24 hours.