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 Sender Address in SendGrid

 Overview

OperationDescription
addSenderaddressCreate a new Address.
editSenderaddressEdit an existing Address.
getSenderaddressRetrieve information associated with a particular Address.
listSenderaddressList all Addresses on your account, or check if a particular Address  exists.
deleteSenderaddressRemove an Address from your account.

Operation details

This section provides details on the operations.

Adding a Sender Address
The  addSenderaddress  operation create  a new Address.

addSenderaddress
<sendgrid.addSenderaddress>
    <identity>{$ctx:identity}</identity>
    <name>{$ctx:name}</name>
    <email>{$ctx:email}</email>
    <replyto>{$ctx:replyto}</replyto>
    <address>{$ctx:address}</address>
    <city>{$ctx:city}</city>
    <state>{$ctx:state}</state>
    <zip>{$ctx:zip}</zip>
    <country>{$ctx:country}</country>
</sendgrid.addSenderaddress>

Properties

identity  : Required- Create  an Address named this.

name: Required-Specify  the name to be used for this Address.

email: Required-Specify  the email address to be used for this Address.

replyTo: Specify  an email address to be used in the Reply-To field. If not defined,  will default to the email parameter.

address: Required-Specify  the physical address to be used for this Address.

city: Required-Specify  the city to be used for this Address.

state: Required-Specify  the state to be used for this Address.

zip: Required-Specify  the zipcode/postal code to be used for this Address.

country: Required-Specify  the country to be used for this Address.

 

Sample Request for addSenderaddress
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"Sender_Address1",
  "name":"Grant",
  "email":"grant@gmail.com",
  "address":"929_Pearl_Stree",
  "city":"Boulder",
  "state":"Colorado",
  "zip":"80302",
  "country":"SL"  
}

Edit a Sender Address
 

The  editSenderaddress edits  an existing Address.

editSenderaddress
<sendgrid.editSenderaddress>
    <identity>{$ctx:identity}</identity>
    <newidentity>{$ctx:newidentity}</newidentity>
    <name>{$ctx:name}</name>
    <email>{$ctx:email}</email>
    <replyto>{$ctx:replyto}</replyto>
    <address>{$ctx:address}</address>
</sendgrid.editSenderaddress>

 properties

identity  : Required-  The Address you wish to edit.

newidentity:  Specify the new name to be used for this Address.

name:  Specify the new name to be used for this Address.

email:  Required  -Specify the email address to be used for this Address.

replyTo: Specify  an email address to be used in the Reply-To field. If not defined, will default to the email  parameter.

address:Specify  the new physical address to be used for this Address.

 

Sample Request for editSenderaddress
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"NewSender_Address1",
  "email":"grantnew@gmail.com"
}

Get information about Sender Address

The getSenderaddress  operation  retrieves  information associated with a particular Address.   

getSenderaddress
<sendgrid.getSenderaddress>
    <identity>{$ctx:identity}</identity>
</sendgrid.getSenderaddress>

properties

identity:  required  - Retrieve contents of the specified Address.

 

Sample Request for getSenderaddress
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"NewSender_Address1"
}

List all Sender Address

The  listSenderaddress  operation  lists  all Addresses on your account, or check if a particular Address  exists.

listSenderaddress
<sendgrid.listSenderaddress>
    <identity>{$ctx:identity}</identity>
</sendgrid.listSenderaddress>

properties

identity:  Check for this particular Identity.

 

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

Deleting a Sender Address

The  deleteSenderaddress  removes  an Address from your account. 

deleteSenderaddress
<sendgrid.deleteSenderaddress>
    <identity>{$ctx:identity}</identity>
</sendgrid.deleteSenderaddress>

properties

identity:  Required-Remove  the specified Address from your account.

 

Sample Request for deleteSenderaddress
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "identity":"NewSender_Address1"
}

Sample configuration

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