Skip to content

SendGrid “invalid_email” DELETE api is not deleting the data

So my code looks like this. This is copied from SendGrid’s docs. I have a similar function for deletion of spam emails and bounce emails. But this function throws an error whenever “Response response = sg.api(request);” is executed. Please help.

  public boolean deleteInvalidByEmail(String email, String apiKey) throws Exception{
         com.sendgrid.SendGrid sg = new SendGrid(apiKey);
         Request request = new Request();
         try {

            request.addQueryParam("email", email);
            Response response = sg.api(request);
            logger.debug("Mapped Output =========================");
        } catch (Exception ex) {
            throw new Exception("Unable to get Delete Bounce Email Address");
        return true;



From your comments, it seems that you are getting a 404 error, which tells you that the data you are trying to delete is not present. The error message says “resource not found”.

So, the email address you are trying to delete is not an invalid email that is available to delete. Note that invalid emails are described in the docs as:

An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipient’s mail server. Examples include addresses without the “@” sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.

Are you trying to delete an email that isn’t invalid?

2 People found this is helpful