The personal finance app for everyone (by everyone)
Ruby
# ================================ PLEASE READ ===========================================================
# This file outlines all the possible environment variables supported by the Sure app for self hosting.
#
# If you're a developer setting up your local environment, please use `.env.local.example` instead.
# ========================================================================================================
# Required self-hosting vars
# --------------------------------------------------------------------------------------------------------
# Enables self hosting features (should be set to true unless you know what you're doing)
SELF_HOSTED=true
# Controls onboarding flow (valid: open, closed, invite_only)
ONBOARDING_STATE=open
# Secret key used to encrypt credentials (https://api.rubyonrails.org/v7.1.3.2/classes/Rails/Application.html#method-i-secret_key_base)
# Has to be a random string, generated eg. by running `openssl rand -hex 64`
SECRET_KEY_BASE=secret-value
# Optional self-hosting vars
# --------------------------------------------------------------------------------------------------------
# Optional: days a cached page (Reports) is kept when nobody opens it. Also
# settable on the Self-Hosting page, like the two below.
# PAGE_CACHE_DAYS=7
# Optional: the most all cached pages may take together, in MB. The pages opened
# longest ago are dropped first when it would be exceeded.
# PAGE_CACHE_MAX_MB=100
# Optional: after its data changes, a cached page is still shown while it is
# rebuilt in the background, at most once in this many minutes (0: every change).
# PAGE_CACHE_COOLDOWN_MINUTES=60
# Optional: OpenAI-compatible API endpoint config
OPENAI_ACCESS_TOKEN=
OPENAI_MODEL=
OPENAI_URI_BASE=
# Optional: LLM token budget for the OpenAI-compatible provider (chat, auto-categorize, merchant detection, PDF processing).
# Lower these for small-context local models (Ollama, LM Studio, LocalAI).
# For larger local models, raise the context window to match the model you actually run.
# Example: Gemma 3/4, Qwen, and other large-context models often need `LLM_CONTEXT_WINDOW=8192` or higher.
# LLM_CONTEXT_WINDOW=2048
# LLM_MAX_RESPONSE_TOKENS=512
# LLM_MAX_HISTORY_TOKENS=
# LLM_SYSTEM_PROMPT_RESERVE=256
# LLM_MAX_ITEMS_PER_CALL=25 # Not a token budget: items per AI rule/merchant job, for every provider
# Optional: how long the chat waits for an assistant response before showing a
# "no response" error. Raise for slow local models — OpenAI-compatible providers
# are not streamed, so nothing renders until the whole reply is generated.
#
# This clock starts when the message is queued and covers the whole turn, so it
# is a SUM, not a maximum. The worst case is:
#
# (1 + ASSISTANT_MAX_TOOL_CALL_ITERATIONS) * OPENAI_REQUEST_TIMEOUT
# + tool execution + queue wait
#
# At the defaults that bound is 6 * 60 = 360s plus overhead. The 90s default is
# sized for typical latency rather than that bound — cloud models answer in
# seconds, so a turn rarely approaches it. Size against the formula once your
# per-call latency is genuinely near OPENAI_REQUEST_TIMEOUT, which is the case
# for local models. Set too low, you get a generic "no response" instead of the
# specific timeout error, and the job keeps burning tokens after the chat gave up.
# Minimum 30; also settable on the Self-Hosting settings page.
# AI_RESPONSE_TIMEOUT=90
#
# Lowering the tool-call cap is often the better lever on slow hardware: it cuts
# the first term of that sum instead of requiring a very long timeout.
# ASSISTANT_MAX_TOOL_CALL_ITERATIONS=5
# Optional: OpenAI-compatible capability flags
# OPENAI_REQUEST_TIMEOUT=60 # HTTP timeout in seconds; raise for slow local models
# OPENAI_EXTRA_HEADERS='{"x-opencode-session":"{session_id}"}' # Extra JSON headers for chat requests; value containing {session_id} becomes the chat UUID
# OPENAI_SUPPORTS_PDF_PROCESSING=true # Set to false for endpoints without vision support
# OPENAI_SUPPORTS_RESPONSES_ENDPOINT= # Override Responses-API vs chat.completions routing
# LLM_JSON_MODE= # auto | strict | json_object | none
# Optional: native Anthropic provider. LLM_PROVIDER picks the provider for chat
# and background AI jobs, except categorization when Jev is selected (also
# settable on the Self-Hosting settings page).
# The token budget above doesn't trim or split Anthropic requests.
# LLM_PROVIDER=anthropic # openai (default) | anthropic
# ANTHROPIC_API_KEY= # ANTHROPIC_ACCESS_TOKEN also works and wins if both are set
# ANTHROPIC_MODEL=claude-sonnet-4-6 # Required with ANTHROPIC_BASE_URL
# ANTHROPIC_MAX_TOKENS=4096 # Reply limit, sent with every request
# ANTHROPIC_REQUEST_TIMEOUT=600 # HTTP timeout in seconds
# ANTHROPIC_BASE_URL= # Anthropic-compatible endpoint (e.g. a Bedrock or Vertex gateway)
# Optional: Jev (TypeSafe) — a classification provider used for transaction
# categorization. It answers typed questions with calibrated probabilities
# rather than generating text, so it is never used for chat or PDF processing
# and is configured independently of LLM_PROVIDER.
# JEV_API_KEY= # Required to enable Jev; no fallback to other keys
# CATEGORIZATION_PROVIDER= # llm | jev — overrides each family's choice
# JEV_ENDPOINT= # Default: https://api.typesafe.ai/v1/systemone
# JEV_MODEL= # Default: jev-latest
# Defaults go straight to TypeSafe. To reach Jev through a gateway such as
# OpenRouter instead -- which means your transaction descriptions transit that
# provider too -- set both:
# JEV_ENDPOINT=https://openrouter.ai/api/alpha/decisions
# JEV_MODEL=~typesafe/jev-latest
# Optional: document-search vector store. Hosted OpenAI is selected by default
# when OPENAI_ACCESS_TOKEN is configured. For a local OpenAI-compatible LLM,
# use pgvector plus a separate OpenAI-compatible embeddings endpoint.
# VECTOR_STORE_PROVIDER=pgvector # openai | pgvector | qdrant (scaffolded only)
# EMBEDDING_URI_BASE=http://ollama:11434/v1
# EMBEDDING_MODEL=mxbai-embed-large
# EMBEDDING_DIMENSIONS=1024 # Must match the embedding model
# EMBEDDING_ACCESS_TOKEN= # Optional; falls back to OPENAI_ACCESS_TOKEN
# AI_HEALTH_PROBE_TIMEOUT=5 # Per-request timeout for admin live checks (overrides Self-Hosting setting)
# AI_HEALTH_PROBE_CACHE_TTL=60 # Cache live results and deduplicate failure logs
# Optional: External AI Assistant — delegates chat to a remote AI agent
# instead of calling LLMs directly. The agent calls back to Sure's /mcp endpoint.
# See docs/hosting/ai.md for full details.
# ASSISTANT_TYPE=external
# EXTERNAL_ASSISTANT_URL=https://your-agent-host/v1/chat/completions
# EXTERNAL_ASSISTANT_TOKEN=your-api-token # pipelock:ignore
# EXTERNAL_ASSISTANT_MODEL=openclaw/main # Defaults to openclaw/main
# EXTERNAL_ASSISTANT_AGENT_ID=main # Legacy; used only when no model is selected
# EXTERNAL_ASSISTANT_SESSION_KEY=agent:main:main
# [email protected]
# Optional: MCP server endpoint — enables /mcp for external AI assistants.
# Both values are required. MCP_USER_EMAIL must match an existing user's email.
# MCP_API_TOKEN=your-random-bearer-token # pipelock:ignore
# [email protected]
# Optional: Langfuse config
LANGFUSE_HOST=https://cloud.langfuse.com
LANGFUSE_PUBLIC_KEY=
LANGFUSE_SECRET_KEY=
# Optional: Twelve Data API Key for exchange rates + stock prices
# (you can also set this in your self-hosted settings page)
# Get it here: https://twelvedata.com/
TWELVE_DATA_API_KEY=
# Optional: Provider selection for exchange rates and securities data
# Options: twelve_data (default), yahoo_finance
# EXCHANGE_RATE_PROVIDER=twelve_data
# SECURITIES_PROVIDER=twelve_data
# Optional: how far a cross-currency pair may drift from the cached daily exchange
# rate and still be auto-matched as a transfer, as a fraction (0.1 = 10%). Only
# accounts linked to a provider are auto-matched across currencies. Lower it if
# unrelated round-number transactions are being linked; values above 0.5 are capped,
# and an unusable value falls back to the default. The manual "match as transfer"
# dialog always searches at least 10%.
# TRANSFER_MATCH_EXCHANGE_RATE_TOLERANCE=0.1
# Alternative: Use Yahoo Finance as provider (free, no API key required)
EXCHANGE_RATE_PROVIDER=yahoo_finance
SECURITIES_PROVIDER=yahoo_finance
# Optional: daily market data (security price) import. These only set the
# defaults; once you change the import on the Self-Hosting settings page, the
# saved value wins. The job runs Monday to Friday at the given local time
# (default 22:00 UTC, about an hour after the New York close). Set the time
# shortly after your main exchange closes, or set ENABLED to 0 to turn the
# import off. Only "1" counts as enabled. The timezone accepts IANA names such as
# Europe/Berlin; an unknown name falls back to UTC.
# MARKET_DATA_SYNC_ENABLED=1
# MARKET_DATA_SYNC_TIME=22:00
# MARKET_DATA_SYNC_TIMEZONE=UTC
# Optional: linked-account balance anchoring. When enabled, a stale provider
# balance anchor that the sync's imported transactions explain is moved forward
# instead of being kept as a reconciliation waypoint. Default off.
# See docs/hosting/balance-anchors.md for rollout and rollback behavior.
# BALANCE_REUSE_EXPLAINED_ANCHOR=1
# Brandfetch to grab logos for banks and merchants
BRAND_FETCH_CLIENT_ID=
# Optional: Chimnie API key for automatic UK property valuations by UPRN
# (you can also set this in your self-hosted settings page)
# Get a free key here: https://dashboard.chimnie.com (requires a business or custom-domain email)
CHIMNIE_API_KEY=
# CHIMNIE_MAX_REQUESTS_PER_MONTH=1000
# Custom port config
# For users who have other applications listening at 3000, this allows them to set a value puma will listen to.
PORT=3000
# SMTP Configuration
# This is only needed if you intend on sending emails from your Sure instance (such as for password resets or email financial reports).
# Resend.com is a good option that offers a free tier for sending emails.
SMTP_ADDRESS=
SMTP_PORT=465
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_TLS_ENABLED=true
SMTP_TLS_SKIP_VERIFY=false
# Address that emails are sent from
EMAIL_SENDER=
# Database Configuration
DB_HOST=localhost # May need to be changed to `DB_HOST=db` if using devcontainer
DB_PORT=5432
POSTGRES_PASSWORD=postgres # pipelock:ignore
POSTGRES_USER=postgres
# Redis configuration
# Standard Redis URL (for direct connection)
REDIS_URL=redis://localhost:6379/1
# Redis Sentinel configuration (for high availability)
# When REDIS_SENTINEL_HOSTS is set, it takes precedence over REDIS_URL
# REDIS_SENTINEL_HOSTS=sentinel1:26379,sentinel2:26379,sentinel3:26379
# REDIS_SENTINEL_MASTER=mymaster
# REDIS_SENTINEL_USERNAME=default
# REDIS_PASSWORD=your-redis-password # pipelock:ignore
# Sidekiq Web UI (/sidekiq)
# The queue dashboard is reachable in production only by signed-in super admins
# (the first user created on the instance). Optionally set BOTH variables below
# to require basic-auth credentials as a second layer on top of that.
# SIDEKIQ_WEB_USERNAME=
# SIDEKIQ_WEB_PASSWORD=
# Scheduled jobs (daily sync, market data import, cleanups) that were missed by
# more than this many seconds are skipped, for example while the host sleeps.
# Default 600 (10 minutes). Laptops or NAS boxes that sleep overnight can set
# 86400 so the most recent missed run of each job still happens once on wake.
# SIDEKIQ_CRON_GRACE_PERIOD_SECONDS=600
# App Domain
# This is the domain that your Sure instance will be hosted at. It is used to generate links in emails and other places.
APP_DOMAIN=
# WebAuthn / passkey configuration
# RP ID is usually the registrable domain (example.com), not a full URL.
# Allowed origins is a comma-separated list of the full origins where users
# access Sure (scheme included), e.g. https://sure.example.com,https://app.example.com.
WEBAUTHN_RP_ID=
WEBAUTHN_ALLOWED_ORIGINS=
# Set to false to keep passkeys as a second factor only, instead of also
# allowing passwordless sign-in. See docs/hosting/webauthn.md.
# AUTH_PASSKEY_LOGIN_ENABLED=true
# OpenID Connect configuration
OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=
OIDC_ISSUER=
OIDC_REDIRECT_URI=
# Product/Brand Name
PRODUCT_NAME=
BRAND_NAME=
# Legal pages
# Full URLs of this instance's privacy policy and terms of service. When set,
# /privacy and /terms redirect to them and the login, signup and onboarding
# footers link to them; when unset, the footer shows no link for that page.
# LEGAL_PRIVACY_URL=
# LEGAL_TERMS_URL=
# PostHog configuration
POSTHOG_KEY=
POSTHOG_HOST=
# Content Security Policy: true only reports violations in the browser console
# instead of blocking them (see docs/hosting/content-security-policy.md)
# CSP_REPORT_ONLY=false
# Disable enforcing SSL connections
# DISABLE_SSL=true
# Customizations to outbound SSL/TLS connections
# Path to custom CA certificate (PEM format)
# SSL_CA_FILE=
# Enable/disable SSL verification
# SSL_VERIFY=true
# Enable verbose SSL logging
# SSL_DEBUG=false
# Active Record Encryption Keys (Optional)
# These keys are used to encrypt sensitive data like API keys in the database.
# For managed mode: Set these environment variables to provide encryption keys.
# For self-hosted mode: If not provided, they will be automatically generated based on your SECRET_KEY_BASE.
# You can generate your own keys by running: rails db:encryption:init
# Set all three or none. Adding them to an instance that already has data changes its keys;
# see "Encrypting sensitive data" in docs/hosting/docker.md first.
# ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=
# ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=
# ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=
# ======================================================================================================
# Active Storage Configuration - responsible for storing file uploads
# ======================================================================================================
#
# * Defaults to disk storage but you can also use Amazon S3, Cloudflare R2, or Google Cloud Storage
# * Set the appropriate environment variables to use these services.
# * Ensure libvips is installed on your system for image processing - https://github.com/libvips/libvips
#
# Amazon S3
# ==========
# ACTIVE_STORAGE_SERVICE=amazon <- Enables Amazon S3 storage
# S3_ACCESS_KEY_ID=
# S3_SECRET_ACCESS_KEY=
# S3_REGION= # defaults to `us-east-1` if not set
# S3_BUCKET=
#
# Cloudflare R2
# =============
# ACTIVE_STORAGE_SERVICE=cloudflare <- Enables Cloudflare R2 storage
# CLOUDFLARE_ACCOUNT_ID=
# CLOUDFLARE_ACCESS_KEY_ID=
# CLOUDFLARE_SECRET_ACCESS_KEY=
# CLOUDFLARE_BUCKET=
#
# Generic S3
# ==========
# ACTIVE_STORAGE_SERVICE=generic_s3 <- Enables Generic S3 storage
# GENERIC_S3_ACCESS_KEY_ID=
# GENERIC_S3_SECRET_ACCESS_KEY=
# GENERIC_S3_REGION=
# GENERIC_S3_BUCKET=
# GENERIC_S3_ENDPOINT=
# GENERIC_S3_FORCE_PATH_STYLE= <- defaults to false
#
# Google Cloud Storage
# ====================
# ACTIVE_STORAGE_SERVICE=google <- Enables Google Cloud Storage
# GCS_PROJECT=
# GCS_BUCKET=
# GCS_KEYFILE_JSON= <- JSON content of service account key (preferred)
# GCS_KEYFILE= <- path to service account JSON key file
# Skylight
# ========
SKYLIGHT_AUTHENTICATION=
SKYLIGHT_ENABLED=
# ======================================================================================================
# Backup Configuration (Optional)
# ======================================================================================================
#
# Used by the "backup" service (bin/sure-backup in the Sure image). Each backup holds the database,
# uploaded files, .env and compose file, under <BACKUP_DIR>/<version>/<timestamp>-<manual|scheduled>/.
# See docs/hosting/docker.md "Backups, upgrades and rollbacks".
#
# SURE_IMAGE_TAG="stable" # Image tag for web/worker/backup: stable, latest, or a version such as 0.7.4 (pin it to roll back)
# BACKUP_DIR="./backups" # Host folder for backups
# BACKUP_SCHEDULE="0 2 * * *" # Daily time for scheduled backups: "minute hour * * *" in UTC (default 02:00)
# BACKUP_KEEP_DAYS="7" # Delete scheduled backups older than this many days; manual backups are kept
#
# Off-site copies, made by the optional "backup-offsite" service with rclone (S3, R2, B2, SFTP, Google Drive, etc.):
# BACKUP_DESTINATION="s3:my-bucket" # Rclone remote (remote:bucket/path)
# INSTANCE_ID="default" # Scopes off-site backups under BACKUP_DESTINATION/<INSTANCE_ID> to isolate retention per deployment
#
# Example Rclone configuration for an S3 compatible provider (e.g., Cloudflare R2):
# RCLONE_CONFIG_S3_TYPE=s3
# RCLONE_CONFIG_S3_PROVIDER=Cloudflare
# RCLONE_CONFIG_S3_ACCESS_KEY_ID=
# RCLONE_CONFIG_S3_SECRET_ACCESS_KEY=
# RCLONE_CONFIG_S3_ENDPOINT=