Table of Contents

Back to Users API

Send a Custom Notification to the User's Email Address


Use the POST /send transaction to send an email notification to the linked email address of the user.

Synopsis

Mail details

You can create a custom message to be sent to your own email address from jess@ensims.com. There are three fields in the mail details object. The email field is only valid for the administrators. The title field will appear on the subject line of the email, and the message forms the main body.

{
   "email": "abc@def.org",
   "title": "Test message",
   "message": "Hello!"
}

Transaction return object

A successful transaction return object contains the status flag and a message, as shown below.

{
  "ok" : true,
  "status": "Email has been sent to yi@jeplus.org"
}

Transaction failed response

An HTTP 401 - Unauthorized response will be received if the existing token is invalid.

An HTTP 500 - Internal error response will be received if the message cannot be sent for some reasons.

Example using curl://

Assuming the session token has been saved in the cookies file using the log on command, send the confirm command using curl in Linux as below:

curl -b cookies -H 'Content-Type: application/json' -X POST -d '{"title": "Test Message", "message": "Hi, again!"}' https://api.ensims.com/users/api/send

If successful, a transaction return object with 'OK' status will be received. If the session token is invalid, an HTTP 401 code will be returned.

Example using Python Requests

Make sure Requests is correctly installed in your Python environment, and run the following lines:

import requests

headers = {'Content-Type': 'application/json'}
body = {"title": "Test Message", "message": "Hi, again!"}

# Make a post request. Session token must be available in the saved cookies during log-on
r = requests.post('https://api.ensims.com/users/api/send', headers=headers, json=body, cookies=cookies)

# Show return info
r.json()