Kartra Documentation Technical Documentation for Kartra

Activating the API

The outbound API is intended to inform you of events happening in your Kartra account. The API will send out those outbound calls whenever a specific list of actions, pre-defined by you inside the Kartra account, are triggered.

 

Configuring your outbound API

To pre-define those actions, navigate to My Integrations -> My API -> Outbound API. All you need to do is to enter the URL(s) you want our API to ping, and the specific event(s) you want us to notify you about. You may configure multiple URLs, and multiple notification events per URL.

471

 

The data contained inside the API calls

There are a number of events our API can notify you about, such as…

  • When a lead gets tagged.
  • When a lead is granted access to a membership.
  • When a transaction is processed.
  • When a lead fills in an opt-in form.
  • Etc.

The specific information contained within each of those event is different on a case by case scenario. For example, transaction-related notifications contain relevant details about the transaction itself: product, transaction amount, customer details, etc. That being said, the info is always sent as a raw body POST JSON formatted object.

Here’s an example of a JSON object sent when a lead is subscribed to a list:

{
    "lead":{
        "id": "1",
        "first_name": "John",
        "middle_name": "Doe",
        "last_name": "Doe",
        "last_name2": "Doe",
        "email": "johndoe@gmail.com",
        "phone_country_code": "+1",
        "phone": "1234567",
        "company": "company",
        "address": "address",
        "city": "New York",
        "zip": "1234",
        "state": "state",
        "country": "United States",
        "date_joined": "2018-04-26 00:00:00",
        "website": "http://www.example.com",
        "ip": "127.0.0.1",
        "ip_country": "United States",
        "facebook": "facebook",
        "twitter": "twitter",
        "linkedin": "linkedin",
        "google_plus": "google_plus",
        "sales_tax_id": "1234",
        "lead_picture": "http://www.example.com",
        "source": "0",
        "score": "0",
        "lead_deleted": "0",
        "lead_deleted_date": "2018-04-26 00:00:00",
        "referring_id": "0", 
        "blacklisted": "0",    
        "source_id": "0",
        "gdpr_lead_status": 1,
        "gdpr_lead_status_date": "2018-04-26 00:00:00",
        "gdpr_lead_status_ip": "127.0.0.1",
        "gdpr_lead_communications": 0,
        "custom_fields": [
	    {
	        "field_id":"323",
	        "field_identifier":"color",
	        "field_type":"checkbox",
	        "field_value":[
	            {
		        "option_id":"1",
		        "option_value":"red",
		    },
		    {
		        "option_id":"2",
		        "option_value":"blue",
		    }
                ]
	    },
	    {
	        "field_id":"324",
	        "field_identifier":"gender",
	        "field_type":"drop_down",
	        "field_value":[
	            {
		        "option_id":"1",
		        "option_value":"male",
		    }
                ]
	    },
	    {
	        "field_id":"325",
	        "field_identifier":"favorite_dish",
	        "field_type":"input_field",
	        "field_value":"beef lasagna",
	    }
        ]      
    },
    "action":"list_subscription",
    "action_details":{
        "list":{
            "list_id":1,
            "list_name":"list 1"
        }
    }
}

 

Fetching the data

Finally, you have to make sure that, inside your end-point URL(s), you have a script that catches and interprets the data passed by our API outbound notifications. For that purpose, your end point URL(s) must be written in a programming language that can catch the HTTP raw post request.

Here is a small PHP sample on how to get the raw post:

<?php 
    $postdata = file_get_contents("php://input"); 
    
    // The data comes as an JSON so you will need to decode it 
    $postdata_decoded = json_decode($postdata); 

    // Now that you have all the data, you may grab it and pass it to your custom scripts 
    // Example: $postdata_decoded->lead contains the details of the specific lead triggering the action
?>

© 2024 Kartra All Rights Reserved