2

We're moving from Mandrill to SparkPost. We figured that SparkPost's transmission is the closest thing to Mandrill's send-template message call.

Mandrill responded to those calls with a list of ids and statuses for each email. On the other hand SparkPost returns a single id and summary statistics (number of emails that were sent and number of emails that failed). Is there some way to get those ids and statuses out of the transmission response or at all?

jahu
  • 5,427
  • 3
  • 37
  • 64

3 Answers3

3

you can get the message IDs for messages sent using the tranmissions API two ways:

  • Query the message events API, which allows you to filter by recipients, template IDs, campaign IDs, and other values
  • Use webhooks - messages are sent to your endpoint in batches, and each object in the batch contains the message ID

Which method you choose really depends on your use case. It's essentially poll (message events) vs. push (webhooks). There is no way to get the IDs when you send the transmission because they are sent asynchronously.

richleland
  • 1,442
  • 9
  • 13
1

Querying message events API, while a viable option, would needlessly complicate our simple solution. On the other hand we very much want to use Webhooks, but not knowing which message they relate to would be troublesome...

The missing link was putting our own id in rcpt_meta. Most of the webhooks we care about do contain rcpt_meta, so we can substitute message_id with that.

jahu
  • 5,427
  • 3
  • 37
  • 64
0

I'm stacked too in this problem.. using rcpt_meta solution would be perfect if substitution would work on rcpt_meta but it's not the case.

So, in case of sending a campaign, I cannot specify all recipients inline but have to make a single API call for every message, wich is bad for - say - 10/100k recipients! But now, all transmission_id are unique for every SINGLE recipient, so I have the missing key and rcpt_meta is not needed anymore.

so the key to be used when receiving a webhook is composed:

transmission_id **AND** rcpt_to
lhenry2k
  • 99
  • 1
  • 5
  • @richleland , can you confirm my point about using substituition on metadata field in not doable ? tnx ! – lhenry2k Apr 14 '16 at 10:43
  • Hi @lhenry2k - you can't use substitution data in metadata. You can specify the metadata at both the transmission level and recipient level. Recipient level metadata will override any transmission level metadata.If I'm understanding correctly you'll want to specify your unique identifier at the recipient level. – richleland Apr 14 '16 at 13:33
  • Here's an example of what that would look like: "recipients": [ { "address": { "email": "wilma@flintstone.com", "name": "Wilma Flintstone" }, "metadata": { "myId": "wflintstone" } } ] – richleland Apr 14 '16 at 13:34