notifications-ruby-client 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +1 -0
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +26 -21
- data/DOCUMENTATION.md +390 -291
- data/Dockerfile +3 -0
- data/Makefile +11 -44
- data/lib/notifications/client/helper_methods.rb +7 -2
- data/lib/notifications/client/version.rb +1 -1
- data/scripts/run_with_docker.sh +22 -0
- metadata +5 -4
- data/bin/generate_docker_env.sh +0 -29
data/DOCUMENTATION.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
This documentation is for developers interested in using the GOV.UK Notify Ruby client to send emails, text messages or letters.
|
4
4
|
|
5
|
-
|
5
|
+
## Set up the client
|
6
6
|
|
7
|
-
|
7
|
+
### Install the client
|
8
8
|
|
9
9
|
Run the following in the command line:
|
10
10
|
|
@@ -14,7 +14,7 @@ gem install 'notifications-ruby-client'
|
|
14
14
|
|
15
15
|
Refer to the [client changelog](https://github.com/alphagov/notifications-ruby-client/blob/master/CHANGELOG.md) for the version number and the latest updates.
|
16
16
|
|
17
|
-
|
17
|
+
### Create a new instance of the client
|
18
18
|
|
19
19
|
Add this code to your application:
|
20
20
|
|
@@ -25,13 +25,13 @@ client = Notifications::Client.new(api_key)
|
|
25
25
|
|
26
26
|
To get an API key, [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page. You can find more information in the [API keys](#api-keys) section of this documentation.
|
27
27
|
|
28
|
-
|
28
|
+
## Send a message
|
29
29
|
|
30
30
|
You can use GOV.UK Notify to send text messages, emails or letters.
|
31
31
|
|
32
|
-
|
32
|
+
### Send a text message
|
33
33
|
|
34
|
-
|
34
|
+
#### Method
|
35
35
|
|
36
36
|
```ruby
|
37
37
|
smsresponse = client.send_sms(
|
@@ -40,9 +40,9 @@ smsresponse = client.send_sms(
|
|
40
40
|
)
|
41
41
|
```
|
42
42
|
|
43
|
-
|
43
|
+
#### Arguments
|
44
44
|
|
45
|
-
|
45
|
+
##### phone_number (required)
|
46
46
|
|
47
47
|
The phone number of the text message recipient. This can be a UK or international number. For example:
|
48
48
|
|
@@ -50,7 +50,7 @@ The phone number of the text message recipient. This can be a UK or internationa
|
|
50
50
|
phone_number:"+447900900123"
|
51
51
|
```
|
52
52
|
|
53
|
-
|
53
|
+
##### template_id (required)
|
54
54
|
|
55
55
|
To find the template ID:
|
56
56
|
|
@@ -64,7 +64,7 @@ For example:
|
|
64
64
|
template_id:"f33517ff-2a88-4f6e-b855-c550268ce08a"
|
65
65
|
```
|
66
66
|
|
67
|
-
|
67
|
+
##### personalisation (optional)
|
68
68
|
|
69
69
|
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:
|
70
70
|
|
@@ -77,7 +77,7 @@ personalisation: {
|
|
77
77
|
|
78
78
|
You can leave out this argument if a template does not have any placeholder fields for personalised information.
|
79
79
|
|
80
|
-
|
80
|
+
##### reference (optional)
|
81
81
|
|
82
82
|
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:
|
83
83
|
|
@@ -87,7 +87,7 @@ reference: "your_reference_string"
|
|
87
87
|
|
88
88
|
You can leave out this argument if you do not have a reference.
|
89
89
|
|
90
|
-
|
90
|
+
##### sms_sender_id (optional)
|
91
91
|
|
92
92
|
A unique identifier of the sender of the text message notification.
|
93
93
|
|
@@ -111,7 +111,7 @@ sms_sender_id: "8e222534-7f05-4972-86e3-17c5d9f894e2"
|
|
111
111
|
|
112
112
|
You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.
|
113
113
|
|
114
|
-
|
114
|
+
#### Response
|
115
115
|
|
116
116
|
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#method), the object is named `smsresponse`.
|
117
117
|
|
@@ -119,17 +119,17 @@ You can then call different methods on this object:
|
|
119
119
|
|
120
120
|
|Method|Information|Type|
|
121
121
|
|:---|:---|:---|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
|#`smsresponse.id`|Notification UUID|String|
|
123
|
+
|#`smsresponse.reference`|`reference` argument|String|
|
124
|
+
|#`smsresponse.content`|- `body`: Message body sent to the recipient<br>- `from_number`: SMS sender number of your service|Hash|
|
125
|
+
|#`smsresponse.template`|Contains the `id`, `version` and `uri` of the template|Hash|
|
126
|
+
|#`smsresponse.uri`|Notification URL|String|
|
127
127
|
|
128
128
|
If you are using the [test API key](#test), all your messages come back with a `delivered` status.
|
129
129
|
|
130
130
|
All messages sent using the [team and guest list](#team-and-guest-list) or [live](#live) keys appear on your GOV.UK Notify dashboard.
|
131
131
|
|
132
|
-
|
132
|
+
#### Error codes
|
133
133
|
|
134
134
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
135
135
|
|
@@ -143,9 +143,9 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
143
143
|
|`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](#daily-limits) for the limit number|
|
144
144
|
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
|
145
145
|
|
146
|
-
|
146
|
+
### Send an email
|
147
147
|
|
148
|
-
|
148
|
+
#### Method
|
149
149
|
|
150
150
|
```ruby
|
151
151
|
emailresponse = client.send_email(
|
@@ -154,9 +154,9 @@ emailresponse = client.send_email(
|
|
154
154
|
)
|
155
155
|
```
|
156
156
|
|
157
|
-
|
157
|
+
#### Arguments
|
158
158
|
|
159
|
-
|
159
|
+
##### email_address (required)
|
160
160
|
|
161
161
|
The email address of the recipient. For example:
|
162
162
|
|
@@ -164,7 +164,7 @@ The email address of the recipient. For example:
|
|
164
164
|
email_address: "sender@something.com"
|
165
165
|
```
|
166
166
|
|
167
|
-
|
167
|
+
##### template_id (required)
|
168
168
|
|
169
169
|
To find the template ID:
|
170
170
|
|
@@ -178,7 +178,7 @@ For example:
|
|
178
178
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
179
179
|
```
|
180
180
|
|
181
|
-
|
181
|
+
##### personalisation (optional)
|
182
182
|
|
183
183
|
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:
|
184
184
|
|
@@ -191,7 +191,7 @@ personalisation: {
|
|
191
191
|
|
192
192
|
You can leave out this argument if a template does not have any placeholder fields for personalised information.
|
193
193
|
|
194
|
-
|
194
|
+
##### reference (optional)
|
195
195
|
|
196
196
|
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:
|
197
197
|
|
@@ -201,7 +201,7 @@ reference: "your_reference_string"
|
|
201
201
|
|
202
202
|
You can leave out this argument if you do not have a reference.
|
203
203
|
|
204
|
-
|
204
|
+
##### email_reply_to_id (optional)
|
205
205
|
|
206
206
|
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.
|
207
207
|
|
@@ -221,31 +221,40 @@ email_reply_to_id: '8e222534-7f05-4972-86e3-17c5d9f894e2'
|
|
221
221
|
|
222
222
|
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.
|
223
223
|
|
224
|
-
|
224
|
+
### Send a file by email
|
225
225
|
|
226
226
|
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.
|
227
227
|
|
228
228
|
The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
|
229
229
|
|
230
|
-
|
230
|
+
Your file will be available to download for a default period of 78 weeks (18 months). From 29 March 2023 we will reduce this to 26 weeks (6 months) for all new files. Files sent before 29 March will not be affected.
|
231
|
+
|
232
|
+
To help protect your files you can also:
|
233
|
+
|
234
|
+
* ask recipients to confirm their email address before downloading
|
235
|
+
* choose the length of time that a file is available to download
|
236
|
+
|
237
|
+
To turn these features on or off, you will need version 5.4.0 of the Ruby client library or a more recent version.
|
238
|
+
|
239
|
+
#### Add contact details to the file download page
|
231
240
|
|
232
241
|
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
233
242
|
1. Go to the __Settings__ page.
|
234
243
|
1. In the __Email__ section, select __Manage__ on the __Send files by email__ row.
|
235
244
|
1. Enter the contact details you want to use, and select __Save__.
|
236
245
|
|
237
|
-
|
246
|
+
#### Add a placeholder to the template
|
238
247
|
|
239
248
|
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
240
249
|
1. Go to the __Templates__ page and select the relevant email template.
|
241
250
|
1. Select __Edit__.
|
242
|
-
1. Add a placeholder to the email template using double brackets. For example:
|
251
|
+
1. Add a placeholder to the email template using double brackets. For example: "Download your file at: ((link_to_file))"
|
243
252
|
|
244
|
-
|
253
|
+
Your email should also tell recipients how long the file will be available to download.
|
245
254
|
|
246
|
-
|
255
|
+
#### Upload your file
|
247
256
|
|
248
|
-
You can upload PDF, CSV, .odt, .txt and MS Word Document files. Your file must be smaller than 2MB. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support/ask-question-give-feedback) if you need to send other file types.
|
257
|
+
You can upload PDF, CSV, .odt, .txt, .rtf, .xlsx and MS Word Document files. Your file must be smaller than 2MB. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support/ask-question-give-feedback) if you need to send other file types.
|
249
258
|
|
250
259
|
1. Pass the file object as an argument to the `Notifications.prepare_upload` helper method.
|
251
260
|
1. Pass the result into the personalisation argument.
|
@@ -263,7 +272,7 @@ File.open("file.pdf", "rb") do |f|
|
|
263
272
|
end
|
264
273
|
```
|
265
274
|
|
266
|
-
|
275
|
+
##### CSV Files
|
267
276
|
|
268
277
|
Uploads for CSV files should use the `is_csv` parameter on the `prepare_upload()` helper method. For example:
|
269
278
|
|
@@ -278,7 +287,82 @@ File.open("file.csv", "rb") do |f|
|
|
278
287
|
end
|
279
288
|
```
|
280
289
|
|
281
|
-
|
290
|
+
#### Ask recipients to confirm their email address before they can download the file
|
291
|
+
|
292
|
+
This new security feature is optional. You should use it if you send files that are sensitive - for example, because they contain personal information about your users.
|
293
|
+
|
294
|
+
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.
|
295
|
+
|
296
|
+
From 29 March 2023, we will turn this feature on by default for every file you send. Files sent before 29 March will not be affected.
|
297
|
+
|
298
|
+
##### Turn on email address check
|
299
|
+
|
300
|
+
To use this feature before 29 March 2023 you will need version 5.4.0 of the Ruby client library, or a more recent version.
|
301
|
+
|
302
|
+
To make the recipient confirm their email address before downloading the file, set the `confirm_email_before_download` flag to `true`.
|
303
|
+
|
304
|
+
You will not need to do this after 29 March.
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
File.open("file.pdf", "rb") do |f|
|
308
|
+
...
|
309
|
+
personalisation: {
|
310
|
+
first_name: "Amala",
|
311
|
+
application_date: "2018-01-01",
|
312
|
+
link_to_file: Notifications.prepare_upload(f, confirm_email_before_download: true),
|
313
|
+
}
|
314
|
+
end
|
315
|
+
```
|
316
|
+
|
317
|
+
##### Turn off email address check (not recommended)
|
318
|
+
|
319
|
+
If you do not want to use this feature after 29 March 2023, you can turn it off on a file-by-file basis.
|
320
|
+
|
321
|
+
To do this you will need version 5.4.0 of the Ruby client library, or a more recent version.
|
322
|
+
|
323
|
+
You should not turn this feature off if you send files that contain:
|
324
|
+
|
325
|
+
* personally identifiable information
|
326
|
+
* commercially sensitive information
|
327
|
+
* information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the [Government Security Classifications](https://www.gov.uk/government/publications/government-security-classifications) policy
|
328
|
+
|
329
|
+
To let the recipient download the file without confirming their email address, set the `confirm_email_before_download` flag to `false`.
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
File.open("file.pdf", "rb") do |f|
|
335
|
+
...
|
336
|
+
personalisation: {
|
337
|
+
first_name: "Amala",
|
338
|
+
application_date: "2018-01-01",
|
339
|
+
link_to_file: Notifications.prepare_upload(f, confirm_email_before_download: false),
|
340
|
+
}
|
341
|
+
end
|
342
|
+
```
|
343
|
+
|
344
|
+
#### Choose the length of time that a file is available to download
|
345
|
+
|
346
|
+
Set the number of weeks you want the file to be available using the `retention_period` key.
|
347
|
+
|
348
|
+
You can choose any value between 1 week and 78 weeks.
|
349
|
+
|
350
|
+
To use this feature will need version 5.4.0 of the Ruby client library, or a more recent version.
|
351
|
+
|
352
|
+
If you do not choose a value, the file will be available for the default period of 78 weeks (18 months).
|
353
|
+
|
354
|
+
```ruby
|
355
|
+
File.open("file.pdf", "rb") do |f|
|
356
|
+
...
|
357
|
+
personalisation: {
|
358
|
+
first_name: "Amala",
|
359
|
+
application_date: "2018-01-01",
|
360
|
+
link_to_file: Notifications.prepare_upload(f, retention_period: '52 weeks'),
|
361
|
+
}
|
362
|
+
end
|
363
|
+
```
|
364
|
+
|
365
|
+
#### Response
|
282
366
|
|
283
367
|
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#send-an-email-method), the object is named `emailresponse`.
|
284
368
|
|
@@ -286,13 +370,13 @@ You can then call different methods on this object to return the requested infor
|
|
286
370
|
|
287
371
|
|Method|Information|Type|
|
288
372
|
|:---|:---|:---|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
373
|
+
|#`emailresponse.id`|Notification UUID|String|
|
374
|
+
|#`emailresponse.reference`|`reference` argument|String|
|
375
|
+
|#`emailresponse.content`|- `body`: Message body<br>- `subject`: Message subject<br>- `from_email`: From email address of your service found on the **Settings** page|Hash|
|
376
|
+
|#`emailresponse.template`|Contains the `id`, `version` and `uri` of the template|Hash|
|
377
|
+
|#`emailresponse.uri`|Notification URL|String|
|
294
378
|
|
295
|
-
|
379
|
+
#### Error codes
|
296
380
|
|
297
381
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
298
382
|
|
@@ -300,9 +384,12 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
300
384
|
|:--- |:---|:---|:---|
|
301
385
|
|`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
|
302
386
|
|`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
|
303
|
-
|`400`|`BadRequestError: Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'`|`BadRequestError`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc, .docx or .odt files|
|
387
|
+
|`400`|`BadRequestError: Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'`|`BadRequestError`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc, .docx, .xlsx, .rtf or .odt files|
|
388
|
+
|`400`|`BadRequestError: Unsupported value for retention_period '(PERIOD)'. Supported periods are from 1 to 78 weeks.`|Choose a period between 1 and 78 weeks|
|
389
|
+
|`400`|`BadRequestError: Unsupported value for confirm_email_before_download: '(VALUE)'. Use a boolean true or false value.`|Use either true or false|
|
304
390
|
|`400`|`BadRequestError: File did not pass the virus scan`|`BadRequestError`|The file contains a virus|
|
305
391
|
|`400`|`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`|`BadRequestError`|See how to [add contact details to the file download page](#add-contact-details-to-the-file-download-page)|
|
392
|
+
|`400`|`BadRequestError: Can only send a file by email` | `BadRequestError`|Make sure you are using an email template|
|
306
393
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
307
394
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
308
395
|
|`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information|
|
@@ -310,7 +397,7 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
310
397
|
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
|
311
398
|
|-|`ArgumentError: File is larger than 2MB")`|-|The file is too big. Files must be smaller than 2MB|
|
312
399
|
|
313
|
-
|
400
|
+
### Send a letter
|
314
401
|
|
315
402
|
When you add a new service it will start in [trial mode](https://www.notifications.service.gov.uk/features/trial-mode). You can only send letters when your service is live.
|
316
403
|
|
@@ -320,7 +407,7 @@ To send Notify a request to go live:
|
|
320
407
|
1. Go to the __Settings__ page.
|
321
408
|
1. In the __Your service is in trial mode__ section, select __request to go live__.
|
322
409
|
|
323
|
-
|
410
|
+
#### Method
|
324
411
|
|
325
412
|
```ruby
|
326
413
|
letterresponse = client.send_letter(
|
@@ -328,14 +415,14 @@ letterresponse = client.send_letter(
|
|
328
415
|
personalisation: {
|
329
416
|
address_line_1: 'The Occupier',
|
330
417
|
address_line_2: '123 High Street',
|
331
|
-
|
418
|
+
address_line_3: 'SW14 6BH',
|
332
419
|
},
|
333
420
|
)
|
334
421
|
```
|
335
422
|
|
336
|
-
|
423
|
+
#### Arguments
|
337
424
|
|
338
|
-
|
425
|
+
##### template_id (required)
|
339
426
|
|
340
427
|
To find the template ID:
|
341
428
|
|
@@ -349,13 +436,25 @@ For example:
|
|
349
436
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
350
437
|
```
|
351
438
|
|
352
|
-
|
439
|
+
##### personalisation (required)
|
353
440
|
|
354
441
|
The personalisation argument always contains the following parameters for the letter recipient’s address:
|
355
442
|
|
356
443
|
- `address_line_1`
|
357
444
|
- `address_line_2`
|
358
|
-
- `
|
445
|
+
- `address_line_3`
|
446
|
+
- `address_line_4`
|
447
|
+
- `address_line_5`
|
448
|
+
- `address_line_6`
|
449
|
+
- `address_line_7`
|
450
|
+
|
451
|
+
The address must have at least 3 lines.
|
452
|
+
|
453
|
+
The last line needs to be a real UK postcode or the name of a country outside the UK.
|
454
|
+
|
455
|
+
Notify checks for international addresses and will automatically charge you the correct postage.
|
456
|
+
|
457
|
+
The `postcode` personalisation argument has been replaced. If your template still uses `postcode`, Notify will treat it as the last line of the address.
|
359
458
|
|
360
459
|
Any other placeholder fields included in the letter template also count as required parameters. You must provide their values in a hash. For example:
|
361
460
|
|
@@ -364,26 +463,13 @@ Any other placeholder fields included in the letter template also count as requi
|
|
364
463
|
personalisation: {
|
365
464
|
address_line_1: 'The Occupier', # mandatory address field
|
366
465
|
address_line_2: '123 High Street', # mandatory address field
|
367
|
-
|
466
|
+
address_line_3: 'SW14 6BH', # mandatory address field
|
368
467
|
name: 'John Smith', # field from template
|
369
468
|
application_date: '2018-01-01' # field from template
|
370
469
|
},
|
371
470
|
```
|
372
471
|
|
373
|
-
|
374
|
-
|
375
|
-
The following parameters in the letter recipient’s address are optional:
|
376
|
-
|
377
|
-
```ruby
|
378
|
-
personalisation: {
|
379
|
-
address_line_3: 'Richmond', # optional address field
|
380
|
-
address_line_4: 'London', # optional address field
|
381
|
-
address_line_5: 'Middlesex', # optional address field
|
382
|
-
address_line_6: 'UK', # optional address field
|
383
|
-
},
|
384
|
-
```
|
385
|
-
|
386
|
-
#### reference (optional)
|
472
|
+
##### reference (optional)
|
387
473
|
|
388
474
|
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:
|
389
475
|
|
@@ -391,7 +477,7 @@ A unique identifier you can create if necessary. This reference identifies a sin
|
|
391
477
|
reference: 'your_reference_string'
|
392
478
|
```
|
393
479
|
|
394
|
-
|
480
|
+
#### Response
|
395
481
|
|
396
482
|
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#send-a-letter-method), the object is named `letterresponse`.
|
397
483
|
|
@@ -399,44 +485,45 @@ You can then call different methods on this object to return the requested infor
|
|
399
485
|
|
400
486
|
|Method|Information|Type|
|
401
487
|
|:---|:---|:---|
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
488
|
+
|#`letterresponse.id`|Notification UUID|String|
|
489
|
+
|#`letterresponse.reference`|`reference` argument|String|
|
490
|
+
|#`letterresponse.content`|- `body`: Letter body<br>- `subject`: Letter subject or main heading|Hash|
|
491
|
+
|#`letterresponse.template`|Contains the `id`, `version` and `uri` of the template|Hash|
|
492
|
+
|#`letterresponse.uri`|Notification URL|String|
|
407
493
|
|
408
494
|
|
409
|
-
|
495
|
+
#### Error codes
|
410
496
|
|
411
497
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
412
498
|
|
413
499
|
|error.code|error.message|class|How to fix|
|
414
500
|
|:--- |:---|:---|:---|
|
415
|
-
|`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)
|
416
|
-
|`400`|`BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)
|
417
|
-
|`400`|`ValidationError: personalisation address_line_1 is a required property`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](#personalisation-required) for more information
|
418
|
-
|`400`|`ValidationError: Must be a real UK postcode
|
419
|
-
|`
|
420
|
-
|`403`|`AuthError:
|
421
|
-
|`
|
422
|
-
|`429`|`
|
423
|
-
|`
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
501
|
+
|`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys).|
|
502
|
+
|`400`|`BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode).|
|
503
|
+
|`400`|`ValidationError: personalisation address_line_1 is a required property`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](#personalisation-required) for more information.|
|
504
|
+
|`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Must be a real UK postcode"`<br>`}]`|Ensure that the value for the last line of the address is a real UK postcode.|
|
505
|
+
|`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Last line of address must be a real UK postcode or another country"`<br>`}]`|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.|
|
506
|
+
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock.|
|
507
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information.|
|
508
|
+
|`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information.|
|
509
|
+
|`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number.|
|
510
|
+
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification.|
|
511
|
+
|
512
|
+
### Send a precompiled letter
|
513
|
+
|
514
|
+
#### Method
|
428
515
|
```ruby
|
429
516
|
precompiled_letter = client.send_precompiled_letter(reference, pdf_file)
|
430
517
|
```
|
431
518
|
|
432
|
-
|
519
|
+
#### Arguments
|
433
520
|
|
434
|
-
|
521
|
+
##### reference (required)
|
435
522
|
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.
|
436
523
|
|
437
|
-
|
524
|
+
##### pdf_file (required)
|
438
525
|
|
439
|
-
The precompiled letter must be a PDF file which meets [the GOV.UK Notify
|
526
|
+
The precompiled letter must be a PDF file which meets [the GOV.UK Notify letter specification](https://www.notifications.service.gov.uk/using-notify/guidance/letter-specification).
|
440
527
|
|
441
528
|
```ruby
|
442
529
|
File.open("path/to/pdf_file", "rb") do |pdf_file|
|
@@ -444,25 +531,25 @@ File.open("path/to/pdf_file", "rb") do |pdf_file|
|
|
444
531
|
end
|
445
532
|
```
|
446
533
|
|
447
|
-
|
534
|
+
##### postage (optional)
|
448
535
|
|
449
536
|
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.
|
450
537
|
|
451
538
|
|
452
|
-
|
539
|
+
#### Response
|
453
540
|
|
454
|
-
If the request to the client is successful, the client returns a `Notifications::Client:ResponsePrecompiledLetter` object. In the example shown in the [Method section](#send-a-
|
541
|
+
If the request to the client is successful, the client returns a `Notifications::Client:ResponsePrecompiledLetter` object. In the example shown in the [Method section](#send-a-precompiled-letter-method), the object is named `precompiled_letter`.
|
455
542
|
|
456
543
|
You can then call different methods on this object to return the requested information.
|
457
544
|
|
458
545
|
|Method|Information|Type|
|
459
546
|
|:---|:---|:---|
|
460
|
-
|
461
|
-
|
462
|
-
|
547
|
+
|#`precompiled_letter.id`|Notification UUID|String|
|
548
|
+
|#`precompiled_letter.reference`|`reference` argument|String|
|
549
|
+
|#`precompiled_letter.postage`|`postage` argument|String|
|
463
550
|
|
464
551
|
|
465
|
-
|
552
|
+
#### Error codes
|
466
553
|
|
467
554
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
468
555
|
|
@@ -476,67 +563,30 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
476
563
|
|`429`|`RateLimitError: Exceeded rate limit for key type live of 10 requests per 20 seconds`|`RateLimitError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
477
564
|
|`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
|
478
565
|
|
479
|
-
|
566
|
+
## Get message status
|
480
567
|
|
481
|
-
Message status depends on the type of message you have sent.
|
482
568
|
|
483
|
-
You can only get the status of messages that are 7 days old or newer.
|
484
|
-
|
485
|
-
## Status - email
|
486
569
|
|
487
|
-
|
488
|
-
|:---|:---|
|
489
|
-
|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.|
|
490
|
-
|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.|
|
491
|
-
|Delivered|The message was successfully delivered.|
|
492
|
-
|Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database."<br>- `temporary-failure` - "The provider could not deliver the message. This can happen when the recipient’s inbox is full. You can try to send the message again."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again."|
|
570
|
+
### Get the status of one message
|
493
571
|
|
494
|
-
|
572
|
+
You can only get the status of messages sent within the retention period. The default retention period is 7 days.
|
495
573
|
|
496
|
-
|
497
|
-
|:---|:---|
|
498
|
-
|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.|
|
499
|
-
|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.|
|
500
|
-
|Pending|GOV.UK Notify is waiting for more delivery information.<br>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 notification.|
|
501
|
-
|Sent / Sent internationally|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 client API returns this status as `sent`. The GOV.UK Notify client app returns this status as `Sent internationally`.|
|
502
|
-
|Delivered|The message was successfully delivered.|
|
503
|
-
|Failed|This covers all failure statuses:<br>- `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](https://www.notifications.service.gov.uk/support). If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered."<br>- `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."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure."|
|
504
|
-
|
505
|
-
## Status - letter
|
506
|
-
|
507
|
-
|Status|information|
|
508
|
-
|:---|:---|
|
509
|
-
|Failed|The only failure status that applies to letters is `technical-failure`. GOV.UK Notify had an unexpected error while sending to our printing provider.|
|
510
|
-
|Accepted|GOV.UK Notify has sent the letter to the provider to be printed.|
|
511
|
-
|Received|The provider has printed and dispatched the letter.|
|
512
|
-
|
513
|
-
## Status - precompiled letter
|
514
|
-
|
515
|
-
|Status|information|
|
516
|
-
|:---|:---|
|
517
|
-
|Pending virus check|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
|
518
|
-
|Virus scan failed|GOV.UK Notify found a potential virus in the precompiled letter file.|
|
519
|
-
|Validation failed|Content in the precompiled letter file is outside the printable area. See the [GOV.UK Notify PDF letter specification](https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.3.pdf) for more information.|
|
520
|
-
|
521
|
-
## Get the status of one message
|
522
|
-
|
523
|
-
You can only get the status of messages that are 7 days old or newer.
|
524
|
-
|
525
|
-
### Method
|
574
|
+
#### Method
|
526
575
|
|
527
576
|
```ruby
|
528
577
|
response = client.get_notification(id)
|
529
578
|
```
|
530
579
|
|
531
|
-
|
580
|
+
#### Arguments
|
532
581
|
|
533
|
-
|
582
|
+
##### id (required)
|
534
583
|
|
535
|
-
The ID of the notification.
|
584
|
+
The ID of the notification. To find the notification ID, you can either:
|
536
585
|
|
537
|
-
|
586
|
+
* check the response to the [original notification method call](#response)
|
587
|
+
* [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page
|
538
588
|
|
539
|
-
|
589
|
+
#### Response
|
540
590
|
|
541
591
|
If the request to the client is successful, the client returns a `Notifications::Client::Notification` object. In the example shown in the [Method section](#get-the-status-of-one-message-method), the object is named `response`.
|
542
592
|
|
@@ -544,29 +594,29 @@ You can then call different methods on this object to return the requested infor
|
|
544
594
|
|
545
595
|
|Method|Information|Type|
|
546
596
|
|:---|:---|:---|
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
597
|
+
|#`response.id`|Notification UUID|String|
|
598
|
+
|#`response.reference`| String supplied in `reference` argument|String|
|
599
|
+
|#`response.email_address`|Recipient email address (email only)|String|
|
600
|
+
|#`response.phone_number`|Recipient phone number (SMS only)|String|
|
601
|
+
|#`response.line_1`|Recipient address line 1 of the address (letter only)|String|
|
602
|
+
|#`response.line_2`|Recipient address line 2 of the address (letter only)|String|
|
603
|
+
|#`response.line_3`|Recipient address line 3 of the address (letter only)|String|
|
604
|
+
|#`response.line_4`|Recipient address line 4 of the address (letter only)|String|
|
605
|
+
|#`response.line_5`|Recipient address line 5 of the address (letter only)|String|
|
606
|
+
|#`response.line_6`|Recipient address line 6 of the address (letter only)|String|
|
607
|
+
|#`response.line_7`|Recipient address line 7 of the address (letter only)|String|
|
608
|
+
|#`response.postage`|Postage class of the notification sent (letter only)|String|
|
609
|
+
|#`response.type`|Type of notification sent (sms, email or letter)|String|
|
610
|
+
|#`response.status`|Notification status (sending / delivered / permanent-failure / temporary-failure / technical-failure)|String|
|
611
|
+
|#`response.template`|Template UUID|String|
|
612
|
+
|#`response.body`|Notification body|String|
|
613
|
+
|#`response.subject`|Notification subject (email and letter)|String|
|
614
|
+
|#`response.sent_at`|Date and time notification sent to provider|String|
|
615
|
+
|#`response.created_at`|Date and time notification created|String|
|
616
|
+
|#`response.completed_at`|Date and time notification delivered or failed|String|
|
617
|
+
|#`response.created_by_name`|Name of sender if notification sent manually|String|
|
618
|
+
|
619
|
+
#### Error codes
|
570
620
|
|
571
621
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
572
622
|
|
@@ -577,13 +627,13 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
577
627
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
578
628
|
|`404`|`NoResultFound: No result found`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
|
579
629
|
|
580
|
-
|
630
|
+
### Get the status of multiple messages
|
581
631
|
|
582
632
|
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.
|
583
633
|
|
584
634
|
You can only get messages that are 7 days old or newer.
|
585
635
|
|
586
|
-
|
636
|
+
#### Method
|
587
637
|
|
588
638
|
```ruby
|
589
639
|
args = {
|
@@ -599,22 +649,22 @@ You can leave out the `older_than` argument to get the 250 most recent messages.
|
|
599
649
|
|
600
650
|
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.
|
601
651
|
|
602
|
-
|
652
|
+
#### Arguments
|
603
653
|
|
604
654
|
You can leave out these arguments to ignore these filters.
|
605
655
|
|
606
|
-
|
656
|
+
##### status (optional)
|
607
657
|
|
608
658
|
You can filter by each:
|
609
659
|
|
610
|
-
* [email status](#status-
|
611
|
-
* [text message status](#
|
612
|
-
* [letter status](#status-
|
613
|
-
* [precompiled letter status](#
|
660
|
+
* [email status](#email-status-descriptions)
|
661
|
+
* [text message status](#text-message-status-descriptions)
|
662
|
+
* [letter status](#letter-status-descriptions)
|
663
|
+
* [precompiled letter status](#precompiled-letter-status-descriptions)
|
614
664
|
|
615
665
|
You can leave out this argument to ignore this filter.
|
616
666
|
|
617
|
-
|
667
|
+
##### templateType (optional)
|
618
668
|
|
619
669
|
You can filter by:
|
620
670
|
|
@@ -622,7 +672,7 @@ You can filter by:
|
|
622
672
|
* `sms`
|
623
673
|
* `letter`
|
624
674
|
|
625
|
-
|
675
|
+
##### reference (optional)
|
626
676
|
|
627
677
|
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:
|
628
678
|
|
@@ -630,7 +680,7 @@ A unique identifier you can create if necessary. This reference identifies a sin
|
|
630
680
|
reference: 'your_reference_string'
|
631
681
|
```
|
632
682
|
|
633
|
-
|
683
|
+
##### older_than (optional)
|
634
684
|
|
635
685
|
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:
|
636
686
|
|
@@ -642,7 +692,7 @@ If you leave out this argument, the client returns the most recent 250 notificat
|
|
642
692
|
|
643
693
|
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.
|
644
694
|
|
645
|
-
|
695
|
+
#### Response
|
646
696
|
|
647
697
|
If the request to the client is successful, the client returns a `Notifications::Client::NotificationsCollection` object. In the example shown in the [Method section](#get-the-status-of-multiple-messages-method), the object is named `response`.
|
648
698
|
|
@@ -650,37 +700,37 @@ You must then call either the `.links` method or the `.collection` method on thi
|
|
650
700
|
|
651
701
|
|Method|Information|
|
652
702
|
|:---|:---|
|
653
|
-
|
654
|
-
|
703
|
+
|#`response.links`|Returns a hash linking to the requested notifications (limited to 250)|
|
704
|
+
|#`response.collection`|Returns an array of the required notifications|
|
655
705
|
|
656
706
|
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:
|
657
707
|
|
658
708
|
|Method|Information|Type|
|
659
709
|
|:---|:---|:---|
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
710
|
+
|#`response.id`|Notification UUID|String|
|
711
|
+
|#`response.reference`| String supplied in `reference` argument|String|
|
712
|
+
|#`response.email_address`|Recipient email address (email only)|String|
|
713
|
+
|#`response.phone_number`|Recipient phone number (SMS only)|String|
|
714
|
+
|#`response.line_1`|Recipient address line 1 of the address (letter only)|String|
|
715
|
+
|#`response.line_2`|Recipient address line 2 of the address (letter only)|String|
|
716
|
+
|#`response.line_3`|Recipient address line 3 of the address (letter only)|String|
|
717
|
+
|#`response.line_4`|Recipient address line 4 of the address (letter only)|String|
|
718
|
+
|#`response.line_5`|Recipient address line 5 of the address (letter only)|String|
|
719
|
+
|#`response.line_6`|Recipient address line 6 of the address (letter only)|String|
|
720
|
+
|#`response.postcode`|Recipient postcode (letter only)|String|
|
721
|
+
|#`response.type`|Type of notification sent (sms, email or letter)|String|
|
722
|
+
|#`response.status`|Notification status (sending / delivered / permanent-failure / temporary-failure / technical-failure)|String|
|
723
|
+
|#`response.template`|Template UUID|String|
|
724
|
+
|#`response.body`|Notification body|String|
|
725
|
+
|#`response.subject`|Notification subject (email and letter)|String|
|
726
|
+
|#`response.sent_at`|Date and time notification sent to provider|String|
|
727
|
+
|#`response.created_at`|Date and time notification created|String|
|
728
|
+
|#`response.completed_at`|Date and time notification delivered or failed|String|
|
729
|
+
|#`response.created_by_name`|Name of sender if notification sent manually|String|
|
680
730
|
|
681
731
|
If the notification specified in the `older_than` argument is older than 7 days, the client returns an empty `collection` response.
|
682
732
|
|
683
|
-
|
733
|
+
#### Error codes
|
684
734
|
|
685
735
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
686
736
|
|
@@ -691,9 +741,57 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
691
741
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
692
742
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
693
743
|
|
694
|
-
|
744
|
+
### Email status descriptions
|
745
|
+
|
746
|
+
|Status|Description|
|
747
|
+
|:---|:---|
|
748
|
+
|#`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.|
|
749
|
+
|#`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.|
|
750
|
+
|#`delivered`|The message was successfully delivered.|
|
751
|
+
|#`permanent-failure`|The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.|
|
752
|
+
|#`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](https://www.gov.uk/service-manual/design/sending-emails-and-text-messages#protect-your-users-from-spam-and-phishing) before you try to send the message again.|
|
753
|
+
|#`technical-failure`|Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again.|
|
754
|
+
|
755
|
+
### Text message status descriptions
|
756
|
+
|
757
|
+
|Status|Description|
|
758
|
+
|:---|:---|
|
759
|
+
|#`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.|
|
760
|
+
|#`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.|
|
761
|
+
|#`pending`|GOV.UK Notify is waiting for more delivery information.<br>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.|
|
762
|
+
|#`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'.|
|
763
|
+
|#`delivered`|The message was successfully delivered.|
|
764
|
+
|#`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](https://www.notifications.service.gov.uk/support). If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered.
|
765
|
+
|#`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.|
|
766
|
+
|#`technical-failure`|Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure.|
|
767
|
+
|
768
|
+
### Letter status descriptions
|
769
|
+
|
770
|
+
|Status|Description|
|
771
|
+
|:---|:---|
|
772
|
+
|#`accepted`|GOV.UK Notify has sent the letter to the provider to be printed.|
|
773
|
+
|#`received`|The provider has printed and dispatched the letter.|
|
774
|
+
|#`cancelled`|Sending cancelled. The letter will not be printed or dispatched.|
|
775
|
+
|#`technical-failure`|GOV.UK Notify had an unexpected error while sending the letter to our printing provider.|
|
776
|
+
|#`permanent-failure`|The provider cannot print the letter. Your letter will not be dispatched.|
|
777
|
+
|
778
|
+
### Precompiled letter status descriptions
|
779
|
+
|
780
|
+
|Status|Description|
|
781
|
+
|:---|:---|
|
782
|
+
|#`accepted`|GOV.UK Notify has sent the letter to the provider to be printed.|
|
783
|
+
|#`received`|The provider has printed and dispatched the letter.|
|
784
|
+
|#`cancelled`|Sending cancelled. The letter will not be printed or dispatched.|
|
785
|
+
|#`pending-virus-check`|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
|
786
|
+
|#`virus-scan-failed`|GOV.UK Notify found a potential virus in the precompiled letter file.|
|
787
|
+
|#`validation-failed`|Content in the precompiled letter file is outside the printable area. See the [GOV.UK Notify letter specification](https://www.notifications.service.gov.uk/using-notify/guidance/letter-specification) for more information.|
|
788
|
+
|#`technical-failure`|GOV.UK Notify had an unexpected error while sending the letter to our printing provider.|
|
789
|
+
|#`permanent-failure`|The provider cannot print the letter. Your letter will not be dispatched.|
|
790
|
+
|
791
|
+
|
792
|
+
### Get a PDF for a letter notification
|
695
793
|
|
696
|
-
|
794
|
+
#### Method
|
697
795
|
|
698
796
|
This returns the pdf contents of a letter notification.
|
699
797
|
|
@@ -703,19 +801,20 @@ pdf_file = client.get_pdf_for_letter(
|
|
703
801
|
)
|
704
802
|
```
|
705
803
|
|
706
|
-
|
804
|
+
#### Arguments
|
707
805
|
|
708
|
-
|
806
|
+
##### id (required)
|
709
807
|
|
710
|
-
The ID of the notification.
|
808
|
+
The ID of the notification. To find the notification ID, you can either:
|
711
809
|
|
712
|
-
|
810
|
+
* check the response to the [original notification method call](#get-the-status-of-one-message-response)
|
811
|
+
* [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page
|
713
812
|
|
714
|
-
|
813
|
+
#### Response
|
715
814
|
|
716
815
|
If the request to the client is successful, the client will return a `string` containing the raw PDF data.
|
717
816
|
|
718
|
-
|
817
|
+
#### Error codes
|
719
818
|
|
720
819
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
721
820
|
|
@@ -731,11 +830,11 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
731
830
|
|`404`|`NoResultFound: No result found`|`BadRequestError`|Check the notification ID|
|
732
831
|
|
733
832
|
|
734
|
-
|
833
|
+
## Get a template
|
735
834
|
|
736
|
-
|
835
|
+
### Get a template by ID
|
737
836
|
|
738
|
-
|
837
|
+
#### Method
|
739
838
|
|
740
839
|
This returns the latest version of the template.
|
741
840
|
|
@@ -743,9 +842,9 @@ This returns the latest version of the template.
|
|
743
842
|
response = client.get_template_by_id(id)
|
744
843
|
```
|
745
844
|
|
746
|
-
|
845
|
+
#### Arguments
|
747
846
|
|
748
|
-
|
847
|
+
##### id (required)
|
749
848
|
|
750
849
|
The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
|
751
850
|
|
@@ -753,7 +852,7 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
|
|
753
852
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
754
853
|
```
|
755
854
|
|
756
|
-
|
855
|
+
#### Response
|
757
856
|
|
758
857
|
If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](#get-a-template-by-id-method), the object is named `response`.
|
759
858
|
|
@@ -761,18 +860,18 @@ You can then call different methods on this object to return the requested infor
|
|
761
860
|
|
762
861
|
|Method|Information|Type|
|
763
862
|
|:---|:---|:---|
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
863
|
+
|#`response.id`|Template UUID|String|
|
864
|
+
|#`response.name`|Template name|String|
|
865
|
+
|#`response.type`|Template type (email/sms/letter)|String|
|
866
|
+
|#`response.created_at`|Date and time template created|String|
|
867
|
+
|#`response.updated_at`|Date and time template last updated (may be nil if version 1)|String|
|
868
|
+
|#`response.created_by`|Email address of person that created the template|String|
|
869
|
+
|#`response.version`|Template version|String|
|
870
|
+
|#`response.body`|Template content|String|
|
871
|
+
|#`response.subject`|Template subject (email and letter)|String|
|
872
|
+
|#`response.letter_contact_block`|Template letter contact block (letter)|String|
|
873
|
+
|
874
|
+
#### Error codes
|
776
875
|
|
777
876
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
778
877
|
|
@@ -783,17 +882,17 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
783
882
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
784
883
|
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-arguments-id-required)|
|
785
884
|
|
786
|
-
|
885
|
+
### Get a template by ID and version
|
787
886
|
|
788
|
-
|
887
|
+
#### Method
|
789
888
|
|
790
889
|
```ruby
|
791
890
|
response = client.get_template_version(id, version)
|
792
891
|
```
|
793
892
|
|
794
|
-
|
893
|
+
#### Arguments
|
795
894
|
|
796
|
-
|
895
|
+
##### id (required)
|
797
896
|
|
798
897
|
The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
|
799
898
|
|
@@ -801,11 +900,11 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
|
|
801
900
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
802
901
|
```
|
803
902
|
|
804
|
-
|
903
|
+
##### version (required)
|
805
904
|
|
806
905
|
The version number of the template.
|
807
906
|
|
808
|
-
|
907
|
+
#### Response
|
809
908
|
|
810
909
|
If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](#get-a-template-by-id-and-version-method), the object is named `response`.
|
811
910
|
|
@@ -813,18 +912,18 @@ You can then call different methods on this object to return the requested infor
|
|
813
912
|
|
814
913
|
|Method|Information|Type|
|
815
914
|
|:---|:---|:---|
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
915
|
+
|#`response.id`|Template UUID|String|
|
916
|
+
|#`response.name`|Template name|String|
|
917
|
+
|#`response.type`|Template type (email/sms/letter)|String|
|
918
|
+
|#`response.created_at`|Date and time template created|String|
|
919
|
+
|#`response.updated_at`|Date and time template last updated (may be nil if it is the first version)|String|
|
920
|
+
|#`response.created_by`|Email address of person that created the template|String|
|
921
|
+
|#`response.version`|Template version|String|
|
922
|
+
|#`response.body`|Template content|String|
|
923
|
+
|#`response.subject`|Template subject (email and letter)|String|
|
924
|
+
|#`response.letter_contact_block`|Template letter contact block (letter)|String|
|
925
|
+
|
926
|
+
#### Error codes
|
828
927
|
|
829
928
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
830
929
|
|
@@ -835,9 +934,9 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
835
934
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
836
935
|
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-and-version-arguments-id-required) and [version](#version-required)|
|
837
936
|
|
838
|
-
|
937
|
+
### Get all templates
|
839
938
|
|
840
|
-
|
939
|
+
#### Method
|
841
940
|
|
842
941
|
This returns the latest version of all templates inside a collection object.
|
843
942
|
|
@@ -848,9 +947,9 @@ args = {
|
|
848
947
|
response = client.get_all_templates(args)
|
849
948
|
```
|
850
949
|
|
851
|
-
|
950
|
+
#### Arguments
|
852
951
|
|
853
|
-
|
952
|
+
##### type (optional)
|
854
953
|
|
855
954
|
If you do not use `type`, the client returns all templates. Otherwise you can filter by:
|
856
955
|
|
@@ -858,7 +957,7 @@ If you do not use `type`, the client returns all templates. Otherwise you can fi
|
|
858
957
|
- `sms`
|
859
958
|
- `letter`
|
860
959
|
|
861
|
-
|
960
|
+
#### Response
|
862
961
|
|
863
962
|
If the request to the client is successful, the client returns a `Notifications::Client::TemplateCollection` object. In the example shown in the [Method section](#get-all-templates-method), the object is named `response`.
|
864
963
|
|
@@ -868,20 +967,20 @@ Once the client has returned a template array, you must then call the following
|
|
868
967
|
|
869
968
|
|Method|Information|Type|
|
870
969
|
|:---|:---|:---|
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
970
|
+
|#`response.id`|Template UUID|String|
|
971
|
+
|#`response.name`|Template name|String|
|
972
|
+
|#`response.type`|Template type (email/sms/letter)|String|
|
973
|
+
|#`response.created_at`|Date and time template created|String|
|
974
|
+
|#`response.updated_at`|Date and time template last updated (may be nil if it is the first version)|String|
|
975
|
+
|#`response.created_by`|Email address of person that created the template|String|
|
976
|
+
|#`response.version`|Template version|String|
|
977
|
+
|#`response.body`|Template content|String|
|
978
|
+
|#`response.subject`|Template subject (email and letter)|String|
|
979
|
+
|#`response.letter_contact_block`|Template letter contact block (letter)|String|
|
881
980
|
|
882
981
|
If no templates exist for a template type or there no templates for a service, the templates array will be empty.
|
883
982
|
|
884
|
-
|
983
|
+
#### Error codes
|
885
984
|
|
886
985
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
887
986
|
|
@@ -889,9 +988,9 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
889
988
|
|:---|:---|:---|:---|
|
890
989
|
|`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the Notify team|
|
891
990
|
|
892
|
-
|
991
|
+
### Generate a preview template
|
893
992
|
|
894
|
-
|
993
|
+
#### Method
|
895
994
|
|
896
995
|
This generates a preview version of a template.
|
897
996
|
|
@@ -901,9 +1000,9 @@ response = client.generate_template_preview(id)
|
|
901
1000
|
|
902
1001
|
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.
|
903
1002
|
|
904
|
-
|
1003
|
+
#### Arguments
|
905
1004
|
|
906
|
-
|
1005
|
+
##### id (required)
|
907
1006
|
|
908
1007
|
The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
|
909
1008
|
|
@@ -911,7 +1010,7 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
|
|
911
1010
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
912
1011
|
```
|
913
1012
|
|
914
|
-
|
1013
|
+
##### personalisation (optional)
|
915
1014
|
|
916
1015
|
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:
|
917
1016
|
|
@@ -924,7 +1023,7 @@ personalisation: {
|
|
924
1023
|
|
925
1024
|
You can leave out this argument if a template does not have any placeholder fields for personalised information.
|
926
1025
|
|
927
|
-
|
1026
|
+
#### Response
|
928
1027
|
|
929
1028
|
If the request to the client is successful, the client returns a `Notifications::Client::TemplatePreview` object. In the example shown in the [Method section](#generate-a-preview-template-method), the object is named `response`.
|
930
1029
|
|
@@ -932,14 +1031,14 @@ You can then call different methods on this object to return the requested infor
|
|
932
1031
|
|
933
1032
|
|Method|Information|Type|
|
934
1033
|
|:---|:---|:---|
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
1034
|
+
|#`response.id`|Template UUID|String|
|
1035
|
+
|#`response.version`|Template version|String|
|
1036
|
+
|#`response.body`|Template content|String|
|
1037
|
+
|#`response.subject`|Template subject (email and letter)|String|
|
1038
|
+
|#`response.type`|Template type (sms/email/letter)|String|
|
1039
|
+
|#`response.html`|Body as rendered HTML (email only)|String|
|
941
1040
|
|
942
|
-
|
1041
|
+
#### Error codes
|
943
1042
|
|
944
1043
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
945
1044
|
|
@@ -950,7 +1049,7 @@ If the request is not successful, the client raises a `Notifications::Client::Re
|
|
950
1049
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
951
1050
|
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
952
1051
|
|
953
|
-
|
1052
|
+
## Get received text messages
|
954
1053
|
|
955
1054
|
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.
|
956
1055
|
|
@@ -958,13 +1057,13 @@ You can only get the status of messages that are 7 days old or newer.
|
|
958
1057
|
|
959
1058
|
You can also set up [callbacks](#callbacks) for received text messages.
|
960
1059
|
|
961
|
-
|
1060
|
+
### Enable received text messages
|
962
1061
|
|
963
1062
|
Contact the GOV.UK Notify team using the [support page](https://www.notifications.service.gov.uk/support) or [chat to us on Slack](https://ukgovernmentdigital.slack.com/messages/C0E1ADVPC) to request a unique number for text message replies.
|
964
1063
|
|
965
|
-
|
1064
|
+
### Get a page of received text messages
|
966
1065
|
|
967
|
-
|
1066
|
+
#### Method
|
968
1067
|
|
969
1068
|
```ruby
|
970
1069
|
args = {
|
@@ -977,9 +1076,9 @@ To get older messages, pass the ID of an older notification into the `older_than
|
|
977
1076
|
|
978
1077
|
If you leave out the `older_than` argument, the client returns the most recent 250 notifications.
|
979
1078
|
|
980
|
-
|
1079
|
+
#### Arguments
|
981
1080
|
|
982
|
-
|
1081
|
+
##### older_than (optional)
|
983
1082
|
|
984
1083
|
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:
|
985
1084
|
|
@@ -991,31 +1090,31 @@ If you leave out the `older_than` argument, the client returns the most recent 2
|
|
991
1090
|
|
992
1091
|
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.
|
993
1092
|
|
994
|
-
|
1093
|
+
#### Response
|
995
1094
|
|
996
|
-
If the request to the client is successful, the client returns a `Notifications::Client::ReceivedTextCollection` object. In the example shown in the [Method section](#get-received-text-messages-method), the object is named `response`.
|
1095
|
+
If the request to the client is successful, the client returns a `Notifications::Client::ReceivedTextCollection` object. In the example shown in the [Method section](#get-a-page-of-received-text-messages-method), the object is named `response`.
|
997
1096
|
|
998
1097
|
You must then call either the `.links` method or the `.collection` method on this object.
|
999
1098
|
|
1000
1099
|
|Method|Information|
|
1001
1100
|
|:---|:---|
|
1002
|
-
|
1003
|
-
|
1101
|
+
|#`response.links`|Returns a hash linking to the requested texts (limited to 250)|
|
1102
|
+
|#`response.collection`|Returns an array of the required texts|
|
1004
1103
|
|
1005
1104
|
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:
|
1006
1105
|
|
1007
1106
|
|Method|Information|Type|
|
1008
1107
|
|:---|:---|:---|
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1108
|
+
|#`response.id`|Received text UUID|String|
|
1109
|
+
|#`response.created_at`|Date and time of received text|String|
|
1110
|
+
|#`response.content`|Received text content|String|
|
1111
|
+
|#`response.notify_number`|Number that received text was sent to|String|
|
1112
|
+
|#`response.service_id`|Received text service ID|String|
|
1113
|
+
|#`response.user_number`|Number that received text was sent from|String|
|
1015
1114
|
|
1016
1115
|
If the notification specified in the `older_than` argument is older than 7 days, the client returns an empty `collection` response.
|
1017
1116
|
|
1018
|
-
|
1117
|
+
#### Error codes
|
1019
1118
|
|
1020
1119
|
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
1021
1120
|
|