Edit a contact's deal by APIs

Hello,

I’m trying to modify a contact’s deals by the API, I don’t know if that’s possible.

I thought that maybe I could achieve it by an automation. What would be the best option of doing this?

1 Like

Hi, are you using the v3 or v2 API?
I believe that the contacts endpoint in the v3 API still hasn’t been finished.

Vote on my idea to finish/provide an update on it here:
https://ideas.activecampaign.com/ideas/AC-I-11589

Hi there, Amy from ActiveCampaign’s Customer Experience Team. We’re just refreshing our forum page and I wanted to add some help here for anyone who comes across this page/question/post.

Modifying a contact’s deals via the API is indeed possible with ActiveCampaign. You can use the Deals API to create, update, or delete deals associated with a contact.

Here’s what you’d need to do:

  1. Retrieve the Contact’s Deals: Before modifying a contact’s deals, you need to retrieve the existing deals associated with that contact. You can use the Deals API to fetch this information.

Here’s an example using Python and the requests library:

import requests

url = "https://your-account.api-us1.com/api/3/contacts/123/deals"

headers = {
    "Api-Token": "your-api-key"
}

response = requests.get(url, headers=headers)

deals = response.json()

print(deals)
  1. Update the Deals: Once you have retrieved the contact’s deals, you can modify them as needed. You can update deal properties such as deal stage, deal value, or any custom deal fields.

Here’s an example of how you might use the Update a Deal API call to modify a contact’s deal:

import requests

url = "https://your-account.api-us1.com/api/3/deals/{dealId}"

headers = {
    "Api-Token": "your-api-key",
    "Content-Type": "application/json"
}

payload = {
    "deal": {
        "id": "123",  # Specify the ID of the deal you want to update
        "contact_id": "456",  # Specify the ID of the contact associated with the deal
        "title": "Updated Deal Name",
        "value": 1000,  # Updated deal value
        "stage": 2  # Updated deal stage ID
    }
}

response = requests.put(url, headers=headers, json=payload)

print(response.json())

Replace "your-account.api-us1.com", "your-api-key", {dealId}, "123", "456", "Updated Deal Name", 1000, and 2 with your actual data.

This example updates the name, value, and stage of a specific deal associated with a contact.

If API isn’t your thing and you prefer a more automated approach, you can utilise automations. You can create a custom automation that triggers based on certain conditions (e.g., when a contact submits a form or has a tag applied - whichever ‘milestone’ you want them to achieve) and then performs actions to modify the contact’s deals accordingly. To do this you will need to set up:

  • Trigger: Define the trigger for the automation, such as a tag being added to the contact or a custom field reaching a certain value.
  • Action: Use the “Update Deal” action within the automation to modify the contact’s deals. You can specify which deal to update and what changes to make, such as moving the deal to a different stage or updating deal properties.

Using the automation approach can provide more flexibility and scalability, especially if you have multiple milestones or conditions that trigger updates to the contact’s deals. Additionally, in my opinion, it’s just way more user-friendly :slight_smile:

Here’s a summary of the steps involved:

  1. Determine the conditions or triggers that should initiate the modification of the contact’s deals.
  2. Set up an automation in ActiveCampaign that is triggered by these conditions.
  3. Within the automation, use the “Update Deal” action to modify the contact’s deals based on your criteria.

Any questions or additional ideas, thread them below!