8 Service APIs

This section provides a reference for APIs that should be implemented by this Building Block.

This section provides a reference for APIs that should be implemented by this Building Block. The APIs defined here establish a blueprint for how the Building Block will interact with other Building Blocks. Additional APIs may be implemented by the Building Block, but the listed APIs define a minimal set of functionality that should be provided by any implementation of this Building Block.

The GovStack non-functional requirements document provides additional information on how 'adaptors' may be used to translate an existing API to the patterns described here. This section also provides guidance on how candidate products are tested and how GovStack validates a product's API against the API specifications defined here.

The tests for the Messaging Building Block can be found in this GitHub repository.

8.1 Government to person (G2P)

8.1.1 Sending emails

8.1.1.1 Sending single emails one by one

This API is designed to send out emails one by one.

Although an email can be sent to multiple recipients by using email, emailCC and emailBCC appropriately, this is still considered as sending a single email.

Sample user story

As a Doctor working in a hospital, I want to notify my patient about a confirmed registration so that the patient would know when to come for a visit.

API endpoint

Send a single email

post
Query parameters
bodyobjectrequired

Email containing information about the recipient

Header parameters
apiKeystringrequired
Responses
post
curl -L \
  --request POST \
  --url '/send/email/single?body=%5Bobject+Object%5D' \
  --header 'apiKey: text'
{
  "response": "Request successfully accepted. Use \\\"requestUid\\\" to track it's status.",
  "requestUid": "UfQK-CPju-Ea5B-6y7X-8A72-VqU5"
}

8.1.1.2 Sending multiple (batch) emails at once

This API is designed to send out identical emails to multiple (batch) recipients at once.

Sample user story

As a Hospital I want to notify a specified group of my clients about the possibility to register to vacant time slots within a limited period of time so that the clients potentially needing it the most would have a guaranteed chance to get an appointment

API endpoint

Send batch emails

post

When sending batch emails, recipients information is passed in base64 format. Sender information and email content must be the same for all recipients.

Query parameters
bodyobjectrequired

Email containing information about the recipient

Header parameters
apiKeystringrequired
Body
stringoptional
Responses
post
curl -L \
  --request POST \
  --url '/send/email/batch?body=%5Bobject+Object%5D' \
  --header 'apiKey: text' \
  --header 'Content-Type: application/json' \
  --data '"text"'
{
  "response": "Request successfully accepted. Use \\\"requestUid\\\" to track it's status.",
  "requestUid": "UfQK-CPju-Ea5B-6y7X-8A72-VqU5"
}

8.2 Person to Government (P2G)

8.2.1 Responding to emails

This API is designed to accept responses to emails that have been previously sent out by using the Messaging Building Block. The protocol itself is lightweight and expects custom services from anyone using it. The Messaging Building Block is responsible for delivering the message and does not know (or want to know) anything about the content of it, how it will be used, etc.

Sample user story

As a Hospital, I want to get and send responses from and to clients so that I could continue and keep track of email conversations taking place via GovStack

API endpoint

An optional custom service to provide an endpoint for client-specific functionality to accept replied emails, etc

post

This service may reside on both Messaging BB's and client's side. If used, a matching OpenAPI spec must be provided by the service provider, describing the expected input when making request to the endpoint.

Query parameters
bodyobjectrequired

Email containing information about the recipient

Header parameters
apiKeystringrequired
requestUidstringrequired
Responses
post
curl -L \
  --request POST \
  --url '/callback/email?body=%5Bobject+Object%5D' \
  --header 'apiKey: text' \
  --header 'requestUid: text'

No Content

8.2.2 Reading the status of emails

This API is designed to provide information about the status of emails sent to the Messaging Building Block.

Sample user story

As a Doctor working in a hospital I want to know which emails I have sent haven't reached their destination so that I could contact such patients by using different means

API endpoint

Get an overview of sent emails statuses

get

Get status of sent emails. Use both "apiKey" and "requestUid" in your request.

Query parameters
statusstring · enum[]required

Select status values to fetch data for

Header parameters
apiKeystringrequired
requestUidstringrequired
Responses
get
curl -L \
  --url '/status/email?status=scheduled' \
  --header 'apiKey: text' \
  --header 'requestUid: text'
{
  "scheduled": 0,
  "processing": 1004,
  "deferred": 0,
  "bounced": 257,
  "notSent": 0,
  "delivered": 9032
}

Status of emails

Possible status of emails that can be queried are as follows:

  1. scheduled

  2. processing

  3. deferred

  4. bounced

  5. not sent

  6. delivered

There is no keeping track of emails which have been sent successfully, as this would end up creating and maintaining a massive database of emails, their senders and recipients, etc., which would be wrong for so many reasons.

Last updated

Was this helpful?