This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Recipients in SendGrid

 Overview

OperationDescription

addRecipient

Assign a List to a Marketing Email.

getRecipient

Get all lists assigned to a particular marketing email.

deleteRecipient

Remove assigned lists from marketing email.

Operation details

This section provides details on the operations.

Add a new Recipient
The addRecipient operation assigns a list to a Marketing Email.

addRecipient
<sendgrid.addRecipient>
 <list>{$ctx:list}</list>
 <name>{$ctx:name}</name>
</sendgrid.addRecipient>

Properties

list: Required -The name of the list to assign to the marketing email.

name: Required - The name of the marketing email.

 

Sample Request for addRecipient
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "name":"test",
  "name":"SendGrid_Testnew"
}

Get list of recipient
The getRecipient operation gets all list lists assigned to a particular marketing email.

getRecipient
<sendgrid.getRecipient>
 <name>{$ctx:name}</name>
</sendgrid.getRecipient>

Properties

name: Required - The name of the marketing email for which to retrieve lists.

 

Sample Request for getRecipient
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "name":"SendGrid_Testnew"
}

Delete a list from marketing email

The deleteRecipient operation removes assigned lists from marketing email.

deleteRecipient
<sendgrid.deleteRecipient>
    <name>{$ctx:name}</name>
    <list>{$ctx:list}</list>
</sendgrid.deleteRecipient>

Properties

list:  Required - To marketing email from which the list will be unassigned.

name: Required -Remove this list from the marketing email.

 

Sample Request for deleteRecipient
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "name":"SendGrid_Testnew",
  "list":"test"
}

Sample configuration

Following is a sample proxy service that illustrates how to connect to SendGrid with the init operation and use the addRecipient operation. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="sendgrid_addRecipient"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <property name="apiUser" expression="json-eval($.apiUser)"/>
            <property name="apiKey" expression="json-eval($.apiKey)"/>
			<property name="list" expression="json-eval($.list)"/>
			<property name="name" expression="json-eval($.name)"/>
		
			<sendgrid.init>
    			<apiUrl>{$ctx:apiUrl}</apiUrl>
    			<apiUser>{$ctx:apiUser}</apiUser>
    			<apiKey>{$ctx:apiKey}</apiKey>
			</sendgrid.init>
			
			<sendgrid.addRecipient>
    			<list>{$ctx:list}</list>
    			<name>{$ctx:name}</name>
			</sendgrid.addRecipient>
   
           <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>