Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Last active November 17, 2015 08:04
Show Gist options
  • Save thinkingserious/40139ff4a12307d1d58a to your computer and use it in GitHub Desktop.
Save thinkingserious/40139ff4a12307d1d58a to your computer and use it in GitHub Desktop.
SendGrid Python v3 API Keys Example POST
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]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
name = "My Amazing API Key"
status, msg = client.apikeys.post(name)
msg = json.loads(msg)
api_key_id = msg['api_key_id']
print status
print msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment