sparkpost.transmissions

class sparkpost.transmissions.Transmissions(base_uri, api_key)

Transmission class used to send, list and get transmissions. For detailed request and response formats, see the Transmissions API documentation.

get(transmission_id)

Get a transmission by ID

Parameters:transmission_id (str) – ID of the transmission you want to retrieve
Returns:the requested transmission if found
Raises:SparkPostAPIException if transmission is not found
list()

Get a list of your transmissions

Returns:list of transmissions
Raises:SparkPostAPIException if API call fails
send(**kwargs)

Send a transmission based on the supplied parameters

Parameters:
  • recipients (list|dict) – If list it is an list of email addresses, if dict {'address': {'name': 'Name', 'email': 'me' }}
  • recipient_list (str) – ID of recipient list, if set recipients above will be ignored
  • cc – List of email addresses to send carbon copy to
  • bcc – List of email addresses to send blind carbon copy to
  • template (str) – ID of template. If set HTML or text will not be used
  • use_draft_template (bool) – Default to False. Set to true if you want to send a template that is a draft
  • html (str) – HTML part of transmission
  • text (str) – Text part of transmission
  • subject (str) – Subject of transmission
  • from_email (str) – Friendly from of transmission, domain must be a verified sending domain to your account or transmission will fail
  • reply_to (str) – Reply to of transmission
  • description (str) – Description of transmission
  • campaign (str) – Campaign of transmission
  • metatdata (dict) – Any data you want to send along with transmission, used in WebHooks
  • substitution_data (dict) – Corresponds to substitutions in html/text content. See substitutions reference.
  • attachments (dict) – Corresponds to attachments. See Attachment Attributes reference. Replace data by filename if you want the library to perform the base64 conversion. Example: “filename”: “/full/path/test.txt”
  • start_time (str) – Delay generation of messages until this datetime. Format YYYY-MM-DDTHH:MM:SS+-HH:MM. Example: ‘2015-02-11T08:00:00-04:00’.
  • track_opens (bool) – Defaults to True. Used to track opens of transmission
  • track_clicks (bool) – Defaults to True. Used to track clicks of transmission
  • use_sandbox (bool) – Flag must be set to use sandbox domain instead of verified sending domain. Limited to a lifetime of 50 transmissions with this domain
  • transactional (bool) – Whether message is transactional or non-transactional for unsubscribe and suppression purposes
  • skip_suppression (bool) – Whether or not to ignore customer suppression rules, for this transmission only. Only applicable if your configuration supports this parameter. (SparkPost Elite only)
  • custom_headers (dict) – Used to set any headers associated with transmission
Returns:

a dict with the ID and number of accepted and rejected recipients

Raises:

SparkPostAPIException if transmission cannot be sent