Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for the new Email Activity API (beta) #587

Closed
thinkingserious opened this issue Mar 14, 2018 · 13 comments · Fixed by #759
Closed

Updates for the new Email Activity API (beta) #587

thinkingserious opened this issue Mar 14, 2018 · 13 comments · Fixed by #759
Labels
difficulty: medium fix is medium in difficulty status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap

Comments

@thinkingserious
Copy link
Contributor

SendGrid has added an API to download information from the Email Activity feed. There are four new endpoints:

A getting started doc for the API is here.

The following items need to be updated in this repo:

@thinkingserious thinkingserious added status: help wanted requesting help from the community difficulty: medium fix is medium in difficulty up-for-grabs type: twilio enhancement feature request on Twilio's roadmap labels Mar 14, 2018
@benrolfe
Copy link

Have these new endpoints been implemented in the PHP SDK?

@mudit1987100
Copy link

I am using the sendgrid api in my project and working fine but it's not returning the msg_id and also I don't found any documentation that how to get that msg_id in response when we send a email. Can you please, help me on this. Thanks in advance.

@childish-sambino
Copy link
Contributor

@mudit1987100 It's a response header when sending mail: X-Message-Id

@mudit1987100
Copy link

mudit1987100 commented Jul 8, 2020

@childish-sambino Thanks for your response but this message id is not that id using which I can track the activity of the email. How I can get the sendgrid assigned ID so I can pass it into the activity API. I have checked the webhooks but for that we have to upgrade our servers which will be costly so is there any way we can get the ID in response and directly pass that ID into activity API. Please, help on this.

@childish-sambino
Copy link
Contributor

@mudit1987100 This was discussed here with some examples: #948

@mudit1987100
Copy link

@childish-sambino Thanks for your quick reply. I tried this way:

https://api.sendgrid.com/v3/messages?limit=10&query=msg_id%3D%22iioCSRBVTmWWymThlO0kbA%25%22

e.g. msg_id = 'message_id%'

but I am getting blank array:

stdClass Object ( [messages] => Array ( ) )

@childish-sambino
Copy link
Contributor

@mudit1987100 Recommend trying this with cURL or Postman first to make sure the syntax is proper.

@mudit1987100
Copy link

mudit1987100 commented Jul 8, 2020

@childish-sambino Many Thanks. I am using cURL to call this API here's the code below:

$url = 'https://api.sendgrid.com/v3/messages?limit=10&query=msg_id%3D%22iioCSRBVTmWWymThlO0kbA%25%22';
$header = array();
$header[] = 'Authorization: Bearer <<My API Key Here>>';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response);
curl_close($ch); // Close the connection
print_r($result);

@childish-sambino
Copy link
Contributor

@mudit1987100 You'll need to use LIKE to do the prefix matching I mentioned in the other thread. E.g.,
$url = 'https://api.sendgrid.com/v3/messages?limit=10&query=msg_id LIKE "iioCSRBVTmWWymThlO0kbA%"';

@mudit1987100
Copy link

@childish-sambino Many Many Thanks. It worked. Here's the final url I encoded may be it can help someone else:

$url = 'https://api.sendgrid.com/v3/messages?limit=10&query=msg_id+LIKE+%22iioCHDBVTmWWymThlO5kbA%25%22'

Below is the response:

( [messages] => Array ( [0] => stdClass Object ( [from_email] => [email protected] [msg_id] => iioCSRBVTmWWymThlO8kbA.filterdrecv-p3mdw1-75c584b9c6-jp7b2-18-5F15E2A1-X.0 [subject] => Sending with Twilio SendGrid is Fun [to_email] => [email protected] [status] => delivered [opens_count] => 3 [clicks_count] => 0 [last_event_time] => 2020-07-08T15:19:00Z ) ) )

Again Thanks @childish-sambino

@mudit1987100
Copy link

@childish-sambino is it possible to get the messade id using the SMTP email as I'm using SMTP protocol to send email but not getting the X-Message-ID in header. Please, help me on this. Many Thanks

@childish-sambino
Copy link
Contributor

@mudit1987100 I'm not familiar with what data is available in the SMTP response. Best to reach out to support.

@mudit1987100
Copy link

@childish-sambino many thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants