SendGrid Advanced Suppression Manager (ASM) Java Client
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


SendGrid Advanced Suppression Manager (ASM) Java Client

Manages global and group based e-mail suppressions using the SendGrid Advanced Suppression Manager. This library does not send e-mail.

#This project has been deprecated. The SendGrid Java Client version 3.x.x now supports ASM out of the box.

This library uses the older SendGrid v2 Web API and was a stop-gap until the ASM features were supported in the standard Java client. The project will be maintained as needed. I expect the SendGrid v2 Web API to be turned off at some point, so you are encouraged to upgrade.


Jackson for JSON parsing

Apache HttpClient

Apache Fluent HttpClient




dependencies {
    compile "com.github.krenfro:sendgrid-asm-java:0.0.4"
    compile "org.apache.httpcomponents:httpclient:4.3.6"
    compile "org.apache.httpcomponents:fluent-hc:4.3.6"
    compile "com.fasterxml.jackson.core:jackson-databind:2.4.0"


Classes can be loaded using either an API Key, or your username and password.


SuppressionManager suppressionMgr = new SuppressionManager("apiKey"); // or:
//SuppressionManager suppressionMgr = new SuppressionManager("username", "password");

//get Suppression for a particular group and user
Suppression suppression = suppressionMgr.retrieve(42, "email");

//if you already have a Group, you can use that instead
suppression = suppressionMgr.retrieve(group, "email");

if (suppression.isSuppressed()){

//add suppressions
suppressionMgr.add(group, "email");
suppressionMgr.add(group, "email", "email2", "email3");

//remove a suppression
suppressionMgr.remove(group, "email");
suppressionMgr.remove(group, "email", "email2", "email3");

//get list of all Suppressions, one for each suppression group
List<Suppression> suppressions = suppressionMgr.retrieve("email");

//selectively save all of them"email", suppressions);

//get list of all e-mails suppressed in a group
List<String> emails = suppressionMgr.retrieve(group);


GroupManager groupMgr = new GroupManager("apiKey"); // or:
//GroupManager groupMgr = new GroupManager("username", "password");

//retrieve all groups
List<Group> groups = groupMgr.retrieve();

//add a new group
Group group = groupMgr.add("group name", "group description");

//retrieve by id
group = groupMgr.retrieve(42);

//remove groups

##Global Suppressions

GlobalSuppressionManager globalMgr = new GlobalSuppressionManager("apiKey"); // or:
//GlobalSuppressionManager globalMgr = new GlobalSuppressionManager("username", "password");

if (globalMgr.has("email")){
	//do something


//you can add and remove multiple
globalMgr.add("email", "email2", "email3");
globalMgr.remove("email", "email2", "email3");


Integration tests run against an actual SendGrid account with either form of credentials:

mvn -Dsendgrid-username=ABC -Dsendgrid-password=XXXXX clean test
mvn -Dsendgrid-apikey=XXXXX clean test