# Sending custom field info via api

**URL:** <https://integration.keap.com/t/sending-custom-field-info-via-api/88606>\
**Category:** API Q&A\
**Created:** [August 30, 2022, 8:30am UTC](https://integration.keap.com/t/sending-custom-field-info-via-api/88606 "2022-08-30T08:30:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_Eaves](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Andy\_Eaves](https://integration.keap.com/u/Andy_Eaves)\
**Post date:** [August 30, 2022, 8:30am UTC](https://integration.keap.com/t/sending-custom-field-info-via-api/88606/1 "2022-08-30T08:30:28Z")

</div>

I am building a form for customers to fill in with custom fields. I was testing it for ages and they were not being created with the new contact in keap and I finally found out from the chat that the fields have to be first created within keap. So that’s ok although annoying. So I was led to understand that to send the values I need to state the id of the custom field but there seems to be no indication anywhere of what the id number is. I also read in the documentation that custom field names need to be prefixed by an underscore so does that mean the ID needs to be the field name plus underscore? Please can someone give me definitive method of sending this stuff? Many thanks

---

<div class="post-metadata">

**Author:** ![Pav](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/pav/32/124_2.png) [@Pav](https://integration.keap.com/u/Pav)\
**Post date:** [August 30, 2022, 9:23am UTC](https://integration.keap.com/t/sending-custom-field-info-via-api/88606/2 "2022-08-30T09:23:54Z")

</div>

Hi Andy, the question here is are you using REST (I guess it is this one) or XML-RPC to communicate with the API?

For REST, you can use this API call to retrieve the Contact Custom Fields to see the Id numbers.  
[https://developer.keap.com/docs/rest/#operation/retrieveContactModelUsingGET](https://developer.keap.com/docs/rest/#operation/retrieveContactModelUsingGET)

And example of sending custom fields is given in this discussion here:

> [@Update Contact Custom Field](https://integration.keap.com/t/update-contact-custom-field/546):
>
> I am trying to use the REST API to update a custom field for a contact. I have looked up the database name from Admin-\>Settings (customField) and have read that there needs to be an underscore preceding the database name (\_customField). The data type for my field is text. Here is the request I am sending to PATCH “[https://api.infusionsoft.com/crm/rest/v1/contacts/userId?access\_token=access\_token](https://api.infusionsoft.com/crm/rest/v1/contacts/userId?access_token=access_token)” (userID and access\_token values replaced of course) custom\_fields: [ { content: ‘test’, id: ‘\_…

For XML-RPC, you would have to prefix the custom field name with the underscore, but there is no Id Number.

---

<div class="post-metadata">

**Author:** ![Andy\_Eaves](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Andy\_Eaves](https://integration.keap.com/u/Andy_Eaves)\
**Post date:** [August 30, 2022, 10:04am UTC](https://integration.keap.com/t/sending-custom-field-info-via-api/88606/3 "2022-08-30T10:04:44Z")

</div>

Thanks Pav this is useful but I can’t work out how to turn the API call you linked to into actual PHP code to retrieve the ID numbers. I am using REST. Would you be able to help me with that please? This is the closest I’ve got which lists all contacts but no custom fields for any of them:

$infusionsoft = new \Infusionsoft\Infusionsoft(array(  
‘clientId’ =\> $apikey,  
‘clientSecret’ =\> $secret,  
‘redirectUri’ =\> $redirecturl,  
));  
//once token is set it is stored in a session and then:  
$infusionsoft-\>setToken(unserialize($\_SESSION[‘token’]));  
$contact = $infusionsoft-\>contacts()-\>get(‘custom\_fields’);

---

<div class="post-metadata">

**Author:** ![Pav](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/pav/32/124_2.png) [@Pav](https://integration.keap.com/u/Pav)\
**Post date:** [August 31, 2022, 2:34pm UTC](https://integration.keap.com/t/sending-custom-field-info-via-api/88606/4 "2022-08-31T14:34:48Z")

</div>

The SDK is behind with things, as I see it does not have all the functions mapped to the API methods.  
I see that it runs in a mixture of REST and XML-RPC calls. It uses REST for some methods, defaults to XML-RPC for others.

So you need to use the “DataService - Query” method on the “DataFormField” table to return the Custom Fields. The code (untested) below should list all the Contact Custom Fields. From there you can get the “Id” number.

`$custom_fields = $infusionsoft->data()->query('DataFormField', 1000, 0, ['FormId' => -1], ['Id', 'Name', 'Label'], 'Id', true);`
