How to request for user information as well as their subscriptions via the API

Hello,
I’m super new to the community and want to say thanks in advance for any advise you may have for me. I’ve been reading through the API docs. I am using ARC (which is very similar to Postman) for seeing responses back via the Active Campaign API. From my Active Campaign account I have my API token. As far as my learning goes, I’m running ‘GET’ requests to easily see results from the following examples :

//sends back data about a specific user based on their email address
https://<account-name>.api-us1.com/api/3/contacts?search=foobar@gmail.com

//show me what custom fields are tied to a specific user
https://<account-name>.api-us1.com/api/3/contacts/<user-id>/fieldValues

//shows me the actual name of the custom field I want to focus on
https://<account-name>.api-us1.com/api/3/fieldValues/<field-id>/field

The three above examples are great, but I want to take things further…

Before I create or update a contact with Sync

…I want see results back representing the full name, email address, ID, “AND” all the custom fields (including the names of the actual fields) that a specific user is subscribed too, all in one shot through ARC? Is this possible?

My end goal is to populate my custom PHP form with these values so that I can then invite the user to see their subscription information, and then invite them to submit that form with updates back to Active Campaign.

Thanks for any tips!

Perhaps there are PHP tutorials with Sync, so that I can learn some simple practices to help subscribe or unsubscribe users with my custom WordPress form…?

Thanks for any help!

Welcome to the Community!!

I just pinged one of our developers internally to help with this. I’ll follow up with you shortly!

1 Like

After a bit of research, I can get you closer to your goal, but you might need some code to bridge the gap:

First a note:
Using ?search=foobar@gmail.com will most likely return what you’re looking for, but it’s search and not a filter, so I recommend using ?filters[email]=foobar@gmail.com so it directly filters on the specific email you’re looking for.

To get what you need with the API:
A GET call to {{yourAccountUrl}}/api/3/contacts?include=fieldValues&filters[email]=foobar@gmail.com

Will return you:

  • Full name
  • Email
  • ActiveCampaign Contact ID
  • Custom Field Values

The only thing missing from this response is the Titles of the Custom Field, which can be retrieve individually via a GET to {{yourAccountUrl}}/api/3/fieldValues/<field-id>/field (note that this field-id will be exclusive for that contact only)

Or you can pull the list of all the fields and their titles with a GET call to {{yourAccountUrl}}/api/3/fields (note: this returns a list of fields and titles, and the id in this list will match the "field" in the call to /contacts.

You can follow the first call with the second to get the title, or if you’re only using set of custom fields/titles that don’t change, just you can map them.

If I come up with a way to do it in a single call, I will update you.

3 Likes

Thanks for chiming in! @gsvoboda

Thank you so much gsvoboda! This is what I was looking for.

1 Like

It’s my pleasure. Have a great day!