Contact Counts API Methods

Table of Contents:


(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. 

Methods Summary

GET /api/contact_counts/<id>

Description 

  • This method provides a count for specific Count ID.
  • In order to get a Count Id, first use POST /api/contact_counts method as detailed in the next section.

Response

GET URL: https://api.ongage.net/api/contact_counts/<id>

{
    "metadata": {
        "error": false,
        "total": "917655"
    },
    "payload": {
        "active": 743895,
        "bounced": 172413,
        "complaint": 966,
        "unsubscribed": 381
    }
}

Error Codes

  • 404 - Not found

POST /api/contact_counts

Description 

Initiate a count process, typically used to get the latest count for a Segment but can also be done on a criteria. 

  • This method returns a Count ID in response.
  • You will need the Count ID returned from this POST request, in the GET method above, in order to get the number count of contacts for the segment/criteria provided in the POST request.

  • Some users might only want to issue a count, so the latest segment count will be seen in the Ongage UI, in which case there's no need to save the Count ID, nor use the GET command.

Request

segment_id

Required (only when criteria is empty) int

criteria

Required (only when segment_id is empty) array of arrays - Criteria to filter by results

*field_name : String - The field_name for this criteria

*type : String - The type of field (string/numeric/email/date)

*operator : String - "LIKE" / "NOT LIKE" / "_LIKE" (begins with) / "LIKE_" (ends with) / "empty" / "notempty" / "=" / "!=" / "><" / ">" / "<" / ">=" / "<="

*operand : Array - Array of operand values, will be filter with OR condition

*case_sensitive: 1 or 0 - Case sensitivity

Criteria Example 

POST URL: https://api.ongage.net/<list_id>/api/contact_counts

{
    "criteria": {
      "field_name": "name",
      "type": "string",
      "operator": "LIKE",
      "operand": [ "John", "Mary" ],
      "case_sensitive": "0"
    }
}

Response

  { "payload": { "id": 30 } }

(info) Above is the ID to use in the GET method.

Error Codes

  • 404 - Not found
  • 500 - Validation error

Segment Count Example

Segment Count Post Example

POST URL: https://api.ongage.net/<list_id>/api/contact_counts/

{"segment_id": 1234567890}

Response

{
  "metadata": {
    "error": false
  },
  "payload": {
    "id": 1112223334
  }
}

(info) Above is the ID to use in the following GET method.

Segment Count Get Example

GET URL: https://api.ongage.net/<list_id>/api/contact_counts/1112223334

{
    "metadata": {
        "error": false,
        "total": "917655"
    },
    "payload": {
        "active": 743895,
        "bounced": 172413,
        "complaint": 966,
        "unsubscribed": 381
    }
}