ActiveCampaign Forum

How to retrieve a contact along with any custom fields using API v3?


#1

I’m currently using v3 of your RESTful API to integrate ActiveCampaign with my company’s web application (running Laravel php framework).

And I wonder is it possible while retrieving a contact using [GET @ /contacts/id](https://developers.activecampaign.com/reference#get-contact) to have all the custom fields and their values along with the standard build-in fields (email, firstName, lastName, phone…) ?

I know that there is a dedicated endpoint for retrieving custom field values, but this is somewhat cumbersome :confused: IMO and increases the requests our app needs to fire, especially given the fact we are going to have dozens of custom fields for the contacts.

Thanks,
Viktor


#2

What do you mean by

along with the standard build-in fields (email, firstName, lastName, phone…)

?

If you retrieve a contact by id then the response will include a “fieldValues” array including a lot information. So everything will be in place.

example:

GET https://foo.api-us1.com/api/3/contacts/4

will give you this for example:

{
    "contactAutomations": [
        {
            "contact": "4",
            "seriesid": "1",
            "startid": "2",
            "status": "2",
            "batchid": null,
            "adddate": "2019-01-30T07:57:24-06:00",
            "remdate": "2019-01-30T07:57:25-06:00",
            "timespan": "1",
            "lastblock": "2",
            "lastlogid": "3",
            "lastdate": "2019-01-30T07:57:25-06:00",
            "completedElements": "1",
            "totalElements": "2",
            "completed": 1,
            "completeValue": 100,
            "links": {
                "automation": "https://foo.api-us1.com/api/3/contactAutomations/3/automation",
                "contact": "https://foo.api-us1.com/api/3/contactAutomations/3/contact",
                "contactGoals": "https://foo.api-us1.com/api/3/contactAutomations/3/contactGoals"
            },
            "id": "3",
            "automation": "1"
        }
    ],
    "contactLists": [
        {
            "contact": "4",
            "list": "1",
            "form": null,
            "seriesid": "0",
            "sdate": "2019-01-30T10:19:42-06:00",
            "status": "1",
            "responder": "1",
            "sync": "0",
            "unsubreason": "",
            "campaign": null,
            "message": null,
            "first_name": "",
            "last_name": "",
            "ip4Sub": "0",
            "sourceid": "3",
            "autosyncLog": null,
            "ip4_last": "0",
            "ip4Unsub": "0",
            "unsubscribeAutomation": null,
            "links": {
                "automation": "https://foo.api-us1.com/api/3/contactLists/6/automation",
                "list": "https://foo.api-us1.com/api/3/contactLists/6/list",
                "contact": "https://foo.api-us1.com/api/3/contactLists/6/contact",
                "form": "https://foo.api-us1.com/api/3/contactLists/6/form",
                "autosyncLog": "https://foo.api-us1.com/api/3/contactLists/6/autosyncLog",
                "campaign": "https://foo.api-us1.com/api/3/contactLists/6/campaign",
                "unsubscribeAutomation": "https://foo.api-us1.com/api/3/contactLists/6/unsubscribeAutomation",
                "message": "https://foo.api-us1.com/api/3/contactLists/6/message"
            },
            "id": "6",
            "automation": null
        }
    ],
    "deals": [],
    "fieldValues": [
        {
            "contact": "4",
            "field": "3",
            "value": "Pupil",
            "cdate": "2019-01-30T07:54:18-06:00",
            "udate": "2019-01-30T07:54:18-06:00",
            "links": {
                "owner": "https://foo.api-us1.com/api/3/fieldValues/3/owner",
                "field": "https://foo.api-us1.com/api/3/fieldValues/3/field"
            },
            "id": "3",
            "owner": "4"
        },
        {
            "contact": "4",
            "field": "2",
            "value": "99",
            "cdate": "2019-01-30T07:54:38-06:00",
            "udate": "2019-01-30T07:54:38-06:00",
            "links": {
                "owner": "https://foo.api-us1.com/api/3/fieldValues/6/owner",
                "field": "https://foo.api-us1.com/api/3/fieldValues/6/field"
            },
            "id": "6",
            "owner": "4"
        }
    ],
    "geoIps": [],
    "contact": {
        "cdate": "2019-01-18T14:32:33-06:00",
        "email": "foo@bar.de",
        "phone": "",
        "firstName": "",
        "lastName": "",
        "orgid": "0",
        "segmentio_id": "",
        "bounced_hard": "1",
        "bounced_soft": "0",
        "bounced_date": "2019-01-30",
        "ip": "0",
        "ua": "",
        "hash": "548ab7378479121c1f0d5438b55438d0",
        "socialdata_lastcheck": "0000-00-00 00:00:00",
        "email_local": "",
        "email_domain": "",
        "sentcnt": "1",
        "rating_tstamp": "0000-00-00",
        "gravatar": "1",
        "deleted": "0",
        "anonymized": "0",
        "adate": "2019-01-30T10:19:49-06:00",
        "udate": "2019-01-30T10:19:42-06:00",
        "deleted_at": "0000-00-00 00:00:00",
        "created_utc_timestamp": "2019-01-18 14:32:33",
        "updated_utc_timestamp": "2019-01-30 10:19:42",
        "contactAutomations": [
            "3"
        ],
        "contactLists": [
            "6"
        ],
        "fieldValues": [
            "3",
            "6"
        ],
        "geoIps": [],
        "deals": [],
        "links": {
            "bounceLogs": "https://foo.api-us1.com/api/3/contacts/4/bounceLogs",
            "contactAutomations": "https://foo.api-us1.com/api/3/contacts/4/contactAutomations",
            "contactData": "https://foo.api-us1.com/api/3/contacts/4/contactData",
            "contactGoals": "https://foo.api-us1.com/api/3/contacts/4/contactGoals",
            "contactLists": "https://foo.api-us1.com/api/3/contacts/4/contactLists",
            "contactLogs": "https://foo.api-us1.com/api/3/contacts/4/contactLogs",
            "contactTags": "https://foo.api-us1.com/api/3/contacts/4/contactTags",
            "contactDeals": "https://foo.api-us1.com/api/3/contacts/4/contactDeals",
            "deals": "https://foo.api-us1.com/api/3/contacts/4/deals",
            "fieldValues": "https://foo.api-us1.com/api/3/contacts/4/fieldValues",
            "geoIps": "https://foo.api-us1.com/api/3/contacts/4/geoIps",
            "notes": "https://foo.api-us1.com/api/3/contacts/4/notes",
            "organization": "https://foo.api-us1.com/api/3/contacts/4/organization",
            "plusAppend": "https://foo.api-us1.com/api/3/contacts/4/plusAppend",
            "trackingLogs": "https://foo.api-us1.com/api/3/contacts/4/trackingLogs",
            "scoreValues": "https://foo.api-us1.com/api/3/contacts/4/scoreValues"
        },
        "id": "4",
        "organization": null
    }
}

Voilá

fieldValues


#3

Thank you @learnattack79526,

I’ve overlooked it, but still there is the need for additional request so that I can get the title of the custom fields.

The fieldValues are absent when fetching collection of contacts, but I guess I can live with that :slight_smile: