Configuration Overview
GOV.UK Notify API uses environment variables for configuration. Configuration is managed through theConfig class and environment-specific overrides.
Reference: app/config.py:82-706
Required Environment Variables
Core Application
Environment name:
development, test, or production environment name.Default: developmentFlask secret key for session management and CSRF protection.Example:
dev-notify-secret-keySalt for cryptographic signing operations.Example:
dev-notify-saltDatabase Configuration
PostgreSQL connection string.Format:
postgresql+psycopg2://user:password@host:port/databaseExample: postgresql+psycopg2://localhost/notification_apiRead replica connection string for bulk/analytics queries. Falls back to primary if not set.Format:
postgresql+psycopg2://host1:port,host2:port/database (supports multiple hosts)Database connection pool size per process.Default:
5Database Performance Tuning
Statement timeout in milliseconds for primary database.Default:
1200000 (20 minutes)Statement timeout in milliseconds for replica database.Default:
1200000 (20 minutes)Max parallel workers per query on primary database.Default:
None (uses database default)Max parallel workers per query on replica database.
Set to
1 to disable parallel queries on primary.Redis Configuration
Redis connection URL.Format:
redis://host:port/dbExample: redis://localhost:6379/0Enable Redis caching. Set to
1 to enable, 0 to disable.Default: 1 (enabled unless explicitly set to 0)AWS Configuration
AWS region for SQS, S3, and SES.Default:
eu-west-1AWS account ID for SQS queue URLs.Default:
123456789012Prefix for SQS queue names to identify environment.Example:
local_dev_john or production-S3 Buckets
S3 bucket for CSV file uploads.
S3 bucket for contact lists.
S3 bucket for letter PDFs.
S3 bucket for email template attachments.
S3 bucket for archived notification history.
S3 bucket for report request downloads.
API Configuration
Public-facing API hostname.Example:
https://api.notifications.service.gov.ukInternal API hostname (used on AWS for inter-service communication).
URL of the admin application.Default:
http://localhost:6012API Keys and Secrets
JSON object mapping client IDs to API keys for internal services.Format:
{"notify-admin": ["key1"], "notify-functional-tests": ["key2"]}API key for MMG SMS provider.
API key for Firetext SMS provider.
API key for Firetext international SMS.Default:
placeholderZendesk API key for support ticket integration.
Optional Environment Variables
Logging
Application log level.Options:
DEBUG, INFO, WARNING, ERROR, CRITICALDefault: INFOLog level for handlers. Falls back to
NOTIFY_LOG_LEVEL.Log level for HTTP request logging.Default:
INFOCelery Configuration
Celery worker log level.Options:
DEBUG, INFO, WARNING, ERROR, CRITICALDefault: CRITICALCelery Beat log level.Default:
INFONumber of tasks a worker prefetches. Set to 1 for long-running tasks.Default: Celery default (4)
Monitoring and Metrics
StatsD hostname for metrics collection.Example:
statsd.example.comStatsD port.Default:
8125Automatically enabled if
STATSD_HOST is set.Enable Cronitor monitoring. Set to
1 to enable.Default: 0JSON object mapping task names to Cronitor monitor keys.
Performance Tuning
Gunicorn worker timeout in seconds.Default:
30Log detailed diagnostics for requests exceeding this duration.
Enable eventlet statistics. Set to
1 to enable.Default: 0External Services
Template preview service URL.Default:
http://localhost:6013Template preview service API key.Default:
my-secret-keyDocument download service URL.Default:
http://localhost:7000Internal document download service URL.
Document download service API key.Default:
auth-tokenSMS Provider Configuration
MMG API endpoint.Default:
https://api.mmg.co.uk/jsonv2a/api.phpFiretext API endpoint.Default:
https://www.firetext.co.uk/api/sendsms/jsonDefault SMS sender number.
Distribution of SMS traffic between providers (must total 100%).Default:
{"mmg": 51, "firetext": 49}Email Configuration
AWS SES stub URL for testing. When set, uses stub client instead of real SES.
Email domain for Notify-generated emails.Example:
notifications.service.gov.ukFeature Flags
Enable API rate limiting. Set to
1 to enable.Default: 1Enable antivirus scanning for uploaded files.Default:
1 (enabled in production)Register functional testing endpoints. Set to
1 to enable.Default: 0 (enabled in development)Send alerts to Zendesk. Set to
1 to enable.Default: 0Monitor and alert on slow SMS delivery. Set to
1 to enable.Default: 0Notification Archiving
Minimum age in days before notifications are archived to S3.Default:
365Maximum hours of notifications to archive in a single run.Default:
240 (10 days)S3 key prefix for archived notifications.Default: “ (empty)
Delete notifications from database after archiving. Set to
1 to enable.Default: 1Environment-Specific Configuration
Development
Development environment automatically sets:DEBUG = TrueREDIS_ENABLED = False(unless explicitly set)- Development S3 bucket names
- Local API endpoints
- Test API keys for providers
Test
Test environment automatically sets:TESTING = True- Test S3 bucket names
- Mock Celery broker
- Simulated email/SMS endpoints
SQLALCHEMY_RECORD_QUERIES = True
Example Configuration
Development Setup
Createenvironment.sh:
Production Setup
Configuration Validation
The application validates configuration on startup:- Required variables must be set
- Database connection is tested
- AWS credentials are verified
- Redis connection is tested (if enabled)