Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Last active September 23, 2015 23:42
Show Gist options
  • Save thinkingserious/ab70d83a11313b1b5149 to your computer and use it in GitHub Desktop.
Save thinkingserious/ab70d83a11313b1b5149 to your computer and use it in GitHub Desktop.
SendGrid Python v3 ASM Suppressions Example
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
# POST
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
group_id = <group_id_number> # If no group_id_number, the emails will be added to the global suppression group
emails = ['[email protected]', '[email protected]']
status, msg = client.asm_suppressions.post(group_id, emails)
print status
print msg
# GET
status, msg = client.asm_suppressions.get()
print status
print msg
status, msg = client.asm_suppressions.get(None,'[email protected]')
print status
print msg
status, msg = client.asm_suppressions.get(67,'[email protected]')
print status
print msg
# DELETE
status, msg = client.asm_suppressions.delete(67,'[email protected]')
print status
print msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment