Back

Java client documentation

This documentation is for developers interested in using the GOV.UK Notify Java client to send emails, text messages or letters.

.NET client documentation

This documentation is for developers interested in using the GOV.UK Notify .NET client to send emails (including documents), text messages or letters. GOV.UK Notify supports .NET framework 4.6.2 and .NET Core 2.0.

Node.js client documentation

This documentation is for developers interested in using the GOV.UK Notify Node.js client to send emails, text messages or letters.

PHP client documentation

This documentation is for developers interested in using the GOV.UK Notify PHP client to send emails, text messages or letters.

Python client documentation

This documentation is for developers interested in using the GOV.UK Notify Python client to send emails, text messages or letters. Notify supports Python 3.8 and higher.

Ruby client documentation

This documentation is for developers interested in using the GOV.UK Notify Ruby client to send emails, text messages or letters.

REST API documentation

This documentation is for developers interested in using the GOV.UK Notify API to send emails, text messages or letters.

You can use it to integrate directly with the API if you cannot use one of our 6 client libraries.

Developers can also use our OpenAPI file with tools such as Swagger and Redoc to assist with using the REST API. You cannot use Swagger Editor to make test API requests.

Set up the client

Set up the client

Set up the client

Set up the client

The Notify PHP Client is based on a PSR-7 HTTP model. To install it, you must select your preferred PSR-7 compatible HTTP client. You can follow these instructions to use Guzzle v7.

Set up the client

Set up the client

Making a request

Install the client

The notifications-java-client deploys to Maven Central.

Go to the GOV.UK Notify Java client page on Maven Central:

  1. Select the most recent version.
  2. Copy the dependency configuration snippet for your build tool.

Refer to the client changelog for the version number and the latest updates.

Prerequisites

This documentation assumes you are using either Microsoft Visual Studio (Windows) or Visual Studio Code with the C# extension (Windows, macOS, or Linux) and with the NuGet Package Manager.

Refer to the client changelog for the version number and the latest updates.

Install the client

Run the following in the command line:

npm install --save notifications-node-client

Guzzle v7

  1. Use Composer to install the GOV.UK Notify PHP client. Run the following in the command line:

    composer require php-http/guzzle7-adapter alphagov/notifications-php-client
    

    You can now use the autoloader to download the GOV.UK Notify PHP client.

  2. Add the following code to your application to create a new instance of the client:

    $notifyClient = new \Alphagov\Notifications\Client([
        'apiKey' => '{your api key}',
        'httpClient' => new \Http\Adapter\Guzzle7\Client
    ]);
    

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

Install the client

Run the following code in the command line:

pip install notifications-python-client

Refer to the client changelog for the client version number and the latest updates.

Install the client

Base URL

https://api.notifications.service.gov.uk

Add notifications-ruby-client to your application’s Gemfile, for example:

gem "notifications-ruby-client"

Then run bundle install from your project’s directory.

Refer to the client changelog for the version number and the latest updates.

Installing globally

Run the following from the command line:

gem install notifications-ruby-client

Create a new instance of the client

Add this code to your application:

import uk.gov.service.notify.NotificationClient;
NotificationClient client = new NotificationClient(apiKey);

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

Install the client

The GOV.UK Notify client can be installed from Nuget.org.

You can install the GOV.UK Notify client package using either the command line or Microsoft Visual Studio.

Create a new instance of the client

Add this code to your application:

let NotifyClient = require("notifications-node-client").NotifyClient;

let notifyClient = new NotifyClient(apiKey);

Create a new instance of the client

Add this code to your application:

from notifications_python_client.notifications import NotificationsAPIClient

notifications_client = NotificationsAPIClient(api_key)

Create a new instance of the client

Add this code to your application:

require "notifications/client"
client = Notifications::Client.new(api_key)

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

Headers

Connect through a proxy (optional)

If you use a proxy you can pass it into the NotificationClient constructor.

import uk.gov.service.notify.NotificationClient;
NotificationClient client = new NotificationClient(apiKey, proxy);

Use the dotnet command line interface

Go to your project directory and run the following in the command line to install the client package:

dotnet add package GovukNotify

Arguments

Arguments

Authorisation header

The authorisation header is an API key that is encoded using JSON Web Tokens. You must include an authorisation header.

JSON Web Tokens have a standard header and a payload. The header consists of:

{
  "typ": "JWT",
  "alg": "HS256"
}

The payload consists of:

{
  "iss": "26785a09-ab16-4eb0-8407-a37497a57506",
  "iat": 1568818578
}

JSON Web Tokens are encoded using a secret key with the following format:

3d844edf-8d35-48ac-975b-e847b4f122b0

That secret key forms a part of your API key, which follows the format {key_name}-{iss-uuid}-{secret-key-uuid}.

For example, if your API key is my_test_key-26785a09-ab16-4eb0-8407-a37497a57506-3d844edf-8d35-48ac-975b-e847b4f122b0:

  • your API key name is my_test_key
  • your iss (your service id) is 26785a09-ab16-4eb0-8407-a37497a57506
  • your secret key is 3d844edf-8d35-48ac-975b-e847b4f122b0

iat (issued at) is the current time in UTC in epoch seconds. The token expires within 30 seconds of the current time.

Refer to the JSON Web Tokens website for more information on encoding your authorisation header.

When you have an encoded and signed token, add that token to a header as follows:

"Authorization": "Bearer encoded_jwt_token"
api_key (required)

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

api_key (required)

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

timeout (optional)

The default timeout is 30 seconds. For more information about timeouts see https://docs.python-requests.org/en/latest/user/advanced/#timeouts.

Use Microsoft Visual Studio or Visual Studio Code with C# Extension

Use the NuGet Package Manager to install the GovukNotify client package in Visual Studio.

You can use either the console or the UI.

Connect through a proxy (optional)

Add this code to your application:

const proxyConfig = {
  host: proxyHost,
  port: proxyPort
};

notifyClient.setProxy(proxyConfig);

where the proxyConfig should be an object supported by axios.

Content header

The content header is application/json:

"Content-type": "application/json"
Console

Run the following in the NuGet package manager console to install the client package:

nuget install GovukNotify
User Interface (UI)

Use the Package Manager UI to search for and install the client package.

Provide your own underlying Axios client (optional)

You can provide your own Axios client to the Notify client. This is useful if you want to use a custom Axios client with specific settings, like custom interceptors.

Add this code to your application:

notifyClient.setClient(customAxiosClient);

where customAxiosClient is an instance of Axios.

Create a new instance of the client

Add this code to your application:

using Notify.Client;
using Notify.Models;
using Notify.Models.Responses;

var client = new NotificationClient(apiKey);

To get an API key, sign in to GOV.UK Notify and go to the API integration page. You can find more information in the API keys section of this documentation.

Connect through a proxy (optional)

If you use a proxy, you must set the proxy configuration in the web.config file. Refer to the Microsoft documentation on proxy configuration for more information.

using Notify.Client;
using Notify.Models;
using Notify.Models.Responses;
using System.Net.Http;

var httpClientWithProxy = new HttpClientWrapper(new HttpClient(...));
var client = new NotificationClient(httpClientWithProxy, apiKey);

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a message

You can use GOV.UK Notify to send text messages, emails and letters.

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a message

You can use GOV.UK Notify to send emails, text messages and letters.

Send a text message

Send a text message

Send a text message

Send a text message

Send a text message

Send a text message

Send a text message

Method

SendSmsResponse response = client.sendSms(
    templateId,
    phoneNumber,
    personalisation,
    reference,
    smsSenderId
);

Method

SmsNotificationResponse response = client.SendSms(
  mobileNumber: "+447900900123",
  templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a",
  );

Method

notifyClient
  .sendSms(templateId, phoneNumber, {
    personalisation: personalisation,
    reference: reference,
    smsSenderId: smsSenderId
  })
  .then(response => console.log(response))
  .catch(err => console.error(err));

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

sendSms( $phoneNumber, $templateId, array $personalisation = array(), $reference = '', $smsSenderId = NULL  )

For example:

try {
    $response = $notifyClient->sendSms(
        '+447777111222',
        'df10a23e-2c6d-4ea5-87fb-82e520cbf93a', [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968'
        ],
        'unique_ref123',
        '862bfaaf-9f89-43dd-aafa-2868ce2926a9'
    );

} catch (ApiException $e){}

Method

response = notifications_client.send_sms_notification(
    phone_number="+447700900123",
    template_id="f33517ff-2a88-4f6e-b855-c550268ce08a",
)

Method

smsresponse = client.send_sms(
  phone_number: "+447900900123",
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
)

Method

POST /v2/notifications/sms

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

Request body

{
  "phone_number": "+447900900123",
  "template_id": "f33517ff-2a88-4f6e-b855-c550268ce08a"
}
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

String templateId="f33517ff-2a88-4f6e-b855-c550268ce08a";
mobileNumber (required)

The phone number of the recipient of the text message. This can be a UK or international number.

string mobileNumber: "+447900900123";
phoneNumber (required)

The phone number of the recipient of the text message. This can be a UK or international number.

For example:

let phoneNumber = "+447900900123";
phoneNumber (required)

The phone number of the recipient of the text message. This can be a UK or international number.

phone_number (required)

The phone number of the recipient of the text message. This can be a UK or international number.

For example:

phone_number="+447700900123", # required string
phone_number (required)

The phone number of the text message recipient. This can be a UK or international number. For example:

phone_number: "+447900900123"
phoneNumber (required)

The phone number of the recipient of the text message. This number can be a UK or international number.

String phoneNumber="+447900900123";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

let templateId = "f33517ff-2a88-4f6e-b855-c550268ce08a"; // required UUID string
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id="f33517ff-2a88-4f6e-b855-c550268ce08a", # required UUID string
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
personalisation (required)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in a map. For example:

Map<String, Object> personalisation = new HashMap<>();
personalisation.put("first_name", "Amala");
personalisation.put("application_date", "2018-01-01");
personalisation.put("list", listOfItems); // Will appear as a comma separated list in the message

If a template does not have any placeholder fields for personalised information, you must pass in an empty map or null.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a Dictionary. For example:

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"}
};

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in an object. For example:

let personalisation = {
    first_name: "Amala",
    appointment_date: "1 January 2018 at 1:00pm"
};
personalisation (optional)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in a dictionary with key value pairs. For example:

$personalisation = [
    'name' => 'Amala',
    'application_date'  => '2018-01-01'
];

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in a dictionary with key value pairs. For example:

personalisation={
    "first_name": "Amala",
    "appointment_date": "1 January 2018 at 01:00PM",
},

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in a hash. For example:

personalisation: {
  name: "John Smith",
  ID: "300241",
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. If you do not have a reference, you must pass in an empty string or null.

String reference='STRING';
reference (optional)

A unique identifier you can create if you need to. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

string reference: "my reference";

You can leave out this argument if you do not have a reference.

reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique message or a batch of messages. It must not contain any personal information such as name or postal address. For example:

let reference = "your reference"; // optional string - identifies notification(s)
reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

$reference = 'STRING';

You can leave out this argument if you do not have a reference.

reference (optional)

An identifier you can create if necessary. This reference identifies a single unique message or a batch of messages. It must not contain any personal information such as name or postal address. For example:

reference="your reference", # optional string - identifies notification(s)

You can leave out this argument if you do not have a reference.

reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

reference: "your_reference_string"

You can leave out this argument if you do not have a reference.

smsSenderId (optional)

A unique identifier of the sender of the text message notification.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service will use, and select Save
String smsSenderId='8e222534-7f05-4972-86e3-17c5d9f894e2'

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

smsSenderId (optional)

A unique identifier of the sender of the text message notification.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service uses, and select Save

For example:

string smsSenderId: "8e222534-7f05-4972-86e3-17c5d9f894e2";

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

smsSenderId (optional)

A unique identifier of the sender of the text message.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service will use, and select Save
let smsSenderId = "8e222534-7f05-4972-86e3-17c5d9f894e2";

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

smsSenderId (optional)

A unique identifier of the sender of the text message notification.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service will use, and select Save
$smsSenderId='8e222534-7f05-4972-86e3-17c5d9f894e2'

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

sms_sender_id (optional)

A unique identifier of the sender of the text message.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service will use, and select Save
sms_sender_id="8e222534-7f05-4972-86e3-17c5d9f894e2", # optional UUID string

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

sms_sender_id (optional)

A unique identifier of the sender of the text message notification.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service uses, and select Save

For example:

sms_sender_id: "8e222534-7f05-4972-86e3-17c5d9f894e2"

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

Response

If the request to the client is successful, the client returns a SendSmsResponse:

UUID notificationId;
Optional<String> reference;
UUID templateId;
int templateVersion;
String templateUri;
String body;
Optional<String> fromNumber;

If you are using the test API key, all your messages come back with a delivered status.

All messages sent using the team and guest list or live keys appear on your dashboard.

Response

If the request to the client is successful, the client returns an SmsNotificationResponse:

public String id;
public String reference;
public String uri;
public Template template;
public SmsResponseContent;

public class Template {
    public String id;
    public String uri;
    public Int32 version;
}
public class SmsResponseContent{
    public string body;
    public string fromNumber;
}

If you use the test API key, all your messages come back with a delivered status.

All messages sent using the team and guest list or live keys appear on your dashboard.

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a", // required string - notification ID
    "reference": "your reference", // optional string - reference you provided when sending the message
    "content": {
        "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00pm", // required string - message content
        "from_number": "GOVUK" // required string - sender name / phone number
    },
    "uri": "https://api.notifications.service.gov.uk/v2/notifications/740e5834-3a29-46b4-9a6f-16142fde533a", // required string
    "template": {
        "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
        "version": 3, // required integer
        "uri": "https://api.notifications.service.gov.uk/v2/template/f33517ff-2a88-4f6e-b855-c550268ce08a" // required string
    }
};

If you are using the test API key, all your messages will come back with a delivered status.

All messages sent using the team and guest list or live keys will appear on your dashboard.

Response

If the request to the client is successful, the client returns an array:

[
    "id" => "bfb50d92-100d-4b8b-b559-14fa3b091cda",
    "reference" => None,
    "content" => [
        "body" => "Some words",
        "from_number" => "40604"
    ],
    "uri" => "https =>//api.notifications.service.gov.uk/v2/notifications/ceb50d92-100d-4b8b-b559-14fa3b091cd",
    "template" => [
        "id" => "ceb50d92-100d-4b8b-b559-14fa3b091cda",
       "version" => 1,
       "uri" => "https://api.notifications.service.gov.uk/v2/templates/bfb50d92-100d-4b8b-b559-14fa3b091cda"
    ]
];

If you are using the test API key, all your messages will come back with a delivered status.

All messages sent using the team and guest list or live keys will appear on your dashboard.

Response

If the request to the client is successful, the client returns a dict:

{
  "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  # required string - notification ID
  "reference": "your reference", # optional string - reference you provided when sending the message
  "content": {
    "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00pm",  # required string - message content
    "from_number": "GOVUK"  # required string - sender name / phone number
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/740e5834-3a29-46b4-9a6f-16142fde533a",  # required string
  "template": {
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", # required string - template ID
    "version": 3,  # required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/f33517ff-2a88-4f6e-b855-c550268ce08a"  # required string
  }
}

If you are using the test API key, all your messages will come back with a delivered status.

All messages sent using the team and guest list or live keys will appear on your dashboard.

Response

If the request to the client is successful, the client returns a Notifications::Client:ResponseNotification object. In the example shown in the Method section, the object is named smsresponse.

You can then call different methods on this object:

Method Information Type
smsresponse.id Notification UUID String
smsresponse.reference reference argument String
smsresponse.content - body: Message body sent to the recipient
- from_number: SMS sender number of your service
Hash
smsresponse.template Contains the id, version and uri of the template Hash
smsresponse.uri Notification URL String

If you are using the test API key, all your messages come back with a delivered status.

All messages sent using the team and guest list or live keys appear on your GOV.UK Notify dashboard.

Arguments

phone_number (required)

The phone number of the recipient of the text message. This can be a UK or international number.

For example:

"phone_number": "+447900900123"
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

"template_id": "f33517ff-2a88-4f6e-b855-c550268ce08a"
personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in a dictionary with key value pairs. For example:

"personalisation": {
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

reference (optional)

An identifier you can create if necessary. This reference identifies a single unique message or a batch of messages. It must not contain any personal information such as name or postal address. For example:

// optional string - identifies notification(s)
"reference": "your reference"

You can leave out this argument if you do not have a reference.

sms_sender_id (optional)

A unique identifier of the sender of the text message notification.

To find the text message sender:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Text Messages section, select Manage on the Text Message sender row.

You can then either:

  • copy the sender ID that you want to use and paste it into the method
  • select Change to change the default sender that the service will use, and select Save
"sms_sender_id": "8e222534-7f05-4972-86e3-17c5d9f894e2"

You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

phone_number Too many digits Provide a valid recipient phone number.
phone_number Not enough digits Provide a valid recipient phone number.
phone_number Not a UK mobile number Provide a valid British recipient phone number.
phone_number Must not contain letters or symbols Provide a valid recipient phone number.
phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError (status code 400)
sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient using a team-only API key"
}]
Use the correct type of API key
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"
}]
Your service cannot send this notification in trial mode
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
429 [{
"error": "RateLimitError",
"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"
}]
Refer to API rate limits for more information
429 [{
"error": "TooManyRequestsError",
"message": "Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today"
}]
Refer to service limits for the limit size
500 [{
"error": "Exception",
"message": "Internal server error"
}]
Notify was unable to process the request, resend your notification

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

phone_number Too many digits Provide a valid recipient phone number.
phone_number Not enough digits Provide a valid recipient phone number.
phone_number Not a UK mobile number Provide a valid British recipient phone number.
phone_number Must not contain letters or symbols Provide a valid recipient phone number.
phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError (status code 400)
sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

phone_number Too many digits Provide a valid recipient phone number.
phone_number Not enough digits Provide a valid recipient phone number.
phone_number Not a UK mobile number Provide a valid British recipient phone number.
phone_number Must not contain letters or symbols Provide a valid recipient phone number.
phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError (status code 400)
sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

phone_number Too many digits Provide a valid recipient phone number.
phone_number Not enough digits Provide a valid recipient phone number.
phone_number Not a UK mobile number Provide a valid British recipient phone number.
phone_number Must not contain letters or symbols Provide a valid recipient phone number.
phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError (status code 400)
sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: phone_number Too many digits Provide a valid recipient phone number.
ValidationError: phone_number Not enough digits Provide a valid recipient phone number.
ValidationError: phone_number Not a UK mobile number Provide a valid British recipient phone number.
ValidationError: phone_number Must not contain letters or symbols Provide a valid recipient phone number.
ValidationError: phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError: sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
BadRequestError: Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
BadRequestError: Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Response

If the request is successful, the response body is json with a status code of 201:

{
  "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  // required string - notification ID
  "reference": "your reference", // optional string - reference you provided when sending the message
  "content": {
    "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00PM",  // required string - message content
    "from_number": "GOVUK"  // required string - sender name / phone number
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/740e5834-3a29-46b4-9a6f-16142fde533a",  // required string
  "template": {
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
    "version": 3,  // required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/f33517ff-2a88-4f6e-b855-c550268ce08a"  // required string
  }
}

If you are using the test API key, all your messages will come back with a delivered status.

All messages sent using the team and guest list or live keys will appear on your dashboard.

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

phone_number Too many digits Provide a valid recipient phone number.
phone_number Not enough digits Provide a valid recipient phone number.
phone_number Not a UK mobile number Provide a valid British recipient phone number.
phone_number Must not contain letters or symbols Provide a valid recipient phone number.
phone_number Not a valid country prefix Provide a valid recipient phone number.
BadRequestError (status code 400)
sms_sender_id <sms_sender_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid sms_sender_id. Check that the API key you are using and the sms_sender_id belong to the same service.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this text message in trial mode. To fix, you need to request for your service to go live.
Cannot send to international mobile numbers Sending to international mobile numbers is turned off for your service. You can change this in your service Settings.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a text message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors.

Send an email

Send an email

Send an email

Send an email

Send an email

Send an email

Send an email

Method

SendEmailResponse response = client.sendEmail(
    templateId,
    emailAddress,
    personalisation,
    reference,
    emailReplyToId
);

Method

EmailNotificationResponse response = client.SendEmail(emailAddress, templateId, personalisation, reference, emailReplyToId);
client.SendEmail(
    emailAddress: "sender@something.com",
    templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a"
);

Method

let options = {
    personalisation: {
        first_name: "Amala",
        appointment_date: "1 January 2018 at 1:00pm",
        required_documents: ["passport", "utility bill", "other id"]
    },
    reference: "your reference",
    oneClickUnsubscribeURL: "https://example.com/unsubscribe.html?opaque=123456789",
    emailReplyToId: "ca4fdde7-2a67-4a6c-8393-62aa7245751f"
};

notifyClient
  .sendEmail(templateId, emailAddress, options) // Pass options as the third argument (optional)
  .then(response => console.log(response))
  .catch(err => console.error(err));

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

sendEmail( $emailAddress, $templateId, array $personalisation = array(), $reference = '', $emailReplyToId = NULL, $oneClickUnsubscribeURL = NULL )

For example:

try {

    $response = $notifyClient->sendEmail(
        'betty@example.com',
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c', [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968'
        ],
        'unique_ref123',
        '862bfaaf-9f89-43dd-aafa-2868ce2926a9',
        );

} catch (ApiException $e){}

Method

response = notifications_client.send_email_notification(
    email_address="amala@example.com",
    template_id="9d751e0e-f929-4891-82a1-a3e1c3c18ee3",
)

Method

emailresponse = client.send_email(
  email_address: "sender@something.com",
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
)

Method

POST /v2/notifications/email

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

Request body

{
  "email_address": "amala@example.com",
  "template_id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3"
}
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

String templateId="f33517ff-2a88-4f6e-b855-c550268ce08a";
emailAddress (required)

The email address of the recipient. For example:

string emailAddress: "sender@something.com";
emailAddress (required)

The email address of the recipient. For example:

let emailAddress = "amala@example.com";
emailAddress (required)

The email address of the recipient.

email_address (required)

The email address of the recipient.

For example:

email_address="amala@example.com", # required string
email_address (required)

The email address of the recipient. For example:

email_address: "sender@something.com"
emailAddress (required)

The email address of the recipient.

String emailAddress='sender@something.com';
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

let templateId = "9d751e0e-f929-4891-82a1-a3e1c3c18ee3";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id="9d751e0e-f929-4891-82a1-a3e1c3c18ee3", # required UUID string
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
personalisation (required)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in a map. For example:

Map<String, Object> personalisation = new HashMap<>();
personalisation.put("first_name", "Amala");
personalisation.put("application_date", "2018-01-01");
// pass in a list and it will appear as bullet points in the message:
personalisation.put("list", listOfItems);

If a template does not have any placeholder fields for personalised information, you must pass in an empty map or null.

Find out how to reduce the risk of malicious content injection in placeholders.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a Dictionary. For example:

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"},
    // pass in a list and it will appear as bullet points in the message:
    {"required_documents", new List<string> {"passport", "utility bill", "other id"}}
};

You can leave out this argument if a template does not have any placeholder fields for personalised information.

Find out how to reduce the risk of malicious content injection in placeholders.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in an object. For example:

let options = {
    personalisation: {
        first_name: "Amala",
        appointment_date: "1 January 2018 at 1:00pm",
        required_documents: ["passport", "utility bill", "other id"]
    },
};

Note: if you pass a list like required_documents in the example above, it will appear as bullet points in your message.

Find out how to reduce the risk of malicious content injection in placeholders.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

$personalisation = [
    'name' => 'Amala',
    'application_date'  => '2018-01-01',
    # pass in an array and it will appear as bullet points in the message:
    'required_documents' => ['passport', 'utility bill', 'other id']
];

You can leave out this argument if a template does not have any placeholder fields for personalised information.

Find out how to reduce the risk of malicious content injection in placeholders.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

personalisation={
    "first_name": "Amala",
    "appointment_date": "1 January 2018 at 1:00pm",
    # pass in a list and it will appear as bullet points in the message:
    "required_documents": ["passport", "utility bill", "other id"],
},

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in a hash. For example:

personalisation: {
  name: "John Smith",
  year: "2016",
  # pass in an array and it will appear as bullet points in the message:
  required_documents: ["passport", "utility bill", "other id"],
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

Find out how to reduce the risk of malicious content injection in placeholders.

reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. If you do not have a reference, you must pass in an empty string or null.

String reference='STRING';
reference (optional)

A unique identifier you can create if you need to. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

string reference: "my reference";

You can leave out this argument if you do not have a reference.

reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique email or a batch of emails. It must not contain any personal information such as name or postal address. For example:

let options = {
    reference: "your-reference"
};
reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

$reference = 'STRING';

You can leave out this argument if you do not have a reference.

reference (optional)

An identifier you can create if necessary. This reference identifies a single unique email or a batch of emails. It must not contain any personal information such as name or postal address. For example:

reference="your reference", # optional string - identifies notification(s)

You can leave out this argument if you do not have a reference.

reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

reference: "your_reference_string"

You can leave out this argument if you do not have a reference.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

URI oneClickUnsubscribeURL = 'https://example.com/unsubscribe.html?opaque=123456789'

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

string oneClickUnsubscribeURL : "https://example.com/unsubscribe.html?opaque=123456789";

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

let options = {
    oneClickUnsubscribeURL: "https://example.com/unsubscribe.html?opaque=123456789"
};

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You should also add an unsubscribe link to the bottom of your email. Find out how to add an unsubscribe link when you create a New template or Edit an email template.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

If you send subscription emails you must let recipients opt out of receiving themThe one-click. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

$one_click_unsubscribe_url = 'https://example.com/unsubscribe.html?opaque=123456789'

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

one_click_unsubscribe_url = "https://example.com/unsubscribe.html?opaque=123456789", # optional string, a URL

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email clients will use it to add an unsubscribe button.

one_click_unsubscribe_url: "https://example.com/unsubscribe.html?opaque=123456789"

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

emailReplyToId (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.
String emailReplyToId='8e222534-7f05-4972-86e3-17c5d9f894e2'

You can leave out this argument if your service only has one reply-to email address, or you want to use the default email address.

emailReplyToId (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.

For example:

string emailReplyToId: "8e222534-7f05-4972-86e3-17c5d9f894e2";

You can leave out this argument if your service only has one email reply-to address, or you want to use the default email address.

emailReplyToId (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.
let options = {
    emailReplyToId:"ca4fdde7-2a67-4a6c-8393-62aa7245751f"
};

You can leave out this argument if your service only has one reply-to email address, or you want to use the default email address.

emailReplyToId (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.

For example:

$emailReplyToId='8e222534-7f05-4972-86e3-17c5d9f894e2'

You can leave out this argument if your service only has one email reply-to address, or you want to use the default email address.

email_reply_to_id (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.

For example:

email_reply_to_id="ca4fdde7-2a67-4a6c-8393-62aa7245751f", # optional UUID string

You can leave out this argument if your service only has one reply-to email address, or you want to use the default email address.

email_reply_to_id (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.

For example:

email_reply_to_id: "8e222534-7f05-4972-86e3-17c5d9f894e2"

Response

If the request to the client is successful, the client returns a SendEmailResponse:

UUID notificationId;
Optional<String> reference;
Optional<URI> oneClickUnsubscribeURL;
UUID templateId;
int templateVersion;
String templateUri;
String body;
String subject;
Optional<String> fromEmail;

Response

If the request to the client is successful, the client returns an EmailNotificationResponse:

public String id;
public String reference;
public String oneClickUnsubscribeURL;
public String uri;
public Template template;
public EmailResponseContent content;

public class Template{
    public String id;
    public String uri;
    public Int32 version;
}
public class EmailResponseContent{
  public String fromEmail;
  public String body;
  public String subject;
}

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "201b576e-c09b-467b-9dfa-9c3b689ee730", // required string - notification ID
    "reference": "your reference", // optional string - reference you provided when sending the message
    "content": {
        "subject": "Your upcoming pigeon registration appointment",  // required string - message subject
        "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - message content
        "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk", // required string - "FROM" email address, not a real inbox
        "one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789" // optional string
    },
    "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730", // required string
    "template": {
        "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3", // required string - template ID
        "version": 1, // required integer
        "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3" // required string
    }
};

Response

If the request to the client is successful, the client returns an array:

[
    "id" => "bfb50d92-100d-4b8b-b559-14fa3b091cda",
    "reference" => None,
    "content" => [
        "subject" => "SUBJECT TEXT",
        "body" => "MESSAGE TEXT",
        "from_email" => "SENDER EMAIL
    ],
    "uri" => "https://api.notifications.service.gov.uk/v2/notifications/ceb50d92-100d-4b8b-b559-14fa3b091cd",
    "template" => [
        "id" => "ceb50d92-100d-4b8b-b559-14fa3b091cda",
        "version" => 1,
        "uri" => "https://api.notificaitons.service.gov.uk/service/your_service_id/templates/bfb50d92-100d-4b8b-b559-14fa3b091cda"
    ]
];

Response

If the request to the client is successful, the client returns a dict:

{
  "id": "201b576e-c09b-467b-9dfa-9c3b689ee730",  # required string - notification ID
  "reference": "your reference",  # optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  # required string - message subject
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - message content
    "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk",  # required string - "FROM" email address, not a real inbox
    "one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789",  # optional string
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730",  # required string
  "template": {
    "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3",  # required string - template ID
    "version": 1,  # required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3"  # required string
  }
}

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

You can leave out this argument if your service only has one email reply-to address, or you want to use the default email address.

Arguments

email_address (required)

The email address of the recipient.

For example:

"email_address": "amala@example.com" // required string
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

"template_id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3", // required UUID string
personalisation (optional)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

"personalisation": {
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  // pass in a list and it will appear as bullet points in the message:
  "required_documents": ["passport", "utility bill", "other id"],
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

Find out how to reduce the risk of malicious content injection in placeholders.

reference (optional)

An identifier you can create if necessary. This reference identifies a single unique email or a batch of emails. It must not contain any personal information such as name or postal address. For example:

"reference": "your reference"

You can leave out this argument if you do not have a reference.

If you send subscription emails you must let recipients opt out of receiving them. Read our Using Notify page for more information about unsubscribe links.

The one-click unsubscribe URL will be added to the headers of your email. Email s will use it to add an unsubscribe button.

"one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789" // optional string, a URL

The one-click unsubscribe URL must respond to an empty POST request by unsubscribing the user from your emails. You can include query parameters to help you identify the user.

Your unsubscribe URL and response must comply with the guidance specified in Section 3.1 of IETF RFC 8058.

You can leave out this argument if the email being sent is not a subscription email.

You must also add an unsubscribe link to the bottom of your email. The unsubscribe link at the bottom of your email should take the email recipient to a webpage where they can confirm that they want to unsubscribe.

Find out how to add a link when you create a New template or Edit an email template.

email_reply_to_id (optional)

This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.

To add a reply-to email address:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Reply-to email addresses row.
  4. Select Add reply-to address.
  5. Enter the email address you want to use, and select Add.

For example:

"email_reply_to_id": "8e222534-7f05-4972-86e3-17c5d9f894e2" // optional UUID string

You can leave out this argument if your service only has one reply-to email address, or you want to use the default email address.

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

email_address Not a valid email address Provide a valid recipient email address.
one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError (status code 400)
email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

email_address Not a valid email address Provide a valid recipient email address.
one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError (status code 400)
email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Response

If the request to the client is successful, the client returns a Notifications::Client:ResponseNotification object. In the example shown in the Method section, the object is named emailresponse.

You can then call different methods on this object to return the requested information.

Method Information Type
emailresponse.id Notification UUID String
emailresponse.reference reference argument String
emailresponse.content - body: Message body
- subject: Message subject
- from_email: From email address of your service found on the Settings page
Hash
emailresponse.template Contains the id, version and uri of the template Hash
emailresponse.uri Notification URL String

Response

If the request is successful, the response body is json with a status code of 201:

{
  "id": "201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string - notification ID
  "reference": "your reference",  // optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  // required string - message subject
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00PM.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - message content
    "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk",  // required string - "FROM" email address, not a real inbox
    "one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789",  // optional string
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string
  "template": {
    "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3",  // required string - template ID
    "version": 1,  // required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3"  // required string
  }
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

email_address Not a valid email address Provide a valid recipient email address.
one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError (status code 400)
email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient using a team-only API key"
}]
Use the correct type of API key
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"
}]
Your service cannot send this notification in trial mode
400 [{
"error": "BadRequestError",
"message": "File did not pass the virus scan"
}]
The file contains a virus
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information.
429 [{
"error": "RateLimitError",
"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"
}]
Refer to API rate limits for more information
429 [{
"error": "TooManyRequestsError",
"message": "Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today"
}]
Refer to daily limits for the limit size
500 [{
"error": "Exception",
"message": "Internal server error"
}]
Notify was unable to process the request, resend your notification.

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

email_address Not a valid email address Provide a valid recipient email address.
one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError (status code 400)
email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: email_address Not a valid email address Provide a valid recipient email address.
ValidationError: one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError: email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
BadRequestError: Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
BadRequestError: Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Reducing the risk of malicious content injection in placeholders

Notify lets you personalise messages using placeholders.

You can format content or add links and urls into placeholders using Markdown.

If you pass in information from untrusted sources (such as online forms) into your Notify template using personalisation, this may be used to add malicious content and links to notifications you send via Notify.

The malicious content could be:

  • Markdown syntax intended to be rendered into HTML
  • a plain text URL which would be rendered into a clickable phishing link

An example of how malicious content can be injected into Notify personalisation:

Template in Notify:

Hello ((name))

Personalisation:

{name: "Anne Example, now [click this evil link](https://malicious.link)"}

Email will appear as:

 Dear Anne Example, now click this evil link

We recommend you sanitise all input from untrusted sources to prevent the injection of malicious content. You can use a backslash to escape individual characters. The characters of most concern are those that could be used to add a URL link such as [, ], ( or ).

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

email_address Not a valid email address Provide a valid recipient email address.
one_click_unsubscribe_url is not a valid https url Provide a valid https url for your unsubscribe link.
BadRequestError (status code 400)
email_reply_to_id <reply to id> does not exist in database for service id <service id> Go to your service Settings and copy a valid email_reply_to_id. Double check that the API key you are using and the email_reply_to_id belong to the same service.
Emails cannot be longer than 2000000 bytes. Your message is <rendered template size in bytes> bytes. Shorten your email message.
Cannot send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this email in trial mode. To fix, you need to request for your service to go live.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors about a file you try to send via email. You can find a list of these errors at the end of Send a file by email
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Send a file by email

To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.

The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.

Your file will be available to download for a default period of 26 weeks (6 months).

To help protect your files you can also:

  • ask recipients to confirm their email address before downloading
  • choose the length of time that a file is available to download

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add contact details to the file download page

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Email section, select Manage on the Send files by email row.
  4. Enter the contact details you want to use, and select Save.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Add a placeholder to the template

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant email template.
  3. Select Edit.
  4. Add a placeholder to the email template using double brackets. For example: “Download your file at: ((link_to_file))”

Your email should also tell recipients how long the file will be available to download.

Upload your file

You can upload the following files types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

  1. Convert the PDF to a byte[].
  2. Pass the byte[] to the personalisation argument.
  3. Call the sendEmail method.

For example:

ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("document_to_upload.pdf").getFile());
byte [] fileContents = FileUtils.readFileToByteArray(file);

HashMap<String, Object> personalisation = new HashMap();
personalisation.put("link_to_file", client.prepareUpload(fileContents));
client.sendEmail(templateId,
                 emailAddress,
                 personalisation,
                 reference,
                 emailReplyToId);

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

  1. Convert the PDF to a byte[].
  2. Pass the byte[] to the personalisation argument.
  3. Call the sendEmail method.

For example:


byte[] documentContents = File.ReadAllBytes("<file path>");

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"},
    { "link_to_file", NotificationClient.PrepareUpload(
        documentContents: documentContents)
    }
};

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

Pass the file object as a value into the personalisation argument. For example:

let fs = require("fs")

fs.readFile("path/to/document.pdf", function (err, pdfFile) {
  console.log(err)
  notifyClient.sendEmail(templateId, emailAddress, {
    personalisation: {
      first_name: "Amala",
      appointment_date: "1 January 2018 at 1:00pm",
      link_to_file: notifyClient.prepareUpload(pdfFile)
    }
  }).then(response => console.log(response)).catch(err => console.error(err))
})

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB.. Contact the GOV.UK Notify team if you need to send other file types.

Pass the file object as a value into the personalisation argument. For example:

try {
    $file_data = file_get_contents('/path/to/my/file.pdf');

    $response = $notifyClient->sendEmail(
        'betty@example.com',
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c',
        [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968',
            'link_to_file' => $notifyClient->prepareUpload( $file_data )
        ]
    );
}
catch (ApiException $e){}
catch (InvalidArgumentException $e){}

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

Pass the file object as a value into the personalisation argument. For example:

from notifications_python_client import prepare_upload

with open("file.pdf", "rb") as f:
    ...
    personalisation={
      "first_name": "Amala",
      "appointment_date": "1 January 2018 at 1:00pm",
      "link_to_file": prepare_upload(f),
    }

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

  1. Pass the file object as an argument to the Notifications.prepare_upload helper method.
  2. Pass the result into the personalisation argument.

For example:

File.open("file.pdf", "rb") do |f|
    ...
    personalisation: {
      first_name: "Amala",
      application_date: "2018-01-01",
      link_to_file: Notifications.prepare_upload(f),
    }
end

Upload your file

You can upload the following file types:

  • CSV (.csv)
  • image (.jpeg, .jpg, .png)
  • Microsoft Excel Spreadsheet (.xlsx)
  • Microsoft Word Document (.doc, .docx)
  • PDF (.pdf)
  • text (.json, .odt, .rtf, .txt)

Your file must be smaller than 2MB. Contact the GOV.UK Notify team if you need to send other file types.

You’ll need to convert the file into a string that is base64 encoded.

Pass the encoded string into an object with a file key, and put that in the personalisation argument. For example:

"personalisation":{
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  "link_to_file": {"file": "file as base64 encoded string"}
}

Set the filename

To do this you will need version 5.0.0-RELEASE of the Java client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("document_to_upload.pdf").getFile());
byte [] fileContents = FileUtils.readFileToByteArray(file);

HashMap<String, Object> personalisation = new HashMap();
personalisation.put("link_to_file", client.prepareUpload(fileContents, "report.csv"));
client.sendEmail(templateId,
                 emailAddress,
                 personalisation,
                 reference,
                 emailReplyToId);

Set the filename

To do this you will need version 7.0.0 of the .NET client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.


byte[] documentContents = File.ReadAllBytes("<file path>");

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"},
    { "link_to_file", NotificationClient.PrepareUpload(
        documentContents: documentContents, 
        filename: "2023-12-25-daily-report.csv")
    }
};

Set the filename

To do this you will need version 8.0.0 of the Node client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

let fs = require("fs")
fs.readFile("path/to/document.csv", function (err, csvFile) {
  console.log(err)
  notifyClient.sendEmail(templateId, emailAddress, {
    personalisation: {
      first_name: "Amala",
      appointment_date: "1 January 2018 at 1:00pm",
      link_to_file: notifyClient.prepareUpload(csvFile, { filename: "amala_pigeon_affairs_bureau_invite.csv" })
    }
  }).then(response => console.log(response)).catch(err => console.error(err))
})

Set the filename

To do this you will need version 6.0.0 of the PHP client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

try {
    $file_data = file_get_contents('/path/to/my/file.csv');

    $response = $notifyClient->sendEmail(
        'betty@example.com',
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c',
        [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968',
            'link_to_file' => $notifyClient->prepareUpload( $file_data, "report.csv" )
        ]
    );
}
catch (ApiException $e){}
catch (InvalidArgumentException $e){}

Set the filename

To do this you will need version 9.0.0 of the Python client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

from notifications_python_client import prepare_upload

with open("file.csv", "rb") as f:
    ...
    personalisation={
      "first_name": "Amala",
      "appointment_date": "1 January 2018 at 1:00pm",
      "link_to_file": prepare_upload(f, filename="amala_pigeon_affairs_bureau_invite.csv"),
    }

Set the filename

To do this you will need version 6.0.0 of the Ruby client library, or a more recent version.

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

File.open("file.csv", "rb") do |f|
    ...
    personalisation: {
      first_name: "Amala",
      application_date: "2018-01-01",
      link_to_file: Notifications.prepare_upload(f, filename: "2023-12-25-daily-report.csv"),
    }
end

Set the filename

You should provide a filename when you upload your file.

The filename should tell the recipient what the file contains. A memorable filename can help the recipient to find the file again later.

The filename must end with a file extension. For example, .csv for a CSV file. If you include the wrong file extension, recipients may not be able to open your file.

If you do not provide a filename for your file, Notify will:

  • generate a random filename
  • try to add the correct file extension

If Notify cannot add the correct file extension, recipients may not be able to open your file.

"personalisation":{
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  "link_to_file": {"file": "CSV file as base64 encoded string", "filename": "amala_pigeon_affairs_bureau_invite.csv"}
}

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

Ask recipients to confirm their email address before they can download the file

When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.

This security feature is turned on by default.

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 3.19.0-RELEASE of the Java client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirmEmailBeforeDownload flag to false.

ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("document_to_upload.pdf").getFile());
byte [] fileContents = FileUtils.readFileToByteArray(file);

HashMap<String, Object> personalisation = new HashMap();
personalisation.put("link_to_file", client.prepareUpload(fileContents, false, false, "52 weeks"));
client.sendEmail(templateId,
                 emailAddress,
                 personalisation,
                 reference,
                 emailReplyToId);

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 6.1.0 of the .NET client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirmEmailBeforeDownload flag to false.


byte[] documentContents = File.ReadAllBytes("<file path>");

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"},
    { "link_to_file", NotificationClient.PrepareUpload(
        documentContents: documentContents, 
        confirmEmailBeforeDownload: false)
    }
};

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 5.2.0 of the Node.js client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirmEmailBeforeDownload option to false.

let fs = require("fs")

fs.readFile("path/to/document.pdf", function (err, pdfFile) {
  console.log(err)
  notifyClient.sendEmail(templateId, emailAddress, {
    personalisation: {
      first_name: "Amala",
      appointment_date: "1 January 2018 at 1:00pm",
      link_to_file: notifyClient.prepareUpload(pdfFile, { confirmEmailBeforeDownload: false })
    }
  }).then(response => console.log(response)).catch(err => console.error(err))
})

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 4.2.0 of the PHP client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirm_email_before_download flag to false.

try {
    $file_data = file_get_contents('/path/to/my/file.pdf');

    $response = $notifyClient->sendEmail(
        'betty@example.com',
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c',
        [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968',
            'link_to_file' => $notifyClient->prepareUpload( $file_data, false, false )
        ]
    );
}
catch (ApiException $e){}
catch (InvalidArgumentException $e){}

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 6.4.0 of the Python client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirm_email_before_download flag to False.

from notifications_python_client import prepare_upload

with open("file.pdf", "rb") as f:
    ...
    personalisation={
      "first_name": "Amala",
      "appointment_date": "1 January 2018 at 1:00pm",
      "link_to_file": prepare_upload(f, confirm_email_before_download=False),
    }

If you do not want to use this feature, you can turn it off on a file-by-file basis.

To do this you will need version 5.4.0 of the Ruby client library, or a more recent version.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirm_email_before_download flag to false.

File.open("file.pdf", "rb") do |f|
    ...
    personalisation: {
      first_name: "Amala",
      application_date: "2018-01-01",
      link_to_file: Notifications.prepare_upload(f, confirm_email_before_download: false),
    }
end

If you do not want to use this feature, you can turn it off on a file-by-file basis.

You should not turn this feature off if you send files that contain:

  • personally identifiable information
  • commercially sensitive information
  • information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy

To let the recipient download the file without confirming their email address, set the confirm_email_before_download flag to false.

"personalisation":{
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  "link_to_file": {"file": "file as base64 encoded string", "confirm_email_before_download": false}
}

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retention_period parameter.

To use this feature you will need 3.19.0-RELEASE of the Java client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("document_to_upload.pdf").getFile());
byte [] fileContents = FileUtils.readFileToByteArray(file);

HashMap<String, Object> personalisation = new HashMap();
personalisation.put("link_to_file",
                    client.prepareUpload(
                            fileContents,
                            false,
                            false,
                            new RetentionPeriodDuration(52, ChronoUnit.WEEKS)
                    ));
client.sendEmail(templateId,
                 emailAddress,
                 personalisation,
                 reference,
                 emailReplyToId);

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retentionPeriod parameter.

To use this feature will need version 6.1.0 of the .NET client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).


byte[] documentContents = File.ReadAllBytes("<file path>");

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"},
    { "link_to_file", NotificationClient.PrepareUpload(
        documentContents: documentContents, 
        confirmEmailBeforeDownload: true, 
        retentionPeriod: "52 weeks")
    }
};

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retentionPeriod option.

To use this feature will need version 5.2.0 of the Node.js client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

let fs = require("fs")

fs.readFile("path/to/document.pdf", function (err, pdfFile) {
  console.log(err)
  notifyClient.sendEmail(templateId, emailAddress, {
    personalisation: {
      first_name: "Amala",
      appointment_date: "1 January 2018 at 1:00pm",
      link_to_file: notifyClient.prepareUpload(pdfFile, { retentionPeriod: "52 weeks" })
    }
  }).then(response => console.log(response)).catch(err => console.error(err))
})

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retentionPeriod key.

To use this feature will need version 4.2.0 of the PHP client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

try {
    $file_data = file_get_contents('/path/to/my/file.pdf');

    $response = $notifyClient->sendEmail(
        'betty@example.com',
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c',
        [
            'name' => 'Betty Smith',
            'dob'  => '12 July 1968',
            'link_to_file' => $notifyClient->prepareUpload( $file_data, false, null, "52 weeks" )
        ]
    );
}
catch (ApiException $e){}
catch (InvalidArgumentException $e){}

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retention_period key.

To use this feature will need version 6.4.0 of the Python client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

from notifications_python_client import prepare_upload

with open("file.pdf", "rb") as f:
    ...
    personalisation={
      "first_name": "Amala",
      "appointment_date": "1 January 2018 at 1:00pm",
      "link_to_file": prepare_upload(f, retention_period="4 weeks"),
    }

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retention_period key.

To use this feature will need version 5.4.0 of the Ruby client library, or a more recent version.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

File.open("file.pdf", "rb") do |f|
    ...
    personalisation: {
      first_name: "Amala",
      application_date: "2018-01-01",
      link_to_file: Notifications.prepare_upload(f, retention_period: "52 weeks"),
    }
end

Choose the length of time that a file is available to download

Set the number of weeks you want the file to be available using the retention_period key.

You can choose any value between 1 week and 78 weeks. When deciding this, you should consider:

  • the need to protect the recipient’s personal information
  • whether the recipient will need to download the file again later

If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).

Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).

"personalisation":{
  "first_name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  "link_to_file": {"file": "file as base64 encoded string", "retention_period": "4 weeks"}
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
filename cannot be longer than 100 characters Choose a shorter filename
filename must end with a file extension. For example, filename.csv Include the file extension in your filename
Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
File did not pass the virus scan The file contains a virus
Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
Can only send a file by email Make sure you are using an email template
Client error (no status code)
ValueError('File is larger than 2MB') The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Response

public String id;
public String reference;
public String oneClickUnsubscribeURL;
public String uri;
public Template template;
public EmailResponseContent content;

public class Template{
    public String id;
    public String uri;
    public Int32 version;
}
public class EmailResponseContent{
  public String fromEmail;
  public String body;
  public String subject;
}

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
  "id": "201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string - notification ID
  "reference": "your reference",  // optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  // required string - message subject
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\n Here is a link to your invitation document:\r\nhttps://documents.service.gov.uk/d/YlxDzgNUQYi1Qg6QxIpptA/th46VnrvRxyVO9div6f7hA?key=R0VDmwJ1YzNYFJysAIjQd9yHn5qKUFg-nXHVe3Ioa3A\r\n\r\nPlease bring the invite with you to the appointment.\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - message content - see that the link to document is embedded in the message content
    "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk",  // required string - "FROM" email address, not a real inbox
    "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789",  // optional string
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string
  "template": {
    "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3",  // required string - template ID
    "version": 1,  // required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3"  // required string
  }
}

Response

If the request to the client is successful, the client returns an array:

[
    "id" => "bfb50d92-100d-4b8b-b559-14fa3b091cda",
    "reference" => None,
    "content" => [
        "subject" => "SUBJECT TEXT",
        "body" => "MESSAGE TEXT",
        "from_email" => "SENDER EMAIL
    ],
    "uri" => "https://api.notifications.service.gov.uk/v2/notifications/ceb50d92-100d-4b8b-b559-14fa3b091cd",
    "template" => [
        "id" => "ceb50d92-100d-4b8b-b559-14fa3b091cda",
        "version" => 1,
        "uri" => "https://api.notificaitons.service.gov.uk/service/your_service_id/templates/bfb50d92-100d-4b8b-b559-14fa3b091cda"
    ]
];

Response

If the request to the client is successful, the client returns a dict:

{
  "id": "201b576e-c09b-467b-9dfa-9c3b689ee730",  # required string - notification ID
  "reference": "your reference",  # optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  # required string - message subject
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\n Here is a link to your invitation document:\r\nhttps://documents.service.gov.uk/d/YlxDzgNUQYi1Qg6QxIpptA/th46VnrvRxyVO9div6f7hA?key=R0VDmwJ1YzNYFJysAIjQd9yHn5qKUFg-nXHVe3Ioa3A\r\n\r\nPlease bring the invite with you to the appointment.\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - message content - see that the link to document is embedded in the message content
    "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk",  # required string - "FROM" email address, not a real inbox
    "one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789",  # optional string
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730",  # required string
  "template": {
    "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3",  # required string - template ID
    "version": 1,  # required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3"  # required string
  }
}

Response

If the request to the client is successful, the client returns a Notifications::Client:ResponseNotification object. In the example shown in the Method section, the object is named emailresponse.

You can then call different methods on this object to return the requested information.

Method Information Type
emailresponse.id Notification UUID String
emailresponse.reference reference argument String
emailresponse.content - body: Message body
- subject: Message subject
- from_email: From email address of your service found on the Settings page
Hash
emailresponse.template Contains the id, version and uri of the template Hash
emailresponse.uri Notification URL String

Response

If the request is successful, the response body is json with a status code of 201:

{
  "id": "201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string - notification ID
  "reference": "your reference",  // optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  // required string - message subject
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00PM.\r\n\r\n Here is a link to your invitation document:\r\nhttps://documents.service.gov.uk/d/YlxDzgNUQYi1Qg6QxIpptA/th46VnrvRxyVO9div6f7hA?key=R0VDmwJ1YzNYFJysAIjQd9yHn5qKUFg-nXHVe3Ioa3A\r\n\r\nPlease bring the invite with you to the appointment.\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - message content - see that the link to document is embedded in the message content
    "from_email": "pigeon.affairs.bureau@notifications.service.gov.uk",  // required string - "FROM" email address, not a real inbox
    "one_click_unsubscribe_url": "https://example.com/unsubscribe.html?opaque=123456789",  // optional string
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/201b576e-c09b-467b-9dfa-9c3b689ee730",  // required string
  "template": {
    "id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3",  // required string - template ID
    "version": 1,  // required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/9d751e0e-f929-4891-82a1-a3e1c3c18ee3"  // required string
  }
}

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient using a team-only API key"
}]
Use the correct type of API key
400 [{
"error": "BadRequestError",
"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"
}]
Your service cannot send this notification in trial mode
400 [{
"error": "BadRequestError",
"message": "Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'"
}]
Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
400 [{
"error": "BadRequestError",
"message": "`filename` cannot be longer than 100 characters"
}]
Choose a shorter filename
400 [{
"error": "BadRequestError",
"message": "`filename` must end with a file extension. For example, filename.csv"
}]
Include the file extension in your filename
400 [{
"error": "BadRequestError",
"message": "Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks."
}]
Choose a period between 1 and 78 weeks
400 [{
"error": "BadRequestError",
"message": "Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value."
}]
Use either true or false
400 [{
"error": "BadRequestError",
"message": "File did not pass the virus scan"
}]
The file contains a virus
400 [{
"error": "BadRequestError",
"message": "Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email"
}]
See how to add contact details to the file download page
400 [{
"error": "BadRequestError",
"message": "Can only send a file by email"
}]
Make sure you are using an email template
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information.
429 [{
"error": "RateLimitError",
"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"
}]
Refer to API rate limits for more information
429 [{
"error": "TooManyRequestsError",
"message": "Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today"
}]
Refer to service limits for the limit size
500 [{
"error": "Exception",
"message": "Internal server error"
}]
Notify was unable to process the request, resend your notification.
N/A File is larger than 2MB The file is too big. Files must be smaller than 2MB

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
filename cannot be longer than 100 characters Choose a shorter filename
filename must end with a file extension. For example, filename.csv Include the file extension in your filename
Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
File did not pass the virus scan The file contains a virus
Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
Can only send a file by email Make sure you are using an email template
Client error (no status code)
ValueError('File is larger than 2MB') The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
filename cannot be longer than 100 characters Choose a shorter filename
filename must end with a file extension. For example, filename.csv Include the file extension in your filename
Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
File did not pass the virus scan The file contains a virus
Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
Can only send a file by email Make sure you are using an email template
Client error (no status code)
ValueError('File is larger than 2MB') The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
filename cannot be longer than 100 characters Choose a shorter filename
filename must end with a file extension. For example, filename.csv Include the file extension in your filename
Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
File did not pass the virus scan The file contains a virus
Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
Can only send a file by email Make sure you are using an email template
Client error (no status code)
ValueError('File is larger than 2MB') The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

BadRequestError: Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
BadRequestError: filename cannot be longer than 100 characters Choose a shorter filename
BadRequestError: filename must end with a file extension. For example, filename.csv Include the file extension in your filename
BadRequestError: Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
BadRequestError: Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
BadRequestError: File did not pass the virus scan The file contains a virus
BadRequestError: Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
BadRequestError: Can only send a file by email Make sure you are using an email template
ArgumentError (no status code)
File is larger than 2MB The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)' Wrong file type. You can only upload .csv, .doc, .docx, .jpeg, .jpg, .odt, .pdf, .png, .rtf, .txt or .xlsx files
filename cannot be longer than 100 characters Choose a shorter filename
filename must end with a file extension. For example, filename.csv Include the file extension in your filename
Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks. Choose a period between 1 and 78 weeks
Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value. Use either True or False
File did not pass the virus scan The file contains a virus
Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email See how to add contact details to the file download page
Can only send a file by email Make sure you are using an email template
Client error (no status code)
ValueError('File is larger than 2MB') The file is too big. Files must be smaller than 2MB.

In addition to the above, you may also encounter:

  • other errors related to sending an email.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Send a letter

When you add a new service it will start in trial mode. You can only send letters when your service is live.

To send Notify a request to go live:

  1. Sign in to GOV.UK Notify.
  2. Go to the Settings page.
  3. In the Your service is in trial mode section, select request to go live.

Method

SendLetterResponse response = client.sendLetter(
    templateId,
    personalisation,
    reference
);

Method

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a"
Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    { "address_line_1", "The Occupier" }, // required
    { "address_line_2", "123 High Street" }, // required
    { "address_line_3", "SW14 6BF" }, // required
      ... // any other optional address lines, or personalisation fields found in your template
};
string reference = "my reference"

LetterNotificationResponse response = client.SendLetter(templateId, personalisation, reference);

Method

notifyClient
  .sendLetter(templateId, {
    personalisation: personalisation,
    reference: reference
  })
  .then(response => console.log(response))
  .catch(err => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

sendLetter( $templateId, array $personalisation = array(), $reference = '' )

For example:

try {

    $response = $notifyClient->sendEmail(
        'df10a23e-2c0d-4ea5-87fb-82e520cbf93c',
        [
            'name'=>'Fred',
            'address_line_1' => 'Foo',
            'address_line_2' => 'Bar',
            'address_line_3' => 'SW1 1AA'
        ],
        'unique_ref123'
    );

} catch (ApiException $e){}

Method

    response = notifications_client.send_letter_notification(
        template_id="64415853-cb86-4cc4-b597-2aaa94ef8c39",
        personalisation={
          "address_line_1": "Amala Bird"
          "address_line_2": "123 High Street"
          "address_line_3": "SW14 6BH"
        },
    )

Method

letterresponse = client.send_letter(
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
  personalisation: {
    address_line_1: "The Occupier",
    address_line_2: "123 High Street",
    address_line_3: "SW14 6BH",
  },
)

Method

POST /v2/notifications/letter

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

Request body

{
  "template_id": "64415853-cb86-4cc4-b597-2aaa94ef8c39",
  "personalisation": {
    "address_line_1": "Amala Bird",
    "address_line_2": "123 High Street",
    "address_line_3": "SW14 6BH"
  }
}
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

String templateId = "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

let templateId = "64415853-cb86-4cc4-b597-2aaa94ef8c39";
templateId (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id="64415853-cb86-4cc4-b597-2aaa94ef8c39", # required UUID string
template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You must provide their values in a map. For example:

Map<String, Object> personalisation = new HashMap<>();
personalisation.put("address_line_1", "The Occupier"); // mandatory address field
personalisation.put("address_line_2", "Flat 2"); // mandatory address field
personalisation.put("address_line_3", "SW14 6BH"); // mandatory address field, must be a real UK postcode
personalisation.put("first_name", "Amala"); // field from template
personalisation.put("application_date", "2018-01-01"); // field from template
// pass in a list and it will appear as bullet points in the letter:
personalisation.put("list", listOfItems);

If a template does not have any placeholder fields for personalised information, you must pass in an empty map or null.

personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You need to provide their values in a Dictionary. For example:

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"address_line_1", "The Occupier"},
    {"address_line_2", "123 High Street"},
    {"address_line_3", "Richmond upon Thames"},
    {"address_line_4", "Middlesex"},
    {"address_line_5", "SW14 6BF"},
    {"first_name", "Amala"},
    {"application_id", "4134325"},
    // pass in a list and it will appear as bullet points in the letter:
    {"required_documents", new List<string> {"passport", "utility bill", "other id"}}
};
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You must provide their values in an object. For example:

{
  personalisation: {
    "address_line_1": "Amala Bird", // required string
    "address_line_2": "123 High Street", // required string
    "address_line_3": "Richmond upon Thames", // required string
    "address_line_4": "Middlesex",
    "address_line_5": "SW14 6BF",  // last line of address you include must be a postcode or a country name  outside the UK
    "name": "Amala",
    "appointment_date": "1 January 2018 at 1:00pm",
    // pass in an array and it will appear as bullet points in the letter:
    "required_documents": ["passport", "utility bill", "other id"]
  }
}
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You need to provide their values in a dictionary with key value pairs. For example:

$personalisation =
          [
            'address_line_1' => 'The Occupier',
            'address_line_2' => '123 High Street',
            'address_line_3' => 'Richmond upon Thames',
            'address_line_4' => 'Middlesex',
            'address_line_5' => 'SW14 6BF',
            'name' => 'John Smith',
            'application_id' => '4134325',
            # pass in an array and it will appear as bullet points in the letter:
            'required_documents' => ['passport', 'utility bill', 'other id']
          ];
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You need to provide their values in a dictionary with key value pairs. For example:

personalisation={
  "address_line_1": "Amala Bird",  # required string
  "address_line_2": "123 High Street",  # required string
  "address_line_3": "Richmond upon Thames",  # required string
  "address_line_4": "Middlesex",
  "address_line_5": "SW14 6BF",  # last line of address you include must be a postcode or a country name  outside the UK
  "name": "Amala",
  "appointment_date": "1 January 2018 at 1:00pm",
  # pass in a list and it will appear as bullet points in the letter:
  "required_documents": ["passport", "utility bill", "other id"],
}
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You must provide their values in a hash. For example:

personalisation: {
  address_line_1: "The Occupier",  # mandatory address field
  address_line_2: "123 High Street", # mandatory address field
  address_line_3: "SW14 6BH",  # mandatory address field
  name: "John Smith", # field from template
  application_date: "2018-01-01" # field from template,
  # pass in an array and it will appear as bullet points in the letter:
  required_documents: ["passport", "utility bill", "other id"],
},
reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. If you do not have a reference, you must pass in an empty string or null.

String reference='STRING';
reference (optional)

A unique identifier you can create if you need to. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

string reference: "my reference";

You can leave out this argument if you do not have a reference.

reference (optional)

A unique identifier you can create if required. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

let reference = "your_reference_here";
reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

$reference = 'STRING';
reference (optional)

An identifier you can create if necessary. This reference identifies a single unique letter or a batch of letters. It must not contain any personal information such as name or postal address. For example:

reference="your reference" # optional string - identifies notification(s)
reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

reference: "your_reference_string"

Response

If the request to the client is successful, the client returns a SendLetterResponse:

UUID notificationId;
Optional<String> reference;
UUID templateId;
int templateVersion;
String templateUri;
String body;
String subject;

Response

If the request to the client is successful, the client returns a LetterNotificationResponse:

public String id;
public String reference;
public String uri;
public Template template;
public string postage;
public LetterResponseContent content;

public class Template
{
    public String id;
    public String uri;
    public Int32 version;
}
public class LetterResponseContent{
    public string body;
    public string subject;
}

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "3d1ce039-5476-414c-99b2-fac1e6add62c",  // required string - notification ID
    "reference": "your reference",  // optional string - reference you provided when sending the message
    "content": {
        "subject": "Your upcoming pigeon registration appointment",  // required string - letter heading
        "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - letter content
    },
    "uri": "https://api.notifications.service.gov.uk/v2/notifications/3d1ce039-5476-414c-99b2-fac1e6add62c",  // required string
    "template": {
        "id": "64415853-cb86-4cc4-b597-2aaa94ef8c39",  // required string - template ID
        "version": 3,  // required integer
        "uri": "https://api.notifications.service.gov.uk/v2/template/64415853-cb86-4cc4-b597-2aaa94ef8c39"  // required string
    }
}

Response

If the request to the client is successful, the client returns an array:

[
    "id" => "bfb50d92-100d-4b8b-b559-14fa3b091cda",
    "reference" => "unique_ref123",
    "content" => [
        "subject" => "Licence renewal",
        "body" => "Dear Bill, your licence is due for renewal on 3 January 2016.",
    ],
    "uri" => "https://api.notifications.service.gov.uk/v2/notifications/ceb50d92-100d-4b8b-b559-14fa3b091cd",
    "template" => [
        "id" => "ceb50d92-100d-4b8b-b559-14fa3b091cda",
        "version" => 1,
        "uri" => "https://api.notifications.service.gov.uk/service/your_service_id/templates/bfb50d92-100d-4b8b-b559-14fa3b091cda"
    ],
    "scheduled_for" => null
];

Response

If the request to the client is successful, the client returns a dict:

{
  "id": "3d1ce039-5476-414c-99b2-fac1e6add62c",  # required string - notification ID
  "reference": "your reference",  # optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  # required string - letter heading
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - letter content
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/3d1ce039-5476-414c-99b2-fac1e6add62c",  # required string
  "template": {
    "id": "64415853-cb86-4cc4-b597-2aaa94ef8c39",  # required string - template ID
    "version": 3,  # required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/64415853-cb86-4cc4-b597-2aaa94ef8c39"  # required string
  },
  "scheduled_for": None
}

Response

If the request to the client is successful, the client returns a Notifications::Client:ResponseNotification object. In the example shown in the Method section, the object is named letterresponse.

You can then call different methods on this object to return the requested information.

Method Information Type
letterresponse.id Notification UUID String
letterresponse.reference reference argument String
letterresponse.content - body: Letter body
- subject: Letter subject or main heading
Hash
letterresponse.template Contains the id, version and uri of the template Hash
letterresponse.uri Notification URL String

Arguments

template_id (required)

To find the template ID:

  1. Sign in to GOV.UK Notify.
  2. Go to the Templates page and select the relevant template.
  3. Select Copy template ID to clipboard.

For example:

"template_id": "9d751e0e-f929-4891-82a1-a3e1c3c18ee3", // required UUID string
personalisation (required)

The personalisation argument always contains the following parameters for the letter recipient’s address:

  • address_line_1
  • address_line_2
  • address_line_3
  • address_line_4
  • address_line_5
  • address_line_6
  • address_line_7

The address must have at least 3 lines.

The last line needs to be a real UK postcode or the name of a country outside the UK.

Notify checks for international addresses and will automatically charge you the correct postage.

The postcode personalisation argument has been replaced. If your template still uses postcode, Notify will treat it as the last line of the address.

Any other placeholder fields included in the letter template also count as required parameters. You need to provide their values in a dictionary with key value pairs. For example:

"personalisation": {
  "address_line_1": "Amala Bird",  // required string
  "address_line_2": "123 High Street",  // required string
  "address_line_3": "Richmond upon Thames",  // required string
  "address_line_4": "Middlesex",
  "address_line_5": "SW14 6BF",  // last line of address you include must be a postcode or a country name  outside the UK
  "name": "Amala",
  "appointment_date": "1 January 2018 at 1:00PM",
  // pass in a list and it will appear as bullet points in the letter:
  "required_documents": ["passport", "utility bill", "other id"]
}
reference (optional)

An identifier you can create if necessary. This reference identifies a single unique letter or a batch of letters. It must not contain any personal information such as name or postal address. For example:

"reference": "your reference" // optional string - identifies notification(s)

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
Address must be at least 3 lines Provide at least 3 lines of address.
Address must be no more than 7 lines Provide no more than 7 lines of address.
Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError (status code 400)
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
403 [{
"error": "BadRequestError",
"message": "Cannot send letters with a team api key"
}]
Use the correct type of API key.
400 [{
"error": "BadRequestError",
"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"
}]
Your service cannot send this notification in trial mode.
400 [{
"error": "ValidationError",
"message": "personalisation address_line_1 is a required property"
}]
Ensure that your template has a field for the first line of the address, refer to personalisation for more information.
400 [{
"error": "ValidationError",
"message": "Must be a real UK postcode"
}]
Ensure that the value for the last line of the address is a real UK postcode.
400 [{
"error": "ValidationError",
"message": "Last line of address must be a real UK postcode or another country"
}]
Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock.
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information.
429 [{
"error": "RateLimitError",
"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"
}]
Refer to API rate limits for more information.
429 [{
"error": "TooManyRequestsError",
"message": "Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today"
}]
Refer to service limits for the limit size.
500 [{
"error": "Exception",
"message": "Internal server error"
}]
Notify was unable to process the request, resend your notification.

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
Address must be at least 3 lines Provide at least 3 lines of address.
Address must be no more than 7 lines Provide no more than 7 lines of address.
Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError (status code 400)
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
Address must be at least 3 lines Provide at least 3 lines of address.
Address must be no more than 7 lines Provide no more than 7 lines of address.
Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError (status code 400)
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
Address must be at least 3 lines Provide at least 3 lines of address.
Address must be no more than 7 lines Provide no more than 7 lines of address.
Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError (status code 400)
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
ValidationError: Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
ValidationError: Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
ValidationError: Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
ValidationError: The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
ValidationError: Address must be at least 3 lines Provide at least 3 lines of address.
ValidationError: Address must be no more than 7 lines Provide no more than 7 lines of address.
ValidationError: Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
ValidationError: postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
BadRequestError: Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
BadRequestError: letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
AuthError (status code 403)
BadRequestError: Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Response

If the request is successful, the response body is json and the status code is 201:

{
  "id": "3d1ce039-5476-414c-99b2-fac1e6add62c",  // required string - notification ID
  "reference": "your reference",  // optional string - reference you provided when sending the message
  "content": {
    "subject": "Your upcoming pigeon registration appointment",  // required string - letter heading
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00PM.\r\n\r\nPlease bring:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - letter content
  },
  "uri": "https://api.notifications.service.gov.uk/v2/notifications/3d1ce039-5476-414c-99b2-fac1e6add62c",  // required string
  "template": {
    "id": "64415853-cb86-4cc4-b597-2aaa94ef8c39",  // required string - template ID
    "version": 3,  // required integer
    "uri": "https://api.notifications.service.gov.uk/v2/template/64415853-cb86-4cc4-b597-2aaa94ef8c39"  // required string
  },
  "scheduled_for": null
}

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

personalisation address_line_1 is a required property Ensure that your template has a field for the first line of the address, check personalisation for more information.
Must be a real UK postcode Ensure that the value for the last line of the address is a real UK postcode.
Must be a real address Provide a real recipient address. We do not accept letters for “no fixed abode” addresses, as those cannot be delivered.
Last line of address must be a real UK postcode or another country Ensure that the value for the last line of the address is a real UK postcode or the name of a country outside the UK.
The last line of a BFPO address must not be a country. The last line of a BFPO address must not be a country.
Address must be at least 3 lines Provide at least 3 lines of address.
Address must be no more than 7 lines Provide no more than 7 lines of address.
Address lines must not start with any of the following characters: @ ( ) = [ ] ” \ / , < > Change the start of an address line, so it doesn’t start with one of these characters. This is a requirement from our printing provider.
postage invalid. It must be either first, second or economy. Specify valid postage option.
BadRequestError (status code 400)
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this letter in trial mode.
Service is not allowed to send letters Turn on sending letters in your service Settings on GOV.UK Notify webpage
letter_contact_id <letter_contact_id> does not exist in database for service id <service id> Go to your service Settings and copy a valid letter_contact_id. Check that the API key you are using and the letter_contact_id belong to the same service.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending an email, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Send a precompiled letter

Send a precompiled letter

Send a precompiled letter

Send a precompiled letter

Send a precompiled letter

Send a precompiled letter

Send a precompiled letter

POST /v2/notifications/letter

Method

LetterResponse response = client.sendPrecompiledLetter(
    reference,
    precompiledPDFAsFile
    );
LetterResponse response = client.sendPrecompiledLetterWithInputStream(
    reference,
    precompiledPDFAsInputStream
    );
LetterResponse response = client.sendPrecompiledLetter(
    reference,
    precompiledPDFAsFile,
    postage
    );
LetterResponse response = client.sendPrecompiledLetterWithInputStream(
    reference,
    precompiledPDFAsInputStream,
    postage
    );

Method

LetterNotificationsResponse response = client.SendPrecompiledLetter(
    clientReference: "my reference",
    pdfContents: File.ReadAllBytes("<PDF file path>"),
    postage: "first"
    );

Method

let response = notifyClient.sendPrecompiledLetter(
  reference,
  pdfFile,
  postage
)

Method

$response = $notifyClient->sendPrecompiledLetter(
    $reference,
    $pdf_data,
    $postage,
);

Method

with open("path/to/pdf_file.pdf", "rb") as pdf_file:
  response = notifications_client.send_precompiled_letter_notification(
      reference="your reference",
      pdf_file=pdf_file,
  )

Method

precompiled_letter = client.send_precompiled_letter(reference, pdf_file)

Request body

{
  "reference": "your reference",
  "content": "file as base64 encoded string"
}

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

String reference="STRING";
clientReference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

string reference = "my reference";
reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

let reference = "your reference";
reference (required)

A unique identifier you create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

$reference = 'STRING';
reference (required)

An identifier you create. This reference identifies a single unique precompiled letter or a batch of precompiled letters. It must not contain any personal information such as name or postal address.

reference="your reference" # required string - identifies notification(s)
reference (required)

A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

reference (required)

An identifier you create. This reference identifies a single unique precompiled letter or a batch of precompiled letters. It must not contain any personal information such as name or postal address.

"reference": "your reference" // required string - identifies notification(s)
precompiledPDFAsFile (required for the sendPrecompiledLetter method)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification.

This argument adds the precompiled letter PDF file to a Java file object. The method sends this Java file object to GOV.UK Notify.

File precompiledPDF = new File("<PDF file path>");
pdfContents (required for the SendPrecompiledLetter method)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification. The method sends the contents of the file to GOV.UK Notify.

byte[] pdfContents = File.ReadAllBytes("<PDF file path>");
pdfFile (required)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification. For example:

let fs = require("fs")

fs.readFile("path/to/document.pdf", function (err, pdfFile) {
  if (err) {
    console.error(err)
  }
  let notification = notifyClient.sendPrecompiledLetter(
    "your reference", pdfFile
  )
})
pdf_data (required)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification. The method sends the contents of the file to GOV.UK Notify.

$pdf_data = file_get_contents("path/to/pdf_file");
try {

    $response = $notifyClient->sendPrecompiledLetter(
        'unique_ref123',
        $pdf_data,
        'first',
    );

} catch (ApiException $e){}
pdf_file (required)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification.

with open("path/to/pdf_file.pdf", "rb") as pdf_file:
    notification = notifications_client.send_precompiled_letter_notification(
        reference="your reference", pdf_file=pdf_file
    )
pdf_file (required)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification.

File.open("path/to/pdf_file", "rb") do |pdf_file|
    client.send_precompiled_letter("your reference", pdf_file)
end
content (required)

The precompiled letter must be a PDF file which meets the GOV.UK Notify letter specification. You’ll need to convert the file into a string that is base64 encoded.

"content": "file as base64 encoded string"
precompiledPDFAsInputStream (required for the sendPrecompiledLetterWithInputStream method)

The precompiled letter must be an InputStream. This argument adds the precompiled letter PDF content to a Java InputStream object. The method sends this InputStream to GOV.UK Notify.

InputStream precompiledPDFAsInputStream = new FileInputStream(pdfContent);
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, second for second class or economy for economy mail. If you do not pass in this argument, the postage will default to second class.

string postage = "first";
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, second for second class or economy for economy mail. If you do not pass in this argument, the postage will default to second class.

let postage = "first";
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, second for second class or economy for economy mail. If you do not pass in this argument, the postage will default to second class.

$postage = 'first';
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, second for second class or economy for economy mail. If you do not pass in this argument, the postage will default to second class.

postage="first" # optional string
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, second for second class or economy for economy mail. If you do not pass in this argument, the postage will default to second class.

precompiled_letter = client.send_precompiled_letter(
  reference, pdf_file, "first"
)
postage (optional)

You can choose first or second class postage for your precompiled letter. Set the value to first for first class, or second for second class. If you do not pass in this argument, the postage will default to second class.

"postage": "second"
postage (optional)

You can choose first class, second class or economy mail postage for your precompiled letter. Set the value to first for first class, or second for second class. If you do not pass in this argument, the postage will default to second class.

Response

If the request to the client is successful, the client returns a LetterResponse:

UUID notificationId;
String reference;
String postage

Response

If the request to the client is successful, the client returns a LetterNotificationResponse with the id, reference and postage:

public String id;
public String reference;
public String postage;
public String uri;  // null for this response
public Template template;  // null for this response
public LetterResponseContent content;  // null for this response

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "1d986ba7-fba6-49fb-84e5-75038a1dd968",  // required string - notification ID
    "reference": "your reference",  // required string - reference your provided
    "postage": "first"  // required string - postage you provided, or else default postage for the letter
}

Response

If the request to the client is successful, the client returns an array:

[
  "id" => "740e5834-3a29-46b4-9a6f-16142fde533a",
  "reference" => "unique_ref123",
  "postage" => "first"
];

Response

If the request to the client is successful, the client returns a dict:

{
  "id": "1d986ba7-fba6-49fb-84e5-75038a1dd968",  # required string - notification ID
  "reference": "your reference",  # required string - reference your provided
  "postage": "first"  # required string - postage you provided, or else default postage for the letter
}

Response

If the request to the client is successful, the client returns a Notifications::Client:ResponsePrecompiledLetter object. In the example shown in the Method section, the object is named precompiled_letter.

You can then call different methods on this object to return the requested information.

Method Information Type
precompiled_letter.id Notification UUID String
precompiled_letter.reference reference argument String
precompiled_letter.postage postage argument String

Response

If the request is successful, the response body is json and the status code is 201:

{
  "id": "1d986ba7-fba6-49fb-84e5-75038a1dd968",  // required string - notification ID
  "reference": "your reference",  // required string - reference your provided
  "postage": "first"  // required string - postage you provided, or else default postage for the letter
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

reference is a required property Add a reference argument to the method call
postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError (status code 400)
Letter content is not a valid PDF PDF file format is required.
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
403 [{
"error": "BadRequestError",
"message": "Cannot send letters with a team api key"
}]
Use the correct type of API key
400 [{
"error": "BadRequestError",
"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"
}]
Your service cannot send this notification in trial mode
400 [{
"error": "ValidationError",
"message": "personalisation address_line_1 is a required property"
}]
Send a valid PDF file
400 [{
"error": "ValidationError",
"message": "reference is a required property"
}]
Add a reference argument to the method call
400 [{
"error": "ValidationError",
"message": "postage invalid. It must be either first, second or economy."
}]
Change the value of postage argument in the method call to either ‘first’, ‘second’ or ‘economy’
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
429 [{
"error": "RateLimitError",
"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"
}]
Refer to API rate limits for more information
429 [{
"error": "TooManyRequestsError",
"message": "Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today"
}]
Refer to service limits for the limit size
N/A "message":"precompiledPDF must be a valid PDF file" Send a valid PDF file
N/A "message":"reference cannot be null or empty" Populate the reference parameter
N/A "message":"precompiledPDF cannot be null or empty" Send a PDF file with data in it

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

reference is a required property Add a reference argument to the method call
postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError (status code 400)
Letter content is not a valid PDF PDF file format is required.
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

reference is a required property Add a reference argument to the method call
postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError (status code 400)
Letter content is not a valid PDF PDF file format is required.
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

reference is a required property Add a reference argument to the method call
postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError (status code 400)
Letter content is not a valid PDF PDF file format is required.
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: reference is a required property Add a reference argument to the method call
ValidationError: postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError: Letter content is not a valid PDF PDF file format is required.
BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
AuthError (status code 403)
BadRequestError: Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

reference is a required property Add a reference argument to the method call
postage invalid. It must be either first, second or economy. Change the value of postage argument in the method call to either "first", "second" or "economy"
BadRequestError (status code 400)
Letter content is not a valid PDF PDF file format is required.
Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode Your service cannot send this precompiled letter in trial mode.
BadRequestError (status code 403)
Cannot send letters with a team api key Use the correct type of API key.

In addition to the above, you may also encounter:

  • other errors related to sending an letter.
  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to sending a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get message status

Get message status

Get message status

Get message status

Get message status

Get message status

Get message status

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of one message

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Method

Notification notification = client.getNotificationById(notificationId);

Method

Notification notification = client.GetNotificationById(notificationId: "740e5834-3a29-46b4-9a6f-16142fde533a");

Method

notifyClient
  .getNotificationById(notificationId)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

getNotification( $notificationId )

For example:

try {

    $response = $notifyClient->getNotification( 'c32e9c89-a423-42d2-85b7-a21cd4486a2a' );

} catch (ApiException $e){}

Method

response = notifications_client.get_notification_by_id(notification_id)

Method

response = client.get_notification(id)

Method

GET /v2/notifications/{notification_id}

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

URL parameters

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

string notificationId = "740e5834-3a29-46b4-9a6f-16142fde533a";
notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notification_id (required)

The ID of the notification. To find the notification ID, you can either:

id (required)

The ID of the notification. To find the notification ID, you can either:

notification_id (required)

The ID of the notification. To find the notification ID, you can either:

3d1ce039-5476-414c-99b2-fac1e6add62c

Response

If the request to the client is successful, the client returns a Notification:

UUID id;
Optional<String> reference;
Optional<String> emailAddress;
Optional<String> phoneNumber;
Optional<String> line1;
Optional<String> line2;
Optional<String> line3;
Optional<String> line4;
Optional<String> line5;
Optional<String> line6;
Optional<String> line7;
Optional<String> postage;
String notificationType;
String status;
UUID templateId;
int templateVersion;
String templateUri;
String body;
Optional<String> subject;
ZonedDateTime createdAt;
Optional<ZonedDateTime> sentAt;
Optional<ZonedDateTime> completedAt;
Optional<ZonedDateTime> estimatedDelivery;
Optional<String> createdByName;
boolean isCostDataReady;
double costInPounds;
Optional<Integer> billableSmsFragments;
Optional<Double> internationalRateMultiplier;
Optional<Double> smsRate;
Optional<Integer> billableSheetsOfPaper;
Optional<String> postageType;

Response

If the request to the client is successful, the client returns a Notification.

public String id;
public String completedAt;
public String createdAt;
public String emailAddress;
public String body;
public String subject;
public String line1;
public String line2;
public String line3;
public String line4;
public String line5;
public String line6;
public String line7;
public String phoneNumber;
public String postage;
public String reference;
public String sentAt;
public String status;
public Template template;
public String type;
public string createdByName;
public bool isCostDataReady;  
public double costInPounds;
public CostDetails costDetails; 

public class Template
{
    public String id;
    public String uri;
    public Int32 version;
}

public class CostDetails
{
    [JsonProperty("billable_sms_fragments")]
    public int? billableSmsFragments;

    [JsonProperty("international_rate_multiplier")]
    public double? internationalRateMultiplier;

    [JsonProperty("sms_rate")]
    public double? smsRate;

    [JsonProperty("billable_sheets_of_paper")]
    public int? billableSheetsOfPaper;

    public string postage;
}

For more information, see the:

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  // required string - notification ID
    "reference": "your reference",  // optional string - reference you provided when sending the message
    "email_address": "amala@example.com",  // required string for emails
    "phone_number": "+447700900123",  // required string for text messages
    "line_1": "Amala Bird",  // required string for letter
    "line_2": "123 High Street",  // required string for letter
    "line_3": "Richmond upon Thames",  // required string for letter
    "line_4": "Middlesex",  // optional string for letter
    "line_5": "SW14 6BF",  // optional string for letter
    "line_6": null,  // optional string for letter
    "line_7": null, // optional string for letter
    "postage": "first / second / economy / europe / rest-of-world", // required string for letter
    "type": "sms / letter / email",  // required string
    "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  // required string
    "template": {
        "version": 1, // required integer
        "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  // required string - template ID
        "uri": "/v2/template/{id}/{version}"  // required string
    },
    "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00pm",  // required string - body of notification
    "subject": "Your upcoming pigeon registration appointment",  // required string for email - subject of email
    "created_at": "2024-05-17 15:58:38.342838",  // required string - date and time notification created
    "created_by_name": "Charlie Smith",  // optional string - name of the person who sent the notification if sent manually
    "sent_at": "2024-05-17 15:58:30.143000",  // optional string - date and time notification sent to provider
    "completed_at": "2024-05-17 15:59:10.321000",  // optional string - date and time notification delivered or failed
    "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789", // optional string, email only - URL that you provided so your recipients can unsubscribe
    "is_cost_data_ready": True,  // required boolean, this field is true if cost data is ready, and false if it isn't
    "cost_in_pounds": 0.0027,  // optional number - cost of the notification in pounds. The cost does not take free allowance into account
    "cost_details": {
    // for text messages:
        "billable_sms_fragments": 1,  // optional integer - number of billable sms fragments in your text message
        "international_rate_multiplier": 1,  // optional integer - for international sms rate is multiplied by this value
        "sms_rate": 0.0027,  // optional number - cost of 1 sms fragment
    // for letters:
        "billable_sheets_of_paper": 2,  // optional integer - number of sheets of paper in the letter you sent, that you will be charged for
        "postage": "first / second / economy / europe / rest-of-world"  // optional string
    }
}

Response

If the request to the client is successful, the client returns an array:

[
    "id" => "notify_id",
    "body" => "Hello Foo",
    "subject" => "null|email_subject",
    "reference" => "client reference",
    "email_address" => "email address",
    "phone_number" => "phone number",
    "line_1" => "full name of a person or company",
    "line_2" => "123 The Street",
    "line_3" => "Some Area",
    "line_4" => "Some Town",
    "line_5" => "Some county",
    "line_6" => "Something else",
    "line_7" => "Postcode or country",
    "postage" => "null|first|second|economy",
    "type" => "sms|letter|email",
    "status" => "sending / delivered / permanent-failure / temporary-failure / technical-failure",
    "template" => [
        "version" => 1,
        "id" => "f33517ff-2a88-4f6e-b855-c550268ce08a",
        "uri" => "/template/{id}/{version}"
    ],
    "body" => "STRING",
    "subject" => "STRING",
    "created_at" => "2024-05-17 15:58:38.342838",
    "created_by_name" => "STRING",
    "sent_at" => "2024-05-17 15:58:30.143000",
    "completed_at" => "2024-05-17 15:59:10.321000",
    "scheduled_for" => "2024-05-17 9:00:00.000000",
    "one_click_unsubscribe" => "STRING",
    "is_cost_data_ready" => true,
    "cost_in_pounds" => 0.0027,
    "cost_details" => [
        // for text messages:
        "billable_sms_fragments" => 1,
        "international_rate_multiplier" => 1,
        "sms_rate" => 0.0027,
        // for letters:
        "billable_sheets_of_paper" => 2,
        "postage" => "first / second / economy / europe / rest-of-world"
    ]
];

Response

If the request to the client is successful, the client will return a dict:

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  # required string - notification ID
    "reference": "your reference",  # optional string - reference you provided when sending the message
    "email_address": "amala@example.com",  # required string for emails
    "phone_number": "+447700900123",  # required string for text messages
    "line_1": "Amala Bird",  # required string for letter
    "line_2": "123 High Street",  # required string for letter
    "line_3": "Richmond upon Thames",  # required string for letter
    "line_4": "Middlesex",  # optional string for letter
    "line_5": "SW14 6BF",  # optional string for letter
    "line_6": None,  # optional string for letter
    "line_7": None, # optional string for letter
    "postage": "first / second / economy / europe / rest-of-world", # required string for letter
    "type": "sms / letter / email",  # required string
    "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  # required string
    "template": {
        "version": 1, # required integer
        "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  # required string - template ID
        "uri": "/v2/template/{id}/{version}"  # required string
    },
    "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00pm",  # required string - body of notification
    "subject": "Your upcoming pigeon registration appointment",  # required string for email - subject of email
    "created_at": "2024-05-17 15:58:38.342838",  # required string - date and time notification created
    "created_by_name": "Charlie Smith",  # optional string - name of the person who sent the notification if sent manually
    "sent_at": "2024-05-17 15:58:30.143000",  # optional string - date and time notification sent to provider
    "completed_at": "2024-05-17 15:59:10.321000",  # optional string - date and time notification delivered or failed
    "scheduled_for": "2024-05-17 9:00:00.000000", # optional string - date and time notification has been scheduled to be sent at
    "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789", # optional string, email only - URL that you provided so your recipients can unsubscribe
    "is_cost_data_ready": True,  # required boolean, this field is true if cost data is ready, and false if it isn't
    "cost_in_pounds": 0.0027,  # optional number - cost of the notification in pounds. The cost does not take free allowance into account
    "cost_details": {
        # for text messages:
        "billable_sms_fragments": 1,  # optional integer - number of billable sms fragments in your text message
        "international_rate_multiplier": 1,  # optional integer - for international sms rate is multiplied by this value
        "sms_rate": 0.0027,  # optional number - cost of 1 sms fragment
        # for letters:
        "billable_sheets_of_paper": 2,  # optional integer - number of sheets of paper in the letter you sent, that you will be charged for
        "postage": "first / second / economy / europe / rest-of-world"  # optional string
    }
}

For more information, see the:

Response

If the request to the client is successful, the client returns a Notifications::Client::Notification object. In the example shown in the Method section, the object is named response.

You can then call different methods on this object to return the requested information.

Method Information Type
response.id Notification UUID String
response.reference String supplied in reference argument String
response.email_address Recipient email address (email only) String
response.phone_number Recipient phone number (SMS only) String
response.line_1 Recipient address line 1 of the address (letter only) String
response.line_2 Recipient address line 2 of the address (letter only) String
response.line_3 Recipient address line 3 of the address (letter only) String
response.line_4 Recipient address line 4 of the address (letter only) String
response.line_5 Recipient address line 5 of the address (letter only) String
response.line_6 Recipient address line 6 of the address (letter only) String
response.postage Postage class of the notification sent (letter only) String
response.type Type of notification sent (sms, email or letter) String
response.status Notification status (sending / delivered / permanent-failure / temporary-failure / technical-failure) String
response.template Template UUID String
response.body Notification body String
response.subject Notification subject (email and letter) String
response.sent_at Date and time notification sent to provider String
response.created_at Date and time notification created String
response.completed_at Date and time notification delivered or failed String
response.created_by_name Name of sender if notification sent manually String
response.one_click_unsubscribe URL that you provided so your recipients can unsubscribe (email only) String
response.is_cost_data_ready This field is true if cost data is ready, and false if it isn’t Boolean
response.cost_in_pounds Cost of the notification in pounds. The cost does not take free allowance into account Float
response.cost_details.billable_sms_fragments Number of billable SMS fragments in your text message (SMS only) Integer
response.cost_details.international_rate_multiplier For international SMS rate is multiplied by this value (SMS only) Integer
response.cost_details.sms_rate Cost of 1 SMS fragment (SMS only) Float
response.cost_details.billable_sheets_of_paper Number of sheets of paper in the letter you sent, that you will be charged for (letter only) Integer
response.cost_details.postage Postage class of the notification sent (letter only) String

Response

If the request is successful, the response body is json and the status code is 200:

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  // required string - notification ID
    "reference": "your reference",  // optional string - reference you provided when sending the message
    "email_address": "amala@example.com",  // required string for emails
    "phone_number": "+447700900123",  // required string for text messages
    "line_1": "Amala Bird",  // required string for letter
    "line_2": "123 High Street",  // required string for letter
    "line_3": "Richmond upon Thames",  // required string for letter
    "line_4": "Middlesex",  // optional string for letter
    "line_5": "SW14 6BF",  // optional string for letter
    "line_6": null,  // optional string for letter
    "line_7": null, // optional string for letter
    "postage": "first / second / europe / rest-of-world", // required string for letter
    "type": "sms / letter / email",  // required string
    "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  // required string
    "template": {
        "version": 1, // required integer
        "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  // required string - template ID
        "uri": "/v2/template/{id}/{version}"  // required string
    },
    "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00PM",  // required string - body of notification
    "subject": "Your upcoming pigeon registration appointment",  // required string for email - subject of email
    "created_at": "2024-05-17 15:58:38.342838",  // required string - date and time notification created
    "created_by_name": "Charlie Smith",  // optional string - name of the person who sent the notification if sent manually
    "sent_at": "2024-05-17 15:58:30.143000",  // optional string - date and time notification sent to provider
    "completed_at": "2024-05-17 15:59:10.321000",  // optional string - date and time notification delivered or failed
    "scheduled_for": "2024-05-17 9:00:00.000000", // optional string - date and time notification has been scheduled to be sent at
    "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789", // optional string, email only - URL that you provided so your recipients can unsubscribe
    "is_cost_data_ready": true,  // required boolean, this field is true if cost data is ready, and false if it isn't
    "cost_in_pounds": 0.0027,  // optional number - cost of the notification in pounds. The cost does not take free allowance into account
    "cost_details": {
        // for text messages:
        "billable_sms_fragments": 1,  // optional integer - number of billable sms fragments in your text message
        "international_rate_multiplier": 1,  // optional integer - for international sms rate is multiplied by this value
        "sms_rate": 0.0027,  // optional number - cost of 1 sms fragment
        // for letters:
        "billable_sheets_of_paper": 2,  // optional integer - number of sheets of paper in the letter you sent, that you will be charged for
        "postage": "first / second / europe / rest-of-world"  // optional string
    }
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
NoResultFound (status code 404)
No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "ValidationError",
"message": "id is not a valid UUID"
}]
Check the notification ID
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
404 [{
"error": "NoResultFound",
"message": "No result found"
}]
Check the notification ID

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
NoResultFound (status code 404)
No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
NoResultFound (status code 404)
No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
NoResultFound (status code 404)
No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: id is not a valid UUID Check the notification ID.
NotFoundError (status code 404)
NoResultFound: No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
NoResultFound (status code 404)
No result found If it’s outside the retention period, you may no longer get the status of the message. The default retention period is 7 days.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of a message, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThanId argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

Get the status of multiple messages

This API call returns the status of multiple messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThanId argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThan argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get the status of messages sent within the retention period. The default retention period is 7 days.

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

Get the status of multiple messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

GET /v2/notifications

You can filter the returned messages by including the following optional arguments in the method:

Method

NotificationList notification = client.getNotifications(
    status,
    notificationType,
    reference,
    olderThanId
);

To get the most recent messages, you must pass in an empty olderThanId argument or null.

To get older messages, pass the ID of an older notification into the olderThanId argument. This returns the next oldest messages from the specified notification ID.

Method

NotificationList notifications = client.GetNotifications(
    templateType, 
    status, 
    reference, 
    olderThanId, 
    includeSpreadsheetUploads);

For example: csharp NotificationList notifications = client.GetNotifications( templateType: "sms" );

Method

notifyClient
  .getNotifications(templateType, status, reference, olderThan)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

To get the most recent messages, you must pass in an empty olderThan argument or null.

To get older messages, pass the ID of an older notification into the olderThan argument. This returns the next oldest messages from the specified notification ID.

Method

listNotifications( array $filters = array() )
    $response = $notifyClient->listNotifications([
        'older_than' => 'c32e9c89-a423-42d2-85b7-a21cd4486a2a',
        'reference' => 'weekly-reminders',
        'status' => 'delivered',
        'template_type' => 'sms'
    ]);

You can leave out the older_than argument to get the 250 most recent messages.

To get older messages, pass the ID of an older notification into the older_than argument. This returns the next 250 oldest messages from the specified notification ID.

Method

Method

response = client.get_notifications(
  template_type: "sms",
  status: "failed",
  reference: "your_reference_string",
  older_than: "e194efd1-c34d-49c9-9915-e4267e01e92e",
)

You can leave out the older_than argument to get the 250 most recent messages.

To get older messages, pass the ID of an older notification into the older_than argument. This returns the next 250 oldest messages from the specified notification ID.

Query parameters

You can omit any of these arguments to ignore these filters.

One page of up to 250 messages

This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get messages that are within your data retention period. The default data retention period is 7 days. It can be changed in your Service Settings.

response = notifications_client.get_all_notifications(template_type, status, reference, older_than, include_jobs)

You can filter the returned messages by including the following optional arguments in the method:

template_type (optional)

You can filter by:

  • email
  • sms
  • letter
?template_type=email
All messages - as an iterator

This will return a Python iterator object which yields one notification at a time until it has yielded all your notifications.

response = get_all_notifications_iterator()

# to iterate and process the notifications using the iterator:
for notification in response:
    # process notification

You can filter the returned messages by including the following optional arguments in the method:

status (optional)

You can filter by each:

You can leave out this argument to ignore this filter.

You can filter on multiple statuses by repeating the query string.

?status=created&status=sending&status=delivered
reference (optional)

An identifier you can create if necessary. This reference identifies a single unique message or a batch of messages. It must not contain any personal information such as name or postal address. For example:

?reference=your%20reference // optional string - reference you provided when sending the message

You can leave out this argument to ignore this filter.

older_than (optional)

Input a notification ID into this argument. If you use this argument, the method returns the next 250 messages older than the given ID.

?older_than=740e5834-3a29-46b4-9a6f-16142fde533a // optional string - notification ID

If you leave out this argument, the method returns the most recent 250 messages.

The API only returns messages sent within the retention period. The default retention period is 7 days. If the message specified in this argument was sent before the retention period, the API returns an empty response.

include_jobs (optional)

Includes notifications sent as part of a batch upload.

If you leave out this argument, the method only returns notifications sent using the API.

?include_jobs=true

Arguments

You can pass in empty arguments or null to ignore these filters.

Arguments

You can leave out these arguments to ignore these filters.

Arguments

You can pass in empty arguments or null to ignore these filters.

Arguments

You can leave out any of these arguments to ignore these filters.

Arguments

Arguments

You can leave out these arguments to ignore these filters.

Response

If the request is successful, the response body is json and the status code is 200.

status (optional)

You can filter by each:

You can leave out this argument to ignore this filter.

templateType (optional)

You can filter by:

  • email
  • sms
  • letter
status (optional)

You can filter by each:

You can leave out this argument to ignore this filter.

template_type (optional)

You can filter by:

  • email
  • sms
  • letter

You can leave out this argument to ignore this filter.

template_type (optional)

You can filter by:

  • email
  • sms
  • letter

You can leave out this argument to ignore this filter.

status (optional)

The possible statuses that a notification can be in depends on the type of notification:

You can specify a single status:

status: "failed"

Or multiple, by specifying an array:

status: ["permanent-failure", "temporary-failure"]

You can leave out this argument to ignore this filter.

All messages
{
    "notifications": [
        {
            "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  // required string - notification ID
            "reference": "your reference",  // optional string - reference you provided when sending the message
            "email_address": "amala@example.com",  // required string for emails
            "phone_number": "+447700900123",  // required string for text messages
            "line_1": "Amala Bird",  // required string for letter
            "line_2": "123 High Street",  // required string for letter
            "line_3": "Richmond upon Thames",  // required string for letter
            "line_4": "Middlesex",  // optional string for letter
            "line_5": "SW14 6BF",  // optional string for letter
            "line_6": null,  // optional string for letter
            "line_7": null, // optional string for letter
            "postage": "first / second / europe / rest-of-world", // required string for letter
            "type": "sms / letter / email",  // required string
            "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  // required string
            "template": {
                "version": 1, // required integer
                "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  // required string - template ID
                "uri": "/v2/template/{id}/{version}"  // required string
            },
            "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00PM",  // required string - body of notification
            "subject": "Your upcoming pigeon registration appointment",  // required string for email - subject of email
            "created_at": "2024-05-17 15:58:38.342838",  // required string - date and time notification created
            "created_by_name": "Charlie Smith",  // optional string - name of the person who sent the notification if sent manually
            "sent_at": "2024-05-17 15:58:30.143000",  // optional string - date and time notification sent to provider
            "completed_at": "2024-05-17 15:59:10.321000",  // optional string - date and time notification delivered or failed
            "scheduled_for": "2024-05-17 9:00:00.000000", // optional string - date and time notification has been scheduled to be sent at
            "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789", // optional string, email only - URL that you provided so your recipients can unsubscribe
            "is_cost_data_ready": true,  // required boolean, this field is true if cost data is ready, and false if it isn't
            "cost_in_pounds": 0.0027,  // optional number - cost of the notification in pounds. The cost does not take free allowance into account
            "cost_details": {
                // for text messages:
                "billable_sms_fragments": 1,  // optional integer - number of billable sms fragments in your text message
                "international_rate_multiplier": 1,  // optional integer - for international sms rate is multiplied by this value
                "sms_rate": 0.0027,  // optional number - cost of 1 sms fragment
                // for letters:
                "billable_sheets_of_paper": 2,  // optional integer - number of sheets of paper in the letter you sent, that you will be charged for
                "postage": "first / second / europe / rest-of-world"  // optional string
            }
        },
        {
            ...another notification
        }
    ],
    "links": {
        "current": "https://api.notifications.service.gov.uk/v2/notifications?template_type=sms&status=delivered",
        "next": "https://api.notifications.service.gov.uk/v2/notifications?other_than=last_id_in_list&template_type=sms&status=delivered"
    }
}
notificationType (optional)

You can filter by:

  • email
  • sms
  • letter
status (optional)

You can filter by each:

You can leave out this argument to ignore this filter.

notificationType (optional)

You can filter by:

  • email
  • sms
  • letter
status (optional)

You can filter by each:

You can leave out this argument to ignore this filter.

status (optional)

You can filter by each:

If you filter by failed it will return all 3 failure statuses: permanent-failure, temporary-failure and technical-failure.

You can leave out this argument to ignore this filter.

templateType (optional)

You can filter by:

  • email
  • sms
  • letter
reference (optional)

A unique identifier you create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

String reference='STRING';
reference (optional)

A unique identifier you can create if you need to. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

string reference = "my reference";
reference (optional)

A unique identifier you create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

let reference  = "your_reference_here";
reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address.

$reference = 'STRING';

You can leave out this argument to ignore this filter.

reference (optional)

An identifier you can create if necessary. This reference identifies a single unique message or a batch of messages. It must not contain any personal information such as name or postal address. For example:

reference="your reference" # optional string - reference you provided when sending the message

You can leave out this argument to ignore this filter.

reference (optional)

A unique identifier you can create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:

reference: "your_reference_string"
olderThanId (optional)

Input the ID of a notification into this argument. If you use this argument, the client returns the next 250 received notifications older than the given ID.

String olderThanId='8e222534-7f05-4972-86e3-17c5d9f894e2'

If you pass in an empty argument or null, the client returns the most recent 250 notifications.

olderThanId (optional)

Input the ID of a notification into this argument to return the next 250 received notifications older than the given ID. For example:

string olderThanId: "e194efd1-c34d-49c9-9915-e4267e01e92e";

If you leave out this argument, the client returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty response.

olderThan (optional)

Input the ID of a notification into this argument. If you use this argument, the client returns the next 250 received notifications older than the given ID. For example:

let olderThan = "8e222534-7f05-4972-86e3-17c5d9f894e2";

If you pass in an empty argument or null, the client returns the most recent 250 notifications.

older_than (optional)

Input the ID of a notification into this argument. If you use this argument, the method returns the next 250 received notifications older than the specified ID.

older_than='740e5834-3a29-46b4-9a6f-16142fde533a'

If you leave out this argument, the method returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty response.

older_than (optional)

Input a notification ID into this argument. If you use this argument, the method returns the next 250 messages older than the given ID.

older_than="740e5834-3a29-46b4-9a6f-16142fde533a" # optional string - notification ID

If you leave out this argument, the method returns the most recent 250 messages.

The client only returns messages sent within the retention period. The default retention period is 7 days. If the message specified in this argument was sent before the retention period, the client returns an empty response.

older_than (optional)

Input the ID of a notification into this argument. If you use this argument, the client returns the next 250 received notifications older than the given ID. For example:

older_than: "e194efd1-c34d-49c9-9915-e4267e01e92e"

If you leave out this argument, the client returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty response.

includeSpreadsheetUploads (optional)

Specifies whether the response should include notifications which were sent by uploading a spreadsheet of recipients to Notify.

bool includeSpreadsheetUploads = true;

If you do not pass in this argument it defaults to false.

include_jobs (optional)

Includes notifications sent as part of a batch upload.

If you leave out this argument, the method only returns notifications sent using the API.

Response

If the request to the client is successful, the client returns a NotificationList:

List<Notification> notifications;
String currentPageLink;
Optional<String> nextPageLink;

Response

If the request to the client is successful, the client returns a NotificationList.

public List<Notification> notifications;
public Link links;

public class Link {
    public String current;
    public String next;
}

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
  "notifications": [
    {
      "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  // required string - notification ID
      "reference": "STRING",  // optional string - client reference
      "email_address": "sender@something.com",  // required string for emails
      "phone_number": "+447900900123",  // required string for text messages
      "line_1": "ADDRESS LINE 1",  // required string for letter
      "line_2": "ADDRESS LINE 2",  // required string for letter
      "line_3": "ADDRESS LINE 3",  // required string for letter
      "line_4": "ADDRESS LINE 4",  // optional string for letter
      "line_5": "ADDRESS LINE 5",  // optional string for letter
      "line_6": "ADDRESS LINE 6",  // optional string for letter
      "postcode": "valid UK postcode", // optional string
      "postage": "first / second / economy / europe / rest-of-world", // required string for letter
      "type": "sms / letter / email",  // required string
      "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  // required string
      "template": {
        "version": 1, // required integer
        "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  // required string - template ID
        "uri": "/v2/template/{id}/{version}"  // required string
      },
      "body": "STRING",  // required string - body of notification
      "subject": "STRING",  // required string for email - subject of email
      "created_at": "2024-05-17 15:58:38.342838",  // required string - date and time notification created
      "created_by_name": "STRING",  // optional string - name of the person who sent the notification if sent manually
      "sent_at": "2024-05-17 15:58:30.143000",  // optional string - date and time notification sent to provider
      "completed_at": "2024-05-17 15:59:10.321000",  // optional string - date and time notification delivered or failed
      "one_click_unsubscribe": "STRING", // optional string, email only - URL that you provided so your recipients can unsubscribe
      "is_cost_data_ready": true,  // required boolean, this field is true if cost data is ready, and false if it isn't
      "cost_in_pounds": 0.0027,  // optional number - cost of the notification in pounds. The cost does not take free allowance into account
      "cost_details": {
        // for text messages:
        "billable_sms_fragments": 1,  // optional integer - number of billable sms fragments in your text message
        "international_rate_multiplier": 1,  // optional integer - for international sms rate is multiplied by this value
        "sms_rate": 0.0027,  // optional number - cost of 1 sms fragment
        // for letters:
        "billable_sheets_of_paper": 2,  // optional integer - number of sheets of paper in the letter you sent, that you will be charged for
        "postage": "first / second / economy / europe / rest-of-world"  // optional string
      }
    }
  ],
  "links": {
    "current": "/notifications?template_type=sms&status=delivered",
    "next": "/notifications?other_than=last_id_in_list&template_type=sms&status=delivered"
  }
}

Response

If the request to the client is successful, the client returns an array.

[
    "notifications" => [
        [
            "id" => "notify_id",
            "reference" => "client reference",
            "email_address" => "email address",
            "phone_number" => "phone number",
            "line_1" => "full name of a person or company",
            "line_2" => "123 The Street",
            "line_3" => "Some Area",
            "line_4" => "Some Town",
            "line_5" => "Some county",
            "line_6" => "Something else",
            "postcode" => "postcode",
            "postage" => "null|first|second|economy",
            "type" => "sms | letter | email",
            "status" => sending | delivered | permanent-failure | temporary-failure | technical-failure",
            "template" => [
                "version" => 1,
                "id" => "f33517ff-2a88-4f6e-b855-c550268ce08a",
                "uri" => "/template/{id}/{version}"
            ],
            "body" => "STRING",
            "subject" => "STRING",
            "created_at" => "2024-05-17 15:58:38.342838",
            "created_by_name" => "STRING",
            "sent_at" => "2024-05-17 15:58:30.143000",
            "completed_at" => "2024-05-17 15:59:10.321000",
            "scheduled_for" => "2024-05-17 9:00:00.000000",
            "one_click_unsubscribe" => "STRING",
            "is_cost_data_ready" => true,
            "cost_in_pounds" => 0.0027,
            "cost_details" => [
                // for text messages:
                "billable_sms_fragments" => 1,
                "international_rate_multiplier" => 1,
                "sms_rate" => 0.0027,
                // for letters:
                "billable_sheets_of_paper" => 2,
                "postage" => "first / second / economy / europe / rest-of-world"
            ]
        ]
    ],
    "links" => [
        "current" => "/notifications?template_type=sms&status=delivered",
        "next" => "/notifications?other_than=last_id_in_list&template_type=sms&status=delivered"
    ]
];

Response

If the request to the client is successful, the client returns a dict.

Response

If the request to the client is successful, the client returns a Notifications::Client::NotificationsCollection object. In the example shown in the Method section, the object is named response.

You must then call either the .links method or the .collection method on this object.

Method Information
response.links Returns a hash linking to the requested notifications (limited to 250)
response.collection Returns an array of the required notifications

If you call the collection method on this object to return a notification array, you must then call the following methods on the notifications in this array to return information on those notifications:

Method Information Type
response.id Notification UUID String
response.reference String supplied in reference argument String
response.email_address Recipient email address (email only) String
response.phone_number Recipient phone number (SMS only) String
response.line_1 Recipient address line 1 of the address (letter only) String
response.line_2 Recipient address line 2 of the address (letter only) String
response.line_3 Recipient address line 3 of the address (letter only) String
response.line_4 Recipient address line 4 of the address (letter only) String
response.line_5 Recipient address line 5 of the address (letter only) String
response.line_6 Recipient address line 6 of the address (letter only) String
response.postage Postage class of the notification sent (letter only) String
response.postcode Recipient postcode (letter only) String
response.type Type of notification sent (sms, email or letter) String
response.status Notification status (sending / delivered / permanent-failure / temporary-failure / technical-failure) String
response.template Template UUID String
response.body Notification body String
response.subject Notification subject (email and letter) String
response.sent_at Date and time notification sent to provider String
response.created_at Date and time notification created String
response.completed_at Date and time notification delivered or failed String
response.created_by_name Name of sender if notification sent manually String
response.one_click_unsubscribe URL that you provided so your recipients can unsubscribe (email only) String
response.is_cost_data_ready This field is true if cost data is ready, and false if it isn’t Boolean
response.cost_in_pounds Cost of the notification in pounds. The cost does not take free allowance into account Float
response.cost_details.billable_sms_fragments Number of billable SMS fragments in your text message (SMS only) Integer
response.cost_details.international_rate_multiplier For international SMS rate is multiplied by this value (SMS only) Integer
response.cost_details.sms_rate Cost of 1 SMS fragment (SMS only) Float
response.cost_details.billable_sheets_of_paper Number of sheets of paper in the letter you sent, that you will be charged for (letter only) Integer
response.cost_details.postage Postage class of the notification sent (letter only) String

If the notification specified in the older_than argument is older than 7 days, the client returns an empty collection response.

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors
All messages
{
    "notifications": [
        {
            "id": "740e5834-3a29-46b4-9a6f-16142fde533a",  # required string - notification ID
            "reference": "your reference",  # optional string - reference you provided when sending the message
            "email_address": "amala@example.com",  # required string for emails
            "phone_number": "+447700900123",  # required string for text messages
            "line_1": "Amala Bird",  # required string for letter
            "line_2": "123 High Street",  # required string for letter
            "line_3": "Richmond upon Thames",  # required string for letter
            "line_4": "Middlesex",  # optional string for letter
            "line_5": "SW14 6BF",  # optional string for letter
            "line_6": None,  # optional string for letter
            "line_7": None, # optional string for letter
            "postage": "first / second / economy / europe / rest-of-world", # required string for letter
            "type": "sms / letter / email",  # required string
            "status": "sending / delivered / permanent-failure / temporary-failure / technical-failure",  # required string
            "template": {
                "version": 1, # required integer
                "id": "f33517ff-2a88-4f6e-b855-c550268ce08a",  # required string - template ID
                "uri": "/v2/template/{id}/{version}"  # required string
            },
            "body": "Hi Amala, your appointment is on 1 January 2018 at 1:00pm",  # required string - body of notification
            "subject": "Your upcoming pigeon registration appointment",  # required string for email - subject of email
            "created_at": "2024-05-17 15:58:38.342838",  # required string - date and time notification created
            "created_by_name": "Charlie Smith",  # optional string - name of the person who sent the notification if sent manually
            "sent_at": "2024-05-17 15:58:30.143000",  # optional string - date and time notification sent to provider
            "completed_at": "2024-05-17 15:59:10.321000",  # optional string - date and time notification delivered or failed
            "scheduled_for": "2024-05-17 9:00:00.000000", # optional string - date and time notification has been scheduled to be sent at
            "one_click_unsubscribe": "https://example.com/unsubscribe.html?opaque=123456789", # optional string, email only - URL that you provided so your recipients can unsubscribe
            "is_cost_data_ready": True,  # required boolean, this field is true if cost data is ready, and false if it isn't
            "cost_in_pounds": 0.0027,  # optional number - cost of the notification in pounds. The cost does not take free allowance into account
            "cost_details": {
                # for text messages:
                "billable_sms_fragments": 1,  # optional integer - number of billable sms fragments in your text message
                "international_rate_multiplier": 1,  # optional integer - for international sms rate is multiplied by this value
                "sms_rate": 0.0027,  # optional number - cost of 1 sms fragment
                # for letters:
                "billable_sheets_of_paper": 2,  # optional integer - number of sheets of paper in the letter you sent, that you will be charged for
                "postage": "first / second / economy / europe / rest-of-world"  # optional string
            }
        },
        {
            ...another notification
        }
    ],
    "links": {
        "current": "/notifications?template_type=sms&status=delivered",
        "next": "/notifications?other_than=last_id_in_list&template_type=sms&status=delivered"
    }
}
One page of up to 250 messages
<generator object NotificationsAPIClient.get_all_notifications_iterator at 0x1026c7410>

For more information, see the:

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "ValidationError",
"message": "bad status is not one of [created, sending, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure]"
}]
Contact the GOV.UK Notify team
400 [{
"error": "ValidationError",
"message": "Apple is not one of [sms, email, letter]"
}]
Contact the GOV.UK Notify team
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: status ‘elephant’ is not one of [cancelled, created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received] Change the status argument.
ValidationError: ‘Apple’ is not one of [sms, email, letter] Change the template_type argument.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting the status of messages, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Email status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. Check your content does not look like spam before you try to send the message again.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Text message status descriptions

Status Description
created GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.
sending GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.
pending GOV.UK Notify is waiting for more delivery information.
GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the text message.
sent The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify website displays this status as ‘Sent to an international number’.
delivered The message was successfully delivered. If a recipient blocks your sender name or mobile number, your message will still show as delivered.
permanent-failure The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should contact GOV.UK Notify support. If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
temporary-failure The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.
technical-failure Your message was not sent because there was a problem between Notify and the provider.
You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Precompiled letter status descriptions

Status Description
accepted GOV.UK Notify has sent the letter to the provider to be printed.
received The provider has printed and dispatched the letter.
cancelled Sending cancelled. The letter will not be printed or dispatched.
pending-virus-check GOV.UK Notify has not completed a virus scan of the precompiled letter file.
virus-scan-failed GOV.UK Notify found a potential virus in the precompiled letter file.
validation-failed Content in the precompiled letter file is outside the printable area. See the GOV.UK Notify letter specification for more information.
technical-failure GOV.UK Notify had an unexpected error while sending the letter to our printing provider.
permanent-failure The provider cannot print the letter. Your letter will not be dispatched.

Get a PDF for a letter notification

Get a PDF for a letter notification

Get a PDF for a letter notification

Get a PDF for a letter notification

Get a PDF for a letter notification

Get a PDF for a letter notification

Get a PDF for a letter notification

Method

This returns the PDF contents of a letter notification.

byte[] pdfFile = client.getPdfForLetter(notificationId)

Method

This returns the pdf contents of a letter notification.

byte[] pdfFile = client.GetPdfForLetter(notificationId: "740e5834-3a29-46b4-9a6f-16142fde533a");

Method

notifyClient
  .getPdfForLetterNotification(notificationId)
  .then(function (fileBuffer) {
    return fileBuffer
  }) /* the response is a file buffer, an instance of Buffer */
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with fileBuffer if successful
  • fail with an err if unsuccessful

Method

This returns the PDF contents of a letter notification.

$pdf_file = $notifyClient->getPdfForLetter(
  'f33517ff-2a88-4f6e-b855-c550268ce08a' // required string - notification ID
)

Method

This returns the PDF contents of a letter.

pdf_file = notifications_client.get_pdf_for_letter(
  "3d1ce039-5476-414c-99b2-fac1e6add62c" # required string - notification ID
)

Method

This returns the pdf contents of a letter notification.

pdf_file = client.get_pdf_for_letter(
  "f33517ff-2a88-4f6e-b855-c550268ce08a" # notification id (required)
)

Method

This returns the PDF contents of a letter.

GET /v2/notifications/{notification_id}/pdf

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

URL parameters

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notificationId (required)

The ID of the notification. To find the notification ID, you can either:

notification_id (required)

The ID of the notification. To find the notification ID, you can either:

id (required)

The ID of the notification. To find the notification ID, you can either:

notification_id (required)

The ID of the notification. To find the notification ID, you can either:

3d1ce039-5476-414c-99b2-fac1e6add62c

Response

If the request to the client is successful, the client will return a byte[] object containing the raw PDF data.

Response

If the request to the client is successful, the client will return a byte[] object containing the raw PDF data.

Response

If the request is successful, the promise resolves with a response object which will be an instance of the Buffer class containing the raw PDF data.

Response

If the request to the client is successful, the client will return a string containing the raw PDF data.

Response

If the request to the client is successful, the client will return a io.BytesIO object containing the raw PDF data.

Response

If the request to the client is successful, the client will return a string containing the raw PDF data.

Response

If the request to the API is successful, the API will return bytes representing the raw PDF data.

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError (status code 400)
PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError (status code 400)
File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
Notification is not a letter Check that you are looking up the correct notification.
NoResultFound (status code 404)
No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a NotificationClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "ValidationError",
"message": "id is not a valid UUID"
}]
Check the notification ID
400 [{
"error": "ValidationError",
"message": "Notification is not a letter"
}]
Check that you are looking up the correct notification
400 [{
"error": "PDFNotReadyError",
"message": "PDF not available yet, try again later"
}]
Wait for the notification to finish processing. This usually takes a few seconds
400 [{
"error": "BadRequestError",
"message": "File did not pass the virus scan"
}]
You cannot retrieve the contents of a letter notification that contains a virus
400 [{
"error": "BadRequestError",
"message": "PDF not available for letters in technical-failure"
}]
You cannot retrieve the contents of a letter notification in technical-failure
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
404 [{
"error": "NoResultFound",
"message": "No result found"
}]
Check the notification ID

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError (status code 400)
PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError (status code 400)
File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
Notification is not a letter Check that you are looking up the correct notification.
NoResultFound (status code 404)
No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError (status code 400)
PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError (status code 400)
File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
Notification is not a letter Check that you are looking up the correct notification.
NoResultFound (status code 404)
No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError (status code 400)
PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError (status code 400)
File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
Notification is not a letter Check that you are looking up the correct notification.
NoResultFound (status code 404)
No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: id is not a valid UUID Check the notification ID.
ValidationError: Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError: PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError: File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
BadRequestError: PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
BadRequestError: Notification is not a letter Check that you are looking up the correct notification.
NotFoundError (status code 404)
NoResultFound: No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

ValidationError (status code 400)

id is not a valid UUID Check the notification ID.
Notification is not a letter Check that you are looking up the correct notification.
PDFNotReadyError (status code 400)
PDF not available yet, try again later Wait for the letter to finish processing. This usually takes a few seconds.
BadRequestError (status code 400)
File did not pass the virus scan You cannot retrieve the contents of a letter that contains a virus.
PDF not available for letters in technical-failure You cannot retrieve the contents of a letter in technical-failure.
Notification is not a letter Check that you are looking up the correct notification.
NoResultFound (status code 404)
No result found Check the notification ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a PDF for a letter, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get a template

Get a template

Get a template

Get a template

Get a template

Get a template

Get a template

Get a template by ID

Get a template by ID

Get a template by ID

Get a template by ID

Get a template by ID

Get a template by ID

Get a template by ID

Method

This returns the latest version of the template.

Template template = client.getTemplateById(templateId);

Method

This returns the latest version of the template.

TemplateResponse response = client.GetTemplateById(
    templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a"
);

Method

This returns the latest version of the template.

notifyClient
  .getTemplateById(templateId)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

This returns the latest version of the template.

$response = $notifyClient->getTemplate( 'templateId' );

Method

This returns the latest version of the template.

response = notifications_client.get_template(
  template_id="f33517ff-2a88-4f6e-b855-c550268ce08a"
)

Method

This returns the latest version of the template.

response = client.get_template_by_id(id)

Method

This returns the latest version of the template.

GET /v2/template/{template_id}

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

URL parameters

templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

String templateId='f33517ff-2a88-4f6e-b855-c550268ce08a';
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

let templateId = "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

For example:

template_id="f33517ff-2a88-4f6e-b855-c550268ce08a", # required UUID string
id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

"f33517ff-2a88-4f6e-b855-c550268ce08a"
template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

f33517ff-2a88-4f6e-b855-c550268ce08a

Response

If the request to the client is successful, the client returns a Template:

UUID id;
String name;
String templateType;
ZonedDateTime createdAt;
Optional<ZonedDateTime> updatedAt;
String createdBy;
int version;
String body;
Optional<String> subject;
Optional<Map<String, Object>> personalisation;
Optional<String> letterContactBlock;

Response

If the request to the client is successful, the client returns a TemplateResponse.

public String id;
public String name;
public String type;
public DateTime created_at;
public DateTime? updated_at;
public String created_by;
public int version;
public String body;
public String subject; // null if an sms message
public String letter_contact_block; // null if not a letter template or contact block not set for letter

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
    "name": "Pigeon registration - appointment email", // required string - template name
    "type": "sms / email / letter" , // required string
    "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
    "version": 2, // required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", // required string
    "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
}

Response

If the request to the client is successful, the client returns an array.

[
    "id" => "template_id",
    "type" => "sms|email|letter",
    "created_at" => "created at",
    "updated_at" => "updated at",
    "version" => "version",
    "created_by" => "someone@example.com",
    "body" => "body",
    "subject" => "null|email or letter subject",
    "letter_contact_block" => "null|letter_contact_block"
];

Response

If the request to the client is successful, the client returns a dict.

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", # required string - template ID
    "name": "Pigeon registration - appointment email", # required string - template name
    "type": "sms / email / letter" , # required string
    "created_at": "2024-05-10 10:30:31.142535", # required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", # required string - date and time template last updated
    "version": 2, # required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", # required string
    "subject": "Your upcoming pigeon registration appointment",  # required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" # optional string - present for letter templates where contact block is set, otherwise None
}

Response

If the request to the client is successful, the client returns a Notifications::Client::Template object. In the example shown in the Method section, the object is named response.

You can then call different methods on this object to return the requested information.

Method Information Type
response.id Template UUID String
response.name Template name String
response.type Template type (email/sms/letter) String
response.created_at Date and time template created String
response.updated_at Date and time template last updated (may be nil if version 1) String
response.created_by Email address of person that created the template String
response.version Template version String
response.body Template content String
response.subject Template subject (email and letter) String
response.letter_contact_block Template letter contact block (letter) String

Response

If the request is successful, the response body is json and the status code is 200.

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
    "name": "Pigeon registration - appointment email", // required string - template name
    "type": "sms / email / letter" , // required string
    "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
    "version": 2, // required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", // required string
    "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "ValidationError",
"message": "id is not a valid UUID"
}]
Check the notification ID
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
404 [{
"error": "NoResultFound",
"message": "No Result Found"
}]
Check your template ID

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NotFoundError (status code 404)

NoResultFound: No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get a template by ID and version

Get a template by ID and version

Get a template by ID and version

Get a template by ID and version

Get a template by ID and version

Get a template by ID and version

Get a template by ID and version

Method

Template template = client.getTemplateVersion(templateId, version);

Method

TemplateResponse response = client.GetTemplateByIdAndVersion(
    templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a",
    version: 1   // integer required for version number
);

Method

notifyClient
  .getTemplateByIdAndVersion(templateId, version)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

$response = $notifyClient->getTemplateVersion( 'templateId', 1 );

Method

response = notifications_client.get_template_version(
    template_id="f33517ff-2a88-4f6e-b855-c550268ce08a",
    version=1,
)

Method

response = client.get_template_version(id, version)

Method

GET /v2/template/{template_id}/version/{version}

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

URL parameters

templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

String templateId='f33517ff-2a88-4f6e-b855-c550268ce08a';
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

let templateId = "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

For example:

template_id="f33517ff-2a88-4f6e-b855-c550268ce08a", # required UUID string
id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

"f33517ff-2a88-4f6e-b855-c550268ce08a"
template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

f33517ff-2a88-4f6e-b855-c550268ce08a
version (required)

The version number of the template.

version (required)

The version number of the template.

version (required)

The version number of the template.

version (required)

The version number of the template.

version (required)

The version number of the template.

version (required)

The version number of the template.

version (required)

The version number of the template.

1

Response

If the request to the client is successful, the client returns a Template:

UUID id;
String name;
String templateType;
ZonedDateTime createdAt;
Optional<ZonedDateTime> updatedAt;
String createdBy;
int version;
String body;
Optional<String> subject;
Optional<Map<String, Object>> personalisation;
Optional<String> letterContactBlock;

Response

If the request to the client is successful, the client returns a TemplateResponse.

public String id;
public String name;
public String type;
public DateTime created_at;
public DateTime? updated_at;
public String created_by;
public int version;
public String body;
public String subject; // null if an sms message
public String letter_contact_block; // null if not a letter template or contact block not set for letter

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
    "name": "Pigeon registration - appointment email", // required string - template name
    "type": "sms / email / letter" , // required string
    "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
    "version": 1, // required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", // required string
    "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
}

Response

If the request to the client is successful, the client returns an array.

[
    "id" => "template_id",
    "type" => "sms|email|letter",
    "created_at" => "created at",
    "updated_at" => "updated at",
    "version" => "version",
    "created_by" => "someone@example.com",
    "body" => "body",
    "subject" => "null|email or letter subject",
    "letter_contact_block" => "null|letter_contact_block"
];

Response

If the request to the client is successful, the client returns a dict.

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", # required string - template ID
    "name": "Pigeon registration - appointment email", # required string - template name
    "type": "sms / email / letter" , # required string
    "created_at": "2024-05-10 10:30:31.142535", # required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", # required string - date and time template last updated
    "version": 1, # required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", # required string
    "subject": "Your upcoming pigeon registration appointment",  # required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" # optional string - present for letter templates where contact block is set, otherwise None
}

Response

If the request to the client is successful, the client returns a Notifications::Client::Template object. In the example shown in the Method section, the object is named response.

You can then call different methods on this object to return the requested information.

Method Information Type
response.id Template UUID String
response.name Template name String
response.type Template type (email/sms/letter) String
response.created_at Date and time template created String
response.updated_at Date and time template last updated (may be nil if it is the first version) String
response.created_by Email address of person that created the template String
response.version Template version String
response.body Template content String
response.subject Template subject (email and letter) String
response.letter_contact_block Template letter contact block (letter) String

Response

If the request is successful, the response body is json and the status code is 200.

{
    "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
    "name": "Pigeon registration - appointment email", // required string - template name
    "type": "sms / email / letter" , // required string
    "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
    "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
    "version": 1, // required integer - template version
    "created_by": "charlie.smith@pigeons.gov.uk", // required string
    "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
    "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
    "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "ValidationError",
"message": "id is not a valid UUID"
}]
Check the notification ID
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information
404 [{
"error": "NoResultFound",
"message": "No Result Found"
}]
Check your template ID and version

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

NotFoundError (status code 404)

NoResultFound: No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

NoResultFound (status code 404)

No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get all templates

Get all templates

Get all templates

Get all templates

Get all templates

Get all templates

Get all templates

Method

This returns the latest version of all templates.

TemplateList templates = client.getAllTemplates(templateType);

Method

This returns the latest version of all templates.

TemplateList response = client.GetAllTemplates(
    templateType: "sms" // optional
);

Method

This returns the latest version of all templates.

notifyClient
  .getAllTemplates(templateType)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

Method

This returns the latest version of all templates.

    $this->listTemplates(
      $template_type  // optional
    );

Method

This returns the latest version of all templates.

response = notifications_client.get_all_templates(
    template_type="sms / letter / email" # optional string
)

Method

This returns the latest version of all templates inside a collection object.

response = client.get_all_templates(type: "sms")

Method

This returns the latest version of all templates.

GET /v2/templates

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

Query parameters

templateType (optional)

If you do not use templateType, the client returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
templateType (optional)

If left out, the method returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
templateType (optional)

If you leave out this argument, the method returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
template_type (optional)

If omitted, the method returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
template_type (optional)

If you leave out this argument, the method returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
type (optional)

If you do not use type, the client returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter
template_type (optional)

If you leave out this argument, the method returns all templates. Otherwise you can filter by:

  • email
  • sms
  • letter

Response

If the request to the client is successful, the client returns a TemplateList:

List<Template> templates;

If no templates exist for a template type or there no templates for a service, the templates list is empty.

Response

If the request to the client is successful, the client returns a TemplateList.

List<TemplateResponse> templates;

If no templates exist for a template type or there no templates for a service, the client returns a TemplateList with an empty templates list element:

List<TemplateResponse> templates; // empty list of templates

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
    "templates": [
        {
            "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
            "name": "Pigeon registration - appointment email", // required string - template name
            "type": "sms / email / letter" , // required string
            "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
            "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
            "version": 2, // required integer - template version
            "created_by": "charlie.smith@pigeons.gov.uk", // required string
            "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
            "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
            "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
        },
        {
        //...another template
        }
    ]
}

If no templates exist for a template type or there no templates for a service, the object is empty.

Response

If the request to the client is successful, the client returns an array.

[
    "templates"  => [
        [
            "id" => "template_id",
            "type" => "sms|email|letter",
            "created_at" => "created at",
            "updated_at" => "updated at",
            "version" => "version",
            "created_by" => "someone@example.com",
            "body" => "body",
            "subject" => "null|email or letter subject",
            "letter_contact_block" => "null|letter_contact_block"
        ],
        [
            ... another template
        ]
    ]
];

If no templates exist for a template type or there no templates for a service, the client returns a dict with an empty templates list element:

[
    "templates"  => []
];

Response

If the request to the client is successful, the client returns a dict.

{
    "templates": [
        {
            "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", # required string - template ID
            "name": "Pigeon registration - appointment email", # required string - template name
            "type": "sms / email / letter" , # required string
            "created_at": "2024-05-10 10:30:31.142535", # required string - date and time template created
            "updated_at": "2024-08-25 13:00:09.123234", # required string - date and time template last updated
            "version": 2, # required integer - template version
            "created_by": "charlie.smith@pigeons.gov.uk", # required string
            "subject": "Your upcoming pigeon registration appointment",  # required string for email and letter - subject of email / heading of letter
            "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  # required string - body of notification
            "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" # optional string - present for letter templates where contact block is set, otherwise None
        },
        {
            ...another template
        }
    ]
}

If no templates exist for a template type or there no templates for a service, the client returns a dict with an empty templates list element:

{
    "templates": []
}

Response

If the request to the client is successful, the client returns a Notifications::Client::TemplateCollection object. In the example shown in the Method section, the object is named response.

You must then call the .collection method on this object to return an array of the required templates.

Once the client has returned a template array, you must then call the following methods on the templates in this array to return information on those templates.

Method Information Type
response.id Template UUID String
response.name Template name String
response.type Template type (email/sms/letter) String
response.created_at Date and time template created String
response.updated_at Date and time template last updated (may be nil if it is the first version) String
response.created_by Email address of person that created the template String
response.version Template version String
response.body Template content String
response.subject Template subject (email and letter) String
response.letter_contact_block Template letter contact block (letter) String

If no templates exist for a template type or there no templates for a service, the templates array will be empty.

Response

If the request is successful, the response body is json and the status code is 200.

{
    "templates": [
        {
            "id": "f33517ff-2a88-4f6e-b855-c550268ce08a", // required string - template ID
            "name": "Pigeon registration - appointment email", // required string - template name
            "type": "sms / email / letter" , // required string
            "created_at": "2024-05-10 10:30:31.142535", // required string - date and time template created
            "updated_at": "2024-08-25 13:00:09.123234", // required string - date and time template last updated
            "version": 2, // required integer - template version
            "created_by": "charlie.smith@pigeons.gov.uk", // required string
            "subject": "Your upcoming pigeon registration appointment",  // required string for email and letter - subject of email / heading of letter
            "body": "Dear ((first_name))\r\n\r\nYour pigeon registration appointment is scheduled for ((appointment_date)).\r\n\r\nPlease bring:\r\n\n\n((required_documents))\r\n\r\nYours,\r\nPigeon Affairs Bureau",  // required string - body of notification
            "letter_contact_block": "Pigeons Affairs Bureau\n10 Whitechapel High Street\nLondon\nE1 8EF" // optional string - present for letter templates where contact block is set, otherwise null
        },
        {
            ...another template
        }
    ]
}

If no templates exist for a template type or there no templates for a service, the API returns a json object with a templates key for an empty array:

{
    "templates": []
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

ValidationError: Template type is not one of [sms, email, letter] Check your template type.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to getting a template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Generate a preview template

Generate a preview template

Generate a preview template

Generate a preview template

Generate a preview template

Generate a preview template

Generate a preview template

Method

This generates a preview version of a template.

TemplatePreview templatePreview = client.generateTemplatePreview(
    templateId,
    personalisation
);

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client ignores any extra fields in the method.

Method

This generates a preview version of a template.

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"}
};

TemplatePreviewResponse response = client.GenerateTemplatePreview(
    templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a",
    personalisation: personalisation
);

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client ignores any extra fields in the method.

Method

This generates a preview version of a template.

notifyClient
  .previewTemplateById(templateId, personalisation)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client ignores any extra fields in the method.

Method

This generates a preview version of a template.

    $personalisation = [ "foo" => "bar" ];
    $this->previewTemplate( $templateId, $personalisation );

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client will ignore any extra fields in the method.

Method

This generates a preview version of a template.

response = notifications_client.post_template_preview(
    template_id="f33517ff-2a88-4f6e-b855-c550268ce08a",
    personalisation={
        "first_name": "Amala",
        "appointment_date": "1 January 2018 at 1:00pm",
    }
)

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client will ignore any extra fields in the method.

Method

This generates a preview version of a template.

response = client.generate_template_preview(id)

The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client ignores any extra fields in the method.

Method

This generates a preview version of a template.

POST /v2/template/{template_id}/preview

Arguments

Arguments

Arguments

Arguments

Arguments

Arguments

URL parameters

templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

String templateId='f33517ff-2a88-4f6e-b855-c550268ce08a';
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

string templateId: "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

let templateId = "f33517ff-2a88-4f6e-b855-c550268ce08a";
templateId (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

For example:

template_id="f33517ff-2a88-4f6e-b855-c550268ce08a", # required UUID string
id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it. For example:

"f33517ff-2a88-4f6e-b855-c550268ce08a"
template_id (required)

The ID of the template. Sign in to GOV.UK Notify and go to the Templates page to find it.

f33517ff-2a88-4f6e-b855-c550268ce08a
personalisation (required)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in a map. For example:

Map<String, Object> personalisation = new HashMap<>();
personalisation.put("first_name", "Amala");
personalisation.put("application_date", "2018-01-01");

If a template does not have any placeholder fields for personalised information, you must pass in an empty map or null.

personalisation (required)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a Dictionary. For example:

Dictionary<String, dynamic> personalisation = new Dictionary<String, dynamic>
{
    {"first_name", "Amala"},
    {"application_date", "1 January 2018 at 01:00PM"}
};

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (optional)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in an object. For example:

{
  personalisation: {
    "first_name": "Amala",
    "reference_number": "300241"
  }
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

personalisation (required)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

$personalisation = [
    'first_name' => 'Amala',
    'reference_number' => '300241',
];
personalisation (required)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

personalisation={
    "first_name": "Amala",
    "appointment_date": "1 January 2018 at 1:00pm",
    "required_documents": ["passport", "utility bill", "other id"],
},
personalisation (optional)

If a template has placeholder fields for personalised information such as name or application date, you must provide their values in a hash. For example:

personalisation: {
  name: "John Smith",
  ID: "300241",
}

You can leave out this argument if a template does not have any placeholder fields for personalised information.

Response

If the request to the client is successful, the client returns a TemplatePreview:

UUID id;
String templateType;
int version;
String body;
Optional<String> subject;
Optional<String> html;

Response

If the request to the client is successful, you receive a TemplatePreviewResponse response.

public String id;
public String type;
public int version;
public String body;
public String subject; // null if a sms message

Response

If the request is successful, the promise resolves with a response object. For example, the response.data property will look like this:

{
  "id": "notify_id",
  "type": "sms|email|letter",
  "version": "version",
  "body": "Hello bar", // with substitution values
  "subject": "null|email_subject",
  "html": "<p>Example</p>" // Returns the rendered body (email templates only)
}

Response

If the request to the client is successful, the client returns an array.

[
    "id" => "notify_id",
    "type" => "sms|email|letter",
    "version" => "version",
    "body" => "Hello bar" // with substitution values,
    "subject" => "null|email_subject"
];

Response

If the request to the client is successful, you receive a dict response.

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a", # required string - notification ID
    "type": "sms / email / letter" , # required string
    "version": 3,
    # required string - body of notification
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00pm.\r\n\r\n Here is a link to your invitation document:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nPlease bring the invite with you to the appointment.\r\n\r\nYours,\r\nPigeon Affairs Bureau",
    # required string for emails, empty for sms and letters - html version of the email body
    "html": '<p style="Margin: 0 0 20px 0; font-size: 19px; line-height: 25px; color: #0B0C0C;">Dear Amala</p> ... [snippet truncated for readability]',
    # required string for email and letter - subject of email / heading of letter
    "subject": 'Your upcoming pigeon registration appointment',
    'postage': None, # required string for letters, empty for sms and emails - letter postage
}

Response

If the request to the client is successful, the client returns a Notifications::Client::TemplatePreview object. In the example shown in the Method section, the object is named response.

You can then call different methods on this object to return the requested information.

Method Information Type
response.id Template UUID String
response.version Template version String
response.body Template content String
response.subject Template subject (email and letter) String
response.type Template type (sms/email/letter) String
response.html Body as rendered HTML (email only) String

Request body

{
  "personalisation": {
    "first_name": "Amala",
    "appointment_date": "1 January 2018 at 1:00pm",
  }
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NoResultFound (status code 404)
No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
400 [{
"error": "BadRequestError",
"message": "Missing personalisation: [PERSONALISATION FIELD]"
}]
Check that the personalisation arguments in the method match the placeholder fields in the template
400 [{
"error": "NoResultFound",
"message": "No result found"
}]
Check the template ID
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NoResultFound (status code 404)
No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NoResultFound (status code 404)
No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NoResultFound (status code 404)
No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

BadRequestError: Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NotFoundError (status code 404)
NoResultFound: No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Arguments

personalisation (required)

If a template has placeholder fields for personalised information such as name or reference number, you need to provide their values in a dictionary with key value pairs. For example:

{
  "personalisation": {
    "first_name": "Amala",
    "appointment_date": "1 January 2018 at 1:00PM",
    "required_documents": ["passport", "utility bill", "other id"],
  }
}

The keys in the personalisation argument must match the placeholder fields in the actual template. The API will ignore any extra keys in the personalisation argument.

Response

If the request is successful, the response body is json and the status code is 200.

{
    "id": "740e5834-3a29-46b4-9a6f-16142fde533a", // required string - notification ID
    "type": "sms / email / letter" , // required string
    "version": 3,
    // required string - body of notification
    "body": "Dear Amala\r\n\r\nYour pigeon registration appointment is scheduled for 1 January 2018 at 1:00PM.\r\n\r\n Here is a link to your invitation document:\r\n\n\n* passport\n* utility bill\n* other id\r\n\r\nPlease bring the invite with you to the appointment.\r\n\r\nYours,\r\nPigeon Affairs Bureau",
    // required string for emails, empty for sms and letters - html version of the email body
    "html": '<p style="Margin: 0 0 20px 0; font-size: 19px; line-height: 25px; color: #0B0C0C;">Dear Amala</p> ... [snippet truncated for readability]',
    // required string for email and letter - subject of email / heading of letter
    "subject": 'Your upcoming pigeon registration appointment',
    'postage': null, // required string for letters, empty for sms and emails - letter postage
}

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

Error message How to fix

BadRequestError (status code 400)

Missing personalisation: [PERSONALISATION FIELD] Check that the personalisation arguments in the method match the placeholder fields in the template.
NoResultFound (status code 404)
No Result Found Check your template ID.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThanId argument.

You can only get messages that are 7 days old or newer.

You can also set up callbacks for received text messages.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThanId argument.

You can only get the status of messages that are 7 days old or newer.

You can also set up callbacks for received text messages.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the olderThan argument.

You can only get messages that are 7 days old or newer.

You can also set up callbacks for received text messages.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get the status of messages that are 7 days old or newer.

You can also set up callbacks for received text messages.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get the status of messages that are 7 days old or newer.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than argument.

You can only get the status of messages that are 7 days old or newer.

You can also set up callbacks for received text messages.

Get received text messages

This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the older_than query parameter.

You can only get the status of messages that are 7 days old or newer.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Enable received text messages

To receive text messages:

  1. Go to the Text message settings section of the Settings page.
  2. Select Change on the Receive text messages row.

Get a page of received text messages

Get a page of received text messages

Get a page of received text messages

Get a page of received text messages

Get all received text messages

This will return a Python iterator object which yields one received text message at a time until it has yielded all your received text messages.

Get a page of received text messages

Get a page of received text messages

Method

ReceivedTextMessageList response = client.getReceivedTextMessages(olderThanId);

To get the most recent messages, you must pass in an empty argument or null.

To get older messages, pass the ID of an older notification into the olderThanId argument. This returns the next oldest messages from the specified notification ID.

Method

ReceivedTextListResponse response = client.GetReceivedTexts(olderThanId: "e194efd1-c34d-49c9-9915-e4267e01e92e");

Method

notifyClient
  .getReceivedTexts(olderThan)
  .then((response) => console.log(response))
  .catch((err) => console.error(err))

The method returns a promise. The promise will either:

  • resolve with a response if successful
  • fail with an err if unsuccessful

To get the most recent messages, you must pass in an empty argument or null.

To get older messages, pass the ID of an older notification into the olderThan argument. This returns the next oldest messages from the specified notification ID.

Method

    $this->listReceivedTexts(
      $older_than  // optional
    );

To get older messages, pass the ID of an older notification into the older_than argument. This returns the next 250 oldest messages from the specified notification ID.

If you leave out the older_than argument, the client returns the most recent 250 notifications.

Method

response = notifications_client.get_received_texts_iterator()

# to iterate and process the received text messages using the iterator:
for text_message in response:
    # process received text message

Method

response = client.get_received_texts(
  older_than: "e194efd1-c34d-49c9-9915-e4267e01e92e",
)

To get older messages, pass the ID of an older notification into the older_than argument. This returns the next oldest messages from the specified notification ID.

If you leave out the older_than argument, the client returns the most recent 250 notifications.

Method

GET /v2/received-text-messages

You can specify which text messages to receive by inputting the ID of a received text message into the older_than argument.

Arguments

Arguments

Arguments

Arguments

Response

If the request to the client is successful, the client will return a <generator object> that will return all received text messages.

<generator object NotificationsAPIClient.get_received_texts_iterator at 0x1026c7410>

Arguments

Query parameters

olderThanId (optional)

Input the ID of a received text message into this argument. If you use this argument, the client returns the next 250 received text messages older than the given ID.

String olderThanId='8e222534-7f05-4972-86e3-17c5d9f894e2'

If you pass in an empty argument or null, the client returns the most recent 250 text messages.

olderThanId (optional)

Input the ID of a notification into this argument to return the next 250 received notifications older than the given ID. For example:

olderThanId: "740e5834-3a29-46b4-9a6f-16142fde533a"

If you leave out the olderThanId argument, the client returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty ReceivedTextListResponse response.

olderThan (optional)

Input the ID of a received text message into this argument. If you use this argument, the client returns the next 250 received text messages older than the given ID. For example:

let olderThan = "740e5834-3a29-46b4-9a6f-16142fde533a";

If you pass in an empty argument or null, the client returns the most recent 250 text messages.

older_than (optional)

Input the ID of a received text message into this argument. If you use this argument, the client returns the next 250 received text messages older than the given ID. For example:

$older_than = '8e222534-7f05-4972-86e3-17c5d9f894e2'

If you leave out the older_than argument, the client returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty collection response.

older_than (optional)

Input the ID of a received text message into this argument. If you use this argument, the client returns the next 250 received text messages older than the given ID. For example:

older_than: "8e222534-7f05-4972-86e3-17c5d9f894e2"

If you leave out the older_than argument, the client returns the most recent 250 notifications.

The client only returns notifications that are 7 days old or newer. If the notification specified in this argument is older than 7 days, the client returns an empty collection response.

older_than (optional)

Input the ID of a received text message into this argument. If you use this argument, the method returns the next 250 received text messages older than the given ID.

?older_than=740e5834-3a29-46b4-9a6f-16142fde533a // optional string - notification ID

Response

If the request to the client is successful, the client returns a ReceivedTextMessageList that returns all received texts.

private List<ReceivedTextMessage> receivedTextMessages;
private String currentPageLink;
private String nextPageLink;

The ReceivedTextMessageList has the following properties:

private UUID id;
private String notifyNumber;
private String userNumber;
private UUID serviceId;
private String content;
private ZonedDateTime createdAt;

If the notification specified in the olderThanId argument is older than 7 days, the client returns an empty response.

Response

If the request to the client is successful, the client returns a ReceivedTextListResponse that returns all received text messages.

public List<ReceivedText> receivedTextList;
public Link links;

public class Link {
           public String current;
           public String next;
}
public String id;
public String userNumber;
public String createdAt;
public String serviceId;
public String notifyNumber;
public String content;

If the notification specified in the olderThanId argument is older than 7 days, the client returns an empty ReceivedTextListResponse response.

Response

If the request to the client is successful, the promise resolves with an object containing all received texts.

{
    "received_text_messages":
    [
        {
            "id": "b51f638b-4295-46e0-a06e-cd41eee7c33b", // required string - ID of received text message
            "user_number": "447700900123", // required string - number of the end user who sent the message
            "notify_number": "07700900456", // required string - your receiving number
            "created_at": "2024-12-12 18:39:16.123346", // required string - date and time template created
            "service_id": "26785a09-ab16-4eb0-8407-a37497a57506", // required string - service ID
            "content": "STRING" // required string - text content
        },
        {
            //...another received text message
        }
    ],
    "links": {
        "current": "/received-text-messages",
        "next": "/received-text-messages?other_than=last_id_in_list"
    }
}

If the notification specified in the olderThan argument is older than 7 days, the promise resolves an empty response.

Response

If the request to the client is successful, the client returns an array.

[
    "received_text_messages" => [
        [
            "id" => "notify_id",
            "user_number" => "user number",
            "notify_number" => "notify number",
            "created_at" => "created at",
            "service_id" => "service id",
            "content" => "text content"
        ],
        [
            ... another received text message
        ]
    ]
  ],
  "links" => [
     "current" => "/received-text-messages",
     "next" => "/received-text-messages?older_than=last_id_in_list"
  ]
];

Response

If the request to the client is successful, the client returns a Notifications::Client::ReceivedTextCollection object. In the example shown in the Method section, the object is named response.

You must then call either the .links method or the .collection method on this object.

Method Information
response.links Returns a hash linking to the requested texts (limited to 250)
response.collection Returns an array of the required texts

If you call the collection method on this object to return an array, you must then call the following methods on the received texts in this array to return information on those texts:

Method Information Type
response.id Received text UUID String
response.created_at Date and time of received text String
response.content Received text content String
response.notify_number Number that received text was sent to String
response.service_id Received text service ID String
response.user_number Number that received text was sent from String

If the notification specified in the older_than argument is older than 7 days, the client returns an empty collection response.

Response

If the request is successful, the response body is json and the status code is 200.

{
  "received_text_messages":
  [
    {
      "id": "'b51f638b-4295-46e0-a06e-cd41eee7c33b", // required string - ID of received text message
      "user_number": "447700900123", // required string - number of the end user who sent the message
      "notify_number": "07700900456", // required string - your receiving number
      "created_at": "2024-12-12 18:39:16.123346", // required string - date and time template created
      "service_id": "26785a09-ab16-4eb0-8407-a37497a57506", // required string - service ID
      "content": "STRING" // required string - text content
    },
    {
      ...another received text message
    }
  ],
  "links": {
    "current": "https://api.notifications.service.gov.uk/v2/received-text-messages",
    "next": "https://api.notifications.service.gov.uk/v2/received-text-messages?other_than=last_id_in_list"
  }
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns a Notify.Exceptions.NotifyClientException containing the relevant error code.

Status code Message How to fix
403 [{
"error": "AuthError",
"message": "Error: Your system clock must be accurate to within 30 seconds"
}]
Check your system clock
403 [{
"error": "AuthError",
"message": "Invalid token: API key not found"
}]
Use the correct API key. Refer to API keys for more information

Error codes

If the request is not successful, the promise fails with an err. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Error codes

If the request is not successful, the API returns json containing the relevant error code. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Get a page of received text messages

This will return one page of up to 250 text messages.

Method

response = notifications_client.get_received_texts(older_than="740e5834-3a29-46b4-9a6f-16142fde533a")

You can specify which text messages to receive by inputting the ID of a received text message into the older_than argument.

Arguments

older_than (optional)

Input the ID of a received text message into this argument. If you use this argument, the method returns the next 250 received text messages older than the given ID.

older_than="740e5834-3a29-46b4-9a6f-16142fde533a" # optional string - notification ID

If you leave out this argument, the method returns the most recent 250 text messages.

Response

If the request to the client is successful, the client returns a dict.

{
  "received_text_messages":
  [
    {
      "id": "'b51f638b-4295-46e0-a06e-cd41eee7c33b", # required string - ID of received text message
      "user_number": "447700900123", # required string - number of the end user who sent the message
      "notify_number": "07700900456", # required string - your receiving number
      "created_at": "2024-12-12 18:39:16.123346", # required string - date and time template created
      "service_id": "26785a09-ab16-4eb0-8407-a37497a57506", # required string - service ID
      "content": "STRING" # required string - text content
    },
    {
      ...another received text message
    }
  ],
  "links": {
    "current": "/received-text-messages",
    "next": "/received-text-messages?other_than=last_id_in_list"
  }
}

Error codes

If the request is not successful, the client returns an error. To learn more about error structure, go to Errors section.

There are no errors specific to this endpoint, but you may encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.
  • errors that are not related to generating a preview template, but instead are related to things like authentication and rate limits. You can find a list of these errors in General errors

Errors

Error messages

Error messages consist of:

  • a status_code, for example ‘400’
  • an error, for example ’BadRequestError’
  • a message, for example ‘Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -‘

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status_code or the error instead, as these will not change.

Find error codes in:

Errors

Errors

Errors

Errors

Errors

Error handling

If the request is not successful, the client raises an NotificationClientException.

This error consists of:

  • a status code, for example 400
  • an error type, for example BadRequestError
  • a message, for example Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -

To access these details about the exception, read its getHttpResult() and getMessage() methods, for example:

    SendSmsResponse response;
    try {
        response = client.sendSms(
            templateId,
            phoneNumber,
            personalisation,
            reference,
            smsSenderId
        );
        System.out.println(response);
    } catch (NotificationClientException e) {
        if (e.getHttpResult() >= 500) {
            //retry logic
        } else {
            System.out.printf(e.getMessage());
        }
    }

Exception’s getMessage() method returns a String, for example:

Status code: 403 {"errors":[{"error":"AuthError","message":"Invalid token: API key not found"}],"status_code":403}

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

Error handling

If the request is not successful, the promise fails with an err.

  • a status code, for example 400
  • an error type, for example BadRequestError
  • a message, for example Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -

These details about the error can be accessed by reading err.response.data which is json, for example:

{
  errors: [
    {
      error: 'BadRequestError',
      message: 'Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -'
    }
  ],
  status_code: 400
}

A simple illustration of error handling:

notifyClient.sendSms("f33517ff-2a88-4f6e-b855-c550268ce08a", "+447700900123", {
    personalisation: {
                        first_name: "Amala",
                        appointment_date: "1 January 2018 at 1:00pm"
                       },
    reference: "your reference",
    smsSenderId: "445f705f-e394-445d-a5a0-1c80ab958e22"
  })
  .then(response => console.log(response))
  .catch(err => {
      if (err.response.data.status_code >= 500 && err.response.data.status_code <= 599){
          // retry logic;
      }
      else {
        console.log(err.response.data.errors[0]);
      }
})

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

Error handling

If the request is not successful, the client raises an Alphagov\Notifications\Exception\ApiException object.

This error consists of:

  • a status code, for example 400
  • an error type, for example BadRequestError
  • a message, for example Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -

To access these details about the error, read its $e->getCode() and $e->getErrors() fields, for example:

try {
    $response = $notifyClient->sendSms('+447700900123', 'bb323ab6-a6ca-4d38-9450-09cd5b782cc5');
} catch (Exception $e){
    if ($e->getCode() >= 500) { // using status code for error handling
        // Retry logic goes here
    } else {
        print_r($e->getErrors(), $return = false); // accessing error details to debug
    };
};

Error’s $e->getErrors() field is a Array of arrays, for example:

Array
(
    [0] => Array
        (
            [error] => BadRequestError
            [message] => Template not found
        )

)

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

Error handling

If the request is not successful, the client raises an HTTPError.

This error consists of:

  • a status code, for example 400
  • an error type, for example BadRequestError
  • a message, for example Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -

To access these details about the error, read its status_code and message fields, for example:

from notifications_python_client.errors import HTTPError

try:
  response = notifications_client.send_sms_notification(
    phone_number="+447700900123",
    template_id="f33517ff-2a88-4f6e-b855-c550268ce08a",
  )
except HTTPError as e:
  if e.status_code in range(500, 599):  # using status code for error handling
    self.retry()
  else:
    print(e.message)  # accessing error details to debug

Error’s message field is a dict, for example:

[{
  "error": "AuthError",
  "message": "Invalid token: API key not found",
}]

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

Error handling

If the request is not successful, the client raises a Notifications::Client::RequestError exception (or a subclass).

This error consists of:

  • a status code, for example 400
  • an error class, for example BadRequestError
  • a message, for example Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -

To access these details about the error, read its error.code, error.class, and error.message fields, for example:

require_relative "lib/notifications/client/request_error"

begin
  response = client.send_sms(
    phone_number: "+447700900123",
    template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
  )
rescue Notifications::Client::RequestError => e
  if (500..599).include? e.code  # using status code for error handling
    # retry logic goes here
  else
    puts e.message  # accessing error details to debug
  end
else
    # unexpected error, raise!
end

Error’s message field is a string, for example:

"BadRequestError: Template not found"

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

Error handling

If the request is not successful, the API returns json containing:

  • a status code, for example 403
  • an error type, for example AuthError
  • a message, for example Invalid token: service not found

For example:

{
    "errors": [
        {
            "error": "AuthError",
            "message": "Invalid token: service not found"
        }
    ],
    "status_code": 403
}

Do not use the content of the messages in your code. These can sometimes change, which may affect your API integration.

Use the status code or the error type instead, as these will not change.

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
BadRequestError (status code 403)
Error: Your system clock must be accurate to within 30 seconds Check your system clock
Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError (status code 429)
Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
Exception (status code 500)
Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
BadRequestError (status code 403)
Error: Your system clock must be accurate to within 30 seconds Check your system clock
Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError (status code 429)
Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
Exception (status code 500)
Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
BadRequestError (status code 403)
Error: Your system clock must be accurate to within 30 seconds Check your system clock
Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError (status code 429)
Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
Exception (status code 500)
Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
BadRequestError (status code 403)
Error: Your system clock must be accurate to within 30 seconds Check your system clock
Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError (status code 429)
Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
Exception (status code 500)
Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
BadRequestError: Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
BadRequestError: Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
AuthError (status code 403)
BadRequestError: Error: Your system clock must be accurate to within 30 seconds Check your system clock
BadRequestError: Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
RateLimitError: Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError: Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
ServerError (status code 500)
Exception: Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

General errors

You may encounter following errors when making requests to a number of Notify’s API endpoints.

Error message How to fix
BadRequestError (status code 400)
Cannot send to this recipient using a team-only API key. Use a live API key, or add recipient to Guest list (located in API Integration section)
Cannot send to this recipient when service is in trial mode – see https://www.notifications.service.gov.uk/trial-mode You need to request for your service to go live before you can send messages to people outside your team.
BadRequestError (status code 403)
Error: Your system clock must be accurate to within 30 seconds Check your system clock
Invalid token: API key not found Use the correct API key. Refer to API keys for more information
RateLimitError (status code 429)
Exceeded rate limit for key type <team/test/live> of 3000/<custom limit> requests per 60 seconds Refer to API rate limits for more information
TooManyRequestsError (status code 429)
Exceeded send limits (<sms/email/letter/international_sms>: <LIMIT SIZE>) for today Refer to service limits for the limit size
Exception (status code 500)
Internal server error Notify was unable to process the request, resend your notification.

In addition to the above, you may also encounter:

  • various schema validation errors, for example when you forget to pass in an argument, or pass in an argument of a wrong type.

  • endpoint-specific errors, which are listed under each relevant API endpoint section.

Find references for endpoint-specific errors in:

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Testing

All testing takes place in the production environment. There is no test environment for GOV.UK Notify.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Smoke testing

If you need to smoke test your integration with Notify on a regular basis, you must use the following smoke test phone numbers and email addresses.

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Phone numbers

  • 07700900000
  • 07700900111
  • 07700900222

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Email addresses

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk

The smoke test phone numbers and email addresses will validate the request and simulate a successful response, but will not send a real message, produce a delivery receipt or persist the notification to the database.

You can use these smoke test numbers and addresses with any type of API key.

You can smoke test all Notify API client functions except:

  • Get the status of one message
  • Get the status of all messages

You cannot use the smoke test phone numbers or email address with these functions because they return a fake notification_ID. If you need to test these functions, use a test API key and any other phone number or email.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

Other testing

You must use a test API key to do non-smoke testing such as performance or integration testing. You can use any non-smoke testing phone numbers or email addresses. You do not need a specific Notify testing account.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

API keys

There are three different types of API keys:

  • test
  • team and guest list
  • live

When you set up a new service it will start in trial mode. A service in trial mode can create test and team and guest list keys. You must have a live service to create a live key.

To create an API key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Create an API key.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Test

Use a test key to test the performance of your service and its integration with GOV.UK Notify.

Messages sent using a test key:

  • generate realistic responses
  • result in a delivered status
  • are not actually delivered to a recipient
  • do not appear on your dashboard
  • do not count against your text message and email allowances

To test failure responses with a test key, use the following numbers and addresses:

Phone number/Email address Response
07700900003 temporary-failure
07700900002 permanent-failure
temp-fail@simulator.notify temporary-failure
perm-fail@simulator.notify permanent-failure
any other valid number or address delivered

You do not have to revoke test keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Team and guest list

A team and guest list key lets you send real messages to your team members and addresses/numbers on your guest list while your service is still in trial mode.

You will get an error if you use these keys to send messages to anyone who is not on your team or your guest list.

Messages sent with a team and guest list key appear on your dashboard and count against your text message and email allowances.

You do not have to revoke team and guest list keys.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Live

You can only create live keys once your service is live. You can use live keys to send messages to anyone.

Messages sent with a live key appear on your dashboard and count against your text message and email allowances.

You should revoke and re-create these keys on a regular basis. To revoke a key:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select API keys.
  4. Select Revoke for the API key you want to revoke.

You can have more than one active key at a time.

You should never send test messages to invalid numbers or addresses using a live key.

Limits

Limits

Limits

Limits

Limits

Limits

Limits

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Rate limits

You’re limited to sending 3,000 messages per minute.

This limit is calculated on a rolling basis, per API key type. If you exceed the limit, you will get a 429 error RateLimitError.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Daily limits

There’s a limit to the number of messages you can send each day:

Service status Type of API key Daily limit
Live Team or live
  • 250,000 emails
  • 250,000 text messages, including a default 100 international text messages
  • 20,000 letters
Trial Team 50 emails or text messages
Live or trial Test Unlimited

GP surgeries cannot send any text messages in trial mode.

These limits reset at midnight UTC.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Phone network limits

If you repeatedly send text messages to the same number the phone networks will block them.

There’s an hourly limit of:

  • 20 messages with the same content
  • 100 messages with any content

Your messages may not be delivered if you exceed these limits.

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Callbacks

Callbacks are when GOV.UK Notify sends POST requests to your service. You can get callbacks when:

  • a text message or email you’ve sent is delivered or fails
  • your service receives a text message
  • a letter you sent is returned

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Set up callbacks

You must provide:

  • a URL where Notify will post the callback to
  • a bearer token which Notify will put in the authorisation header of the requests

To do this:

  1. Sign in to GOV.UK Notify.
  2. Go to the API integration page.
  3. Select Callbacks.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Retry callbacks

If Notify sends a POST request to your service, but the request fails then we will retry.

We will retry every 5 minutes, up to a maximum of 5 times.

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Delivery receipts

When you send an email or text message, Notify will send a receipt to your callback URL with the status of the message. This is an automated method to get the status of messages.

This functionality works with test API keys, but does not work with smoke testing phone numbers or email addresses.

The callback message is formatted in JSON. All of the values are strings, apart from the template version, which is a number. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the status receipts UUID
reference The reference sent by the service 12345678 or null
to The email address or phone number of the recipient hello@gov.uk or 07700912345
status The status of the notification delivered, permanent-failure, temporary-failure or technical-failure
created_at The time the service sent the request 2017-05-14T12:15:30.000000Z
completed_at The last time the status was updated 2017-05-14T12:15:30.000000Z or null
sent_at The time the notification was sent 2017-05-14T12:15:30.000000Z or null
notification_type The notification type email or sms
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Received text messages

If your service receives text messages in Notify, Notify can forward them to your callback URL as soon as they arrive.

Find out how to let people send text messages to your service.

The callback message is formatted in JSON. All of the values are strings. The key, description and format of the callback message arguments will be:

Key Description Format
id Notify’s id for the received message UUID
source_number The phone number the message was sent from 447700912345
destination_number The number the message was sent to (your number) 07700987654
message The received message Hello Notify!
date_received The UTC datetime that the message was received by Notify 2017-05-14T12:15:30.000000Z

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

Returned letters

When a letter you sent is returned, Notify will send details of the returned letter to your callback URL.

Find more information about returned letters. It can take a few weeks to receive information about a returned letter.

The callback message is formatted in JSON. The key, description and format of the callback message arguments will be:

Key Description Format
notification_id Notify’s ID for the returned letter UUID
reference The reference sent by the service 12345678 or null
date_sent The time the letter was sent 2017-05-14T12:15:30.000000Z
sent_by The email address of the service member who sent the letter hello@gov.uk or null
template_name The name of the template that was used Template name
template_id The id of the template that was used UUID
template_version The version number of the template that was used 1
spreadsheet_file_name The name of the uploaded spreadsheet contact_list.csv or null
spreadsheet_row_number The row in the spreadsheet 2 or null
upload_letter_file_name The name of the uploaded letter uploaded_letter.pdf or null

API architecture

API architecture

API architecture

API architecture

API architecture

API architecture

API architecture

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a text message

  1. The service sends a text message notification to Notify.
  2. Notify sends the text message to the provider.
  3. The provider delivers the text message to the recipient.
  4. The recipient receives the text message and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending an email

  1. The service sends an email notification to Notify.
  2. Notify sends the email to the provider.
  3. The provider delivers the email to the recipient.
  4. The recipient receives the email and sends a delivery receipt to the provider.
  5. The provider sends the delivery receipt to Notify.
  6. Notify receives the delivery receipt and sends an API response to the service.
  7. The service receives the API response.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for sending a letter

  1. The service sends a letter notification to Notify.
  2. Notify sends the letter to the provider.
  3. The provider prints the letter and posts it.
  4. The postal service delivers the letter.
  5. The recipient receives the letter.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting the status of a message

  1. The service requests a notification status from Notify.
  2. Notify queries the database and retrieves the notification status.
  3. Notify sends the API response with the notification status to the service.
  4. The service receives the API response.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.

Architecture for getting received text messages

  1. Recipients send text messages.
  2. Notify receives the text messages.
  3. The service requests all or specific received text messages from Notify.
  4. Notify receives the request for received text messages.
  5. Notify sends the received text messages to the service.
  6. The service receives the received text messages.