diff --git a/app/templates/views/api-keys.html b/app/templates/views/api-keys.html index 6a65eae71..477eaebf8 100644 --- a/app/templates/views/api-keys.html +++ b/app/templates/views/api-keys.html @@ -12,14 +12,14 @@

- To connect to the API you will need to send your service ID, encrypted with - an API key. The API key stays secret. + To connect to the API you will need to create an API Key. Each service can have multiple API Keys to allow + for test and live environments.

- There are client libraries available which can do this for you. See - the - developer documentation for more information. + API usage is described in + the + developer documentation.

diff --git a/app/templates/views/documentation.html b/app/templates/views/documentation.html index 944c84b5c..b7cffcd87 100644 --- a/app/templates/views/documentation.html +++ b/app/templates/views/documentation.html @@ -3,47 +3,162 @@ {% from "components/api-key.html" import api_key %} {% block page_title %} - GOV.UK Notify | API keys and documentation +GOV.UK Notify | API keys and documentation {% endblock %} {% block maincolumn_content %} -
-
+
+

- Developer documentation + Developer documentation

- How to integrate GOV.UK Notify into your service + How to integrate GOV.UK Notify into your service

- blah blah blah this is where we tell you how the API works + Notify provides an API that allows the creation of text notifications and the ability to get the status of a + sent notification.

-

Repositories

+

+ API authentication +

- GOV.UK Notify API + Notify uses JSON Web Tokens (JWT) for authentication. + JWT tokens have a series of claims, standard and application specific. +

+ +

Notify standard claims:

+ +
+            typ: JWT
+            alg: HS256
+        
+ +

Notify application specific:

+
+            iss: service id
+            iat: creation time in  epoch seconds (UTC)
+            req: signed request
+            pay: signed payload (POST requests only)
+        
+ +

Notify API tokens sign both the request being made, and for POST requests, the payload.

+ +

+ The signing algorithm is HMAC signature, using provided key SHA256 hashing algorithm. +

+ +

Request signing is of the form HTTP METHOD PATH.

+ + GET /notification/1234 + +

+ +

Payload signing requires the actual payload to be signed, NOT the JSON object. Serialize the object first + then sign the serialized object.

+ +

+ API endpoints +

+ +

To create a text notification

+ + POST /notifications/sms + +

+

+                {
+                    'to': '+441234123123',
+                    'template': 1
+                }
+            
+ Where 'to' is the phone number and 'template' is the template id to send.

- GOV.UK Notify Python client + Response: +

+                {
+                    'notification':
+                    {
+                        'to': '+441234123123',
+                        'createdAt': '2016-01-01T09:00:00.999999Z',
+                        'status': 'created',
+                        'id': 1,
+                        'message': '....',
+                        'method': 'sms',
+                        'jobId': 1
+                    }
+                }
+            
+

+ +

To get the status of a text notification

+ +

+ + GET /notifications/{id} + +

+ +

+

+            {
+                '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'
+                }
+            }
+            
+

+ +

+ API client libraries +

+ +

A python client library is support by the Notify team:

+ +

+ GOV.UK Notify Python client +

+ +

+ This provides example code for calling the API and for constructing the API tokens. +

+ +

API code

+ +

Notify API code is open sourced at:

+ +

+ GOV.UK Notify API

API endpoint

- https://www.notify.works/api/endpoint + https://www.notify.works/api/endpoint

- API keys for your service + API keys for your service

-
+
{% endblock %}