-
Notifications
You must be signed in to change notification settings - Fork 323
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
How to add/remove contacts to a list via new marketing API? #456
Comments
#391 might be helpful to you. This does need better documentation |
Thanks @rickychilcott , I read through that, but the example is how to create a contact & add it to a list at the same time. I'm trying to figure out how to add/remove contacts to/from lists without updating contact info. Any ideas? Essentially, how to translate DELETE /marketing/lists/{id}/contacts. (https://sendgrid.api-docs.io/v3.0/lists/remove-contacts-from-a-list) to So far, I can retrieve a list
But delete a contact doesn't work, it deletes the entire list instead of a single contact in a list:
|
Adding a user to a list without changing anything else about that should be something like: contacts = [{ email: "[email protected]"}]
list_ids = ["abcd"]
response = sg.client.marketing.contacts.put(request_body: {list_ids: list_ids, contacts: contacts}) Note, if the email address does not exist, it will create a new contact. Regarding deleting a contact from a list, I havent' done it myself. The code you wrote does look close (e.g. But since that URL you linked to is sg.client.marketing.lists._(list_id).contacts.delete(contact_ids: contact_id) |
Thanks @rickychilcott , great ideas! It turns out the correct formatting for removing a contact from a list is:
I found some examples of similar API calls via https://github.com/sendgrid/sendgrid-ruby/blob/main/examples/suppression/suppression.rb |
Please be sure to vote on this issue to help move the priority up. Thanks! |
There doesn't seem to be any documentation on how to add/remove contacts to a list via the new marketing API? Is there a gem wrapper around this https://sendgrid.api-docs.io/v3.0/lists/remove-contacts-from-a-list?
The text was updated successfully, but these errors were encountered: