API – Sending Emails
This article will discuss how to send emails using the API.
There are 2 steps. The first one is to create an email tool entity, and then the other one is to send it.
Sending an Email
This is done by sending a POST request to the /email.tool/next endpoint.
The body of the request will have the following values:
- companyEmailId – The ID of the company email to use in the “From” field
- emailSubject – The subject of the email
- emailContent – The content of the email
- loans – a JSON array of email ids to use
- query – an elastic search query object to use
Note: You only need loans or query, but you may submit both.
Below is an example request
"emailContent":"This is an email from [[v('tenant-name')]].",
The response will look similar to below
This response means that sending the email was successful. If there was an error, then the response would look similar to the following:
"message": "Catchable Fatal Error: Argument 1 passed to Entity\\EmailTool\\EmailTool::linkLoan()
must be an instance of Entity\\Loan, null given, called in /home/deploy/codedeploy/webroot/api/module/Tools/src/Tools/Controller/
EmailToolController.php on line 123 and defined in /home/deploy/codedeploy/webroot/api/entities/Entity/EmailTool/EmailTool.php line 563",
The above error signifies an invalid loan ID (ie. the loan id(s) given does not exist).