Torna al blog
Technical

GetCookies CLI: Command-Line Consent Management for DevOps

Il team di GetCookiesJanuary 1, 202514 min di lettura
CLIDevOpsCI/CDDeveloperTerminal

TLDR: GetCookies CLI lets you manage domains, run scans, and check consent stats from your terminal. Perfect for CI/CD pipelines, DevOps workflows, and developers who prefer command-line over dashboards.

Read full summary

A command-line interface for GetCookies that enables developers to manage cookie consent directly from the terminal. Supports domain management, cookie scanning, consent statistics, widget configuration, and integrates seamlessly with CI/CD pipelines for automated compliance monitoring.

Summary by Claude AI

The 3 AM Deployment Problem

A DevOps engineer pushed a critical hotfix at 3 AM. The deployment succeeded, but they forgot to check if the new feature added any tracking scripts. By morning, the site had been collecting data without consent for 6 hours.

Their existing workflow required logging into the dashboard, navigating to the domain, and running a scan manually. At 3 AM, that wasn't happening.

What they needed: a single command in their deployment pipeline that would scan for new cookies and alert if anything unexpected appeared.

Why a CLI for Cookie Consent?

Developer Workflow Integration

Developers live in terminals. A CLI means:

  • No context-switching to a dashboard
  • Scriptable operations
  • Keyboard-driven efficiency

CI/CD Pipeline Automation

Add compliance checks to your deployment:

deploy:
  script:
    - npm run build
    - npm run deploy
    - getcookie scans start $DOMAIN_ID
    - getcookie scans status $SCAN_ID --wait

DevOps Monitoring

Integrate with existing monitoring tools:

# Cron job for daily compliance check
0 6 * * * getcookie scans start prod-domain && getcookie consent stats prod-domain >> /var/log/consent-stats.log

Installation

npm install -g getcookie-cli

Or with yarn:

yarn global add getcookie-cli

Requires Node.js 18 or later.

Authentication

Login with Credentials

getcookie login -e [email protected] -p yourpassword

Credentials are stored securely using system keychain.

API Key Authentication

For CI/CD environments, set environment variables:

export GETCOOKIE_API_KEY=your_api_key

Check Login Status

getcookie whoami

Logout

getcookie logout

Domain Management

List All Domains

getcookie domains list

Output:

┌──────────┬─────────────────────┬─────────────────────┐
│ ID       │ Domain              │ Last Scan           │
├──────────┼─────────────────────┼─────────────────────┤
│ abc12345 │ example.com         │ 2025-01-15 03:00:00 │
│ def67890 │ shop.example.com    │ 2025-01-14 15:30:00 │
│ ghi11111 │ blog.example.com    │ -                   │
└──────────┴─────────────────────┴─────────────────────┘

Add a Domain

getcookie domains add example.com

Output:

✓ Domain added! ID: abc12345

Delete a Domain

getcookie domains delete abc12345

Cookie Scanning

Start a Scan

getcookie scans start abc12345

Output:

✓ Scan started! ID: scan_xyz789

Check Scan Status

getcookie scans status scan_xyz789

Output:

Status: completed
Pages: 15, Cookies: 23

Wait for Scan Completion

getcookie scans status scan_xyz789 --wait

Blocks until scan completes—useful for CI/CD.

List Detected Cookies

getcookie scans cookies scan_xyz789

Output:

┌────────────────┬────────────┬─────────────────┬─────────┐
│ Name           │ Category   │ Domain          │ Expiry  │
├────────────────┼────────────┼─────────────────┼─────────┤
│ _ga            │ analytics  │ .example.com    │ 730d    │
│ _gid           │ analytics  │ .example.com    │ 1d      │
│ session_id     │ essential  │ example.com     │ Session │
│ _fbp           │ marketing  │ .example.com    │ 90d     │
└────────────────┴────────────┴─────────────────┴─────────┘

Consent Statistics

View Consent Stats

getcookie consent stats abc12345

Output:

Total: 45,231
Accepted: 34,567 | Rejected: 10,664
Acceptance Rate: 76.4%

View Consent Logs

getcookie consent logs abc12345 --limit 10

Output:

┌─────────────────────┬─────────┬────────────────┐
│ Time                │ Consent │ Cookie         │
├─────────────────────┼─────────┼────────────────┤
│ 1/15/2025, 2:34 PM  │ Yes     │ analytics      │
│ 1/15/2025, 2:33 PM  │ No      │ marketing      │
│ 1/15/2025, 2:31 PM  │ Yes     │ all            │
└─────────────────────┴─────────┴────────────────┘

Widget Configuration

Get Current Config

getcookie widget config abc12345

Output (JSON):

{
  "position": "bottom-right",
  "theme": "light",
  "primary_color": "#0066cc",
  "google_consent_mode": true,
  "iab_tcf_enabled": false
}

Get Embed Snippet

getcookie widget snippet abc12345

Output:

<script src="https://cdn.getcookies.co/widget.js?id=abc12345" async></script>

CI/CD Integration Examples

GitHub Actions

name: Deploy with Compliance Check

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy
        run: npm run deploy

      - name: Install GetCookie CLI
        run: npm install -g getcookie-cli

      - name: Run Compliance Scan
        env:
          GETCOOKIE_API_KEY: ${{ secrets.GETCOOKIE_API_KEY }}
        run: |
          SCAN_ID=$(getcookie scans start ${{ vars.DOMAIN_ID }} --json | jq -r '.scan_id')
          getcookie scans status $SCAN_ID --wait
          COOKIES=$(getcookie scans cookies $SCAN_ID --json | jq '.items | length')
          echo "Detected $COOKIES cookies"

      - name: Check for Unclassified Cookies
        run: |
          UNCLASSIFIED=$(getcookie scans cookies $SCAN_ID --json | jq '[.items[] | select(.category == "unclassified")] | length')
          if [ "$UNCLASSIFIED" -gt 0 ]; then
            echo "::warning::Found $UNCLASSIFIED unclassified cookies"
          fi

GitLab CI

stages:
  - deploy
  - compliance

deploy:
  stage: deploy
  script:
    - npm run deploy

compliance-scan:
  stage: compliance
  image: node:20
  script:
    - npm install -g getcookie-cli
    - getcookie scans start $DOMAIN_ID
    - getcookie consent stats $DOMAIN_ID
  variables:
    GETCOOKIE_API_KEY: $GETCOOKIE_API_KEY

Jenkins Pipeline

pipeline {
    agent any

    environment {
        GETCOOKIE_API_KEY = credentials('getcookie-api-key')
    }

    stages {
        stage('Deploy') {
            steps {
                sh 'npm run deploy'
            }
        }

        stage('Compliance Check') {
            steps {
                sh 'npm install -g getcookie-cli'
                sh 'getcookie scans start ${DOMAIN_ID}'
                sh 'getcookie consent stats ${DOMAIN_ID}'
            }
        }
    }
}

Scripting Examples

Daily Compliance Report

#!/bin/bash
# daily-compliance-report.sh

DOMAINS=$(getcookie domains list --json | jq -r '.items[].id')

echo "Daily Compliance Report - $(date)"
echo "================================"

for DOMAIN_ID in $DOMAINS; do
  DOMAIN=$(getcookie domains list --json | jq -r ".items[] | select(.id==\"$DOMAIN_ID\") | .domain")
  STATS=$(getcookie consent stats $DOMAIN_ID --json)

  RATE=$(echo $STATS | jq -r '.acceptance_rate * 100 | floor')
  TOTAL=$(echo $STATS | jq -r '.total_consents')

  echo "$DOMAIN: $RATE% acceptance ($TOTAL total)"
done

New Cookie Alert

#!/bin/bash
# check-new-cookies.sh

SCAN_ID=$(getcookie scans start $DOMAIN_ID --json | jq -r '.scan_id')
getcookie scans status $SCAN_ID --wait

UNCLASSIFIED=$(getcookie scans cookies $SCAN_ID --json | jq '[.items[] | select(.category == "unclassified")]')
COUNT=$(echo $UNCLASSIFIED | jq 'length')

if [ "$COUNT" -gt 0 ]; then
  echo "⚠️ Found $COUNT unclassified cookies:"
  echo $UNCLASSIFIED | jq -r '.[].name'

  # Send Slack notification
  curl -X POST $SLACK_WEBHOOK -d "{\"text\": \"Found $COUNT unclassified cookies on $DOMAIN\"}"
fi

JSON Output

All commands support --json flag for machine-readable output:

getcookie domains list --json
getcookie scans cookies scan_xyz --json
getcookie consent stats domain_id --json

This enables easy integration with jq, scripts, and other tools.

Configuration

Set API URL

For self-hosted or staging environments:

getcookie config set apiUrl https://staging.getcookie.app

View Configuration

getcookie config list

Error Handling

The CLI exits with appropriate codes:

  • 0: Success
  • 1: General error
  • 2: Authentication error
  • 3: Validation error

Use in scripts:

if ! getcookie scans start $DOMAIN_ID; then
  echo "Scan failed"
  exit 1
fi

Getting Started

  1. Install: npm install -g getcookie-cli
  2. Login: getcookie login -e [email protected] -p password
  3. List domains: getcookie domains list
  4. Run a scan: getcookie scans start <domain-id>
  5. Check results: getcookie scans cookies <scan-id>

Cookie compliance belongs in your development workflow—not as an afterthought in a dashboard.

Domande frequenti

What can I do with the CLI?
The CLI supports domain management (list, add, delete), cookie scanning (start, status, results), consent statistics, and widget configuration—all from your terminal.
How do I use the CLI in CI/CD pipelines?
Set the GETCOOKIE_API_KEY environment variable and use commands like `getcookie scans start` and `getcookie scans status --wait` in your deployment scripts.
Does the CLI support JSON output?
Yes, all commands support --json flag for machine-readable output, making it easy to integrate with scripts and other tools.
G

Il team di GetCookies

Scritto e aggiornato dal team di GetCookies di Getia AS a Oslo, in Norvegia. Questo articolo è un'informazione generale sul consenso ai cookie, non una consulenza legale.

Scansiona il tuo sito gratis

Il piano gratuito mostra il banner su un sito con tre scansioni dei cookie al mese. Nessuna carta, nessuna chiamata commerciale.