API V3 - How to set contact custom fields on add/sync api calls

+1 on this one. We are trying to achieve the same thing.

We have coded a custom deep data integration. & now need to also update some custom fields every time an order goes through. Thinking using the add/sync contact update is the best idea, but lots how to update 10 fields at once.

Any help would be appreciated.

1 Like

Hello @henryreith.

I’ve found this API call to update fields:

But it does not tell how we can update multiple custom fields at once and also it does not allow us to add/sync contacts and set the custom fields at the same time. According to documentation, we would have to do 2 Http calls to simply add a contact and set custom fields:

1- http call to sync the contact
2- http call to update custom fields (I don’t even know if this is possible as the documentation shows only one custom field at request body. I’ll try it out passing multiple fields in request body to see how api will respond.

Even if this option works, would be necessary to do 2 http calls. Would be easier if add-sync contact Api call also supports custom fields, as they are directly related to contacts.

Note: It sounds possible on API version 1. API Examples Using contact_add. I will keep you update if I find a good solution for that.

Cheers

Nice work. That’s what we have found too. So we are using the API V1 to update contacts custom fields as we have so many to do at once.

Awesome! Doing same here as we also have many custom fields :slight_smile:

Any update on this? Would like to create a contact with a custom field using the v3 API.

1 Like

Same here. is there any update using the APIv3?

Currently we use active campaign heavily. we have around 8100+ contacts. We currently add new contacts directly via the site itself but we are wanting to add contacts from another source like another database using the api.

I can create a contact, create an account and create an account association but the contact has custom fields for address, city, state etc. So how do i associate the contacts address etc via the custom fields?

Create custom fields sounds like it creates a brand new custom field. Does the ‘Create Custom Field Values’ do the work of associating the contact with the correct custom field?

{
“fieldValue”: {
“contact”: 2,
“field”: 3,
“value”: “Blue”
}
}

+1 as well. When I add a contact, I need to set several custom fields at once. It seems silly to make 5-6 API calls when one would suffice.

Hey Everyone, there’s an undocumented call you can use to do this sort of thing, but it also allows you to BULK UPDATE EVERY CONTACT!!! I write in caps, because we had an error that updated a whole stack of contacts because the payload was created incorrectly. You will want adequate protection in your update command to ensure that it always has a contact id included in the payload.

Here’s a laravel implementation we completed which you could modify for your own purposes.

        if(data_get($customFieldPayload, 'contactIds') === null) {
            throw new \InvalidArgumentException('An ID must be supplied to prevent catastrophic updates in AC which can cause mass mailouts');
        }
        // This api call is not documented. AC may change it without notice. Keep an eye out for errors.
        $this->getClient()->post('contact/bulk_update', $customFieldPayload);

I’m dealing with the same issue, how to create a contact with custom fields.
I interpreted the
{
“fieldValue”: {
“contact”: 2,
“field”: 3,
“value”: “Blue”
}
}
code as what is needed to create a field via the API. The fields are already created in my AC account, I just need to create/sync contact with custom field values.

Has anyone worked this out?
A bulk update makes me very nervous.

Anyone else who finds this thread looking for the answer. If you are using the php wrapper they put out you can send all the custom fields in a single array. However it is recommended you wrap ALL of the custom field declarations in a urlencode. Like so. $contact[urlencode(‘field[%FIELDNAME%]’)] = ‘value’;

Does anyone know what the /id in the call to update a custom field value stands for?
https://developers.activecampaign.com/reference#update-a-custom-field-value-for-contact

PUT https://youraccountname.api-us1.com/api/3/fieldValues/id

I don’t get it, as the field that I want to update is already in here I think:
{
“fieldValue”: {
“contact”: 4,
“field”: 24,
“value”: “Blue”
}
}
What value do I need to use for the id?.. Thanks for any help

Could you please provide the structure of the $customFieldPayload? Also, does the ‘bulk_update’ request only update (PUT only) already existing values or does it also create new contacts if email does not exist?

This seems like the solution we need. Are you using API v1 or v3?

Hi,

I found API for create or update only single custom field value.

For Create : https://youraccountname.api-us1.com/api/3/fieldValues

For Update :
https://youraccountname.api-us1.com/api/3/fieldValues/id

Is there any API available for update or create multiple custom field value at a time in single API call?

Thanks.

Hi,

I am not able to get all field values from API (API Name : List all custom field values). Only 20 field values I am able to get at a time. If we apply filter still I am getting only 20 field values.

API (List all custom field values) : https://youraccountname.api-us1.com/api/3/fieldValues

Thanks

There is any API available with the help of it I can get all custom fields related to one particular contact id.

Thanks

@certaintyinfotech - You can use the API v3 call “Retrieve a contact” to look up a specific contact and any custom field values they have will be returned in the response: https://developers.activecampaign.com/reference#get-contact

Hope this helps!

Hi, I have the same question: what is the id that is requested on the URL? Did you managed to get it to work?

I have a field with number 4, and a fieldOption number 18, but the following request fails without many details:

url: PUT https://youraccountname.api-us1.com/api/3/fieldValues/4

{
    “fieldValue”: {
        “contact”: 1234,
        “field”: 4,
        “value”: “Signed up” // aka fieldOption 18
    }
}

This post describes the use of the bulk contact import/update/subscribe endpoint in version 3 of the API.