2016-03-18 16:25:43 +00:00
|
|
|
|
{% extends "withoutnav_template.html" %}
|
2016-01-19 09:55:13 +00:00
|
|
|
|
{% from "components/page-footer.html" import page_footer %}
|
|
|
|
|
|
{% from "components/api-key.html" import api_key %}
|
|
|
|
|
|
|
|
|
|
|
|
{% block page_title %}
|
2016-03-18 16:25:43 +00:00
|
|
|
|
API documentation – GOV.UK Notify
|
2016-01-19 09:55:13 +00:00
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
{% block maincolumn_content %}
|
|
|
|
|
|
|
2016-02-03 15:49:28 +00:00
|
|
|
|
<h1 class="heading-large">
|
2016-03-18 16:25:43 +00:00
|
|
|
|
Developer documentation
|
2016-02-03 15:49:28 +00:00
|
|
|
|
</h1>
|
|
|
|
|
|
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<div class="grid-row">
|
2016-02-09 10:28:12 +00:00
|
|
|
|
<div class="column-three-quarters">
|
2016-01-19 09:55:13 +00:00
|
|
|
|
|
|
|
|
|
|
<h2 class="heading-medium">
|
2016-01-24 21:03:00 +00:00
|
|
|
|
How to integrate GOV.UK Notify into your service
|
2016-01-19 09:55:13 +00:00
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
Notify provides an API that allows the creation of text notifications and the ability to get the status of a
|
|
|
|
|
|
sent notification.
|
2016-01-19 09:55:13 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<h3 class="heading-medium">
|
|
|
|
|
|
API authentication
|
|
|
|
|
|
</h3>
|
2016-01-19 09:55:13 +00:00
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
Notify uses <a href="https://jwt.io/">JSON Web Tokens (JWT)</a> for authentication.
|
|
|
|
|
|
JWT tokens have a series of claims, standard and application specific.
|
2016-01-19 09:55:13 +00:00
|
|
|
|
</p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<p>Notify standard claims:</p>
|
|
|
|
|
|
|
2016-02-09 10:28:12 +00:00
|
|
|
|
{{'''
|
|
|
|
|
|
{
|
|
|
|
|
|
"typ": "JWT",
|
|
|
|
|
|
"alg": "HS256"
|
|
|
|
|
|
}
|
|
|
|
|
|
'''|syntax_highlight_json}}
|
2016-01-24 21:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
<p>Notify application specific:</p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
{{"""
|
|
|
|
|
|
{
|
|
|
|
|
|
iss: 'string', // service id
|
|
|
|
|
|
iat: 0, // creation time in epoch seconds (UTC)
|
|
|
|
|
|
req: 'string', // signed request
|
|
|
|
|
|
pay: 'string', // signed payload (POST requests only)
|
|
|
|
|
|
}
|
|
|
|
|
|
"""|syntax_highlight_json}}
|
|
|
|
|
|
<div class="grid-row">
|
|
|
|
|
|
<div class="column-three-quarters">
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<p>Notify API tokens sign both the request being made, and for POST requests, the payload.</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
The signing algorithm is HMAC signature, using provided key SHA256 hashing algorithm.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>Request signing is of the form HTTP METHOD PATH.</p>
|
|
|
|
|
|
|
2016-02-09 10:28:12 +00:00
|
|
|
|
{{ "GET /notification/1234"|syntax_highlight_json }}
|
2016-01-24 21:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
<p></p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>Payload signing requires the actual payload to be signed, NOT the JSON object. Serialize the object first
|
|
|
|
|
|
then sign the serialized object.</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3 class="heading-medium">
|
|
|
|
|
|
API endpoints
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
|
|
<p>To create a text notification</p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{{ "POST /notifications/sms"|syntax_highlight_json }}
|
|
|
|
|
|
|
|
|
|
|
|
{{
|
|
|
|
|
|
"""
|
|
|
|
|
|
{
|
2016-03-18 16:25:43 +00:00
|
|
|
|
'to': '+447700900404',
|
2016-02-09 10:28:12 +00:00
|
|
|
|
'template': 1
|
|
|
|
|
|
}
|
|
|
|
|
|
"""|syntax_highlight_json
|
|
|
|
|
|
}}
|
|
|
|
|
|
<div class="grid-row">
|
|
|
|
|
|
<div class="column-three-quarters">
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
Where ‘to’ is the phone number and ‘template’ is the template ID to send.
|
2016-01-24 21:03:00 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
Response:
|
2016-01-24 21:03:00 +00:00
|
|
|
|
</p>
|
2016-02-09 10:28:12 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{{"""
|
|
|
|
|
|
{
|
2016-03-24 14:40:20 +00:00
|
|
|
|
'data':{
|
|
|
|
|
|
'notification': {
|
|
|
|
|
|
'id':1
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-02-09 10:28:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
"""|syntax_highlight_json }}
|
2016-01-24 21:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-02-09 10:28:12 +00:00
|
|
|
|
<p>To get the status of a text notification</p>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
|
2016-02-09 10:28:12 +00:00
|
|
|
|
{{ "GET /notifications/{id}"|syntax_highlight_json }}
|
|
|
|
|
|
|
|
|
|
|
|
{{"""
|
|
|
|
|
|
{
|
2016-03-24 14:40:20 +00:00
|
|
|
|
'data':{
|
|
|
|
|
|
'notification': {
|
|
|
|
|
|
'status':'sent',
|
|
|
|
|
|
'createdAt':'2016-01-01T09:00:00.999999Z',
|
|
|
|
|
|
'to':'+447827992607',
|
|
|
|
|
|
'method':'sms',
|
|
|
|
|
|
'sentAt':'2016-01-01T09:01:00.999999Z',
|
|
|
|
|
|
'id':1,
|
|
|
|
|
|
'message':'...',
|
|
|
|
|
|
'jobId':1,
|
|
|
|
|
|
'sender':'sms-partner'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-02-09 10:28:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
"""|syntax_highlight_json }}
|
2016-01-24 21:03:00 +00:00
|
|
|
|
|
2016-02-09 10:28:12 +00:00
|
|
|
|
<div class="grid-row">
|
|
|
|
|
|
<div class="column-three-quarters">
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<h2 class="heading-medium">
|
|
|
|
|
|
API client libraries
|
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<p>A python client library is support by the Notify team:</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-01-24 21:04:24 +00:00
|
|
|
|
<a href="https://github.com/alphagov/notifications-python-client">GOV.UK Notify Python client</a>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
This provides example code for calling the API and for constructing the API tokens.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h2 class="heading-medium">API code</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<p>Notify API code is open sourced at:</p>
|
|
|
|
|
|
|
2016-01-19 09:55:13 +00:00
|
|
|
|
<p>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
<a href="https://github.com/alphagov/notifications-api">GOV.UK Notify API</a>
|
2016-01-19 09:55:13 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h2 class="heading-medium">API endpoint</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-03-21 14:31:01 +00:00
|
|
|
|
https://api.notifications.service.gov.uk/
|
2016-01-19 09:55:13 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2016-01-24 21:03:00 +00:00
|
|
|
|
</div>
|
2016-01-19 09:55:13 +00:00
|
|
|
|
|
|
|
|
|
|
{% endblock %}
|