Use the POST /send
transaction to send an email notification to the linked email address of the user.
Content-Type
to application/json
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!" }
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" }
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.
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.
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()