Send an Email to a Lead

Lets you send an email to a single lead.

API URL

POST
https://{host}/v2/EmailMarketing.svc/SendEmailToLead?accessKey=AccessKey&secretKey=SecretKey
Copy URL

Request

JSON Body/Payload

Content-Type: application/json

{
"SenderType": "UserEmailAddress",
"Sender": "marketeer@example.com",
"RecipientType": "LeadEmailAddress",
"RecipientEmailFields": "",
"Recipient": "johnsmith@example.com",
"EmailType": "Html",
"EmailLibraryName": "",
"ContentHTML": "Welcome John",
"ContentText": "Welcome John",
"Subject": "Example Subject",
"IncludeEmailFooter": true,
"Schedule": "2017-10-13 10:00:00",
"EmailCategory": ""
}

JSON Properties

Parameter Description
SenderType

This parameter lets you choose how you want to pass the sender of the email. Depending on the chosen value for this parameter, you will have to pass a corresponding value in the “Sender” parameter.

The “SenderType” can be passed as:

  • UserId
    If you pass this value, the “Sender” parameter must contain the user Id of the sender.

 

  • “UserEmailAddress”
    If you pass this value, you can simply specify the sender’s email address in the “Sender” parameter.

 

  • “APICaller”
    If you pass this value, you don’t have to pass any value in the “Sender” parameter. The email address of the person who called the API will automatically be displayed as the sender of the email.

 

  • “LeadOwner”
    If you pass this value, you don’t have to pass any value in the “Sender” parameter. The lead owner will automatically be displayed as the sender of the email.
Sender

This is the sender of the email that your lead will see in the sent from field of your email.

  • If you passed the “SenderType as “UserId” then you will have to specify a user Id here. If you’re having trouble finding a user id, use the Get User API.

 

  • If you passed the “SenderType” as “UserEmailAddress” then simply pass an email address here.

 

  • You don’t have to pass a value for the “Sender” parameter if you passed “APICaller” or “LeadOwner” as the “SenderType”.
RecipientType

Similar to the “SenderType” parameter, this parameter lets you choose how you want to pass the recipient of your email.

You can pass the “RecipientType” as:

  • “Lead Number”
  • “LeadEmailAddress”
  • “LeadId”
RecipientEmailFields

This parameter is not mandatory. If you have created custom fields for your leads where you are recording a secondary or alternative email address then you can pass the schema name of that field here. If you pass this parameter, your email will be delivered to all the email addresses recorded in your custom fields. You can find the schema name by navigating to Settings>Customization>Lead Fields

Recipient

This is the lead that will receive your email.

  • If you passed “LeadNumber” in the “RecipientType” parameter, then pass the lead number here. If you’re having trouble locating the lead number, go to your LeadSquared account and navigate to the lead details section on the lead details landing page.

 

  • If you passed “LeadEmailAddress” in the “RecipientType” parameter, then pass the email address of the lead here.

 

  • If you passed “LeadId” in the “RecipientType” parameter, then pass the lead Id here. You can get the lead Id from the URL on the lead details page.
EmailType

You can pass the “EmailType” as either:

  • “HTML”
    If you pass this value, the “ContentHTML”, “ContentText” and “Subject” parameters will be mandatory.

 

  • “Template”
    If you pass this value, the “EmailLibraryName” parameter will be mandatory.
EmailLibraryName

This parameter is only required if you passed the “EmailType parameter as “Template”. You can pass the name of any email template that you saved in your LeadSquared account. You can find your saved templates by navigating to Content>Email Library.

ContentHTML

This parameter is required if you passed the “EmailType” parameter as “HTML”. You can pass the HTML code that you want rendered on the email here.
Be sure to use a valid JSON data format to pass the HTML contents in the email body. For example:
“<h1>Hello Lead, </h1>
<h4 id=”second”>This is the second line of the email</h4>
<p id=”third” class=”third-value”>Third Row</p>”

ContentText

This parameter is required if you passed the “EmailType” parameter as “HTML”. Since some email clients do not support certain HTML formats, this parameter gives you the ability to deliver simple text in the body of your email. You can pass any text you want here.

Subject

Pass the subject of your email here.

IncludeEmailFooter

You can pass this value as “true” if you wish to add a footer in your email or as “false” if you don’t.

Schedule

This parameter allows you to schedule the email for a later date and time. If you don’t pass this value the email will be sent immediately.
Be sure to adhere to the “YYYY-mm-dd HH:mm:ss” format.

EmailCategory

This parameter is not mandatory but you can pass the email category name if you have them created in your LeadSquared account. You can create new email categories by navigating to Settings>Email Settings on the LeadSquared UI.

Response

200 OK

Content-Type: application/json

{
    "ID": "302a8f26-9465-11e7-b0ab-02e89b2fb8f4",
    "MemberCount": 1,
    "TotalRecipient": 1
}

HTTP Response Code

Code Description
200 OK

This is the status code for successful API call.

401 Unauthorized

The API call was made with invalid access credentials. Check your AccessKey and SecretKey.

400 Bad Request

The message body on the request is not as per API specification. Make sure that content type is set to “application/json” and the JSON body has correct attribute names and structure.

404 Not Found

The API could not be found. Please check the API signature.

429 Too Many Requests

API calls exceeded the limit of 25 in 5 second(s)

500 Internal Server Error

The API called failed. There could be many reasons for it. Check the exception message to get more details.