Set Contact > Email opt_out. via API (postman) or .csv Import

Hello all,

I am looking at how I can update Contact Records > Email Address > "Opt_Out" 

 - But via csv. (for either import or using Postman > Runner)

Found this old post but has a missing image - the crucial part of the solution Nerd



For info, we send some campaigns not from Sugar, and if folk opt out of those other campaigns i wish to opt them out from their contact record > email address in back in Sugar.

But, I am stuck on what that will look like.
I do a ton of updates and things using Postman, api.  And also use postman's runner often.  Hoping to do that.

tried this initial attempt:

PUT {{url}}Contacts/MassUpdate

Fullscreen
1
2
3
4
5
6
7
8
9
{ "massupdate_params":
{ "uid":
[ "003d000001lVSEtAAO"
],
"email_opt_out": false
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



If I GET my own contact record in postman I see this within:

Fullscreen
1
2
3
4
5
6
7
8
9
"email": [
{
"email_address": " --my-email-address--",
"invalid_email": false,
"opt_out": false,
"email_address_id": "0kQoprP4FqQdpKThqWhtZKHZYDo4DT",
"primary_address": true,
"reply_to_address": false
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Do I need to use something like:  <module>/:record/link/
Do I need the ID of the email?

Then this does work...   but I will not (not at first) know the email ID for each record:

PUT {{url}}Contacts/MassUpdate

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ "massupdate_params":
{ "uid":
[ "003d000001lVSEtAAO"
],
"email": [
{
"email_address": "--my-email-address--",
"invalid_email": false,
"opt_out": true,
"email_address_id": "0kQoprP4FqQdpKThqWhtZKHZYDo4DT",
"primary_address": true,
"reply_to_address": false
}
]
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Thank you in advance for any tips.  I may be on the wrong track completely!
No rush.
Just stuck.

  • sorry, somehow posted this Not in the dev club area.

  • Hi  

    With regards to the older SugarClub post, there is a KB article that covers updating email address attributes:

    Importing Email Address Attributes and Multiple Email Addresses

    For updating email addresses via API, the following dev guide page should help:

    Updating Email Addresses Using the REST API

    Chris

  • Ah great, thank you Chris (I saw you were online and was hoping you would see the post Smiley)
    That second link looks like exactly what was after - thank you.


    This is what I came up with in the meantime too:

     - I now have a report (rows & columns) which I got the query/sql from (show query > preview)
     - And created a custom query with that SQL. (manage advanced reports > show custom queries > create)

     - I can then change this:
     WHERE (((l1.email_address='myemailaddress'

     - to:
     WHERE (((l1.email_address IN('myemailaddress','nextEmail','nextEmail','nextEmail','and so on')

    Then, with our export from the other system of just the email addresses to opt out I can textjoin those in the spreadheet into an array like:
    'myemailaddress','nextEmail','nextEmail','nextEmail','and so on'

    Paste that into the custom query which will then return me the email address, contact id, email id, opt_out, email_invalid.

    Then, I can use those as variables in postman runner (where the .csv headers match exactly).

    I will update what I currently have using the link you provided too - then test!

    I am ahead of the game as I don't have the list from the other system yet. 
    But as I had said "yeah, just give me the list and I will opt them out in my system (sugar)"  I thought I better make sure I can actually do that! 

  • Hi   - not a problem, I just moved it over to DevClub for you Slight smile