Authentication Method
The API uses JWT (JSON Web Token) authentication with HS256 signing:- Generate a JWT token signed with your API key secret
- Include the token in the
Authorizationheader - Token must be valid (not expired, correct signature)
API Keys
API keys are managed through the GOV.UK Notify admin interface. Each API key has:- Key ID - UUID identifying the key
- Secret - Used to sign JWT tokens
- Key type - Determines permissions and rate limits
Key Types
- Live (Normal) Keys
- Team Keys
- Test Keys
Production use - Send to any recipient
- Can send to any phone number or email address
- Subject to full rate limits
- Notifications are billable
- Used for production services
Generating JWT Tokens
Token Structure
A valid JWT token for Notify must include these claims:JWT claims
Issuer - Your service ID (UUID)
Issued at - Unix timestamp when token was created
Token Signing
Tokens must be signed using HS256 (HMAC-SHA256) with your API key secret:Python example
Node.js example
Ruby example
Making Authenticated Requests
Authorization Header
Include the JWT token in theAuthorization header with the Bearer scheme:
cURL example
Complete Request Example
Python with requests
Authentication Errors
Common authentication errors and how to fix them:401 Unauthorized - Invalid token
401 Unauthorized - Invalid token
403 Forbidden - Token not found
403 Forbidden - Token not found
Error message:
Invalid token: API key not foundCauses:- API key has been revoked
- API key ID is incorrect
- Service ID in token doesn’t exist
- Check API key hasn’t been revoked in admin interface
- Verify service ID is correct
- Generate a new API key if needed
403 Forbidden - Token expired
403 Forbidden - Token expired
Error message:
Error: Your system clock must be accurate to within 30 secondsCauses:- System clock is not synchronized
iatclaim is more than 30 seconds in the past or future
- Synchronize your system clock with NTP
- Generate a fresh token for each request
- Don’t cache tokens for extended periods
Best Practices
Generate tokens per request
Create a new token for each API request instead of reusing tokens. This avoids clock skew issues.
Secure storage
Store API key secrets securely using environment variables or secret management systems. Never commit secrets to version control.
Key rotation
Rotate API keys periodically and when team members with access leave.
Use appropriate key type
Use test keys for development, team keys for testing, and live keys only in production.
Using Client Libraries
Official client libraries handle JWT token generation automatically:Python client
Next Steps
Rate limits
Understand API rate limits
Send notifications
Start sending notifications