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

{ "massupdate_params": 
    { "uid": 
        [ "003d000001lVSEtAAO"
    ], 

    "email_opt_out": false

    }
}



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

 "email": [
        {
            "email_address": " --my-email-address--",
            "invalid_email": false,
            "opt_out": false,
            "email_address_id": "0kQoprP4FqQdpKThqWhtZKHZYDo4DT",
            "primary_address": true,
            "reply_to_address": false
        }

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

{ "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
        }
    ]

    }
}


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

Parents
  • 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! 

Reply
  • 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! 

Children
No Data