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 Marketing Emails in SendGrid

 Overview

OperationDescription
addMarketingEmail

Create a new Marketing Email.

editMarketingEmailEdit an existing Marketing Email.
getMarketingEmailRetrieve the contents of an existing Marketing Email.
listMarketingEmailRetrieve a list of all existing Marketing Email.
deleteMarketingEmailRemove an existing Marketing Email.

Operation details

This section provides details on the operations.

Adding a new marketing email

The addMarketingEmail operation creates a new Marketing Email.

addMarketingEmail
<sendgrid.addMarketingEmail>
    <identity>{$ctx:identity}</identity>
    <name>{$ctx:name}</name>
    <subject>{$ctx:subject}</subject>
    <text>{$ctx:text}</text>
    <html>{$ctx:html}</html>
</sendgrid.addMarketingEmail>

Properties

identity : Required - The Identity (Sender Address) that will be used for the Marketing Email being created.

name: Required - The name that will be used for the Marketing Email being created.

subject: Required - The subject that will be used for the Marketing Email being created.

text: Required - The text portion of the Marketing Email being created.

html: Required - The html portion of the Marketing Email being created.

 

Sample Request for addMarketingEmail
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"Sender_Address",
  "name":"SendGrid_Test",
  "subject":"testSubject",
  "text":"testText",
  "html":"testHtml"
}

Editing an existing marketing email

The editMarketingEmail operation edits an existing Marketing Email.

editMarketingEmail
<sendgrid.editMarketingEmail>
    <identity>{$ctx:identity}</identity>
    <name>{$ctx:name}</name>
    <newname>{$ctx:newname}</newname>
    <subject>{$ctx:subject}</subject>
    <text>{$ctx:text}</text>
    <html>{$ctx:html}</html>
</sendgrid.editMarketingEmail>

Properties

identity : Required - The Identity (Sender Address) that will be used for the Marketing Email being created.

name: Required - The name that will be used for the Marketing Email.

newname: The new name that will be used for the Marketing Email.

subject: Required - The subject that will be used for the Marketing Email.

text: Required - The text portion of the Marketing Email.

html: Required - The html portion of the Marketing Email.

 

Sample Request for editMarketingEmail
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"Sender_Address",
  "name":"SendGrid_Test",
  "newname":"SendGridTestNewName",
  "subject":"testSubject",
  "text":"testText",
  "html":"testHtml"
}

Retrieving contents of marketing email

The getMarketingEmail operation retrieve the contents of an existing Marketing Email.

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

Properties
name: Required - Retrieve the content of an existing Marketing Email.

 

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

Retrieve a list of all existing Marketing Email.

The listMarketingEmail operation retrieves a list of all existing Marketing Email.

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

Properties
name: Required - Search to see if a specific Marketing Email exists rather than a list of all Marketing Emails.

 

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

Remove an existing Marketing Email.

The deleteMarketingEmail operation remove an existing Marketing Email.

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

Properties
name: Required - Remove the Marketing Email with this name.

 

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

Sample configuration

Following is a sample proxy service that illustrates how to connect to SendGrid with the init operation and use the listMarketingEmail 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_listMarketingEmail"
       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="name" expression="json-eval($.name)"/>
		
			<sendgrid.init>
    			<apiUrl>{$ctx:apiUrl}</apiUrl>
    			<apiUser>{$ctx:apiUser}</apiUser>
    			<apiKey>{$ctx:apiKey}</apiKey>
			</sendgrid.init>
			
		<sendgrid.listMarketingEmail>
    		<name>{$ctx:name}</name>
		</sendgrid.listMarketingEmail>
   
           <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>