2
votes

I'm working on a app where I add the user to sendgrid during sign up using the api:

PUT /marketing/contacts

I also add the user to specific list based on the status(DB data) of the user during signup.

Say I've 3 lists in sendgrid List A, List B, List C

Now I run a cron on every hour and check the status of the user and based on the condition I want to move the user from say List A to List B

As I checked I can add the user to the new list using the same api:

PUT /marketing/contacts

And I can remove the user from the previous list I can use the api:

DELETE /marketing/lists/{id}/contacts

But to in which list the user was previously added and to get the contact id from sendgrid I need to get the contacts from sendgrid, I'm using the api:

GET /marketing/contacts

But this api is only returning last 50 data and pagination option is also not there.

I also tried the api:

GET https://api.sendgrid.com/v3/contactdb/recipients?page_size=100&page=1

But this api is also returning me error

error:
{
  "errors": [
     {
       "field": null,
       "message": "access forbidden"
     }
  ]
}

But the api key is fine because the marketing apis works with the same api key and the api key is generated with full access.

https://sendgrid.com/docs/API_Reference/api_v3.html https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html

Can someone please help me to get all contacts from sendgrid via any other api or if there is any params I'm missing in the above mentioned apis.

2
I have been the same trouble, have had you discovery how to solve? - Develop_SP
I have the exact same problem, it's becoming really frustrating. I even ran Arjun tool for finding parameters on a specific URL and it didn't find a single parameter, I'm starting to believe that there really is no way to paginate. - nenadp

2 Answers

1
votes

After contacting support, this is what I got:

In order to fetch all the existing contacts you can use this endpoint: https://api.sendgrid.com/v3/marketing/contacts/exports
POST /marketing/contacts/exports

This will return id, which you use to GET /v3/marketing/contacts/exports/<id>, receiving a file. So download it, open and read csv. Not exactly what I wanted, but it might do the job for others.

Docs about this endoint here.

0
votes

For me, our company is using legacy marketing so i have to use another endpoint POST v3/contactdb/recipient