Send Email through Pardot API in Salesforce Apex
When we use Email One-to-One in Pardot API
Send an email to a single prospect. You can specify the prospect by Pardot ID or email address.
api/email/version/3/do/send/prospect_email/<prospect_email>?...
The required parameter in one-to-one email is:- Specify campaign_id and email_template_id. or Specify campaign_id, text_content, name, subject, from_email and from_name. or Specify campaign_id text_content, name, subject, and from_user_id.
Parameter we can set :-
Example of One-to-One email
POST /api/email/version/3/do/send/prospect_id/1234? HTTP/1.1
Host: pi.pardot.com
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer <ACCESS TOKEN>
Pardot-Business-Unit-Id: <BUSINESS UNIT ID>
campaign_id=5678&from_name=A Marketer&from_email=marketing@company.com&name=An Email&subject=A Subject&text_content=text email body %%unsubscribe%%&html_content=<html><head><head/><body>html email body %%unsubscribe%%</body></html>
Response of One-to-One email
<rsp stat="ok" version="1.0">
<email>
<id>1234</id>
<name>An Email</name>
<isOneToOne>true</isOneToOne>
<subject>A Subject</subject>
<message>
<text>text email body %%unsubscribe%%</text>
<html><html><head><head/><body>html email body %%unsubscribe%%</body></html></html>
</message>
<created_at>2020-11-20 18:04:46</created_at>
</email>
</rsp>
When we use Email List Send in Pardot API
Send an email to every prospect on the specified list.
API Request Url = "https://pi.pardot.com/api/email/version/4/do/send/?format=json"
Body:-
campaign_id=5205&from_name=A Marketer&from_email=<Your Email Address>&list_ids[]=814426&list_ids[]=303&name=An Email&subject=A Subject&text_content=text email body %%unsubscribe%%&html_content=<html><head><head/><body>html email body %%unsubscribe%%</body></html>
Required Parameters
----------------------------
Specify list_ids[], campaign_id, and email_template_id. Or
Specify list_ids[], campaign_id, text_content, name, subject, from_email, and from_name Or
Specify list_ids[], campaign_id text_content, name, subject, and from_user_id.
Parameters we can set:-
Example:-
-------------
curl https://pi.pardot.com/api/email/version/3/do/send \
--header "Authorization: Bearer <ACCESS TOKEN>" \
--header'Pardot-Business-Unit-Id: <BUSINESS UNIT ID>'
--data-urlencode campaign_id=12345 \
--data-urlencode from_assigned_user=1 \
--data-urlencode email_template_id=6789 \
--data-urlencode list_ids[]=123 \
--data-urlencode list_ids[]=456 \
--data-urlencode list_ids[]=789 \
--data-urlencode list_ids[]=101 \
--data-urlencode suppression_list_ids[]=987 \
--data-urlencode suppression_list_ids[]=654 \
--data-urlencode tags[]=new_prospect_email \
--data-urlencode tags[]=cart_abandoned \
--data-urlencode tags[]=subtotal_over_200 \
--data-urlencode scheduled_time=2021-10-31T17:00:00-0400 \
--data-urlencode format=json
Response:-
---------------
<rsp stat="ok" version="1.0">
<email>
<id>1234</id>
<name>An Email</name>
<isOneToOne>false</isOneToOne>
<subject>A Subject</subject>
<message>
<text>text email body %%unsubscribe%%</text>
<html><html><head><head/><body>html email body %%unsubscribe%%</body></html></html>
</message>
<created_at>2020-11-20 18:04:46</created_at>
</email>
</rsp>
References :
https://developer.pardot.com/kb/api-version-3/emails/
https://developer.pardot.com/kb/api-version-3/emails/#creating-the-email

Comments
Post a Comment