Skip to main content
Best answer

How can I setup a Zap to delete contacts from Sendgrid based on Salesforce status change?


I recently created a Zap that adds contacts to a specific list in Sendgrid based on their Status in Salesforce. Now I want to make a Zap that will delete contacts from the same list if their Status changes and they no longer meet the criteria for the list. 

 

I know I can use a DELETE request to remove the contact from the list, but I need the Contact ID from Sendgrid to do so. Does anyone know how I can use a multi-step Zap to do the following?

  1. Trigger when a SFDC Contact Status changes to “Churned” 
  2. Take the contact’s email and search Sendgrid; then return the Sendgrid Contact ID
  3. Take the Contact ID and send it to Sendgrid through a DELETE request

Best answer by Troy Tessalone

@Kiera

Try changing it to Custom Request POST

Add this Header:

Content-Type: application/json

Add this as the Body.

Replace the email with the variable for the email.

{"emails": ["jane_doe@example.com"]}
View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

11 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30923 replies
  • September 22, 2023

Hi @Kiera 

Good question.

You can use the Webhooks app: https://zapier.com/apps/webhook/help

SendGrid API:

Steps

Action: Webook - POST

Action: Webhook - Custom Request (DELETE)

 

 


  • Author
  • New
  • 6 replies
  • September 22, 2023

Hi Troy, thanks for this. I’m receiving an error when I try to set up the POST request — the error is either that it’s not in valid JSON format or that there is no email, which I don’t understand


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30923 replies
  • September 22, 2023

@Kiera 

We would need to see detailed screenshots with how your Zap steps are configured along with the encountered errors.


  • Author
  • New
  • 6 replies
  • September 22, 2023

Of course — this is what I have at the moment. 

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30923 replies
  • Answer
  • September 22, 2023

@Kiera

Try changing it to Custom Request POST

Add this Header:

Content-Type: application/json

Add this as the Body.

Replace the email with the variable for the email.

{"emails": ["jane_doe@example.com"]}

  • Author
  • New
  • 6 replies
  • September 22, 2023

@Troy Tessalone 

That worked, thank you!

 

Now my only other question is how to tell Zapier to pass the returned Contact ID through to the next step, with the DELETE request?

 

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30923 replies
  • September 22, 2023

@Kiera 

Try following this SendGrid API endpoint documentation: https://docs.sendgrid.com/api-reference/contacts/delete-contacts

We would need to see screenshots of your Zap step and errors.


  • Author
  • New
  • 6 replies
  • September 22, 2023

 


  • Author
  • New
  • 6 replies
  • September 22, 2023

@Troy Tessalone Sorry, I just realized I was using the List ID instead of the Contact ID in the screenshots above. I’ve changed it to Contact ID but it still doesn’t seem to be working. In the body, I have:

{contact_ids=VARIABLE”}


  • Author
  • New
  • 6 replies
  • September 22, 2023

@Troy Tessalone Ah, I figured it out. I just needed to append the contact id to the end of the url, rather than in the body.

 

Thanks so much for your help today!


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30923 replies
  • September 22, 2023

@Kiera 

Try this…

Remove the Body values.

In the URL, append this: ?delete_all_contacts=true&ids=[EMAIL]

Replace [EMAIL] with the mapped variable.