Kartra Documentation Technical Documentation for Kartra

Action: Retrieve all the custom fields in your account

This will allow you to retrieve all custom fields set in your Kartra account.

Type Parameters Values
POST cmd* retrieve_custom_fields

* Required fields

Here is an example:

'actions' => [
    '0' => [
        'cmd' => 'retrieve_custom_fields'
    ]
]

Here are the results returned by the request:

Parameters Values
custom_fields String (JSON encoded array containing the details of all the custom fields in your account, empty array if there are no custom fields)

 

JSON parameters Values
field_id integer A unique identifier for the custom field.
field_identifier string The identifier string set when the field was created
field_type string The field type with possible values: ‘input_field’, ‘text_area’, ‘drop_down’, ‘radio_button’, ‘checkbox’.
field_value array Objects containing the option id and the option value. This applies only for multiple selection field types like ‘drop_down’, ‘radio_button’ and ‘checkbox’.

Example of the returned array:

"custom_fields": [
    {
        "field_id": "1",
        "field_identifier": "gender",
        "field_type": "radio_button",
	"field_value":[
	    {
	        "option_id":"1",
		"option_value":"male",
            },
	    {
	        "option_id":"2",
		"option_value":"female",
	    }
	]
    },
    {
        "field_id": "2",
        "field_identifier": "fruits",
        "field_type": "checkbox",
        "field_value":[
	    {
	        "option_id":"1",
	        "option_value":"apple",
	    },
	    {
	        "option_id":"2",
	        "option_value":"pear",
	    }
	]
    },
    {
        "field_id": "3",
        "field_identifier": "field_3",
        "field_type": "input_field"
    },
    {
        "field_id": "4",
        "field_identifier": "field_4",
        "field_type": "drop_down"
        "field_value":[
	    {
	        "option_id":"1",
	        "option_value":"male",
	    },
	    {
	        "option_id":"2",
	        "option_value":"female",
	    }
	]            
    },
    {
        "field_id": "5",
        "field_identifier": "field_5",
        "field_type": "text_area"
    }
]

Action: Create custom fields

This will allow you to create a custom field that can be used to gather custom info related to a Lead.

Type Parameters Values
POST cmd* create_custom_field
POST custom_field_identifier * string
POST custom_field_type* Posible values are ‘input_field’, ‘text_area’, ‘drop_down’, ‘radio_button’, ‘checkbox’
POST custom_field_options ** array of arrays with one parameter: option_name (string containing the name of the option)

* Required fields
** Required for drop_down, radio_button, checkbox field types.

Here is an example:

'actions' => [
    '0' => [
        'cmd' => 'create_custom_field',
        'custom_field_identifier' => 'Custom field name',
        'custom_field_type' => 'drop_down',
        'custom_field_options' => [
            '0' => ['option_name' => 'blue'],
            '1' => ['option_name' => 'brown']
        ]
    ]
]

Success message:

{
  "status": "Success",
  "message": "Custom Field created",
  "type: "114"
}

Error Cases:

Type Number Message Cause
263 Custom Field name can only contain letters, numbers, dashes or underscores
  • custom_field_identifier can only contain letters, numbers, dashes or underscores.
264 Custom Field already exists or not allowed
  • custom_field_identifier value already exists in the database or is not allowed.
265 Custom Field cannot be empty
  • custom_field_identifier must not be an empty string.
269 Custom Field type not valid
  • custom_field_type value is not one of ‘input_field’, ‘text_area’, ‘drop_down’, ‘radio_button’, ‘checkbox’.
270 Options not an array
  • custom_field_options needs to be an array.
272 Option cannot be empty
  • option_name must not be empty.
273 Options must have two or more elements
  • custom_field_options has to be an array with at least two elements for the options.

An example of an error message:

{
  "status": "Error",
  "message": "Custom Field name can only contain letters, numbers, dashes or underscores",
  "type": "263"
}

© 2024 Kartra All Rights Reserved