如何在Pardot中配置Webhook?实现Prospect退订时触发POST请求
Great question—since Pardot (now Salesforce Marketing Cloud Account Engagement) doesn’t have that one-click webhook setup like Mailchimp, we can use its built-in automation tools to replicate this exact functionality. Here are two reliable, actionable methods:
Method 1: Use Automation Rules with "Send Post Message" (No-Code Approach)
This is the quickest way to get up and running if you’re using the modern Pardot/MCAE interface:
Prepare your website’s POST endpoint
First, make sure your site has a publicly accessible endpoint that can accept POST requests (e.g.,https://yourdomain.com/webhooks/pardot-unsubscribe). It should be able to parse incoming JSON payloads with prospect details like email, ID, etc.Build the Automation Rule in Pardot
- Head to Automation > Automation Rules in your Pardot dashboard.
- Click Add Automation Rule and name it something clear, like "Trigger Unsubscribe POST to Website".
- Under Rule Criteria, set the condition to:
Prospect > Unsubscribed > is > True
- Scroll to the Actions section, find and select Send Post Message.
- Configure the request details:
- URL: Paste your website’s endpoint URL.
- Request Method: Choose
POST. - Request Body: Use Pardot merge fields to pass relevant data (example:
{"email":"{{prospect.email}}","prospect_id":"{{prospect.id}}","unsubscribe_timestamp":"{{date_time}}"}). - Authentication (if needed): Add headers for API keys or tokens if your endpoint requires verification.
Test the workflow
Manually unsubscribe a test prospect in Pardot, then check your endpoint logs to confirm the POST request was received successfully.
Method 2: Use Pardot API + Apex (For Salesforce-Integrated Environments)
If you’re running Pardot alongside a full Salesforce org, you can use Apex triggers to listen for unsubscribe sync events:
Ensure Pardot-Salesforce Sync is active
Confirm your Pardot prospects are syncing to Salesforce Contact/Lead records (this should be enabled by default if you’ve set up the integration).Write an Apex Trigger
Create a trigger that fires when a Contact/Lead’sHasOptedOutOfEmailfield flips toTrue(this mirrors Pardot’s unsubscribe status). Use Salesforce’sHttpclasses to send the POST request. Example snippet:trigger UnsubscribeWebhook on Contact (after update) { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://yourdomain.com/webhooks/pardot-unsubscribe'); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json'); for(Contact c : Trigger.New) { // Only trigger when the unsubscribe status is newly set if(c.HasOptedOutOfEmail && !Trigger.OldMap.get(c.Id).HasOptedOutOfEmail) { String payload = JSON.serialize(new Map<String, Object>{ 'email' => c.Email, 'salesforce_contact_id' => c.Id, 'unsubscribe_date' => DateTime.now() }); request.setBody(payload); HttpResponse response = http.send(request); // Add error logging here if you need to debug failures } } }Validate the trigger
Unsubscribe a test prospect in Pardot, wait for the sync to Salesforce, then check your endpoint logs to confirm the POST request was sent.
Key Tips:
- Payload Customization: Both methods let you tailor the data sent to your site—use Pardot merge fields (Method 1) or Salesforce fields (Method 2) to pass exactly what you need.
- Error Handling: For Method 1, check Pardot’s Automation Rule logs if requests fail. For Method 2, add debug logging in Apex to track issues.
- Security: Always use HTTPS for your endpoint, and add authentication (like API keys in headers) to block unauthorized requests.
内容的提问来源于stack exchange,提问作者Mitsu Chatrola




