Showing results for 
Search instead for 
Did you mean: 

Add new contacts via shell (or curl)

Occasional Participant

Add new contacts via shell (or curl)

Hey there,

I'm a newbie with the API and have started to look at the API and am getting a bit overwhelmed ;-)


I'm looking to add customers every time we get an order from our 3rd party provider.  Then I'd like to run a shell script to add the contact's email address (and a few other fields, such as name and country, etc.).  I can generate the JSON file no problem.  


Two questions:

1. Do you have a curl example I can follow? (or whatever is appropriate to call from a shell script).  

2. In our 3rd party order form, we will be asking if customers want to be added to our mailing list.  I have that info when I run my shell script.  I see in another thread that  I can use ACTION_BY_VISITOR to get express consent set in your db,  and ACTION_BY_OWNER to set implied (soft) consent.


However, I do not see that an ACTION field in the list of fields of the JSON data (


Any help on getting new contact info into the constant contact db via a shell script, complete with express or implied consent, would be very helpful!



Occasional Participant

Re: Add new contacts via shell (or curl)

Also, to be clear, I'm not a developer for a 3rd party app for email services. 


I'm just a geek trying to manager our own in-house list(s) for customers.




Re: Add new contacts via shell (or curl)

Hello Pete,

Thank you for reaching out to the API Support team here at Constant Contact.

First the ACTION_BY parameter does not go in the JSON data; it is used as a URL parameter exactly the same way that your API Key is used. Second, you can only set the ACTION_BY parameter when working with base Contacts collection ( All contacts added via the bulk activity method you linked are added as action_by_owner. Below is an example using cURL to post a new contact.

curl -X POST \
  '{API_KEY}&action_by=action_by_visitor' \
  -H 'Authorization: Bearer {ACCESS_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
    "addresses": [
      "address_type": "BUSINESS",
      "city": "Belleville",
      "country_code": "CA",
      "line1": "47 Shawmut Ave.",
      "line2": "Suite 404",
      "postal_code": "K8b 5W6",
      "state_code": "ON"
    "lists": [
        "id": "1"
      "cell_phone": "555-555-5555",
      "company_name": "System Optimzations",
      "confirmed": false,
      "email_addresses": [
        "email_address": ""
  "fax": "555-555-5555",
  "first_name": "Ronald",
  "home_phone": "555-555-5555",
  "job_title": "Systems Analyst 3",
  "last_name": "Martone",
  "prefix_name": "Mr.",
  "work_phone": "555-555-5555"

Please let me know if you have any other questions!


David B.
Tier II API Support Engineer

Tags (2)
Occasional Participant

Re: Add new contacts via shell (or curl)

Thanks so much.  You've provided exactly the answer I needed.  I have a few more questions that I'll take offline and send to you via email.  The questions are just concerning a few details.