Search code examples
c#sendgridsendgrid-api-v3

SendGrid api email activity response authorization required


I have a sendgrid account which includes 7 days of email history. I try to get these with the api command:

var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "messages?limit=10");

but this gives the response: {"errors":[{"message":"authorization required"}]}

I guess the api key isn't correct, but when I try to execute the command:

var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "suppression/bounces/" + email);

it gives no error and responses the right info. I checked the api key and it has full access.

I've also tried: sendgridclient.AddAuthorization(new KeyValuePair<string, string>("Authorization", $"Bearer {apiKey}"));

but this gives the same response

Do you know what I am doing wrong?


Solution

  • Already got an answer from SendGrid:

    Unfortunately in order to gain access to the Email Activity Feed API, you must purchase additional email activity history.

    Or you can use our event webhook for your activity. https://sendgrid.com/docs/for-developers/tracking-events/getting-started-event-webhook/

    So it seems that our license included history is only accessible from the SendGrid website, not from the API without an additional license.