Developing batch email capabilities using REST APIs
The mailing list REST APIs provided by NexJ Systems enable external systems to:
- Retrieve a collection of entity lists (saved lists) from NexJ CRM for a given user.
- Email content generated in the external system to the entities in a saved list that was retrieved in the previous step.
Retrieving a user's entity lists
You can use the following REST API to retrieve a collection of entity lists for a given NexJ CRM user.
Your administrator must grant you the NexJ CRM EntityListView privilege before you can use the API to read entity lists.
API specification
HTTP method | Endpoint |
---|---|
GET | /entityLists |
This API has the following properties:
Property | Type | Description |
---|---|---|
$id | string | Unique ID of the entity list |
name | string | Name of the entity list |
Example
The following code shows an example of a GET request to retrieve entity lists, and a response.
Sending an email to an entity list
You can use the following REST API to send a batch email to an entity list.
Your administrator must grant you the NexJ CRM BatchProcessManage privilege before you can use the REST API to send a batch email to an entity list.
API specification
HTTP method | Endpoint |
---|---|
POST | /sendEmailToEntityList |
This API has the following properties:
Property | Type | Description | Required? |
---|---|---|---|
emailBody | string | Body of the email. | No |
emailSubject | string | Subject of the email. | No |
addLogItem | boolean | Whether to create a log item for recipients. Optional. Default behavior: true. | No |
entityList | Object | JSON object with the ID of the entity list to send the email to. | Yes |
Example
The following code shows an example of a POST request to send a batch email to an entity list, and a response.
When the user making the request does not have an email configured in NexJ CRM, an error is thrown in the API response.
If the batch email fails because one or more contacts do not have email configured, the errors are visible only in NexJ CRM. The API response does not indicate when the batch email process has failures.
Sample UI configuration using APIs
A set of sample configuration artifacts are available to implement user interface features using the APIs in the \etc\restapi\mailinglist
directory of the inform
project. The instructions for setting up the sample configuration are provided in the README.md
file in the same directory. The sample code demonstrates the following:
- Service persisted meta classes that use the APIs to provide a collection of entity lists.
- User interface configuration, including a picker, to select an entity list using the meta class.
- How to send an email using the API to the entity list selected from the picker.
Related link
Enabling and configuring REST API v2