ONEcount API Documentation

Version 2.1 by rayaan@one-count_com on 2023/12/12 04:31

Introduction

ONEcount REST API is designed to allow you to directly manipulate the underlying data within the ONEcount application. This API can be used to lookup, create and update different ONEcount data components which are listed below.

REST takes advantage of the HTTP request methods to layer itself into the existing HTTP architecture. These operations consist of the following:

  1. GET - Used for lookup of resources

  2. PUT - Used to update a resource

  3. POST - Used to create a new resource

Specifically, the ONEcount API provides to the following components:

  1. User data
    1. List users
    2. Lookup users
    3. Create users
    4. Update users
  2. Questions
    1. Lookup questions
    2. List questions
    3. Create questions
  3. Product data
    1. Lookup products
    2. Create products
    3. Update products
  4. Term Data
    1. Lookup terms
    2. Create terms
    3. Update terms
  5. Resource Data
    1. Lookup resources
    2. Create resources
    3. Update resources
  6. Transaction data
    1. Lookup transactions
    2. Create transactions
  7. Source Codes
    1. Lookup source code
    2. Create source codes
    3. Update source codes
  8. Attach a resource to a product
  9. Leads
    1. Create a lead
  10. Engagements
    1. Get all Engagements
    2. Get specific engagement by engagement id
    3. Create Engagements
    4. Update Engagements
    5. Add users data to Engagement


Accessing API

REST API URL: https://api.onecount.net/v2/

Appkey: THIS WILL BE PROVIDED TO YOU


Your HTTP requests to a REST API resource should contain the following information:

  • An HTTP method GET, POST, PUT.

  • An Appkey sent as Appkey header in the http request to authenticate the request.

  • Resource name in the url (/resourcename)

  • Any JSON data or JSON files containing information needed for requests, such as updating a record with new information.


General API Usage

The request data in POST (for create and update) will consist of request parameters required by each method in JSON format. Value of resource will determine which resource is being requested and the access method will determine whether you are trying to create, update or lookup that resource.

For lookup, the parameter list will be part of the request url.


Response

API will output the response in a JSON format discussed below.

Response
{
  "result": {
    "success": "1",
    "error": {
      "code": "0",
      "message": ""
    }
  },
  "Users": {
    "Id": "12562",
    "PartnerId": "5467",
    "Demo": {
      "6": "Rayaan",
      "7": "Ahmed"
    }
  }
}


The result of the api request will be determined by the value of the success property of result object. Here the value of success will either be 1 (true) or 0 (false) depending on whether the requested action succeed.


If value of success is 0 then an error will be generated inside the result object. Code property will have an error code. message property will have the details about the error. This value might be used to display the error in the client application. The response will always have a result object in it plus the individual response listed for each method.

If the value of success is 1 then the response parameters of the called method will also be output.

For GET requests we can pass limit as parameter in URL.

COMPONENT: Users

Users means the customers of your system. Users can be added, updated and searched for using the users resource from the api. For lookup, If a return parameter is specified Users object will have those fields. If nothing is specified by default only UserId is returned.

Additionally (Array of) transaction object specifying parts of the transaction to be added to the new user can be specified. UserId, TransactionId and SubscriptionType will be ignored if specified for this case. As this is new user and new transaction is being added.

In this case the provided demographic information in users object will be used to create a new user in ONEcount and then a response will be generated. Before creating a new user, a check for duplicate will be performed based on Dedupe columns and if found, and error code will be generated.

If username and password is not one of the parameters being passed, then a random username and password will be generated for the user while creating his user account in ONEcount.

Return parameter will have the comma separated list of question Ids that is requested back from the API.

Return is an optional parameter in request. If return is not requested then by default, only UserId (which is ONEcount ID) will be returned in the Users object.


Method

Url

Action

GET

/users

Get users data limiting 25.

GET

/users/<ocid or ocid_hash>

Get data for user id 1. The user id can be a numeric value or a hash

GET

/users/lookup?1=user1@email.com&return=1,2

Lookup for user whose question id (1) is equal to supplied value. The users object returned will have value of questions 1 & 2. Here for example assumed to be firstname and last name.

Return parameter defines a csv of question id that are requested back in response.

POST

/users

Create a new users

Parameters required to create the user needs to be sent as post data in JSON format.

PUT

/users/1

Update user id 1. The user id can be a numeric value or a hash

Parameters required to update the user needs to be sent as post data in JSON format.

GET

/users/1/partners/2

Get user id 1 and partner id 2's ONEcount hash. The user id can be a numeric value or a hash.

POST

/users/login

Check to see user exist with username/email and password.

Parameters required to create JSON object with u as username, e as email and p as password and sent is as POST param.

Example:

{"u":"abc@one-count.com","e":"abc@one-count.com","p":"1234"}

OR

{"u":"abc@one-count.com","p":"1234"}

OR

{"e":"abc@one-count.com","p":"1234"}

OUTPUT : Should get OCID of the user if it finds it otherwise get and error with msg user not found.

GET All Users


 https://api.onecount.net/v2/users

Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Example


Request

Get All Users Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Get All Users Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": [
        {
            "Id": 10,
            "OCID_HASH": "309d0ba643ac9cf164fa7089db622444fb82bf031c79ebb97c8566d0b91a224c",
            "Demo": {
                "1": "ORISH+IMNG12373@gcnmedia.com",
                "2": "user_26_2",
                "3": "pass_262",
                "4": "orish123"
            }
        },
        {
            "Id": 26,
            "OCID_HASH": "362b0815ab579017802c0539fa30d45c46f2e357025756e3a998225aa2c3f123",
            "Demo": {
                "1": "ORISH+IMNG12374@gcnmedia.com",
                "2": "user_82_2",
                "3": "pass_822",
                "4": "orish111"
            }
        },
        {
            "Id": 34,
            "OCID_HASH": "508ae86cfa9185a59a855b6f0aaf1ef52e1895c7a7bd1ee01d1f7be82ea233d2",
            "Demo": {
                "1": "",
                "2": "user_1405614567717",
                "3": "",
                "4": "sonish",
                "5": "shrestha",
                "6": "Test",
                "7": "GCN",
                "8": "Sterling",
                "9": "Norwalk",
                "10": "",
                "11": "",
                "12": "",
                "13": "Nepa",
                "14": "",
                "15": ""
            }
        },
        {
            "Id": 42,
            "OCID_HASH": "3fd11fb98076330290d14edd70265c273eaf5ad72e498fc9ac4f2b580a2f36cc",
            "Demo": {
                "1": "orish@gcnpublishing.com",
                "2": "user_106_42",
                "3": "f5a622347842b9384cae63bb998f2aa19aea2ebc43fa2f00800e9accd85a8dd1",
                "4": "Orish",
                "5": "Shrestha",
                "6": "Director of Engineering",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "",
                "15": "",
                "106": "",
                "114": "",
                "130": "",
                "138": "",
                "146": "",
                "234": "",
                "242": "",
                "250": ""
            }
        },
        {
            "Id": 50,
            "OCID_HASH": "88d721f543c79f8ea718d9020897c9036d1d303099a649585f6d4c37e354c5d3",
            "Demo": {
                "1": "sundeep@gcnpublishing.com",
                "2": "",
                "3": "",
                "4": "Sundeep",
                "5": "Dangol",
                "6": "Director of Integrations",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "",
                "15": "",
                "106": "",
                "114": "",
                "130": "",
                "138": "",
                "146": "",
                "234": "",
                "242": ""
            }
        },
        {
            "Id": 58,
            "OCID_HASH": "c45f5d1d27364ee19973148d6c02999cbfbc8b2ca80f7655dd6a873b864eb211",
            "Demo": {
                "1": "sean@gcnpublishing.com",
                "2": "user_106_34",
                "3": "pass_10634",
                "4": "Sean",
                "5": "Fulton",
                "6": "Vice President",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "UNITED STATES"
            }
        },
        {
            "Id": 66,
            "OCID_HASH": "f037520f7af46301532a95b39d8fd8e607988afe3c7b67f086740e6676775bee",
            "Demo": {
                "1": "joanne@gcnpublishing.com",
                "2": "user_106_2",
                "3": "c55b18c5a4e475034ccc8cd14e132e1fd7e2aadcd8dcc625996ba51d145f160e",
                "4": "Joanne",
                "5": "Persico",
                "6": "President",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "UNITED STATES",
                "234": "",
                "242": "",
                "250": ""
            }
        },
        {
            "Id": 74,
            "OCID_HASH": "abb8adfb275030ad96808967edea5003e3ed9da5965b6d8f4537597dff17af4f",
            "Demo": {
                "1": "melanie@gcnpublishing.com",
                "2": "user_106_18",
                "3": "pass_10618",
                "4": "Melanie",
                "5": "Mason",
                "6": "Director of  Customer Experience",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "UNITED STATES",
                "14": "",
                "15": "",
                "106": "",
                "114": "",
                "130": "",
                "138": "",
                "146": "",
                "154": "",
                "162": "",
                "170": "",
                "178": "",
                "186": "",
                "202": "",
                "218": "",
                "226": "",
                "234": "",
                "242": "",
                "250": ""
            }
        },
        {
            "Id": 82,
            "OCID_HASH": "6b2635a195d46e9df53ec6069d198fa0fe26d26111c0b71b9bc39652935f6034",
            "Demo": {
                "1": "doug@gcnpublishing.com",
                "2": "user_106_58",
                "3": "pass_10658",
                "4": "Doug",
                "5": "LaFarge",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "UNITED STATES"
            }
        },
        {
            "Id": 90,
            "OCID_HASH": "869434d36ef71f8244c5eacaac35cb87d9ee16f3c8bbeddaddb87869588deb52",
            "Demo": {
                "1": "subash@gcnpublishing.com",
                "2": "user_106_50",
                "3": "pass_10650",
                "4": "Subash",
                "5": "Tamang",
                "7": "ONEcount",
                "8": "194 Main Street",
                "9": "Suite 2NW",
                "10": "Norwalk",
                "11": "CT",
                "12": "06851",
                "13": "UNITED STATES"
            }
        },
        {
            "Id": 98,
            "OCID_HASH": "f46e4d07d8c2aede8e3f0b4d30cf984f9ce507147b75cff17315642d456d7cca",
            "Demo": {
                "1": "sonish@gcnpublishing.com",
                "2": "user_106_10",
                "3": "pass_10610",
                "4": "Sonishs",
                "5": "Shrestha",
                "8": "334 Street",
                "10": "Ashburn",
                "11": "VA",
                "12": "11118",
                "13": "United States"
            }
        },
        {
            "Id": 162,
            "OCID_HASH": "86616a428abeabe722079cb29ffd3b76341aa7895b2bd3579dfd89e01a737f0c",
            "Demo": {
                "1": "orish+1@gcnpublishing.com",
                "2": "user_130_42",
                "3": "pass_13042",
                "4": "OrishGCN",
                "5": "Shrestha",
                "8": "123 street",
                "10": "New Rochelle",
                "11": "NY",
                "12": "11111",
                "13": "United States"
            }
        },
        {
            "Id": 170,
            "OCID_HASH": "3fb40dbcd3c0ca47fd3a80f5a34290c68a2e7ff79d4d8f28b388677bea2df2ac",
            "Demo": {
                "1": "sundeep+1@gcnpublishing.com",
                "2": "user_130_26",
                "3": "pass_13026",
                "4": "SundeepGCN",
                "5": "Dangol",
                "8": "456 Street",
                "10": "Bridgeport",
                "11": "CT",
                "12": "11112",
                "13": "United States"
            }
        },
        {
            "Id": 178,
            "OCID_HASH": "ca72068a59896a3cec1faf52a4701d13b539039467cbe9d5d9b60b54e263040f",
            "Demo": {
                "1": "sean+1@gcnpublishing.com",
                "2": "user_130_34",
                "3": "pass_13034",
                "4": "SeanGCN",
                "5": "Fulton",
                "8": "222 Street",
                "10": "Norwalk",
                "11": "CT",
                "12": "11113",
                "13": "United States"
            }
        },
        {
            "Id": 186,
            "OCID_HASH": "4b643f02f3d30d0b6ae465b4d758a721574e798712c3d42bd5458a1fd5634243",
            "Demo": {
                "1": "joanne+1@gcnpublishing.com",
                "2": "user_130_2",
                "3": "pass_1302",
                "4": "JoanneGCN",
                "5": "Persico",
                "8": "222 Street",
                "10": "Norwalk",
                "11": "CT",
                "12": "11114",
                "13": "United States"
            }
        },
        {
            "Id": 194,
            "OCID_HASH": "d3200217585d2d954e0b55ee9ff1c939f265067420ff82c6e924dcdd71ccc960",
            "Demo": {
                "1": "melanie+1@gcnpublishing.com",
                "2": "user_130_18",
                "3": "pass_13018",
                "4": "MelanieGCN",
                "5": "Mason",
                "6": "",
                "7": "",
                "8": "345 Street",
                "9": "",
                "10": "Norwalk",
                "11": "CT",
                "12": "11115",
                "13": "United States",
                "14": "",
                "15": "",
                "106": "",
                "114": "",
                "130": "",
                "138": "",
                "146": "",
                "154": "",
                "162": "",
                "170": "",
                "178": "",
                "186": "",
                "202": "",
                "218": "",
                "226": "",
                "234": "",
                "242": "",
                "250": "",
                "266": "01"
            }
        },
        {
            "Id": 202,
            "OCID_HASH": "a7c7d5016322340c4394538d68f601a0720e70850091387114963aba0f1bae09",
            "Demo": {
                "1": "doug+1@gcnpublishing.com",
                "2": "user_130_58",
                "3": "pass_13058",
                "4": "DougGCN",
                "5": "La Farge",
                "8": "849 Street",
                "10": "Tuson",
                "11": "AZ",
                "12": "11116",
                "13": "United States"
            }
        },
        {
            "Id": 210,
            "OCID_HASH": "f0f0d59478e9a4aa9b0fad6ae5bfc4292a169f899135e8c4d16cada9e9dc267d",
            "Demo": {
                "1": "subash+1@gcnpublishing.com",
                "2": "user_130_50",
                "3": "pass_13050",
                "4": "SubashGCN",
                "5": "Tamang",
                "8": "112 Street",
                "10": "Herndon",
                "11": "VA",
                "12": "11117",
                "13": "United States"
            }
        },
        {
            "Id": 218,
            "OCID_HASH": "4939a3be6dfd79c715a1144d82815f2abe8e413d04e4311284a05610589ad87b",
            "Demo": {
                "1": "sonish+1@gcnpublishing.com",
                "2": "user_130_10",
                "3": "pass_13010",
                "4": "SonishGCN",
                "5": "Shrestha",
                "8": "334 Street",
                "10": "Reston",
                "11": "VA",
                "12": "11118",
                "13": "United States"
            }
        },
        {
            "Id": 282,
            "OCID_HASH": "44421a4b109b0f5eb412b29e0037df61aae9ea95003d73f0175e5d6db8c0f928",
            "Demo": {
                "1": "orish+11@gcnpublishing.com",
                "2": "user_138_42",
                "3": "pass_13842",
                "4": "OrishGCN",
                "5": "Shrestha",
                "8": "123 street",
                "10": "New Rochelle",
                "11": "NY",
                "12": "11111",
                "13": "United States"
            }
        },
        {
            "Id": 290,
            "OCID_HASH": "971c357d4808224595f83a30bba9f05d1118bd7fd4f1d51160cad57dfd6b2137",
            "Demo": {
                "1": "sundeep+11@gcnpublishing.com",
                "2": "user_138_26",
                "3": "pass_13826",
                "4": "SundeepGCN",
                "5": "Dangol",
                "8": "456 Street",
                "10": "Bridgeport",
                "11": "CT",
                "12": "11112",
                "13": "United States"
            }
        },
        {
            "Id": 298,
            "OCID_HASH": "4fa0426afe48ee79602e9c47dda1987797b1983ecaa5975a09885ac4480f5033",
            "Demo": {
                "1": "sean+11@gcnpublishing.com",
                "2": "user_138_34",
                "3": "pass_13834",
                "4": "SeanGCN",
                "5": "Fulton",
                "8": "222 Street",
                "10": "Norwalk",
                "11": "CT",
                "12": "11113",
                "13": "United States"
            }
        },
        {
            "Id": 306,
            "OCID_HASH": "67037db60fea235ebcb48fae4eeef08a4b33c2f8860944925b615e602ba7a6e1",
            "Demo": {
                "1": "joanne+11@gcnpublishing.com",
                "2": "user_138_2",
                "3": "pass_1382",
                "4": "JoanneGCN",
                "5": "Persico",
                "8": "222 Street",
                "10": "Norwalk",
                "11": "CT",
                "12": "11114",
                "13": "United States"
            }
        },
        {
            "Id": 314,
            "OCID_HASH": "6421cab33907111f038ead8fc0aeafed785642e9b92cda544b2048f90ada259f",
            "Demo": {
                "1": "melanie+11@gcnpublishing.com",
                "2": "user_138_18",
                "3": "pass_13818",
                "4": "MelanieGCN",
                "5": "Mason",
                "8": "345 Street",
                "10": "Norwalk",
                "11": "CT",
                "12": "11115",
                "13": "United States"
            }
        },
        {
            "Id": 322,
            "OCID_HASH": "334b6f64d387b9a45b8ac7e0901d438cace133899b608c03a0f8c1f706882958",
            "Demo": {
                "1": "doug+11@gcnpublishing.com",
                "2": "user_138_58",
                "3": "pass_13858",
                "4": "DougGCN",
                "5": "La Farge",
                "8": "849 Street",
                "10": "Tuson",
                "11": "AZ",
                "12": "11116",
                "13": "United States"
            }
        }
    ]
}


GET specific User


 https://api.onecount.net/v2/users/{{OCID}}

{{OCID}} is user id which is provided by ONEcount

Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Example


Request

Get specific User Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users/8418',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Get specific user Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": [
        {
            "Id": 8418,
            "PartnerId": null,
            "OCID_HASH": "7eedae58c56e97e79a9d42e85e7ef6e252563e60e92bd6d9ac7b7be748ffa823",
            "Demo": {
                "1": "",
                "2": "user_242_5634",
                "3": "pass_2425634",
                "4": "Stuart",
                "5": "Allen",
                "6": "Pub",
                "7": "Latinfinance",
                "9": "2121 Ponce de Leon Blvd",
                "10": "Coral Gables",
                "11": "Fl",
                "12": "33134",
                "13": "",
                "15": "",
                "106": "",
                "114": "",
                "122": "305-448-6593",
                "130": "",
                "138": "",
                "146": "5434982f-a05b-5f1e-2176-4809012686bb"
            },
            "Products": [
                34
            ],
            "Resources": [
                114,
                98
            ],
            "Segments": []
        }
    ]
}


POST User Login


 https://api.onecount.net/v2/users/login


Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Body raw (json)


Body
{"e":"rayaan@one-count.com","p":"12345"}

Example


Request

User login Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users/login',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"e":"rayaan@one-count.com","p":"12345"}',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Login user Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": [
        "1845775"
    ]
}


GET lookup User


 https://api.onecount.net/v2/users/lookup?2=user_242_6298&return=1,2,3,4


Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Query Params


2                                                                                                           user_242_6298
return                                                                                                   1,2,3,4

Example


Request

Lookup user Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users/lookup?2=user_242_6298&return=1%2C2%2C3%2C4',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Lookup user Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": [
        {
            "Id": 9082,
            "PartnerId": null,
            "OCID_HASH": "c91c697bc764c64a78bb0bbc9a848ace303169fb17da177a06264d4ede2ca659",
            "Demo": {
                "2": "user_242_6298",
                "3": "pass_2426298"
            }
        }
    ]
}


GET Partners


 https://api.onecount.net/v2/users/{{OCID}}/partners/{{Partner id}}


Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

POST Create user


 https://api.onecount.net/v2/users


Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Body raw (json)


Body
{"Users":{"PartnerId":1,"Demo":{"1":"testApirayaan7@onecount.net","4":"Rayaan","5":"Ahmed"}},"DedupeColumns":"1","Transactions":[]}

Example


Request

Create User Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"Users":{"PartnerId":1,"Demo":{"1":"testApirayaan6@onecount.net","4":"Rayaan","5":"Ahmed"}},"DedupeColumns":"1","Transactions":[]}',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Create user Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": {
        "Id": 1845831
    }
}


PUT Update user


 https://api.onecount.net/v2/users/{{OCID}}


Request Headers


Appkey                                                                                                 {{ONECOUNT API KEY}}

Body raw (json)


Body
{"Users":{"Demo":{"6":"title1"}}}

Example


Request

Update User Request
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'rayaan.onecount.net/api/v2/users/{{OCID}}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>'{"Users":{"Demo":{"6":"title"}}}',
  CURLOPT_HTTPHEADER => array(
   'Appkey: {{ONECOUNT API KEY}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Response                                                                                                                                                                                                                                                                                                                                                                                 200 OK

Update user Response
{
    "result": {
        "success": "1",
        "error": {
            "code": "",
            "message": ""
        }
    },
    "Users": [
        {
            "Id": 1845823,
            "OCID_HASH": "fccaa8dc7afadccc5882528d47b27c2bb53e2788dd0ac1fe170abef77a9c4d5b"
        }
    ]
}






























GET method should be used to lookup users.

Request

Type

Description

Lookup params

String

URL encoded key value string parameters for the lookup. Return property has csv of questions id requested back in Users object.

Params: Value of question Ids: Key value for Lookup question ids for e.g. 1=user1@email.com

return: csv of question id that is requested back. The Users object returned will only have these properties plus UserId (String)

If return is not provided, all the demographics will be returned.



Response

Type

Description

Users

Users

Found users returned with the demo field requested in return parameter in json format


Sample response for /users/<OCID or ocid_hash>

Along with the demo in json format, the active packages and products of the user referred to as products and resources respectively are also returned.

Screen Shot 2020-02-26 at 11.15.52 AM.png


Sample response for /users/lookup?11=santosh@one-count.com&return=2,3

Screen Shot 2020-02-26 at 11.22.13 AM.png


POST method should be used to create users.

Request

Type

Description

Users

Users

Users object that contains information about user to create. PartnerId Needs to be specified.

Transactions

Transactions

(Array of) transaction object specifying parts of the transaction to be added to the new user. UserId and TransactionId, SubscriptionType will be ignored if specified. As this is new user and new transaction is being added.

DedupeColumns

String

CSV of question id's that should be considered to find duplicate.

Return

String

CSV of ONEcount QuestionId's requested back in Users object in response.

Response

Type

Description

Users

Users

Created users returned with the demo field requested in return parameter in json format. If return was not specified only UserId will be returned.


PUT method should be used to update users.

Request

Type

Description

Users

Users

Users object with update fields. Return property has csv of questions id requested back in Users object.

Return

String

CSV of ONEcount QuestionId's requested back in Users object in response

RequestDate

Date

RequestDate to use for the demo update. If not provided current date will be used.

Response

Type

Description

Users

Users

Updated user returned with the demo field requested in return parameter in json format.



Create new users. Here in this example the JSON for request is passed in userFile.json file.

curl -X POST -H “Appkey: xxx” -H "Content-Type: application/json" –data-binary -d '@userFile.json' https://api.onecount.net/v2/users

 

 


COMPONENT: Questions

All data fields in ONEcount are made up of questions. Questions are configurable on a per-client basis, and no two customer installations will have the same question (ie., field) layout. Therefore, before querying or updating any ONEcount installation, you'll need to get an understanding of the question layout of the installation. This API segment will allow you to query ONEcount to determine the question layout for the installation. It will also allow you to create new questions within the system. This resource does not allow you to update the data for a specific user (see User section).

This resource is for manipulating questions resource. Questions in ONEcount means any question that is asked to the subscriber. It could be any questions that appears on customer forms or print forms that gets answered by a subscriber. Questions api call will allow creation, update and search of question in ONEcount. To add a new questions to the system you'll make a POST api call to the questions resource.

The data that is sent should be in JSON format and of type questions as described in References section. The type property of questions object is described below. Questions object will only need a choices block if the question is a multiple choice question(type=4 or 5 or 6)

There can be 6 types of questions:

Type

Description

1

Textbox type questions or short response type question. The response length needs to be less than 255 characters.

2

Textarea type question or long response type question.

3

Password type question. This is basically same as type 1 but when displayed in ONEcount frontend forms typed characters appears as *.

4

Select or dropdown type questions. This is a multiple choice, 1 response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the select question.

5

Radio button type question. This is a multiple choice, 1 response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the radio question.

6

Checkbox type question. This is a multiple choice, multi response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the checkbox question.

Method

Url

Action

GET

/questions

List all questions

GET

/questions/1

Returns question id 1

GET

/questions/lookup?Text=Email

Returns all questions with “Email" in question text

POST

/questions

Create a new question

JSON of the Questions type object needs to be sent as post data. Id field should not be sent.

PUT

/questions

Update a question

JSON of the Questions type object needs to be sent as post data. Id field is mandatory for update.


GET method can be used to lookup questions.

Request

Type

Description

Lookup params

String

URL encoded key value string parameters for the question that a user is trying to search.

Params:

Text: Word or phrase that should be present in the question text (String)

Type: Look up the question type.

Response

Type

Description

Questions

Questions

Returns found question details.


POST method should be used to create questions. The data that is sent should be in JSON format and of type questions as described in references section. Questions object will only need a choices block if the question is a multiple choice question (type=4 or 5 or 6).

Request

Type

Description

Questions

Questions

This defines the question contents and possible responses.

Response

Type

Description

QuestionId

Int

Returns ONEcount question id on successful creation of the question.


PUT method should be used to update question.

Request

Type

Description

Questions

Questions

This defines the question contents and responses.

Response

Type

Description

QuestionId

Int

Returns ONEcount question id on successful update of the question.


Example: Get list of questions from api which has FirstName in text

curl -X GET -H “Appkey: xxx” https://api.onecount.net/v2/questions/lookup?Text=FirstName

{

"result": {

"success": "1",

"error": {

"code": "0",

"message": ""

}

},

"Questions": [

{

"Id": "6",

"Text": "FirstName",

"Type": "1",

"Alias": "FName"

}

]

}


COMPONENT: Products

This resource is for manipulating products resource. A product can be created, updated or searched.

Method

Url

Action

GET

/products

Get all product details

GET

/products/5

Get product id 5

GET

/products/lookup?Title=productname

Lookup products by Title

POST

/products

JSON of the Products type object needs to be sent as post data. Id field should not be sent.

PUT

/products/5

JSON of the Products type object needs to be sent as post data. Id field is mandatory for update.

POST

/products/attachResource

JSON of the Product and Resource ids to be sent as post data.

Both fields are mandatory.

Example:

{"ProductID":"65","ResourceID":”121"}


GET method should be used to lookup products.

Request

Type

Description

Lookup params

String

URL encoded key value string parameter for the lookup.

Params:

Name: Name of the Product for lookup (String)

Response

Type

Description

Products

Products

Returns found product details.


POST method should be used to create products.

Request

Type

Description

Products

Products

Product details in json to be sent as post data. Id should not be set.

Example:

{"Title":"Test123","Description": "Testss","Terms":{"Name":"Product123"},"PrimaryFormId":10,"ResourceID":17}

Response

Type

Description

ProductId

int

Product Id of the newly created product.


PUT method should be used to update an individual product given the product info.

Request

Type

Description

Products

Product

Product details to be updated in json format to be sent with request. Id property needs to be set to identify the product to be updated. If you send term and resource along with product creation then it will automatically attach term to product and resource to product.

Possible Request Params: Title, Description, PrimaryFormId, ResourceID

Example:

{"Title":"Test123","Description": "Testss","PrimaryFormId":10,"ResourceID":17}

Response

Type

Description

ProductId

Int

Product id of the updated product.


COMPONENT: Terms

This resource is for manipulating terms resource. A term can be created, updated or searched.

Method

Url

Action

GET

/terms/5

Get term id 5

GET

/terms/lookup?Name=termname

Lookup terms by Name

POST

/terms

JSON of the terms type object needs to be sent as post data. Id field should not be sent.

PUT

/terms/5

JSON of the terms type object needs to be sent as post data. Id field is mandatory for update.


GET method should be used to lookup products.

Request

Type

Description

Lookup params

String

URL encoded key value string parameter for the lookup.

Params:

Name: Name of the term for lookup (String)

Response

Type

Description

Terms

Terms

Returns found term details.


POST method should be used to create products.

Request

Type

Description

Terms

Terms

Term details in json to be sent as post data. Id should not be set.

Possible Request Params: Name, Description, Duration, DurationUnit, Price, ProductId, Active, ProductStatusId, Quantity, QuantityTxt

Example:

{"Name":"Test123","Description":Testss","Duration":10,"ProductId":17}

Response

Type

Description

TermId

int

Term Id of the newly created term.


PUT method should be used to update an individual term given the term info.

Request

Type

Description

Terms

Term

Term details to be updated in json format to be sent with request. Id property needs to be set to identify the term to be updated.


Example:

{"Name":"Test123","Description":Testss","Duration":10,"ProductId":17}

Response

Type

Description

TermId

Int

term id of the updated term.


COMPONENT: Resources

Resources are the available entities that can be accessed/modified via API. Each resource can be created, updated or requested by using the corresponding http method described above.

  • questions

  • users

  • products

  • terms

  • resources

  • sources

  • transactions

 

This resource is for manipulating resources resource. A resource can be created, updated or searched.

Method

Url

Action

GET

/resources/5

Get resource id 5

GET

/resources/lookup?Name=resourcename

Lookup resources by Name

POST

/resources

JSON of the resources type object needs to be sent as post data. Id field should not be sent.

PUT

/resources/5

JSON of the resources type object needs to be sent as post data. Id field is mandatory for update.


GET method should be used to lookup resources.

Request

Type

Description

Lookup params

String

URL encoded key value string parameter for the lookup.

Params:

Name: Name of the resource for lookup (String)

Response

Type

Description

Resources

Resources

Returns found resource details.


POST method should be used to create resources.

Request

Type

Description

Resources

Resources

resource details in json to be sent as post data. Id should not be set.

Possible Request Params: Name, Description, Type, Value, FreePass

Example:

{"Name":"Test123","Description":Testss","Type":3,"Value":”/digital/”}

{"Name":"Test123","Description":Testss","Type":3,"Value":[”/digital/”, "/article/"]}

{"Name":"Test123","Description":Testss","Type":3,"Value":”/digital/”, "FreePass":1}

{"Name":"Test123","Description":Testss","Type":3,"Value":[”/digital/”, "/article/"],"FreePass":1}

Response

Type

Description

ResourceId

int

Resource Id of the newly created resource.


PUT method should be used to update an individual resource given the resource info.

Request

Type

Description

Resources

Resource

Resource details to be updated injsonformat to be sent withrequest. Id property needs to be set to identify the resource to be updated.


Examples:

{"Name":"Test123","Description":Testss","Type":3,"Value":”/digital/”}

{"Name":"Test123","Description":Testss","Type":3,"Value":[”/digital/”, "/article/"]}

{"Name":"Test123","Description":Testss","Type":3,"Value":”/digital/”,"FreePass":1}

{"Name":"Test123","Description":Testss","Type":3,"Value":[”/digital/”, "/article/"],"FreePass":1}

Response

Type

Description

ResourceId

Int

resource id of the updated resource.




COMPONENT: Source Codes

This resource is for manipulating source code for a resource. A source code can be created, updated or searched.

Method

Url

Action

GET

/sources/1

Get source id 1.

GET

/sources/lookup?Source=sourcename

Lookup sources by source.

POST

/sources

JSON of the Sources type object needs to be sent as post data. Id field should not be sent.

PUT

/sources

JSON of the Sources type object needs to be sent as post data. Id field is mandatory for update.


Sources can be looked up given the code or Id. GET method should be used for lookup.

Request

Type

Description

Lookup params

String

URL encoded key value string parameter for the lookup.

Params:

Source: Source value (String)

Response

Type

Description

Sources

Sources

Returns found source details.



POST method should be used to create an individual source given the source parameters.

Request

Type

Description

Sources

Sources

Defines the contents that makes up the source. Id parameters should not be set.

Response

Type

Description

SourceId

int

Returns created source code id.


PUT method can be used to update an individual source given the id.

Request

Type

Description

Sources

Sources

Defines the contents that makes up the source. The id parameter needs to be set which will identify the id of the source to be updated.

Response

Type

Description

SourceId

int

Returns updated source id.



COMPONENT: Transactions

This resource is for manipulating transactions resource. A transaction can be created or searched.

Method

Url

Action

GET

/transactions

List all transactions

GET

/transactions/lookup?UserId=1

Lookup all transaction of UserId = 1

POST

/transactions

JSON of the Transactions type object needs to be sent as post data. Id field should not be sent.



Transactions can be looked up using transactionId, date range, userid. Use GET method to do lookup.

Request

Type

Description

Lookup params

String

URL encoded key value string parameter for the lookup.

Params:

UserId: Id of the user whose transaction is to be looked up (Int)

StartDate: Date from which the start should happen. Only valid when UserId is set. (Date)

EndDate: When the search should end. Only valid when UserId is set. (Date)

Response

Type

Description

Transactions

Transactions

Returns all transaction that satisfies the search criteria. Returns all the package and product transactions of the user. Package Transactions are the one with TermId and ProductId. Product Transactions are the one with ResourceId.


Sample response for /transactions/lookup?UserId=25255105:

Screen Shot 2020-02-26 at 11.14.29 AM.png


POST method can be used to create user transaction. Transaction info needs to be sent as request and a TransactionId will be returned when the transaction is created.

Request

Type

Description

Transactions

Transactions

Contains fields that define a transaction. Id field should not be set.

Response

Type

Description

TransactionId

int

Returns transactionId of the newly created transaction.



COMPONENT: Leads

Stats resource can be used to submit any type of stat collected on the third party systems. Each type of stat will be represented by a sub-resource. So, for telemarketing it could be /stats/telemarketing endpoint, for videos it can be /stats/videos, for webinar it could be /stats/webinars etc. Right now we only have telemarketing sub-resource.






Telemarketing Leads

This resource is for manipulating telemarketing stat resource. A telemarketing stat can be created or listed.

Method

Url

Action

GET

/stats/telemarketing

List telemarketing stats

GET

/stats/telemarketing/1000

Get telemarketing stat whose id is 1000 in the system.

POST

/stats/telemarketing

JSON of the Telemarketing type object needs to be sent as post data. Id field should not be sent.


POST method can be used to create telemarketing stat. Telemarketing info needs to be sent as request and an Id will be returned when the transaction is created.

Request

Type

Description

Telemarketing

Telemarketing

Contains fields that define a telemarketing stat. Id field should not be set. Refer to telemarketing object in references section.

Workflow: OCID: This id is required field. This represents the unique id of the user in onecount system. This id can be looked up from the /user/lookup resource if the ocid is not known by providing user demographic questions, if not found new user needs to be created in the onecount system by posting the user demographic from /user resource. If the ocid is found send the demo data to user resource (PUT) to update the demographic information.

E.g

{

"Telemarketing":[

{

"OCID":"5000",

"Date": "2016-01-01",

"Time": "10:10:10",

"ResourceId":"250",

"PageUrl": "http://www.one-count.com/detail/a.php",

"PageTitle":"tests"

}

]

}




Response

Type

Description

Ids

String

Returns telemarketing ids of the newly created transaction. If multiple stats are sent, multiple ids are returned in cvs format.






API REFERENCE

Type: Questions

Property Name

Type

Description

Id

Int

Id of the question.

Text

String

Text of the question.

Type

Int

Determines which type of question it is. Textbox, checkbox, select, radio.
There can be 6 types of questions.
type=1 means textbox type questions or short response type question. The response length needs to be less than 255 characters.
type=2 means textarea type question or long response type question.
type=3 means password type question. This is basically same as type 1 but when displayed in ONEcount frontend forms typed characters appears as *
type = 4 means select or dropdown type questions. This is a multiple choice, 1 response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the select question.
type=5 means radio button type question. This is a multiple choice, 1 response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the radio question.
type=6 means checkbox type question. This is a multiple choice, multi response type question. When creating this type of question the choices block also needs to be part of the questions object that will hold the possible choices of the checkbox question.

Choices

choices

If multiple choice question this field will have the choices.

Alias

String

Alias for admin purpose.



Type: Choices

Property Name

Type

Description

Id

int

Id of the choice.

Text

string

Display text of choice.

Value

String

Value stored in db.

Order

Int

Display order.

QuestionId

Int

Tied to which question id.


Type: Users

Property Name

Type

Description

Id

Int

ID of the user in ONEcount.

PartnerId

Int

ID of the user in partners system (e.g. id of your system).

Demo

Demo

Object of user's demo question ids and respective response values.

RequestDate

Date

Request date.


Type: Demo

Property Name

Type

Description

QuestionId (e.g 6)

String

6 is the value of “Id” property of question resource(Text = “First Name”)

QuestionId (e.g 7)

String

7 is the value of “Id” property of question resource(Text = “Last Name”)

...

...

...


Type: Transactions

Property Name

Type

Description

Id

Int

ID of the transaction.

UserId

Int

Id of user in ONEcount.

TermId

Int

TermId in ONEcount.

ProductStatus

Int

Status ID.

SubscriptionType

Char

Can be n,r or u for new, renew or unsubscribe.

TransactionDate

Date

Date when the transaction occurred.

TransactionTime

Time

Time of transaction.

RequestDate

Date

The effective request date for the transaction.

UserIP

String

IP of the user.

Source

String

The transaction needs to be tied to a source code this will define it.

MediaFilePath

String

The url of media associated with that transaction. Eg image, audio.

ExpireDate

Date

Date when the subscription expires.

Amount

Float

If there is amount (USD) included in transaction.


Type: Sources

Property Name

Type

Description

Id

Int

Id of the source.

Source

String

Value of the source.

Description

Text

Description of the source.

ParentId

int

If this is a child source then list the parent source id.


Type: Products

Property Name

Type

Description

Id

Int

Specify only for update.

Name

String

Name of the Product.

Description

Text

Description of the product.

Terms

Terms

(Array of) Terms associated with the product.


Type: Terms

Property Name

Type

Description

Id

int

Id of the term.

Name

string

Name of the Term.

Description

text

Description of the term.

Duration

int

Duration of term validity.

DurationUnit

sting

Y (year), M (Month), D (Days).

ProductId

int

Id of the product the term is tied to.

Price

float

If there is price (USD) for the term.


Type: Resources

Property Name

Type

Description

Id

Int

Specify only for update.

Name

String

Name of the Resource.

Description

Text

Description of the Resource.

Type

Int

Type Options

0 : File

2 : Newsletter

3 : Section

4 : Page

5 : Function

Value

String

or

Array

Value of Resource Type:

When requesting a resource (GET), you should expect a string if there is only one value. If there are multiple values, you should expect an array.

For creating/updating a resource (POST/PUT), it is highly recommended to send an array - this will handle single and multiple value requests.

Example :

if the Type sent is 3 with one value then Value would be "/digital/" or ["/digital"/]. We recommend using the second approach of ["/digital"/].
if the Type sent is 3 with two values then Value would be ["/digital/", "/articles/"]

For Function type resource leave it blank.

limit

Int

Default limit is 25 but if all the data needs to be pulled then pass limit=0.

FreePass

Int

Default value is 0. This parameter is used to provide access to protected content.


Type: Telemarketing

Property Name

Type

Description

Id

int

Id of the telemarketing stat. This is autogenerated from the system and can be used to lookup the stat.

OCID

int

Onecount ID of the user.

Date

Date

Date when the stat occurred. Format: yyyy-mm-dd

Time

Time

Time of stat. Format: h:m:s (24 hour format)

ResourceId

int

Id of resource currently being sent for the sat. If the resource type is page type resource then need to send

PageTitle otherwise it will follow the process described in PageTitle.

PageUrl

string

Page Url belongs to resource that is being sent with this request. If the resource is file type then it needs to be path to that file and if the resource is section it needs to be section. Basically the value here needs to exact what is defined while creating resource.

PageTitle

string

Page title that belongs to the page url that is being sent. If not provided it try to pull the title from the page but if unsuccessful then it will set it as blank.


If the page url already exists and it doesn't match with the one that is being sent then it will throw conflict error with the title in our system.