Kartra API: This article is for developers.

The outbound API is used to create notifications when things happen in your Kartra account. The API sends an outbound call whenever an action defined in the outbound API settings occurs.

Configuring your outbound API

To define those actions you want to be notified about, go to Integrations > My API > Outbound API.

Enter the URL(s) you want the Kartra API to ping, and the specific event(s) you want notifications about. You can specify multiple URLs where the notifications will be sent and multiple events per URL.

The data contained inside the API calls

Kartra's API can notify you about a variety of events that happen in your account, 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 information contained in an event notification is different depending on the event. For example, transaction-related notifications contain relevant details about the transaction itself: product, transaction amount, customer details, etc.

Notifications are 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": "[email protected]",
        "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

Your end-point URL(s) must have a script to catch and interpret the data sent by our API outbound notifications.

To do this, your endpoint 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
?>