Overview
This guide will walk you through sending your first notification using the GOV.UK Notify API. You’ll learn how to authenticate, install a client library, send a test SMS or email, and check the notification status.Before you begin, you’ll need a GOV.UK Notify service account and an API key. If you don’t have these yet, contact your Notify administrator or visit the admin portal.
Prerequisites
- A GOV.UK Notify service ID
- An API key (team, live, or test key)
- Python 3.7+ (or another supported language runtime)
- Your service must have the appropriate permissions (SMS, email, or letter)
Get Your API Credentials
Retrieve Your API Key
API keys are created in the GOV.UK Notify admin interface. Each key has a specific type:- Test key - For development, doesn’t send real notifications
- Team key - Sends only to team members (cannot send letters)
- Live key - Sends to anyone (production use)
Note Your Service ID
You’ll need your service ID (UUID format) for making API calls. This is part of your API key before the first hyphen, or you can find it in the admin interface.Install a Client Library
GOV.UK Notify provides official client libraries for multiple languages. We’ll use Python for this guide.
Client libraries handle JWT authentication, request signing, and error handling automatically.
Direct API Access (cURL)
If you prefer to use the REST API directly without a client library, you’ll need to generate JWT tokens for authentication. See the Authentication Guide for details.Send Your First SMS Notification
Create a Template
First, create a template in the Notify admin interface with a unique ID. For this example, we’ll assume you have a template that looks like:Send the SMS
Response Format
The API returns a JSON response with notification details:The
reference field is optional but recommended for tracking notifications in your own system.Send an Email Notification
Sending emails works similarly to SMS, but with an email address and optional reply-to address.
Email-Specific Features
- File attachments - Send PDFs or CSV files (requires service permission)
- Reply-to addresses - Configure custom reply-to email addresses
- Unsubscribe links - Include one-click unsubscribe URLs (optional)
Check Notification Status
After sending a notification, you can check its delivery status using the notification ID.
Notification Statuses
| Status | Description |
|---|---|
created | Notification created, queued for sending |
sending | Currently being sent to the provider |
pending | Sent to provider, awaiting confirmation |
delivered | Successfully delivered to recipient |
permanent-failure | Could not be delivered (invalid number/email) |
temporary-failure | Delivery failed, will retry |
technical-failure | Technical error, will not retry |
What’s Next?
Authentication Deep Dive
Learn how JWT token authentication works in detail
Template Guide
Master template creation and personalisation
Rate Limits
Understand rate limiting and daily message caps
API Reference
Explore the complete API documentation
Troubleshooting
Authentication Errors (401/403)
Authentication Errors (401/403)
Error: “Invalid token: API key not found”
- Verify your API key is correct and hasn’t been revoked
- Check that your service is active (not archived)
- Ensure you’re using the correct service ID in the token’s
issclaim
- JWT tokens include an
iat(issued at) timestamp - Ensure your server’s clock is synchronized with NTP
- Tokens expire after 30 seconds by default
Validation Errors (400)
Validation Errors (400)
Error: “phone_number is a required property”
- Ensure you’re including all required fields in your request
- Phone numbers must be in international format (+44…)
- Email addresses must be valid format
- Team API keys cannot send letters for security reasons
- Use a test or live API key for letter sending
Service Restrictions
Service Restrictions
Error: “Cannot send letters when service is in trial mode”
- Services in trial mode cannot send letters (except with test keys)
- Contact your administrator to upgrade your service
- Services have daily message limits
- Check your service settings for current limits
- Limits reset at midnight UTC
For more detailed error handling, see the API Error Reference.