Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents:

Table of Contents
minLevel2

Table of Contents:

Table of Contents
minLevel2


(info) Note: Notice that in each API call you must provide the List ID that you are working on, otherwise the default List ID will be used. You can review the possible ways to provide List ID in this link. 

Methods Summary

This API controller is for managing asynchronous contact searches.
Image Added

In order to use the asynchronous flow, the following methods should be used in the following order:

  1. Create instancenew Contacts Manager Report- Create a new contact search using "POST api/contact_search" You  You need to set a title for this new search, and the filters used for contacts segmentation.

  2. Check the instance report status - Check the contact search status using "GET  GET api/contact_search/<Contact search report ID>" When  When contact search is created, its always created in status "Pending" (1), in order to know when the contact search is ready, use this method and verify that the status is "Completed" (2).

  3. Get Retrieve the instance results - When status is Complete, get results using "GET apireport - Use this method GET /api/contact_search/<Contact search report ID>/result" This will return an array of the contacts you searched for.export to export the report

GET /api/contact_search/<Contact search report ID>

Description 

This method fetches a contact search (without results) and it can also be used for checking the contact search status.

Response (Major fields)

KeyDescription
statusContact search status, 1 = Pending,
2 = Completedstatus_descContact search status description (Pending / Completed)

GET /api/contact_search/<Contact search report ID>/result

Description 

This method fetches the contact search results. This is the same report you see in the UI under the Contact Manager Search and/or Analytics -> Contact Activity Report (if you provided include_behavior=true), when you click on the "View Report" icon. This API command provides the same results as the export below, only in this case, it returns the entire result as a JSON response instead of CSV file.

Request

sort

Optional string - Sort by column name

order

Optional string - "ASC" or "DESC"

offset

Optional int

limit

Optional int

Response

The response includes Array of contacts similar to example shared below. 

...

2 = Completed
status_descContact search status description (Pending / Completed)

GET /api/contact_search/<Contact search report ID>/export

Description 

This method exports a contact search report already createdin CSV format, just like in the UI of the platform.

Description 

This method fetches a collection of contact searches (without the results).

Request

list_id

Optional string - List ID (see "Indicating List ID in Ongage API Calls" in APIDocs homepage for more info)

...

Optional int

limit

Optional int

Description 

This method creates a new contact search.

Request

title

Required string - Title for this contact search

...

Code Block
{
 "title": "All Members: Email is not empty",
 "include_behavior": false,
 "filters": {
          "type": "Active",
          "criteria": [{
                     "type": "stringemail",
                     "operator": "notempty",
                     "operand": ["email"],
                     "case_sensitive": 0,
                     "condition": "and",
                     "field_id": "123456" // This is the field id of the email field in that list. You can find that ID under List Settings -> Field Setup
                   }],
                   "user_type": "all"
          },
          "combined_as_and": true
}

...

Code Block
{
 "title":"All contacts from specific segment",
 "filters":{
    "type":"Active",
    "criteria":[
      {
        "type":"segment",
        "operand": [ 123456 ], // segment ID
        "condition": "and"       
       }
     ]
 }
}

Request Example - Creates contact activity report

...

Code Block
{
 "title": "All Members: Email is not empty",
 "include_behavior": false,
 "filters": {
           "type": "Active",
           "criteria": [{
                     "type": "string",
                     "operator": "notempty",
                     "operand": [""],
                     "case_sensitive": 0,
                     "condition": "and",
                     "field_id": "123456" // This is the field id of the email field in that list. You can find that ID under List Settings -> Field Setup
                   }],
                   "user_type": "all"
                    "from_date": 1467320400,
                    "to_date": 1471381199
          },
          "combined_as_and": true
}

Response (Major fields)

KeyDescription
idNewly created contact search ID
statusContact search status, will always be 1 (Pending) in this response

Response Example - For Creating a Contact Search for All Members in a Given List

Code Block
{
  "metadata": {
    "error": false
  },
  "payload": {
    "list_id": 12345,
    "title": "All Members: Email is not empty",
    "include_behavior": false,
    "filters": {
      "type": "Active",
      "criteria": [
        {
          "type": "string",
          "operator": "notempty",
          "operand": [
            ""
          ],
          "case_sensitive": 0,
          "condition": "and",
          "field_id": "123456",
          "field_name": "email"
        }
      ],
      "user_type": "all"
    },
    "combined_as_and": true,
    "account_id": 1234,
    "status": 1,
    "desc": "Pending",
    "id": 82169,                // This is ID of the search report that was created
    "created": 1470930202,
    "modified": 1470930202
  }
}

DELETE /api/contact_search/<Contact search report ID>

Description 

This method deletes a contact search.

...