Getting Started

Configuration Reference

Capacitarr is configured entirely through environment variables. All variables are optional — sensible defaults are used when a variable is not set.

General

VariableDefaultRequiredDescription
PORT2187NoHTTP listen port for the Capacitarr server.
BASE_URL/NoBase URL path for reverse proxy subdirectory deployments. Must start and end with /. Example: /capacitarr/.
DB_PATH/config/capacitarr.dbNoFile path for the SQLite database. The directory must exist and be writable.
DEBUGfalseNoEnable debug logging. Set to true for verbose output. In debug mode, CORS defaults to * (allow all origins) and a static JWT secret is used.

Authentication

VariableDefaultRequiredDescription
JWT_SECRET(auto-generated)RecommendedSecret key for signing JWT authentication tokens. If not set, a random secret is generated at startup — sessions will not persist across container restarts. Set this for stable sessions.
SECURE_COOKIESfalseNoSet to true when serving Capacitarr over HTTPS. Marks authentication cookies with the Secure flag so they are only sent over encrypted connections.
AUTH_HEADER(none)NoTrusted reverse proxy authentication header name. When set, Capacitarr trusts this header for authentication instead of requiring JWT login. Common values: Remote-User (Authelia), X-authentik-username (Authentik), X-WEBAUTH-USER (Organizr).

!!! warning "AUTH_HEADER Security" Only enable AUTH_HEADER when Capacitarr is exclusively accessible through your reverse proxy. If the server is directly reachable, any client can forge this header and bypass authentication entirely.

CORS

VariableDefaultRequiredDescription
CORS_ORIGINS(none)NoComma-separated list of allowed CORS origins. Example: http://localhost:3000,https://app.example.com. When not set: same-origin only (unless DEBUG=true, which allows all origins).

Docker

These variables are handled by the container entrypoint script, not the Go backend.

VariableDefaultRequiredDescription
PUID1000NoUser ID for the container process. Used to set file ownership on the /config volume.
PGID1000NoGroup ID for the container process. Used to set file ownership on the /config volume.

Example: Docker Compose

services:
  capacitarr:
    image: ghentstarshadow/capacitarr:stable
    container_name: capacitarr
    ports:
      - "2187:2187"
    environment:
      - PUID=1000
      - PGID=1000
      - JWT_SECRET=change-me-to-a-random-string
      - SECURE_COOKIES=true
      - DEBUG=false
    volumes:
      - capacitarr-config:/config
    healthcheck:
      test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:2187/api/v1/health"]
      interval: 30s
      timeout: 5s
      start_period: 15s
      retries: 3
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - SETUID
      - SETGID
    restart: unless-stopped

volumes:
  capacitarr-config:

Example: Subdirectory Deployment

When running behind a reverse proxy at a subdirectory (e.g., https://example.com/capacitarr/):

environment:
  - BASE_URL=/capacitarr/
  - JWT_SECRET=change-me-to-a-random-string
  - SECURE_COOKIES=true

Only BASE_URL is needed — the frontend HTML is automatically rewritten at startup to use the correct asset paths, API base URL, and Vue Router base path.

See the Deployment Guide for full reverse proxy configuration examples.

Example: Proxy Authentication

When using Authelia, Authentik, or Organizr for authentication:

environment:
  - AUTH_HEADER=Remote-User
  - JWT_SECRET=change-me-to-a-random-string

See the Deployment Guide for details on proxy authentication setup.

Data & Backup

All persistent data is stored in a single SQLite database file:

FileDefault PathDescription
capacitarr.db/config/capacitarr.dbAll application data: integrations, rules, preferences, audit logs, engine stats, disk groups, notification channels, and authentication credentials.

The /config directory (mapped via Docker volumes) is the only directory that needs to be backed up. No other files or directories contain user data.

Backup Recommendations

  • Stop the container before copying the database to ensure consistency: docker compose stop && cp /path/to/volume/capacitarr.db backup.db && docker compose start
  • Alternatively, use SQLite's .backup command for online backups.
  • The database path can be customized via the DB_PATH environment variable.

Settings Export & Import

Capacitarr provides a built-in settings export/import feature that lets you back up and restore your configuration without dealing with raw database files.

Exporting Settings

  1. Navigate to SettingsBackup & Restore
  2. Select which sections to include in the export:
    • Preferences — Scoring weights, execution mode, tiebreaker method
    • Rules — All custom protection rules
    • Integrations — Integration names, types, URLs, and enabled status
    • Disk Groups — Mount paths and threshold/target percentages
    • Notifications — Channel names, types, event subscriptions, and Apprise tags
  3. Click Export to download a JSON file

Tip: A Backup & Restore shortcut on the Scoring Engine page navigates to Settings with the Rules section pre-selected, making rules-only backups a single click.

Importing Settings

  1. Navigate to SettingsBackup & Restore
  2. Upload a previously exported JSON file
  3. Review the import preview showing which sections are available
  4. Select which sections to import (you can choose a subset)
  5. Click Import to apply the settings

What's Included and Excluded

For security, sensitive credentials are always stripped from exports:

SectionIncludedExcluded
PreferencesAll scoring weights, execution mode, tiebreakerInternal IDs, timestamps
RulesField, operator, value, effect, enabled, integration referenceInternal IDs
IntegrationsName, type, URL, enabled statusAPI keys
Disk GroupsMount path, threshold %, target %Transient disk usage data
NotificationsName, type, enabled, subscriptions, Apprise tagsWebhook URLs

After importing integrations or notification channels, you will need to re-enter API keys and webhook URLs manually.

Rules-Only Backup

To back up just your custom rules, select only the Rules section during export. This produces a portable JSON file containing all your protection rules that can be imported into another Capacitarr instance. Integration references use human-readable names instead of IDs for cross-instance compatibility.

Approval Queue

When the engine mode is set to Approval, items that meet deletion criteria are placed in the approval_queue table instead of being deleted automatically. A user must explicitly approve each item before deletion proceeds.

The approval queue is a separate table from the audit log. Items flow through a state machine: pendingapproved → deleted (moved to audit_log), or pendingrejected (snoozed).

Deletions-Disabled Safety Guard

When Deletions Enabled is turned off in Settings → Advanced, approving items from the approval queue is blocked. The approve action returns a 409 Conflict error:

Deletions are currently disabled in settings. Enable deletions before approving items.

Re-enable Deletions Enabled in Advanced settings before approving queued items. This prevents accidental approvals while the system is in a safe/paused state.

Orphan Recovery

If the container restarts while items are in the approved (processing) state — meaning they were approved but not yet deleted — those items are automatically reverted to pending on startup. They reappear in the approval queue so no items are silently lost.

This recovery also runs at the start of each engine poll cycle as an additional safety measure. The approval_orphans_recovered activity event is published when orphans are detected and recovered.

Automatic Queue Clearing

When disk usage drops below the configured threshold, the approval queue is automatically cleared of all pending and rejected (snoozed) items. This ensures the queue only contains current, actionable deletion candidates — stale items from a previous threshold breach are removed rather than left for manual cleanup.

Items that have already been approved and are actively being processed for deletion are preserved and will complete normally.

When the threshold is breached again on a subsequent engine run, the scoring engine re-evaluates all media and populates the queue with fresh candidates based on current disk usage and media metadata.

Real-Time Updates (SSE)

Capacitarr uses Server-Sent Events (SSE) to push real-time updates to all connected browser tabs. The SSE endpoint is GET /api/v1/events (authenticated).

When running behind a reverse proxy, ensure the proxy does not buffer responses for the SSE endpoint. See the Deployment Guide for proxy-specific configuration.

Application Preferences

Beyond environment variables, Capacitarr has application-level preferences managed through the Settings UI or the GET/PUT /preferences and PATCH /preferences/* API endpoints. These are stored in the database and can be changed at runtime.

Engine & Mode

SettingDefaultDescription
defaultDiskGroupModedry-runDefault execution mode for new disk groups: dry-run, approval, auto, sunset
tiebreakerMethodsize_descTiebreaker when deletion scores are equal: size_desc, size_asc, name_asc, oldest_first, newest_first
deletionsEnabledtrueSafety guard — actual file deletions only occur when true. When false, all deletions are simulated.
snoozeDurationHours24Hours to snooze rejected approval queue items (1-720)
deletionQueueDelaySeconds30Grace period in seconds before processing queued deletions (10-300)
pollIntervalSeconds300Engine poll interval in seconds (minimum 60)

Sunset Mode

See the Sunset Mode Guide for full documentation.

SettingDefaultDescription
sunsetDays30Countdown duration in days before sunset items are deleted (7-90)
sunsetLabelcapacitarr-sunsetLabel/tag applied to media server items in the sunset queue
savedLabelcapacitarr-savedLabel/tag applied to items saved by popular demand
posterOverlayStylecountdownPoster overlay style: off, countdown, simple
sunsetRescoreEnabledtrueEnable daily re-scoring of sunset queue items
savedDurationDays7Days the "Saved by popular demand" marker persists (3-30)

Content Analytics

SettingDefaultDescription
deadContentMinDays90Minimum days in library for media to appear in dead content analytics (30-365)
staleContentDays180Days since last watch for media to appear in stale content analytics (60-365)

Data Management

SettingDefaultDescription
logLevelinfoLog level: debug, info, warn, error
auditLogRetentionDays30Days to keep audit log entries (0 = indefinite)
backupRetentionDays7Days to keep automatic database backups (3, 7, 14, 30)
checkForUpdatestrueEnable outbound update check to GitHub (cached 6 hours)

Disk Group Grace Period

SettingDefaultDescription
diskGroupGracePeriodDays7Days before stale disk groups are permanently removed (0 = immediate)

Disk groups not reported by any integration are marked stale rather than deleted immediately. This protects against accidental data loss when integrations are temporarily disabled or unreachable. Stale groups retain all configuration (thresholds, mode, overrides) and are automatically restored when the mount path reappears. Set to 0 to restore the legacy immediate-deletion behavior.

Data Retention

DataRetentionConfiguration
Activity events7 daysFixed (not configurable)
Audit log entriesConfigurableauditLogRetentionDays preference
Engine run statsLast 1000 rowsFixed
Metrics (raw)2 hoursFixed — rolled up to hourly
Metrics (hourly)7 daysFixed — rolled up to daily
Metrics (daily)30 daysFixed — rolled up to weekly
Metrics (weekly)1 yearFixed