Reading and searching your E-mail inbox with a REST API

Full documentation can be found here

Image showing code

Authentication

In order to use this API and make any calls to the message service, you'll need to first authenticate and get your JSON Web Token (JWT).

curl -X POST "https://api.ijpuk.com/api/v1/authenticate" -H "accept: application/json" -H "authorization: Basic {your base64 encoded username:password}" -d "Content-Length: 0"

In the above example, {your base64 encoded 'username:password'}, needs to be replaced with the token obtained from this page

Making this request returns something similar to what is shown below. The contents of the token returned is required when making future calls to the message service

{
   "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IlVfSUFOXzQwSUpQVUsuQ09NIiwiY2VydHRodW1icHJpbnQiOiI0cW85WjVaTW1QOC9ibm1iKzMrclFBPT0iLCJzdWIiOiJpYW5AaWpwdWsuY29tIiwianRpIjoiODVkaaa3ODQtMjZhZC00Nzk0LWE1NzItZTQzMjRjMWQ1MzUxIiwiaWF0IjoxNTM4MzMwMTI1LCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9wb3N0YWxjb2RlIjoiOTAuMjQwLjcwLjE0MCIsIm5iZiI6MTUzODMzMDEyNSwiZXhwIjoxNTM4MzMzNzI1LCJpc3MiOiJpanB1ay13ZWIuYXp1cmV3ZWJzaXRlcy5uZXQiLCJhdWQiOiJpanB1ay13ZWIuYXp1cmV3ZWJzaXRlcy5uZXQifQ.KwEq01gWlNSqVSnUM1MJp1Y9pRx6wFPR3Mx8MptC-YI"
}

To list all messages in your E-mail box

This call returns a list of all the e-mails in your e-mail inbox. The information returned is supposed to be brief. A more detailed e-mail message is returned see "To retrieve your message"

curl -X GET "https://api.ijpuk.com/api/v1/message" -H "accept: application/json" -H "mailServerKey: {your mail server key}" -H "Authorization: bearer {your token here}"

Response

[
   {
       "id":"6509",
       "subject":"Life 360 - Ian has Just arrived at \"Ian Home\"",
       "dateSent":"2018-07-29T16:56:36+00:00"
   },
   {
       "id":"6514",
       "subject":"Life 360 - Ian has Just left \"Ian Home\"",
       "dateSent":"2018-07-31T16:53:11+00:00"
   }
]

To retrieve your E-mail message

To retrieve more details of a specific e-mail then just specify the email Id.

curl -X GET "https://api.ijpuk.com/api/v1/message/{email id}" -H "accept: application/json" -H "mailServerKey: {your mail server key}" -H "Authorization: bearer {your token here}"

Response

{
   "isPlainText":true,
   "isHtml":true,
   "text":"Just arrived at Ian Home",
   "id":"6526",
   "subject":"Life 360 - Ian has Just arrived at \"Ian Home\"",
   "dateSent":"2018-09-01T11:40:28+00:00"
}

To delete an E-mail

This call will delete a specific E-mail from your e-mail account. Just specify the e-mail Id.

curl -X DELETE "https://api.ijpuk.com/api/v1/message/{email id}" -H "accept: application/json" -H "mailServerKey: {your mail server key}" -H "Authorization: bearer {your token here}"

To search your E-mails

This API call will scan through the e-mail notifications in your e-mail box and return a list of matches.

curl -X POST "https://api.ijpuk.com/api/v1/message/search" -H "accept: application/json" -H "mailServerKey: {your mail server key}" -H "Authorization: bearer {your token here}" -H "Content-Type: application/json" -d "{ \"matchConditions\": [ { \"regEx\": \"Ian (?'status'.+) Home\", \"type\": \"setPresence\", \"parts\": [ { \"variableName\": \"IanHome\", \"regExGroupName\": \"status\", \"matchConditions\": [ \"left\", \"arrived at\", \"is at\" ] } ] }, { \"regEx\": \"^Weather Report: (?'WeatherCapture'.+) today$\", \"type\": \"setWeather\", \"parts\": [ { \"variableName\": \"Weather\", \"regExGroupName\": \"WeatherCapture\" ] } ]}"