NAV
shell javascript php

Getting Started

Welcome to ConsCent! This documentation covers all the steps for you to get set up - from optionally registering your premium content with ConsCent - which priced for a Pay per View basis, followed by integrating the paywall on your content pages and initialising the overlay to ensure all premium content is paid for, logging to your account via authorised credentials.

Registration

The first step is registering your client with ConsCent. This is done by the ConsCent Team internally and your administrator will recieve the login credenitals (email & password) for the ConsCent Client Dashboard on the email they chose to register with. The client must provide a default value for the 'price', 'duration' and optionally geolocation overrides if the client wants geo-fenced pricing options. This will ensure that all the premium content on the clients website/app is micro-priced - even if the client doesn't register the content with ConsCent via API. (Price values are in INR)

Note : By logging in to your ConsCent Client Dashboard and navigating to the Integrations Page in 'Documentation Tab', you will be able to view your active ClientId, API Key and API Secret.

Using ConsCent

Note : Whenever you're utilising the Web Integration Code or Calling any ConsCent APIs - you to update the API_URL and SDK_URL variables based on the environment you're operating in.

Once you have registered your digital content on ConsCent, you need to integrate the paywall on all your Premium Content Pages.

Ensuring that the paywall appears each time any premium content is opened, as well as allowing users to purchase the content via ConsCent.

Integrating the paywall allows the users to purchase any of the Client's Content via ConsCent at Micropriced rates. The Web Integration section includes the steps involved in handling the Success and Failure Callbacks after the users go through the Concent Paywall, followed by validating each unique transaction incurred by a user on the any of the Clients Content.

Web Integration

ConsCent Paywall Initalisation Script:

<script>
  const clientId = '5f92a62013332e0f667794dc';
  (function (w, d, s, o, f, cid) {
    if (!w[o]) {
      w[o] = function () {
        w[o].q.push(arguments);
      };
      w[o].q = [];
    }
    (js = d.createElement(s)), (fjs = d.getElementsByTagName(s)[0]);
    js.id = o;
    js.src = f;
    js.async = 1;
    js.title = cid;
    fjs.parentNode.insertBefore(js, fjs);
  })(window, document, 'script', '_csc', {SDK_URL}, clientId);
</script>

Ensure you replace the 'clientId' with your actual Client ID retrieved from the Conscent Client Dashboard Integration Page and the {SDK_URL} with the sdk url of an environment you want to use, e.g. 'https://sandbox-sdk.conscent.in' for sandbox

Integrating ConsCent on your Website is a simple and direct process. You start by copying the code on the right hand side within the script tags - and adding it to the header section of your Route Index file.

You can get your ConsCent Client Id from the Client Integrations Page of the ConsCent Client Dashboard - as mentioned in the Registration Section.

Including this code in the header section allows the ConsCent Paywall to be initalised and further used whenever required on any Premium Content Page.

Finally, In order to ensure that the ConsCent Paywall appears on all pages which contain Premium Content. You need to implement the following function on the content page - included on the right hand side which calls the initalisation function '_csc' of the ConsCent Paywall and enables a user to purchase the particular premium content at a Micropriced value through ConsCent. Please ensure that you call this function anytime you want the ConsCent paywall to show up on your content page and that you have filtered for users that have subscribed to your platform beforehand and already have access to view the content and thus will not be going through the ConsCent paywall.

Include ConsCent Paywall on Premium Content Content Page:

const csc = window._csc;
csc('init', {
  debug: true, // can be set to false to remove sdk non-error log output
  contentId: contentId,
  subscriptionUrl: {clientSubscriptionUrl},
  signInUrl: {clientSignInUrl},
  clientId: clientId,
  title: contentTitle,
  isMobile: 'false',
  buttonMode,
  successCallback: yourSuccessCallbackFunction,
  wrappingElementId: 'csc-paywall',
  fullScreenMode: 'false', // if set to true, the entire screen will be covered,
  phoneNumber: 9898989898,
  email: test@email.com
})

Success Callback example:

async function yourSuccessCallbackFunction(validationObject: any) {
  // Function to show the premium content to the User since they have paid for it via ConsCent
  // Here you should verify the  validationObject with our backend
  // And then you must provide access to the user for the complete content

  // example verification code:
  console.log('Initiating verification with conscent backend');
  const xhttp = new XMLHttpRequest(); // using vanilla javascript to make a post request
  const url = `${API_URL}/api/v1/content/consumption/${validationObject.consumptionId}`;
  xhttp.open('POST', url, true);
  // e is the response event
  xhttp.onload = (e) => {
    const backendConfirmationData = JSON.parse(e.target.response);

    // verifying that the validation received matches the backend data
    if (
      validationObject.consumptionId === backendConfirmationData.consumptionId &&
      validationObject.payload.clientId === backendConfirmationData.payload.clientId &&
      validationObject.payload.contentId === backendConfirmationData.payload.contentId
    ) {
      // Validation successful
      console.log('successful validation');
      // accessContent would be your function that will do all the actions that need to be done to unlock the entire content
      accessContent(true);
    }
  };
  xhttp.send();
}

We import the initalisation script using the unique '_csc' identifier and run the 'init' function by passing a number of parameters:

Once the ConsCent Paywall has been initalised and the user has gone through the necessary steps needed to purchase the content via ConsCent - you need to implement a 'successCallback' function which will recieve a response containing a validationObject shown below - indicating whether the user has purchased the content, or if the user has access to the content already since they have purchased it before, or whether the transaction has failed and the user has not purchased the content.

{ "message": "Content Purchased Successfully", "payload": { "clientId": "5fbb40b07dd98b0e89d90a25", "contentId": "Client Content Id 5", "createdAt": "2020-12-29T05:51:31.116Z" }, "consumptionId": "a0c433af-a413-49e1-9f40-ce1fbd63f568", "signature": "74h9xm2479m7x792nxx247998975393x08y9hubrufyfy3348oqpqqpyg78fhfurifr3", }

The message "Content Purchased Successfully" appears in the response only when the user has purchased content via ConsCent and the "accessTimeLeft" field appears in the response only when the user has purchased the content previously and still has free access to consume the content. Moreover, the response contains a "consumptionId" field which will be used to verify each unique transaction by a user on the clients content with ConsCent.

Calling the Validate Content Consumption API using the recieved "consumptionId" in the successCallback response can assist the client in authenticating valid and unique transactions on their premium content.

The response validationObject from the 'Validate Content Consumption' API includes the same fields as mentioned in the validationObject above and matching the payload from the 'successCallback' response and 'Validate Content Consumption' response allows the client to ensure each transaction of any premium content via ConsCent is validated by matching the clientId, contentId, and createdAt (Date of Consumption/Transaction);

If the case arrives when the user tries to purchase any content via ConsCent on the client's website and the transaction fails. The client can handle that case as well in a 'failedCallback' function or redirect to any page - as the Client wishes.

Lastly, once the transaction has been validated by the Client - whether they choose to do it in the frontend or the backend - the client needs to provide access to the premium content purchased by the user. You can do this on the same page, or redirect the user to a different page containing the entirety of the premium content.

Authentication

ConsCent uses API keys to allow access to the API for the Client to Create and Register any Content with ConsCent. You can view your API Key and Secret by logging in to your ConsCent Client Dashboard and navigating to the Integrations Page Client Integrations Page. Please contact your administrator for the Login Credentials to access the ConsCent Client Dashboard - provided on the official email address registered with ConsCent.

ConsCent expects for the API Key and Secret to be included as Basic Authentication in certain API requests (Ex. Create Content API utilised by the Client).

Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==

Client Content

Create Content


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/",
  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 =>'{
    "contentId" : "testingID For Client Content",
    "duration" : 30,
    "title" : "Test content for API functionality",
    "price" : 1,
    "currency": "INR",
    "url": "www.google.com",
    "contentType": "STORY",
    "categories": ["category1", "category2"],
    "tags": ["entertainment", "sports"],
    "sections": ["EDITORIAL"],
    "authorId": "7589",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Name",
      "fileType": "PDF"
    },
    "pixels": {
        "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
  }',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl -X POST '{API_URL}/api/v1/content/' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==' \
-H 'Content-Type: application/json' \
-d '{
    "contentId" : "testingID For Client Content",
    "duration" : 30,
    "title" : "Test content for API functionality",
    "price" : 1,
    "currency": "INR",
    "categories": ["category1", "category2"],
    "tags": ["entertainment", "sports"],
    "sections": ["EDITORIAL"],
    "authorId": "7589",
    "contentType": "STORY",
    "url": "www.google.com",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Name",
      "fileType": "PDF"
    },
    "pixels": {
        "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
}'
var axios = require("axios");
var data = JSON.stringify({
  contentId: "testingID For Client",
  duration: 30,
  title: "Test content for API functionality",
  price: 1,
  currency: "INR",
  url: "www.google.com",
  contentType: "STORY",
  categories: ["category1", "category2"],
  tags: ["entertainment", "sports"],
  sections: ["EDITORIAL"],
  authorId: "7589",
  priceOverrides: {
    country: [
      { name: "GL", price: 3 },
      { name: "IN", price: 5 },
      { name: "US", price: 7 },
    ],
  },
  download: {
    url: "https://yourdownloadurl.com",
    fileName: "Download File - Name",
    fileType: "PDF",
  },
  pixels: {
    facebook: {
      pixelId: "98357934724994",
      events: [
        {
          eventType: "VIEW",
          name: "PageView",
        },
        {
          eventType: "CONVERSION",
          name: "Purchase",
          data: {
            value: "dataValue",
          },
        },
      ],
    },
    google: {
      trackingId: "G-RJDY8493",
    },
  },
});

var config = {
  method: "post",
  url: "{API_URL}/api/v1/content/",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "message": "New Content Created!",
  "content": {
    "title": "Test content for API functionality",
    "price": 1,
    "currency": "INR",
    "contentId": "testingID For Client Content",
    "duration": 30,
    "url": "www.google.com",
    "contentType": "STORY",
    "categories": ["category1", "category2"],
    "priceOverrides": {
      "country": [
        {
          "_id": "605b25824646e9233aef61b4",
          "name": "GL",
          "price": 3
        },
        {
          "_id": "605b25824646e9233aef61b5",
          "name": "IN",
          "price": 5
        },
        {
          "_id": "605b25824646e9233aef61b6",
          "name": "US",
          "price": 7
        }
      ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Name",
      "fileType": "PDF",
      "s3Key": "KeyForDownloadedFileOnS3"
    },
    "pixels": {
      "facebook": {
        "pixelId": "98357934724994",
        "events": [
          {
            "eventType": "VIEW",
            "name": "PageView"
          },
          {
            "eventType": "CONVERSION",
            "name": "Purchase",
            "data": {
              "value": "dataValue"
            }
          }
        ]
      },
      "google": {
        "trackingId": "G-RJDY8493"
      }
    }
  }
}

This endpoint allows the Client to Register their Content on ConsCent - with the Content Title, ContentId, Content URL, categories, Analytics Pixels (Facebook and Google), Price as well as any specific Price Overrides for a country - In order to set a different price for the content in the relevant country. Moreover, the Client can also set the duration of a content - which means that if a content if purchased by a user on ConsCent, then that user can have free access to the content for {duration} amount of time. By Default we use a 1 Day duration. Moreover, the ContentType field is optional - and if no 'contentType' is provided then the default 'contentType' of the client will be treated as the 'contentType' of the content being registered. While category based pricing can be used for any content, by passing the priceCategory field on registering the content - as long as the price category has been registered by the client on the ConsCent dashboard along with its respective price, duration and priceOverrides; however, category based pricing only comes into effect if the content does not have a pre-determined price field (price must be null); Moreover, if the content is downloadable on purchase, then the client can pass the download "url", "fileName" and "fileType" in the download object of the request body while creating the content. Finally, the client can pass a 'pixels' object in the request body which can contain either/or facebook and google pixel data - to ensure that the client's pixel events are fired on particular occurances relating to the content (Page View or Purchase of the Content). The pixel object must be passed in accordance with the format provided in the sample requests. Please note that the pixels are NOT fired when a user has blocked 3rd party cookies.

HTTP Request

POST {API_URL}/api/v1/content

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Request Body

Parameter Default Description
contentId required Content Id by which the Content has been registered on the Client CMS. Please ensure that the content ID is at most 32 characters and can only contain letters, numbers, underscores and dashes.
title required Title of the Content
price optional Content Price for pay-per-use pricing
currency optional Currency in which price is determined. Must be an ISO 4217 supported - 3 Digit currency Code. INR is used as the default if no value is provided.
url required URL where the content is available on your website
duration optional Free content access time for user once the user has purchased the content. (Standard Practice - 1 Day);
authorId optional Id of the Author of the content - Mandatory if authorName is present
authorName optional Name of the Author of the content
contentType optional Must be an ENUM from one of the following - STORY, VIDEO, SONG, PODCAST, PREMIUM CONTENT
priceOverrides optional Price Overrides for any particular country with the relevant country code as the name and the ENUM value in the price. The country code list is located the end of this document
download optional Object containing the "url", "fileName" and "fileType". All download parameters must be provided if the content is downloadable on purchase. Also, the "fileType" is an ENUM and only accepts "PDF" currently.
priceCategory optional The priceCategory of the content, which has been registered by the client on the ConsCent Client Dashboard - in order to invoke category based pricing (only valid if story doesn't have a price). Each registered priceCategory will have an associated price, currency, duration and priceOverrides.
pixels optional A nested object with the optional keys being "facebook" and "google". With the "google" object only requiring the trackingId - to include the gcategory throughout the platform. However, for the "facebook" object the "pixelId" must be passed along with an "events" array - containing the event name (as configured on the facebook events manager), the eventType (which is an ENUM to be chosen from ["VIEW", "CONVERSION"]) as well as any data/values associated with the particular event.
categories optional Array of categories associated with the content

Edit Content

Please ensure you URL encode the contentId in the Path Parameters Replace the {contentId} in the API path with your actual Content Id

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/Client%20Content%20Id%2011",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
   CURLOPT_POSTFIELDS =>'{
    "contentId" : "testingID For Client Content",
    "duration" : 30,
    "title" : "Test content for API functionality Edited",
    "price" : 1,
    "currency": "INR",
    "url": "www.google.com",
    "contentType": "PREMIUM CONTENT",
    "categories": ["category3"],
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 2
            },
            {
                "name": "IN",
                "price": 1
            },
            {
                "name": "US",
                "price": 0
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Edited Name",
      "fileType": "PDF"
    },
    "pixels": {
        "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
}',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl -X PATCH '{API_URL}/api/v1/content/{contentId}' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==' \
-H 'Content-Type: application/json' \
-d '{
    "contentId" : "testingID For Client Content",
    "duration" : 30,
    "title" : "Test content for API functionality Edited",
    "price" : 1,
    "currency": "INR",
    "categories": ["category3"],
    "url": "www.google.com",
    "contentType": "PREMIUM CONTENT",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 2
            },
            {
                "name": "IN",
                "price": 1
            },
            {
                "name": "US",
                "price": 0
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Edited Name",
      "fileType": "PDF"
    },
    "pixels": {
        "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
}'
var axios = require("axios");
var data = JSON.stringify({
  contentId: "testingID For Client Content",
  duration: 30,
  title: "Test content for API functionality Edited",
  price: 1,
  currency: "INR",
  categories: ["category3"],
  url: "www.google.com",
  contentType: "PREMIUM CONTENT",
  priceOverrides: {
    country: [
      { name: "GL", price: 2 },
      { name: "IN", price: 1 },
      { name: "US", price: 0 },
    ],
  },
  download: {
    url: "https://yourdownloadurl.com",
    fileName: "Download File - Edited Name",
    fileType: "PDF",
  },
  pixels: {
    facebook: {
      pixelId: "98357934724994",
      events: [
        {
          eventType: "VIEW",
          name: "PageView",
        },
        {
          eventType: "CONVERSION",
          name: "Purchase",
          data: {
            value: "dataValue",
          },
        },
      ],
    },
    google: {
      trackingId: "G-RJDY8493",
    },
  },
});

var config = {
  method: "patch",
  url: "{API_URL}/api/v1/content/{contentId}",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWjnJL877NJSjnkHSk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "message": "Content Edited Successfully",
  "editedContent": {
    "title": "Client Content Id Test Edited",
    "contentId": "testingID For Client Content",
    "price": 1,
    "currency": "INR",
    "duration": 30,
    "categories": ["category3"],
    "url": "https://www.yoursite.com/yournewcontent",
    "contentType": "PREMIUM CONTENT",
    "authorName": "changed-author-name",
    "authorId": "changed-unique-author-id",
    "priceOverrides": {
      "country": [
        {
          "_id": "605b25824646e9233aef61b4",
          "name": "GL",
          "price": 2
        },
        {
          "_id": "605b25824646e9233aef61b5",
          "name": "IN",
          "price": 1
        },
        {
          "_id": "605b25824646e9233aef61b6",
          "name": "US",
          "price": 0
        }
      ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Edited Name",
      "fileType": "PDF",
      "s3Key": "KeyForDownloadedFileOnS3"
    },
    "pixels": {
      "facebook": {
        "pixelId": "98357934724994",
        "events": [
          {
            "eventType": "VIEW",
            "name": "PageView"
          },
          {
            "eventType": "CONVERSION",
            "name": "Purchase",
            "data": {
              "value": "dataValue"
            }
          }
        ]
      },
      "google": {
        "trackingId": "G-RJDY8493"
      }
    }
  }
}

This endpoint allows the Client to Edit their Registered Content on ConsCent - with the editable fields being the Content title, price, currency, priceOverrides, categories, URL, duration, contentType, download, category and pixels . Content ID CANNOT be edited!

HTTP Request

PATCH {API_URL}/api/v1/content/{contentId}

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

URL Parameters

Parameter Description
contentId The ID of the Content you wish to edit ( Ensure it is URL Encoded)

Request Body

Parameter Default Description
title optional Title of the Content
price optional Content Price for Pay-per-use pricing
currency optional Currency in which price is determined. Must be an ISO 4217 supported - 3 Digit currency Code. INR is used as the default if no value is provided.
url optional URL where the content is available on your website
duration optional Free content access time for user once the user has purchased the content. (Standard Practice - 1 Day);
authorId optional Id of the Author of the content - Mandatory if authorName is present
authorName optional Name of the Author of the content
contentType optional Must be an ENUM from one of the following - STORY, VIDEO, SONG, PODCAST, PREMIUM CONTENT
priceOverrides optional Price Overrides for any particular country with the relevant country code as the name and the ENUM value in the price. The country code list is located the end of this document
download optional Object containing the "url", "fileName" and "fileType". All download parameters must be provided if the content is downloadable on purchase. Also, the "fileType" is an ENUM and only accepts "PDF" currently
priceCategory optional The priceCategory of the content, which has been registered by the client on the ConsCent Client Dashboard - in order to invoke category based pricing (only valid if story doesn't have a price). Each registered priceCategory will have an associated price, currency, duration and priceOverrides
pixels optional A nested object with the optional keys being "facebook" and "google". With the "google" object only requiring the trackingId - to include the gcategory throughout the platform. However, for the "facebook" object the "pixelId" must be passed along with an "events" array - containing the event name (as configured on the facebook events manager), the eventType (which is an ENUM to be chosen from ["VIEW", "CONVERSION"]) as well as any data/values associated with the particular event.
categories optional Array of categories associated with the content

View All Content

API to retrieve all of the client's content registered on ConsCent.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/client",
  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(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=="
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl -X GET '{API_URL}/api/v1/content/client' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=='
var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/content/client",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "content": [
    {
      "title": "Client Content Id Test Edit 1",
      "contentId": "Client Content Id 11",
      "price": 1,
      "currency": "INR",
      "duration": 2,
      "categories": ["category1", "category2"],
      "url": "https://www.yoursite.com/yourcontent",
      "contentType": "STORY",
      "priceOverrides": {
        "country": [
          {
            "_id": "605b25824646e9233aef61b4",
            "name": "GL",
            "price": 2
          }
        ]
      }
    },
    {
      "title": "Test content for API functionality",
      "contentId": "testingID for Client Content",
      "price": 3,
      "currency": "INR",
      "categories": ["category3"],
      "duration": 2,
      "url": "https://www.yoursite.com/yourcontent",
      "contentType": "STORY",
      "download": {
        "url": "https://yourdownloadurl.com",
        "fileName": "Download File - Name",
        "fileType": "PDF",
        "s3Key": "KeyForDownloadedFileOnS3"
      }
    }
  ],
  "pagination": {
    "pageNumber": 1,
    "pageSize": 20,
    "totalRecords": 2,
    "totalPages": 1
  }
}

This endpoint allows the Client to view their entire collection of Registered Content on ConsCent. With each retrieved content containing the following details - Title, Price, URL, Content ID and duration.

HTTP Request

GET {API_URL}/api/v1/content/client

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

URL Parameters

Parameter Default Description
pageNumber optional Pagination Parameters - which page of the contents list you would like to retrieve (default = 1). Since each page will have 20 (default) individual contents ONLY.
pageSize optional Pagination Parameters - the number of individual contents to retrieve on each page (default = 20).

View Content Details

Please ensure you URL encode the contentId in the Path Parameters Replace the {contentId} in the API path with your actual Content Id

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/client/Client%20Content%20Id%206",
  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(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=="
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl -X GET '{API_URL}/api/v1/content/client/Client%20Content%20Id%206' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=='
var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/content/client/Client%20Content%20Id%206",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "title": "Tesla Tequila",
  "contentId": "Client Content Id 6",
  "categories": ["category3"],
  "price": 1,
  "currency": "INR",
  "url": "https://www.yoursite.com/yourcontent",
  "duration": 1,
  "contentType": "STORY",
  "priceOverrides": {
    "country": [
      {
        "_id": "605b25824646e9233aef61b4",
        "name": "GL",
        "price": 2
      }
    ]
  }
}

This endpoint allows the Client to retrieve a particular content which they registered with ConsCent - including the details of the content such as the Content ID, title, price, currency, URL, duration, contentType and priceCategory.

HTTP Request

GET {API_URL}/api/v1/content/client/{contentId}

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

URL Parameters

Parameter Description
contentId The ID of the Content you wish to retrieve (Please ensure its URL Encoded)

Client Content Bundles

Create Content Bundle


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/bundle",
  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 =>'{
    "contentId" : "Client Content Bundle 1",
    "duration" : 30,
    "title" : "Test content bundle for API functionality",
    "price" : 10,
    "currency": "INR",
    "url": "www.google.com",
    "categories": ["category4", "category5"],
    "contentType": "STORY",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
  }',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl -X POST '{API_URL}/api/v1/content/bundle' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==' \
-H 'Content-Type: application/json' \
-d '{
    "contentId" : "Client Content Bundle 1",
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
    "duration" : 30,
    "title" : "Test content bundle for API functionality",
    "price" : 10,
    "currency": "INR",
    "categories": ["category4", "category5"],
    "contentType": "STORY",
    "url": "www.google.com",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
}'
var axios = require("axios");
var data = JSON.stringify({
  contentId: "Client Content Bundle 1",
  bundleContentIds: ["Content Id 1", "Content Id 2", "Content Id 3"],
  duration: 30,
  title: "Test content bundle for API functionality",
  price: 10,
  currency: "INR",
  categories: ["category4", "category5"],
  url: "www.google.com",
  contentType: "STORY",
  priceOverrides: {
    country: [
      { name: "GL", price: 3 },
      { name: "IN", price: 5 },
      { name: "US", price: 7 },
    ],
  },
});

var config = {
  method: "post",
  url: "{API_URL}/api/v1/content/bundle",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "message": "New Content Created!",
  "content": {
    "title": "Test content bundle for API functionality",
    "price": 10,
    "currency": "INR",
    "contentId": "Client Content Bundle 1",
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
    "categories": ["category4", "category5"],
    "duration": 30,
    "url": "www.google.com",
    "contentType": "STORY",
    "priceOverrides": {
      "country": [
        {
          "_id": "605b25824646e9233aef61b4",
          "name": "GL",
          "price": 3
        },
        {
          "_id": "605b25824646e9233aef61b5",
          "name": "IN",
          "price": 5
        },
        {
          "_id": "605b25824646e9233aef61b6",
          "name": "US",
          "price": 7
        }
      ]
    }
  }
}

This endpoint allows the Client to Register their Content Bundle on ConsCent - with the Content Title, ContentId, BundleContentIds, Content URL, categories, Price, Currency, as well as any specific Price Overrides for a country - In order to set a different price for the content bundle in the relevant country. Moreover, the Client can also set the duration of a content bundle - which means that if a bundle if purchased by a user on ConsCent, then that user can have free access to all the content in the bundle for {duration} amount of time. By Default we use a 1 Day duration. Moreover, the ContentType field is optional - and if no 'contentType' is provided then the default 'contentType' of the client will be treated as the 'contentType' of the content being registered. While category based pricing can be used for any content bundle, by passing the priceCategory field on registering the content - as long as the priceCategory has been registered by the client on the ConsCent dashboard along with its respective price, duration and priceOverrides; however, category based pricing only comes into effect if the content does not have a pre-determined price field (price must be null); Lastly, the bundleContentIds must be the unique Ids of the client's contents that have been registered with ConsCent previously. Any mismatch in the bundleContentIds will throw an error - so ensure the contentIds that are to be part of the bundle are registered and passed to the API call correctly.

HTTP Request

POST {API_URL}/api/v1/content/bundle

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Request Body

Parameter Default Description
contentId required Unique Content Id by which the Content Bundle will be determined and registered
bundleContentIds required Array of ContentIds - which have been registered on ConsCent by the client and are to be grouped together for purchase - in this bundle
title required Title of the Content Bundle
price optional Content Bundle Price
currency optional Currency in which price is determined. Must be an ISO 4217 supported - 3 Digit currency Code. INR is used as the default if no value is provided.
url required URL where the content bundle is available on your website
duration optional Free content access time for user once the user has purchased the content bundle. (Standard Practice - 1 Day);
contentType optional Must be an ENUM from one of the following - STORY, VIDEO, SONG, PODCAST, PREMIUM CONTENT
priceOverrides optional Price Overrides for any particular country with the relevant country code as the name and the ENUM value in the price. The country code list is located the end of this document
priceCategory optional The priceCategory of the content bundle, which has been registered by the client on the ConsCent Client Dashboard - in order to invoke category based pricing (only valid if story doesn't have a price). Each registered priceCategory will have an associated price, currency, duration and priceOverrides.
categories optional Array of categories associated with the content bundle

Edit Content Bundle

Please ensure you URL encode the contentId in the Path Parameters Replace the {contentId} in the API path with your actual Content Id

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/bundle/Client%20Content%20Bundle%2011",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
   CURLOPT_POSTFIELDS =>'{
    "contentId" : "Client Content Bundle 1",
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
    "duration" : 30,
    "title" : "Test content bundle for API functionality Edited",
    "price" : 15,
    "categories": ["category7"],
    "currency": "INR",
    "url": "www.google.com",
    "contentType": "PREMIUM CONTENT",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 2
            },
            {
                "name": "IN",
                "price": 1
            },
            {
                "name": "US",
                "price": 0
            }
        ]
    },

}',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl -X PATCH '{API_URL}/api/v1/content/bundle/{contentId}' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==' \
-H 'Content-Type: application/json' \
-d '{
    "contentId" : "Client Content Bundle 1",
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
    "duration" : 30,
    "title" : "Test content bundle for API functionality Edited",
    "price" : 15,
    "currency": "INR",
    "categories": ["category7"],
    "url": "www.google.com",
    "contentType": "PREMIUM CONTENT",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 2
            },
            {
                "name": "IN",
                "price": 1
            },
            {
                "name": "US",
                "price": 0
            }
        ]
    },
}'
var axios = require("axios");
var data = JSON.stringify({
  contentId: "Client Content Bundle 1",
  bundleContentIds: ["Content Id 1", "Content Id 2", "Content Id 3"],
  duration: 30,
  title: "Test content bundle for API functionality Edited",
  price: 15,
  currency: "INR",
  url: "www.google.com",
  contentType: "PREMIUM CONTENT",
  categories: ["category7"],
  priceOverrides: {
    country: [
      { name: "GL", price: 2 },
      { name: "IN", price: 1 },
      { name: "US", price: 0 },
    ],
  },
});

var config = {
  method: "patch",
  url: "{API_URL}/api/v1/content/bundle/{contentId}",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWjnJL877NJSjnkHSk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "message": "Content Edited Successfully",
  "editedContent": {
    "title": "Test content bundle for API functionality Edited",
    "contentId": "Client Content Bundle 1",
    "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
    "price": 15,
    "currency": "INR",
    "duration": 30,
    "categories": ["category7"],
    "url": "https://www.yoursite.com/yournewcontent",
    "contentType": "PREMIUM CONTENT",
    "priceOverrides": {
      "country": [
        {
          "_id": "605b25824646e9233aef61b4",
          "name": "GL",
          "price": 2
        },
        {
          "_id": "605b25824646e9233aef61b5",
          "name": "IN",
          "price": 1
        },
        {
          "_id": "605b25824646e9233aef61b6",
          "name": "US",
          "price": 0
        }
      ]
    }
  }
}

This endpoint allows the Client to Edit their Registered Content Bundle on ConsCent - with the editable fields being the bundleContentIds as well as the bundle title, price, currency, priceOverrides, URL, duration, contentType and priceCategory. The Bundle Content ID CANNOT be edited!

HTTP Request

PATCH {API_URL}/api/v1/content/bundle/{contentId}

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

URL Parameters

Parameter Description
contentId The ID of the Content Bundle you wish to edit ( Ensure it is URL Encoded)

Request Body

Parameter Default Description
title optional Title of the Content Bundle
bundleContentIds optional Array of ContentIds - which have been registered on ConsCent by the client and are to be grouped together for purchase - in this bundle
price optional Content Bundle Price
currency optional Currency in which price is determined. Must be an ISO 4217 supported - 3 Digit currency Code. INR is used as the default if no value is provided.
url optional URL where the content bundle is available on your website
duration optional Free content access time for user once the user has purchased the content bundle. (Standard Practice - 1 Day);
contentType optional Must be an ENUM from one of the following - STORY, VIDEO, SONG, PODCAST, PREMIUM CONTENT
priceOverrides optional Price Overrides for any particular country with the relevant country code as the name and the ENUM value in the price. The country code list is located the end of this document
priceCategory optional The priceCategory of the content bundle, which has been registered by the client on the ConsCent Client Dashboard - in order to invoke category based pricing (only valid if story doesn't have a price). Each registered priceCategory will have an associated price, currency, duration and priceOverrides
categories optional Array of categories associated with the content bundle

View All Content Bundles

API to retrieve all of the client's content bundles registered on ConsCent.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/bundles",
  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(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=="
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl -X GET '{API_URL}/api/v1/content/bundles' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw=='
var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/content/bundles",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "content": [
    {
      "title": "Client Content Bundle Edit 2",
      "contentId": "Client Content Bundle 2",
      "bundleContentIds": ["Content Id 4", "Content Id 5"],
      "price": 10,
      "currency": "INR",
      "duration": 2,
      "categories": ["category7"],
      "url": "https://www.yoursite.com/yourcontent",
      "contentType": "STORY",
      "priceOverrides": {
        "country": [
          {
            "_id": "605b25824646e9233aef61b4",
            "name": "GL",
            "price": 2
          }
        ]
      }
    },
    {
      "title": "Test content bundle for API functionality",
      "bundleContentIds": ["Content Id 1", "Content Id 2", "Content Id 3"],
      "contentId": "Client Content Bundle 1",
      "price": 15,
      "currency": "INR",
      "duration": 30,
      "url": "https://www.yoursite.com/yourcontent",
      "contentType": "STORY"
    }
  ],
  "pagination": {
    "pageNumber": 1,
    "pageSize": 20,
    "totalRecords": 2,
    "totalPages": 1
  }
}

This endpoint allows the Client to view their entire collection of Registered Content Bundles on ConsCent. With each retrieved content bundle containing the following details - bundleContentIds, Title, Price, URL, Content ID and duration.

HTTP Request

GET {API_URL}/api/v1/content/bundles

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

URL Parameters

Parameter Default Description
pageNumber optional Pagination Parameters - which page of the content bundles list you would like to retrieve (default = 1). Since each page will have 20 (default) individual contents ONLY.
pageSize optional Pagination Parameters - the number of individual content bundles to retrieve on each page (default = 20).

Validate Content Consumption

Validate Content Details By Consumption ID

Replace the {consumptionId} in the API path with the actual value/string of the consumptionId recieved

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/consumption/11c369df-2a30-4a0d-90dc-5a45797dacdd",
  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",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
curl -X POST '{API_URL}/api/v1/content/consumption/{consumptionId}'
var axios = require("axios");

var config = {
  method: "post",
  url: "{API_URL}/api/v1/content/consumption/{consumptionId}",
  headers: {},
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

[
  {
    "message": "Content Consumption Confirmed",
    "payload": {
      "clientId": "5fbb40b07dd98b0e89d90a25",
      "contentId": "Client Content Id",
      "createdAt": "2020-11-15T13:55:36.659Z"
    },
    "consumptionId": "11c369df-2a30-4a0d-90dc-5a45797dacdd",
    "signature": "4379hrm47mo34m2340cny2rcn487cn209842cr474107nc409c4"
  }
]

This endpoint allows the Client to Validate the Content Details anytime a User Purchases any Content of the Client using ConsCent - with the Client passing the Content ID in the request and recieving details regarding the Content Id and the Date of Purchase of the Content by the User, as well as matching the unique Consumption Id to ensure it cannot be reused.

HTTP Request

POST {API_URL}/api/v1/content/consumption/{consumptionId}

The client will recieve a payload when any content is purchased via ConsCent - providing the details of the content such as the ClientId to identify which client the content belongs to as well as the Client Content ID, Transaction Amount and Date of the Transaction. Moroever, they will also recieve a Consumption ID - by passing the Consumption ID in this API request - the Client can verify the authenticity of the transaction and restrict any spillage.

URL Parameters

Parameter Default Description
consumptionId required consumptionId recieved by the client for each unique transaction on any of the Client's Content registered with ConsCent

Client Stats

Specific Content Stats


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{API_URL}/api/v1/client/stats/content/your-content-id?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z',
  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(
    'Authorization: Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;



curl -X GET '{API_URL}/api/v1/client/stats/content/your-content-id?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z' \
-H 'Authorization: Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ=='

var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/client/stats/content/your-content-id?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z",
  headers: {
    Authorization:
      "Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "count": 53,
  "amount": 588.74,
  "currency": "INR"
}

This endpoint allows our partners to get purchase count and purchase amount for a particular content id. Please pass the date-range as ISO-date strings in the from and to query parameters. Also pass the content id as a path parameter. By default this API provides details of all time consumption.

HTTP Request

POST {API_URL}/api/v1/client/stats/content/:replace-with-contentid

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Query Parameters

Parameter Default Description
from optional ISO date string from which the aggregated stats have to be calculated
to optional ISO date string till which the aggregated stats have to be calculated

Daily Content Stats


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{API_URL}/api/v1/client/stats/daily?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z',
  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(
    'Authorization: Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;



curl -X GET '{API_URL}/api/v1/client/stats/daily?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z' \
-H 'Authorization: Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ=='

var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/client/stats/daily?from=2021-02-12T05:45:41.389Z&to=2021-02-13T05:45:41.389Z",
  headers: {
    Authorization:
      "Basic WTE3UkdRSy1RMlQ0UEo5LU4zWVNSWEotRFNSNERZTTpQUkVTVDdTRTZSTUNXWVBaNjRZQzdXUlA2UEpEWTE3UkdRS1EyVDRQSjlOM1lTUlhKRFNSNERZTQ==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "totalContentConsumed": 17,
  "totalRevenueGenerated": 29.6
}

This endpoint allows the Client to get Aggregate Statistics based on users consumption of their content via ConsCent. By default this API provides details of the previous days' consumption. However, the client can pass the 'from' and 'to' dates as optional query parameters to get aggregated stats for any range that they choose. The value of 'totalRevenueGenerated' in the response if given in "INR" by default.

HTTP Request

POST {API_URL}/api/v1/client/stats/daily

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Query Parameters

Parameter Default Description
from optional ISO date string from which the aggregated stats have to be calculated
to optional ISO date string till which the aggregated stats have to be calculated

Current Subscriber Stats


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{API_URL}/api/v1/subscription/client/list',
  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(
    'Authorization: Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFUkYwWjlBTTFNRkpYNTJDUTRKTUdWSlpNTVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;



curl --location --request GET '{API_URL}/api/v1/subscription/client/list' \
--header 'Authorization: Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFUkYwWjlBTTFNRkpYNTJDUTRKTUdWSlpNTVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg=='

var axios = require("axios");

var config = {
  method: "get",
  url: "{API_URL}/api/v1/subscription/client/list",
  headers: {
    Authorization:
      "Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFUkYwWjlBTTFNRkpYNTJDUTRKTUdWSlpNTVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg==",
  },
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
    "subscriptions": [
        {
            "renewSubscription": false,
            "freeTrial": false,
            "_id": "617a78b780033b289c552298",
            "userAccount": {
                "address": {
                    "apartment": "4792",
                    "area": "Chattarpur",
                    "pincode": "110074",
                    "landmark": "ifelneddckjlj",
                    "city": "New Delhi",
                    "state": "Delhi",
                    "country": "IN"
                },
                "name": "Test Name",
                "phoneNumber": "9847473843",
                "email": "usertesting@email.com"
            },
            "buyingPrice": 96.5,
            "price": 100,
            "country": "IN",
            "city": "bengaluru (nagashettyhalli)",
            "expiryDate": "2022-01-28T10:17:27.354Z",
            "priceDetails": {
                "price": 100,
                "currency": "INR"
            },
            "subscriptionTitle": "Subscription 2",
            "operatingSystem": "Mac OS",
            "device": "desktop",
            "subscriptionType": {
                "physical": false,
                "digital": true
            },
            "createdAt": "2021-10-28T10:17:27.359Z"
        }
    ]

This endpoint allows the Client to get the list of all currently active subscriptions via ConsCent. Including the details of each subscription purchased, such as the title, price, the amount and currency paid by the user, the type of subscription, date of purchase, date of expiry, renewal and free trial booleans, as well as the user details - phone number, email, addressm , OS, device and location.

HTTP Request

POST {API_URL}/api/v1/subscription/client/list

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Client Subscriptions

Migrate User and Purchased Subscription


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://localhost:3001/api/v1/subscription/migrate',
  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 =>'{
    "userPrimaryEmail": "testemail@test.com",
    "userPrimaryPhone": "9545734678",
    "userSecondaryEmail": "testemailsecond@test.com",
    "userSecondaryPhone": "9545732228",
    "userName": "testUser",
    "expiryDate": "2022-01-25T12:39:28.337Z",
    "purchaseDate": "2022-01-25T12:39:28.337Z",
    "country": "IN",
    "clientUserId": "9342793972792",
    "userAddress": {
        "address": "test address line 1",
        "city": "New Delhi",
        "state": "DELHI",
        "postcode": "110001"
    },
    "utmParameters": {
        "utm_source": "website",
        "utm_medium": "facebook"
    },
    "subscriptionDetails": {
        "title": "Migrated Subscription 1",
        "priceDetails": {
            "price": 200,
            "currency": "INR"
        },
        "subscriptionType": {
            "physical": false,
            "digital": true
        },
        "internalSubscriptionId": "89432923924792792379"
    }
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFUkYwWjlBTTF7942mx974727929TUdWSlpNTVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg==',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl -X POST 'http://localhost:3001/api/v1/subscription/migrate' \
--header 'Authorization: Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFU73474977942792SlpNTVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg==' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userPrimaryEmail": "testemail@test.com",
    "userPrimaryPhone": "9545734678",
    "userSecondaryEmail": "testemailsecond@test.com",
    "userSecondaryPhone": "9545732228",
    "userName": "testUser",
    "expiryDate": "2022-01-25T12:39:28.337Z",
    "purchaseDate": "2022-01-25T12:39:28.337Z",
    "country": "IN",
    "clientUserId": "9342793972792",
    "userAddress": {
        "address": "test address line 1",
        "city": "New Delhi",
        "state": "DELHI",
        "postcode": "110001"
    },
    "utmParameters": {
        "utm_source": "website",
        "utm_medium": "facebook"
    },
    "subscriptionDetails": {
        "title": "Migrated Subscription 1",
        "priceDetails": {
            "price": 200,
            "currency": "INR"
        },
        "subscriptionType": {
            "physical": false,
            "digital": true
        },
        "internalSubscriptionId": "89432923924792792379"
    }
}'
var axios = require("axios");
var data = JSON.stringify({
  userPrimaryEmail: "testemail@test.com",
  userPrimaryPhone: "9545734678",
  userSecondaryEmail: "testemailsecond@test.com",
  userSecondaryPhone: "9545732228",
  userName: "testUser",
  expiryDate: "2022-01-25T12:39:28.337Z",
  purchaseDate: "2022-01-25T12:39:28.337Z",
  country: "IN",
  clientUserId: "9342793972792",
  userAddress: {
    address: "test address line 1",
    city: "New Delhi",
    state: "DELHI",
    postcode: "110001",
  },
  utmParameters: { utm_source: "website", utm_medium: "facebook" },
  subscriptionDetails: {
    title: "Migrated Subscription 1",
    priceDetails: { price: 200, currency: "INR" },
    subscriptionType: { physical: false, digital: true },
    internalSubscriptionId: "89432923924792792379",
  },
});

var config = {
  method: "post",
  url: "http://localhost:3001/api/v1/subscription/migrate",
  headers: {
    Authorization:
      "Basic TVZaVEZKOS1CNTlNNE5LLUczTUMyMDYtTUVFVktDMjozUzNFUkYwWj7479m2x7924792x297TVZaVEZKOUI1OU00TktHM01DMjA2TUVFVktDMg==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

The above command returns JSON structured like this:

{
  "message": "Subscription migrated successfully",
  "migratedSubscription": {
    "gstComponents": {
      "physical": 0,
      "digital": 0
    },
    "inrGstComponents": {
      "physical": 0,
      "digital": 0
    },
    "migratedSubscriptionDetails": {
      "priceDetails": {
        "price": 200,
        "currency": "INR"
      },
      "subscriptionType": {
        "physical": false,
        "digital": true
      },
      "title": "Migrated Subscription 1",
      "internalSubscriptionId": "89432923924792792379"
    },
    "manuallyRenewed": false,
    "renewSubscription": false,
    "availedOffers": [],
    "promotional": false,
    "categories": [],
    "bundle": false,
    "bundleContentIds": [],
    "paymentType": [],
    "freeTrial": false,
    "migrated": true,
    "_id": "61f25e0a9d50b5d6b90479eb",
    "clientId": "601a8ea4f2149f089782814f",
    "userAccount": "61f25e0a9d50b5d6b90479e8",
    "price": 0,
    "buyingPrice": 0,
    "priceDetails": {
      "price": 0,
      "currency": "INR"
    },
    "type": "SUBSCRIPTION",
    "subscriptionTitle": "Migrated Subscription 1",
    "subscriptionType": {
      "physical": false,
      "digital": true
    },
    "subscriptionId": "61eff7907acd46480c5259d8",
    "createdAt": "2022-01-27T08:55:38.786Z",
    "migratedCreatedAt": "2022-01-25T12:39:28.337Z",
    "expiryDate": "2022-01-25T12:39:28.337Z",
    "country": "IN",
    "userCountry": "IN",
    "utmParameters": {
      "utm_source": "website",
      "utm_medium": "facebook"
    },
    "updatedAt": "2022-01-27T08:55:38.786Z",
    "__v": 0
  }
}

This endpoint allows the Client to migrate a user's subscription to ConsCent, including the details of the user, subscription and the purchase on their platform - with the userPhoneNumber, userEmail, userName, clientUserId, expiryDate, purchaseDate. utmParameters, userAddress (address, city, state, postcode), country, and other client specific subscriptionDetails - title, priceDetails (price & currency), subscriptionType (digital & physical), and internalSubscriptionId. It is required to pass either the 'userPrimaryEmail' or the 'userPrimaryPhone' - as the primary login of the user on ConsCent.

HTTP Request

POST {API_URL}/api/v1/subscription/migrate

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Request Body

Parameter Default Description
userPrimaryEmail optional The email of the user for whom the purchased subscription is being migrated (used as primary login method)
userPrimaryPhone optional The phone number of the user for whom the purchased subscription is being migrated provided. (used as primary login method is no primary email is provided)
userSecondaryEmail optional The alternate email of the user for whom the purchased subscription is being migrated (not used for login and provided in webhooks/data exports for the client)
userSecondaryPhone optional The phone number of the user for whom the purchased subscription is being migrated provided. (not used for login and provided in webhooks/data exports for the client)
expiryDate required Array of ContentIds - The date on which the migrated subscription will expire for the user (must be an ISO Date String)
purchaseDate required The Date on which the user purchased the subscription on the client's platform (must be an ISO Date String)
country required The country of the user that purchased the subscription (must be an ISO Alpha-2 code from the list provided below)
userName optional The name of the user for whom the purchased subscription is being migrated
clientUserId optional The userID of the associated user in the client's platform - will be returned in relevant webhooks to the client for matching the details/purchases of the user accurately;
userAddress optional REQUIRED for a physical subscription - address of the user for whom the purchased subscription is being migrated - must be passed as an object containing the fields - address, city, state, postcode.
subscriptionDetails required Details of the subscription being migrated. Must be passed as an object containing the fields - title, priceDetails: {price: number, currency: string}, subscriptionType: {physical: boolean, digital: boolean}, internalSubscriptionId - where the subscriptionType is a required field, and must be passed; while all other fields are optional.
utmParameters optional The UTM parameters associated with the subscription being migrated. Must be passed as an object containing the fields - utm_source & utm_source - both of which are optional

Webhooks

1. Sign Up Webhook

You can register your webhook endpoint for receiving ConsCent user data by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user data anytime the user logins in for the first time on the client's website or application via ConsCent.

{
  "userName": "9818329028",
  "userId": "7843y9xm44428xm24x2m0x2xm42",
  "freeTrial": true,
  "phoneNumber": "9818329028",
  "email": "test-email@webhook.com",
  "country": "IN",
  "hashedPhoneNumber": "7942mey829mxe1238z2ym9zy39my29zy2z9dy24793msy29z2z",
  "hashedEmail": "8392mx30mx2mu8034x02mx802ry2480nyd249yx420xfn20w4y04xm2024",
  "name": "Test Name",
  "city": "London",
  "location": {
    "latitude": 8359893,
    "longitude": 7438734,
    "postcode": 221993
  },
  "os": "Mac OS 10.16",
  "browser": "Chrome",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36",
  "address": {
    "apartment": "7923492 Apartment1",
    "area": "Test Area",
    "pincode": "389023",
    "landmark": "test landmark",
    "city": "New York City",
    "state": "New York",
    "country": "US"
  },
  "clientTierId": "TestTierID1",
  "clientSpecificUserId": "11003289298"
}

Description

This event occurs when the user logs in to the platform very first time.

The webhook returns a JSON in the request body - structured like this:

Security

You will either get the user's email or phoneNumber field and accordingly only one of hashedPhoneNumber or hashedEmail. This hash is generated by using jwt.sign and passing the api secret as the secret. Learn more about jwt here. You can verify this by using jwt.verify for security purposes.

Alternately, you can check the authorization headers. Every request to the webhook uses Basic authorization with the api key as the username and the api secret as the password.

-Do note that you will receive either the phoneNumber or the email depending on what the user chooses to log in with.

2. Login Webhook

{
  "userName": "9818329028",
  "phoneNumber": "9818329028",
  "email": "test-email@webhook.com",
  "userId": "7843y9xm44428xm24x2m0x2xm42",
  "freeTrial": true,
  "country": "IN",
  "hashedPhoneNumber": "7942mey829mxe1238z2ym9zy39my29zy2z9dy24793msy29z2z",
  "hashedEmail": "8392mx30mx2mu8034x02mx802ry2480nyd249yx420xfn20w4y04xm2024",
  "name": "Test Name",
  "city": "London",
  "location": {
    "latitude": 8359893,
    "longitude": 7438734,
    "postcode": 221993
  },
  "os": "Mac OS 10.16",
  "browser": "Chrome",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36",
  "address": {
    "apartment": "7923492 Apartment1",
    "area": "Test Area",
    "pincode": "389023",
    "landmark": "test landmark",
    "city": "New York City",
    "state": "New York",
    "country": "US"
  },
  "clientTierId": "TestTierID1",
  "clientSpecificUserId": "11003289298"
}

You can register your webhook endpoint for receiving ConsCent user data by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user data (name, email, phone number, hashed email & phone number, city, location, address & country of the user) anytime the user logins in on the client's website or application via ConsCent.

Description

This event occurs when the user logs in to the platform everytime.

Security

You will either get the user's email or phoneNumber field and accordingly only one of hashedPhoneNumber or hashedEmail. This hash is generated by using jwt.sign and passing the api secret as the secret. Learn more about jwt here. You can verify this by using jwt.verify for security purposes.

Alternately, you can check the authorization headers. Every request to the webhook uses Basic authorization with the api key as the username and the api secret as the password.

Your api key / api secret is visible in the SDK part of the Integration section of the client dashboard

The webhook returns a JSON in the request body - structured like this:

3. Subscription Payment Webhook

{
  "_id": "61b9cf42f5d1f54797aaf14f",
  "userId": "7843y9xm44428xm24x2m0x2xm42",
  "purchaseId": "4932228982489248928208024",
  "manuallyRenewed": false,
  "renewSubscription": true,
  "renewalId": "61efb40a672c7f15840e803c",
  "renewalDetails": {
    "price": 300,
    "currency": "INR"
  },
  "availedOffers": [],
  "promotional": false,
  "tags": [],
  "bundle": false,
  "bundleContentIds": [],
  "paymentType": ["NETWORK"],
  "freeTrial": false,
  "migrated": false,
  "userAccount": "61b9cefbf5d1f54797aaf149",
  "clientId": "601a8ea4f2149f089782814f",
  "buyingPrice": 289.5,
  "price": 300,
  "country": "IN",
  "city": "bengaluru (nagashettyhalli)",
  "location": {
    "latitude": 13.0411,
    "longitude": 77.5702,
    "postcode": "560056"
  },
  "userCountry": "IN",
  "expiryDate": "2022-05-15T11:19:30.897Z",
  "priceDetails": {
    "price": 300,
    "currency": "INR"
  },
  "type": "SUBSCRIPTION",
  "subscriptionTitle": "Subscription 5",
  "device": "desktop",
  "subscriptionType": {
    "physical": false,
    "digital": true
  },
  "subscriptionId": "616ffd76621d69c5ee43c044",
  "tierId": "616ffd76621d69c5ee43c045",
  "createdAt": "2021-12-15T11:19:30.914Z",
  "updatedAt": "2021-12-15T11:19:30.914Z",
  "userEmail": "test@email.com",
  "userPhoneNumber": "9999999999",
  "userName": "john doe",
  "clientSpecificUserId": "11003289298",
  "chosenTier": {
    "clientTierId": "Test Tier ID",
    "_id": "616ffd76621d69c5ee437485",
    "price": 300,
    "duration": 5,
    "priceOverrides": {
      "country": []
    },
    "currency": "INR",
    "basePrice": 0,
    "offers": []
  },
  "gstComponents": {
    "physical": 0,
    "digital": 0
  },
  "inrGstComponents": {
    "physical": 0,
    "digital": 0
  },
  "userAddress": {
    "apartment": "17973 Octane Drive",
    "area": "Sun Valley",
    "pincode": "90210",
    "landmark": "",
    "city": "Los Angeles",
    "state": "California",
    "country": "US"
  },
  "renewedSubscriptionDetails": {
    "renewalCount": 1,
    "rzpSubscriptionId": "sub_Inua2HuuV2lxLG",
    "nextRenewalDate": "2022-06-25T08:38:18.369Z",
    "autoRenew": "ACTIVE",
    "price": 300,
    "currency": "INR"
  }
}

You can register your webhook endpoint for receiving ConsCent purchased subscription data by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's purchased subscription data anytime the user purchases a subscription on the client's platform or application via ConsCent. Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Description

This event occurs whenever the user buys any subscription.

The webhook returns a JSON in the request body - structured like this:

4. Subscription Cancelled Webhook

{
  "cancelledSubscriptionDetails": {
    "renewalCount": 0,
    "rzpSubscriptionId": "sub_InvqpVxG0vu7n8",
    "status": "CANCELLED",
    "price": 300,
    "currency": "INR"
  },
  "userEmail": "admin1@seed.com",
  "userPhoneNumber": "9869779647",
  "userId": "7843y9xm44428xm24x2m0x2xm42",
  "userName": "john doe",
  "userAddress": {
    "apartment": "",
    "area": "",
    "pincode": "",
    "landmark": "",
    "city": "",
    "state": "",
    "country": ""
  },
  "clientSpecificUserId": "11003289298",
  "subscriptionDetails": {
    "freeTrial": {
      "enabled": true,
      "duration": 14
    },
    "recommended": false,
    "benefits": "benefit ewiowe, benefit 2",
    "physical": false,
    "digital": true,
    "enabled": true,
    "migrated": false,
    "couponsEnabled": true,
    "adminCoupon": "",
    "usedCouponNumbers": [1],
    "_id": "616ffd76621d69c5ee43c044",
    "clientId": "601a8ea4f2149f089782814f",
    "title": "Subscription 5",
    "iconUrl": "https://conscent-subscriptions.s3.ap-south-1.amazonaws.com/local/Samakshs-MacBook-Pro-2.local/Screenshot%202021-07-22%20at%209.05.01%20PM.png",
    "tiers": [
      {
        "priceOverrides": {
          "country": []
        },
        "currency": "INR",
        "basePrice": 0,
        "offers": [],
        "_id": "616ffd76621d69c5ee43c045",
        "price": 300,
        "duration": 5
      }
    ],
    "couponCount": 5,
    "createdAt": "2021-10-20T11:28:54.143Z",
    "updatedAt": "2022-01-19T06:45:18.634Z",
    "__v": 5
  },
  "lastPurchaseDetails": {
    "location": {
      "latitude": 13.0411,
      "longitude": 77.5702,
      "postcode": "560056"
    },
    "gstComponents": {
      "physical": 0,
      "digital": 0
    },
    "inrGstComponents": {
      "physical": 0,
      "digital": 0
    },
    "manuallyRenewed": false,
    "renewSubscription": true,
    "availedOffers": [],
    "promotional": false,
    "tags": [],
    "bundle": false,
    "bundleContentIds": [],
    "paymentType": ["REPEAT", "NETWORK"],
    "freeTrial": false,
    "migrated": false,
    "clientId": "601a8ea4f2149f089782814f",
    "buyingPrice": 289.5,
    "price": 300,
    "country": "IN",
    "city": "bengaluru (nagashettyhalli)",
    "userCountry": "IN",
    "expiryDate": "2023-04-25T09:52:52.814Z",
    "priceDetails": {
      "price": 300,
      "currency": "INR"
    },
    "type": "SUBSCRIPTION",
    "subscriptionTitle": "Subscription 5",
    "operatingSystem": "Mac OS",
    "device": "desktop",
    "subscriptionType": {
      "physical": false,
      "digital": true
    },
    "subscriptionId": "616ffd76621d69c5ee43c044",
    "tierId": "616ffd76621d69c5ee43c045",
    "renewalId": "61efc865acb0d82962e2ad14",
    "renewalDetails": {
      "price": 300,
      "currency": "INR"
    }
  }
}

You can register your webhook endpoint for receiving data whenever a user cancels their subscription via ConsCent - by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's cancelled subscription data, along with the details of the subscription and the last purchase/renewal of the user for the particular subscription - anytime the user cancels a client's subscription via ConsCent. Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Description

This event occurs whenever the user cancels the auto renew enabled subscription from ConsCent Dashboard.

The webhook returns a JSON in the request body - structured like this:

5. Pass Payment Webhook

{
  "gstComponents": {
    "physical": 0,
    "digital": 0
  },
  "inrGstComponents": {
    "physical": 0,
    "digital": 0
  },
  "manuallyRenewed": false,
  "renewSubscription": false,
  "availedOffers": [],
  "promotional": false,
  "categories": [],
  "bundle": false,
  "bundleContentIds": [],
  "paymentType": [
    "NEW"
  ],
  "freeTrial": false,
  "migrated": false,
  "_id": "628b76941ed3d9c772be2626",
  "userAccount": "628b765e16d01ac4721e1676",
  "clientId": "5f92a62013332e0f667794dc",
  "clientContentId": "Client-Story-Id-1",
  "contentId": "628b6c2cbf5053737a28a63a",
  "buyingPrice": 80,
  "price": 100,
  "country": "IN",
  "city": "bengaluru (nagashettyhalli)",
  "location": {
    "latitude": 13.0411,
    "longitude": 77.5702,
    "postcode": "560056"
  },
  "userCountry": "IN",
  "expiryDate": "2022-05-23T18:57:07.989Z",
  "passTitle": "qwe",
  "priceDetails": {
    "price": 100,
    "currency": "INR"
  },
  "type": "PASS",
  "operatingSystem": "Mac OS",
  "device": "desktop",
  "createdAt": "2022-05-23T11:57:08.061Z",
  "updatedAt": "2022-05-23T11:57:08.061Z",
  "__v": 0,
  "userId": "628b765e16d01ac4721e1676",
  "userPhoneNumber": "9276278392",
  "userName": "",
  "userAddress": {
    "apartment": "",
    "area": "",
    "pincode": "",
    "landmark": "",
    "city": "",
    "state": "",
    "country": ""
  }
}

You can register your webhook endpoint for receiving data whenever a user pays for their pass via ConsCent - by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's pass payment data, along with the details of the pass and the last purchase/renewal of the user for the particular pass - anytime the user purchases a client's pass via ConsCent. Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Descrption:

This event occurs when the user buys the Pass.

The webhook returns a JSON in the request body - structured like this:

6. Subscription Bundle Payment Webhook

{
  "purchaseId": "62d02f1bf3299d7b21d4a235",
  "userId": "623b1204ff6e065272e3530b",
  "userEmail": "asd@asd.com",
  "userPhoneNumber": "9876543211",
  "userName": "asdasdasd",
  "userAddress": {
    "state": "SIKKIM",
    "city": "asdsa",
    "area": "asdasdasdas",
    "pincode": "110089"
  },
  "userGender": "MALE",
  "userEmploymentType": "FULL_TIME",
  "utmParameters": {
    "utm_source": "KJ007",
    "utm_medium": "medium",
    "utm_name": "name"
  },
  "bundleBuyingPrice": 332,
  "bundlePrice": 369,
  "bundlePriceDetails": { "price": 369, "currency": "INR" },
  "subscriptionsDetail": [
    {
      "title": "Digital",
      "duration": 1,
      "currencySymbol": "₹",
      "buyingPrice": 90.00,
      "price": "100.00",
      "clientName": "Test Client TSB media venture a",
      "currency": "INR"
    },
    {
      "title": "Digital",
      "duration": 19,
      "currencySymbol": "₹",
      "buyingPrice": 242.10,
      "price": "269.00",
      "clientName": "Test client b",
      "currency": "INR"
    }
  ]
}

You can register your webhook endpoint for receiving data whenever a user pays for their subscription bundle via ConsCent - by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's subscription bundle payment data, along with the details of the bundle - anytime the user purchases a client's subscription bundle via ConsCent. Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Description

This event occurs when the user buys bundle subscription.

The webhook returns a JSON in the request body - structured like this:

7. Review Subscription Webhook

{
   "phoneNumber": "9847598673",
  "userId": "6345116cb9beaf3033c065cc",
  "country": "IN",
  "hashedPhoneNumber": "eyJhbGciOiJIUzI1NiJ9.OTg0NzU5ODY3Mw.7tvT8abeu_sGEWSfKdgYRRo7oZ65qBwatyFIF1VOhGY",
  "address": {
    "apartment": "",
    "area": "",
    "pincode": "",
    "landmark": "",
    "city": "",
    "state": "",
    "country": ""
  },
  "name": "",
  "city": "defence colony",
  "location": {
    "latitude": 28.5714,
    "longitude": 77.2327
  },
  "browser": "Chrome",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
  "os": "Mac OS",
  "username": "9847598673",
  "subscriptionDetails": {
    "subscriptionId": "61e951161a563d0729652d21",
    "tierId": "61e951161a563d0729652d23",
    "title": "AD Free",
    "price": 600,
    "currency": "INR"
  }
}

You can register your webhook endpoint for receiving ConsCent review subscription data i.e.(dropoff users) by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's review subscription data, anytime the user makes the payment for buying a subscription and comes to the review page on the client's platform or application via ConsCent.The review subscription webhook lets us keep the records of drop off users.Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Description

This event occurs just before the user confirms the payment for buying a subscription on the review page.

The webhook returns a JSON in the request body - structured like this:

8. Micro Payment Webhook

{
  "gstComponents": {
    "physical": 0,
    "digital": 0
  },
  "inrGstComponents": {
    "physical": 0,
    "digital": 0
  },
  "contentType": {
    "digital": true,
    "adFree": false
  },
  "categories": [],
  "bundle": false,
  "bundleContentIds": [],
  "paymentType": [
    "REPEAT"
  ],
  "migrated": false,
  "_id": "6437ade44c60bc0552ad3477",
  "userAccount": "642ed4902107e35b19bf29fa",
  "clientId": "5f92a62013332e0f667794dc",
  "paywallId": "6435427bb0658c70abe7d18d",
  "clientContentId": "Client-Story-Id-4",
  "contentId": "61fa72efb76afa4ce17fde95",
  "buyingPrice": 79.2,
  "price": 99,
  "country": "IN",
  "city": "deoli",
  "location": {
    "latitude": 28.5025,
    "longitude": 77.2312
  },
  "userCountry": "IN",
  "expiryDate": "2023-04-20T07:23:16.810Z",
  "priceDetails": {
    "price": 99,
    "currency": "INR"
  },
  "type": "CONTENT",
  "operatingSystem": "Mac OS",
  "device": "desktop",
  "createdAt": "2023-04-13T07:23:16.829Z",
  "updatedAt": "2023-04-13T07:23:16.829Z",
  "__v": 0,
  "userId": "642ed4902107e35b19bf29fa",
  "userPhoneNumber": "9488298324",
  "userName": "",
  "userAddress": {
    "apartment": "",
    "area": "",
    "pincode": "",
    "landmark": "",
    "city": "",
    "state": "",
    "country": ""
  }
}

You can register your webhook endpoint for receiving ConsCent purchased content data by logging in to your ConsCent Client Dashboard and navigating to the Webhook Page. You will be able to enable/disable and edit your webhook url from this section. Once the webhook URL is registered and the webhook is in the enabled state - the endpoint will recieve user's purchased content data anytime the user purchases any content on the client's platform or application via ConsCent. Moreover, the webhook is secured by basic auth using the Clients API Key and API Secret provided by ConsCent on the SDK Integration section of the client dashboard - ConsCent Client Integration. You can optionally choose to keep the endpoint as protected and authenticate using the provided credentials which are passed in the headers of the POST request to the configured webhook endpoint.

Description

This event occurs when the user makes the payment for per article/content.

The webhook returns a JSON in the request body - structured like this:

API

User Details and Subscriptions Information

Content Examples:

{
    "userdetails": {
        "name": "AKHIL",
        "email": "testmail51@gmail.com",
        "secondaryPhoneNumber": "9832748888",
        "secondaryEmail": "",
        "dateOfBirth": "1999-01-01T09:50:21.951Z",
        "address": {
            "apartment": "ouy",
            "area": "029384kdsjf",
            "pincode": "530009",
            "landmark": "fj",
            "city": "8732489",
            "state": "",
            "country": "IN"
        },
        "country": "IN",
        "promotionalOptIn": true,
        "lastPurchasedOn": "2022-03-08T11:37:31.667Z",
        "wallet": {
            "balance": {
                "$numberDecimal": "50.00"
            },
            "currency": "INR"
        }
    },
    "userSubscriptions": [
        {
            "_id": "62273ffbd5c69afcd7c05349",
            "client": "Outlook",
            "price": 1000,
            "purchasedOn": "2022-03-08T11:37:31.537Z",
            "subscriptionTitle": "Subscription test physical",
            "expiryDate": "2022-04-08T11:37:31.518Z",
            "subscriptionType": {
                "physical": true,
                "digital": false
            },
            "benefits": "Easy access to contents",
            "logoUrl": "https://conscent-public.s3.ap-south-1.amazonaws.com/stage/Outlook/banners/Outlook%20-%20brandLogo",
            "rzpSubscriptionId": "sub_J4a4NYpUc0qDMU",
            "status": "ACTIVE",
            "freeTrial": false,
            "tierId": "61a49984fabe8d7705a2cabd",
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            },
            "subscriptionDurationInMonths": 1,
            "subscriptionPriceInInr": 1000,
            "allowCancellation": true,
            "cancellationUrl": "http://localhost:3000/consumption?subscription=62273ffbd5c69afcd7c05349",
            "allowRenewal": false,
            "renewalUrl": ""
        }
    ]
}

Get the user Details and subscriptions

HTTP Request

GET {API_URL}/user/user-and-subscription-details

Auth required : NO

Mandatory query Parameters

clientId: Pass clientId

userId: Pass conscent's user Id to get the user details

Success Response Code : 200 OK

Purchased Subscriptions

Content Examples:

{
  "purchases": [
    {
      "manuallyRenewed": false,
      "renewSubscription": false,
      "availedOffers": ["617ba48ec3b5066393988f22"],
      "promotional": false,
      "categories": [],
      "freeTrial": false,
      "migrated": false,
      "clientId": "5f92a62013332e0f667794dc",
      "clientContentId": "Client Story Id 1",
      "contentId": "5fbe46efbee15f1cebc81515",
      "buyingPrice": 100.36,
      "price": 104,
      "priceDetails": {
        "price": 104,
        "currency": "INR"
      },
      "subscriptionDetails": {
        "inrPrice": 104,
        "duration": 1
      },
      "expiryDate": "2022-03-28T12:49:02.844Z",
      "subscriptionId": "61a49855fabe8d7705a2cab4",
      "tierId": "61a49855fabe8d7705a2cab6",
      "createdAt": "2022-03-03T09:13:53.266Z",
      "userId": "613720ec6a14e1100bdfb9f5",
      "userEmail": "asdf@sdf.co",
      "userPhoneNumber": "129347792",
      "userName": "asdf",
      "userAddress": {
        "apartment": "",
        "area": "",
        "pincode": "",
        "landmark": "",
        "city": "",
        "state": "",
        "country": ""
      },
      "clientSpecificUserId": "234234612"
    },
    {
      "manuallyRenewed": false,
      "renewSubscription": false,
      "availedOffers": [],
      "promotional": false,
      "categories": [],
      "freeTrial": false,
      "migrated": false,
      "clientId": "5f92a62013332e0f667794dc",
      "clientContentId": "Client Story Id 1",
      "contentId": "5fbe46efbee15f1cebc81515",
      "buyingPrice": 193.97,
      "price": 201,
      "priceDetails": {
        "price": 201,
        "currency": "INR"
      },
      "subscriptionDetails": {
        "inrPrice": 201,
        "duration": 2
      },
      "expiryDate": "2022-04-25T08:00:12.714Z",
      "subscriptionId": "617a718d04ab353a12d84d30",
      "tierId": "6180db518634ae0b03c136b5",
      "userId": "5fca03a52185f150382ff144",
      "userEmail": "test+stagetest@test.com",
      "userPhoneNumber": "9999999999",
      "userName": "test name",
      "userAddress": {
        "apartment": "India",
        "area": "India",
        "pincode": "123423",
        "landmark": "India",
        "city": "test",
        "state": "ANDHRA PRADESH",
        "country": "IN"
      },
      "clientSpecificUserId": "234234612"
    }
  ],
  "paginationInfo": {
    "pageNumber": 1,
    "pageSize": 2,
    "recordsReturned": 2
  }
}

Get the details of previously purchased subscriptions

HTTP Request

GET {API_URL}/client/purchases/subscriptions

Auth required : YES

Please pass your api key as username and api secret as password as basic auth to access the endpoint

Mandatory query Parameters

userId: Pass conscent's user Id to filter purchases for one particular user

pageSize: Max Number of records returned per page - defaults to 500. Max possible value is 2000

pageNumber: The page number

Success Response Code : 200 OK

from: ISODateString, to filter via a starting datetime

to: ISODateString, to filter via an ending datetime

User and Purchase Details

Content Examples:

{
    "userdetails": {
        "name": "Pushpankar",
        "phoneNumber": "9936225088",
        "secondaryEmail": "skdfjn@jnadf.com",
        "address": {
            "apartment": "Flat",
            "area": "Area",
            "pincode": "Zip",
            "landmark": "",
            "city": "City",
            "state": "ANDAMAN & NICOBAR ISLANDS",
            "country": "IN"
        },
        "country": "IN",
        "promotionalOptIn": true,
        "lastPurchasedOn": "2023-04-17T14:01:00.411Z",
        "wallet": {
            "balance": {
                "$numberDecimal": "0.00"
            },
            "currency": "INR"
        }
    },
    "userSubscriptions": [
        {
            "_id": "63b2b8b938dcac1e9a1d55c6",
            "client": "Demo Client",
            "price": 400,
            "gst": 61.01711999999999,
            "purchasedOn": "2023-01-02T10:58:01.603Z",
            "subscriptionTitle": "Digital",
            "expiryDate": "2023-02-02T10:58:01.600Z",
            "subscriptionType": {
                "physical": false,
                "digital": true,
                "adFree": false
            },
            "benefits": "It's very good,Very Helpful,Good to read,Good content,50% OFF, 100% OFF",
            "logoUrl": "https://conscent-public.s3.ap-south-1.amazonaws.com/Static+Assets/Outlook-Logo.png\n",
            "freeTrial": false,
            "tierId": "6347b644bff071350cfd0f55",
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            },
            "subscriptionDurationInMonths": 1,
            "subscriptionPriceInInr": 400,
            "allowCancellation": false,
            "cancellationUrl": "",
            "allowRenewal": true,
            "renewalUrl": "https://dashboards.tsbdev.co/dashboard/consumption?subscription=63b2b8b938dcac1e9a1d55c6"
        },
        {
            "_id": "637f9be1837ec364a7fa1683",
            "client": "Demo Client",
            "price": 49,
            "gst": 7.4745972,
            "purchasedOn": "2022-11-24T16:29:21.159Z",
            "subscriptionTitle": "AD Free-Lite",
            "expiryDate": "2022-12-24T16:29:21.153Z",
            "subscriptionType": {
                "physical": false,
                "digital": false,
                "adFree": true
            },
            "benefits": "Ad-free experience, Digital Access, Premium Content",
            "logoUrl": "https://conscent-public.s3.ap-south-1.amazonaws.com/Static+Assets/Outlook-Logo.png\n",
            "freeTrial": false,
            "tierId": "61e951161a563d0729652d23",
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            },
            "subscriptionDurationInMonths": 1,
            "subscriptionPriceInInr": 49,
            "allowCancellation": false,
            "cancellationUrl": "",
            "allowRenewal": true,
            "renewalUrl": "https://dashboards.tsbdev.co/dashboard/consumption?subscription=637f9be1837ec364a7fa1683"
        }
    ],
    "passes": [
        {
            "_id": "637c710d7153ef201cd8be8f",
            "client": "Demo Client",
            "price": 78,
            "gst": 11.898338399999998,
            "purchasedOn": "2022-11-22T06:49:49.989Z",
            "expiryDate": "2022-11-22T13:49:49.968Z",
            "freeTrial": false,
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            }
        }
    ],
    "payPerUses": [
        {
            "_id": "643d511c0dfb996ad37a0f1c",
            "client": "Demo Client",
            "price": 10,
            "gst": 1.525428,
            "purchasedOn": "2023-04-17T14:01:00.377Z",
            "expiryDate": "2023-04-24T14:01:00.350Z",
            "freeTrial": false,
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            }
        },
        {
            "_id": "642bbb2b5a3e9b1441cbb058",
            "client": "Demo Client",
            "price": 9999,
            "gst": 1525.2754572,
            "purchasedOn": "2023-04-04T05:52:43.823Z",
            "expiryDate": "2023-04-06T05:52:43.810Z",
            "freeTrial": false,
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            }
        },
        {
            "_id": "64103ec1644c430727a2b654",
            "client": "Demo Client",
            "price": 10,
            "gst": 1.525428,
            "purchasedOn": "2023-03-14T09:30:41.364Z",
            "expiryDate": "2023-03-16T09:30:41.345Z",
            "freeTrial": false,
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            }
        },
        {
            "_id": "637f9b78837ec364a7fa151c",
            "client": "Demo Client",
            "price": 16,
            "gst": 2.4406848,
            "purchasedOn": "2022-11-24T16:27:36.304Z",
            "expiryDate": "2022-11-26T16:27:36.294Z",
            "freeTrial": false,
            "clientId": "5f92a62013332e0f667794dc",
            "gstComponents": {
                "physical": 0,
                "digital": 0
            }
        }
    ]
}

Get the user Details and subscriptions

HTTP Request

GET {API_URL}/user/user-and-purchase-details

Auth required : NO

Mandatory query Parameters

clientId: Pass clientId

userId: Pass conscent's user Id to get the user details

email: Pass the email

phoneNumber: Pass the phoneNumber

Success Response Code : 200 OK

pageSize: Max Number of records returned per page - defaults to 500. Max possible value is 2000

pageNumber: The page number

from: ISODateString, to filter via a starting datetime

to: ISODateString, to filter via an ending datetime

Client Purchases

Content Examples:

{
    "transactionDetails": [
        {
            "promotional": false,
            "_id": "643e49dc2309ab30bc00ccf2",
            "userAccount": {
                "phoneNumber": "8712334265",
                "email": "bnnnn@gmail.com"
            },
            "clientId": {
                "name": "Demo Client"
            },
            "contentId": {
                "title": "Client-Story Id 1",
                "url": "https://csc-mock.netlify.app/5f92a62013332e0f667794dc/Client-Story-Id-1"
            },
            "buyingPrice": 319.21,
            "price": 399,
            "type": "PASS",
            "createdAt": "2023-04-18T07:42:20.749Z"
        }
    ],
    "pagination": {
        "pageNumber": 1,
        "pageSize": 10,
        "totalRecords": 1,
        "totalPages": 1
    }
}

Get the details of the purchases

HTTP Request

GET {API_URL}/client/purchases

Auth required : YES

Please pass your api key as username and api secret as password as basic auth to access the endpoint

Mandatory query Parameters

userId: Pass conscent's user Id to filter purchases for one particular user

email: Pass the email

phoneNumber: Pass the phoneNumber

pageSize: Max Number of records returned per page - defaults to 500. Max possible value is 2000

pageNumber: The page number

Success Response Code : 200 OK

from: ISODateString, to filter via a starting datetime

to: ISODateString, to filter via an ending datetime

Client Passes

Content Examples:


{
    "purchases": [
        {
            "availedOffers": [],
            "promotional": false,
            "categories": [],
            "freeTrial": false,
            "migrated": false,
            "clientId": "5f92a62013332e0f667794dc",
            "clientContentId": "Client-Story-Id-1",
            "contentId": "61fba4adcbcaaf727a00168d",
            "buyingPrice": 319.21,
            "price": 399,
            "priceDetails": {
                "price": 399,
                "currency": "INR"
            },
            "expiryDate": "2023-04-18T14:42:20.741Z",
            "createdAt": "2023-04-18T07:42:20.749Z",
            "userId": "6346608680c2216fe33d84fa",
            "userEmail": "bnnnn@gmail.com",
            "userPhoneNumber": "8243334265",
            "userName": "Kajal",
            "userAddress": {
                "apartment": "ggghhh",
                "area": "kkkkkhhh",
                "pincode": "922111",
                "landmark": "sasshhh",
                "city": "jjjjjhhh",
                "state": "ffffffhhh",
                "country": "iiiiihhh"
            }
        }
    ],
    "paginationInfo": {
        "pageNumber": 1,
        "pageSize": 2,
        "recordsReturned": 1
    }
}

Get the details of the passes

HTTP Request

GET {API_URL}/client/purchases/passes

Auth required : YES

Please pass your api key as username and api secret as password as basic auth to access the endpoint

Mandatory query Parameters

userId: Pass conscent's user Id to filter purchases for one particular user

email: Pass the email

phoneNumber: Pass the phoneNumber

pageSize: Max Number of records returned per page - defaults to 500. Max possible value is 2000

pageNumber: The page number

Success Response Code : 200 OK

from: ISODateString, to filter via a starting datetime

to: ISODateString, to filter via an ending datetime

Client Micropayments

Content Examples:

{
    "purchases": [
        {
            "availedOffers": [],
            "promotional": false,
            "categories": [],
            "freeTrial": false,
            "migrated": false,
            "clientId": "5f92a62013332e0f667794dc",
            "clientContentId": "Client-Story-Id-1",
            "contentId": "61fba4adcbcaaf727a00168d",
            "buyingPrice": 8,
            "price": 10,
            "priceDetails": {
                "price": 10,
                "currency": "INR"
            },
            "expiryDate": "2023-04-15T10:22:57.494Z",
            "createdAt": "2023-04-13T10:22:57.507Z",
            "userId": "6346608680c2216fe33d84fa",
            "userEmail": "bnnnn@gmail.com",
            "userPhoneNumber": "8750314176",
            "userName": "Kajal",
            "userAddress": {
                "apartment": "ggghhh",
                "area": "kkkkkhhh",
                "pincode": "922111",
                "landmark": "sasshhh",
                "city": "jjjjjhhh",
                "state": "ffffffhhh",
                "country": "iiiiihhh"
            }
        },
        {
            "availedOffers": [],
            "promotional": false,
            "categories": [],
            "freeTrial": false,
            "migrated": false,
            "clientId": "5f92a62013332e0f667794dc",
            "clientContentId": "Client-Story-Id-3",
            "contentId": "620b94557bef8873d93bf32b",
            "buyingPrice": 8,
            "price": 10,
            "priceDetails": {
                "price": 10,
                "currency": "INR"
            },
            "expiryDate": "2023-03-26T06:58:54.416Z",
            "createdAt": "2023-03-16T06:58:54.434Z",
            "userId": "6346608680c2216fe33d84fa",
            "userEmail": "bnnnn@gmail.com",
            "userPhoneNumber": "8750334265",
            "userName": "Kajal",
            "userAddress": {
                "apartment": "ggghhh",
                "area": "kkkkkhhh",
                "pincode": "922111",
                "landmark": "sasshhh",
                "city": "jjjjjhhh",
                "state": "ffffffhhh",
                "country": "iiiiihhh"
            }
        },
        {
            "availedOffers": [],
            "promotional": false,
            "categories": [],
            "freeTrial": false,
            "migrated": false,
            "clientId": "5f92a62013332e0f667794dc",
            "clientContentId": "Client-Story-Id-1",
            "contentId": "61fba4adcbcaaf727a00168d",
            "buyingPrice": 16,
            "price": 20,
            "priceDetails": {
                "price": 20,
                "currency": "INR"
            },
            "expiryDate": "2023-02-11T07:39:49.821Z",
            "createdAt": "2023-02-09T07:39:49.856Z",
            "userId": "6346608680c2216fe33d84fa",
            "userEmail": "bnnnn@gmail.com",
            "userPhoneNumber": "8750334265",
            "userName": "Kajal",
            "userAddress": {
                "apartment": "ggghhh",
                "area": "kkkkkhhh",
                "pincode": "922111",
                "landmark": "sasshhh",
                "city": "jjjjjhhh",
                "state": "ffffffhhh",
                "country": "iiiiihhh"
            }
        }
    ],
    "paginationInfo": {
        "pageNumber": 1,
        "pageSize": 3,
        "recordsReturned": 3
    }
}

Get the details of the micro-payments

HTTP Request

GET {API_URL}/client/purchases/micropayments

Auth required : YES

Please pass your api key as username and api secret as password as basic auth to access the endpoint

Mandatory query Parameters

userId: Pass conscent's user Id to filter purchases for one particular user

email: Pass the email

phoneNumber: Pass the phoneNumber

pageSize: Max Number of records returned per page - defaults to 500. Max possible value is 2000

pageNumber: The page number

Success Response Code : 200 OK

from: ISODateString, to filter via a starting datetime

to: ISODateString, to filter via an ending datetime

Cancel Active Subscriptions

The client can cancel the active subscripptions for a user

HTTP Request

POST {API_URL}/client/cancel-subscriptions/{userId}

Please pass the ConsCent user id of the user whose subscriptions you wish to cancel

Auth required : YES

Please pass your api key as username and api secret as password as basic auth to access the endpoint

Success Response Code : 200 OK

Content examples

{ "message": "Subscriptions Cancelled Successfully" }

Login

const csc = window._csc as any;
    csc('conscent-login', {
      debug: true,
      clientId: clientId,
      defaultEmail: defaultEmail || '',
      defaultName: defaultName || '',
      defaultPhone: defaultPhone || '',
      wrappingElementId: 'embed',
      successCallback: async (userDetailsObject: any) => {
        console.log('Success callback received from conscent login', userDetailsObject);
        setUserDetails(userDetailsObject);
        props.setShowLoginModal(false)
      },
      onCrossBtnClickSuccess: async () => {
        console.log('cross btn click successfully');
        props.setShowLoginModal(false)
      },
      unauthorizedCallback: () => {
        console.log('unauthorized callback called');
      },
    });

Integrating ConsCent on your Website is a simple and direct process. The following steps explain how to create credentials for your project. Your applications can then use the credentials to access APIs that you have enabled for that project. You start by copying the code on the right hand side within the script tags - and adding it to the header section of your Route Index file. You can get your ConsCent Client Id from the Client Integration Page ​​of the ConsCent Client Dashboard - as mentioned in the Registration Section. Including this regular script in the header section allows the ConsCent Login to be initalised and further used whenever user requires to login. Finally, In order to ensure that the ConsCent Login appears on your site. You need to implement the 'csc_init' function on the content page - included on the right hand side of the ConsCent Login and enables a user to login through ConsCent on your website. Please ensure that you call this function anytime you want the ConsCent Login to show up on your content page. We import the initalisation script using the unique '_csc' identifier and run the 'csc_init' function by passing a number of parameters.

This script can be called anywhere as you already have the SDK script to your header section.

//call this method on login button click
const callLogoutBtn = () => {
    const csc = window._csc as any;
    csc('logout', {
      debug: true,
      clientId: clientId,
      wrappingElementId: 'logout',
      logoutCallback: async () => {
        console.log('yyy');
      },
      unauthorizedCallback: () => {
        console.log('unauthorized callback called');
      },
    });
  };

App Integration

Kotlin

ConsCent Plugin for developers

This is a step by step guide to include ConsCent Plugin in your app. This plugin is developed in Kotlin and supports both Java and Kotlin languages and supports Api 23 (Android 6.0) and above.

Step-1

Copy plugin's aar file to your libs folder and add it in your app level build gradle file.

Step-2

In your application build.gradle file, include dependency as below with latest versions:

Retrofit and GSON converter implementation 'com.squareup.retrofit2:retrofit:(insert latest version)' implementation 'com.squareup.retrofit2:converter-gson:(insert latest version)'

Coroutines implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:(insert latest version)' Example: implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'

Browser implementation 'androidx.browser:browser:(insert latest version)'

Let us know the version of your browser, kotlinx-coroutines-android

Note:

1. In case of error for Kotlin not enabled, please enable Kotlin for project.

2. In case of error in Manifest merging, please merge Manifest as per Android Studio support or include line tools:replace="android:icon,android:roundIcon" inside your application tag in Android Manifest file.

Step-3

In your application (recommended) or root activity class's onCreate, pass applicationContext, yourClientId, accentColor, Environment Mode and App Mode to be used in your app as below sample: ConscentWrapper.configure(yourApplicationContext, yourClientId, yourAccentColor, MODE, APP_MODE) Remember to set configuration before you call further callbacks.

  1. yourApplicationContext: Pass your application context here.
  2. yourClientId: Pass your clientId received from Conscent.
  3. yourAccentColor: Pass your accentColor for the app.
  4. Mode can be set as :
      • ConscentConfiguration.MODE.STAGE
      • ConscentConfiguration.MODE.SANDBOX
      • ConscentConfiguration.MODE.PRODUCTION

Mode is used for configuration testing of different environments available.

5.APP_MODE can be set as ConsCentConfiguration.APP_MODE.DEBUG ConsCentConfiguration.APP_MODE.PROD APP_MODE is basically used for checking debug and production environment of app. If APP_MODE is DEBUG , then all errors will be shown as Toast messages and Logs. If APP_MODE is PROD, only logs will be available for critical errors like Network unavailability, wrong client_id and wrong content_id.

You can later change your clientId also, by calling the following function:

ConscentWrapper.changeClientId(yourClientId), throws "Configure ConscentWrapper first!" if not configured already!

Step-4

Create an instance of the ConsCent class for each unique contentId (recommended) for more control over your content flow. Use the below described method:

Kotlin

val instance = ConscentWrapper.getConscentInstance( yourCallingActivity, yourParentView, yourContainerView, contentId, onConscentListener )

Java

Conscent instance = ConscentWrapper.Companion.getConscentInstance( yourCallingActivity, yourParentView, yourContainerView, contentId, onConscentListener );

All parameter details are given at the bottom.

Step-5

To check if an article/content is free/paid or a payment needs to be done, in your class, use as below sample: Parameters detail can be checked below for more information.

Kotlin

instance.checkContentAccess( yourContentTitle, yourSubsUrl, canSubscribe, showClose )

Java

instance.checkContentAccess( yourContentTitle, yourSubsUrl, canSubscribe, showClose );

To get all the subscription packages available, in your class, use as below sample: Parameters detail can be checked below for more information.

Kotlin

instance.checkSubscriptions( yourContentTitle, yourSubsUrl, showClose )

Java

instance.checkSubscriptions( yourContentTitle, yourSubsUrl, showClose );

Parameters detail

For eg:

<FrameLayout android:id="@+id/frame" android:layout_width="match_parent" android:layout_height="match_parent" />

Eg: Color.parseColor("#0087ca") or ContextCompat.getColor(context, color_from_colors.xml) like ContextCompat.getColor(this, R.color.red)

onSuccess: This is the success callback which will get called for every successful processing. You can pass your method as a reference or a lambda expression which will get called in case of success.

onError: This is optional. You can pass it as null. This is the failure callback which will get called for every failed processing. You can pass your method as a reference or a lambda expression and it'll get called for failed cases. You can implement your code in it for failed cases.

onSubscribe: This is optional callback. If you want to inflate subscribe layout, pass a subscribe function which will be called when subscribe button will be clicked inside the payment flow. Passing null will not inflate subscribe layout.

onBuyPass : This is optional callback. It will be called when buy-pass button will be clicked inside the payment flow.

onSignIn : This is the callback function which will be called when a user clicks on signIn button in payment flow. This will be only visible if subscribe layout has been inflated.

onAdFree: This is the callback function which will be called when a user clicks on adfree subscription.

Step-6

In you onActivityResult method, pass below line of code: instance.handledIntent()

Java

ConscentWrapper.Companion.INSTANCE?.logoutUser();

Flutter

ConsCent Plugin for developers

This is a step by step guide to include ConsCent Plugin in your app. This plugin is developed in Flutter and supports both Android and IOS Device.

Step-1

Use our plugin package as a library

Step-2

In your application pass client_id, Environment Mode to be used in your app as below sample:

ConscentInitializer("your_client_id", ENVIRONMENTMODE.SANDBOX);

  1. ClientId will be received when you would create a ConsCent account, login to client.conscent.in to get access to your clientid

  2. Mode can be set as ENVIRONMENTMODE.SANDBOX ENVIRONMENTMODE.PRODUCTION. It is used for configuration testing of different environments available.

ENVIRONMENTMODE is used for configuration testing of different environments available.

Step-3

To login into Conscent you need to pass token (token you get from api {{BASE_URL}}/client/generate-temp-token ) and email or phone number. You receive 2 arguments after login method

String redirectUrl = await ConscentMethods() .prepareAutoLoginUrl([(token),(phone),(email)]); Navigator.push( context, MaterialPageRoute( builder: (context) => WebViewDefaultApp( redirectUrl: redirectUrl) ), ).then((value) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('$value'), )); });

To logout from Conscent you need to call ConscentMethods().userLogOut()

TextButton.icon( onPressed: () async { String? logout = await ConscentMethods().userLogOut(); ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('${logout}'), )); }, icon: const Icon( Icons.logout, size: 24.0, ), label: const Text('Logout'), ),

Step-4

To check if an content is free/paid or a payment needs to be done, in your class, use as below sample: Parameters detail can be checked below for more information.

Payment Formats for User

Login to ConsCent from the Paywall, verify your credentials and then purchase access to premium content. There are three types of payments:

  1. CONTENT: Pay-per-use is a system in which users are charged only for the specific premium content they want access to.
  2. PASS: Gives access to user for all the premium content from 1hr to 14 days, which can be changed from ConsCent’s dashboard.
  3. SUBSCRIPTION: Gives user access to all the premium content starting from 1 month.

ConscentInitializer.setContentId('your_content_id');

bool showContent = false; FutureBuilder( future: ConscentMethods().getContentAccess(), builder: (context, snapshot){ if (snapshot.hasData) { var responseData = snapshot.data; showContent = responseData!; return Center( child: Stack( children: [ if (!showContent) Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, alignment: Alignment.bottomCenter, child: Paywall((response) { showContent = responseData; setState(() {}); })), ] ), ); }else if (snapshot.hasError) { return ShowYourErrorPage(); } }, ),

Parameters detail

Premium Content Registration

Whenever you're utilising the ConsCent APIs - you to update the API_URL variables based on the environment you're operating in.

This endpoint allows the Client to Register their Content on ConsCent - with the Content Title, ContentId, Content URL, Tags, Analytics Pixels (Facebook and Google), Price as well as any specific Price Overrides for a country - In order to set a different price for the content in the relevant country. Moreover, the ContentType field is optional - and if no 'contentType' is provided then the default 'contentType' of the client will be treated as the 'contentType' of the content being registered. While category based pricing can be used for any content, by passing the priceCategory field on registering the content - as long as the price category has been registered by the client on the ConsCent dashboard along with its respective price, duration and priceOverrides; however, category based pricing only comes into effect if the content does not have a pre-determined price field (price must be null).

HTTP Request

POST {API_URL}/api/v1/content

Authorization

Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

SWIFT (IOS)

ConsCent Plugin Integration Guide

This guide provides step-by-step instructions on how to include the ConsCent Plugin in your iOS app. The ConsCent Plugin is developed in Swift and supports iOS 13.0 and above.

Step 1: Integration Setup

Step 1.1: Adding the Plugin Framework

  1. Drag the CCPlugin.xcframework folder into your Xcode project.

  2. Select your app target and go to the "Frameworks, Libraries, and Embedded Content" section.

  3. Change the embed mode for CCPlugin.xcframework to "Embed & Sign".

  4. Clean and build your project to ensure the framework is properly integrated.

Step 2: Plugin Configuration

Step 2.1: Importing the Framework

Import the CCPlugin framework into your ViewController class. import CCPlugin

Step 2.2: Configuring the Plugin

In your ViewController class, configure the plugin by providing the client ID and the desired environment mode.

CCPlugin.shared.configure(mode: .sandbox, clientID: "your-client-id")

Parameters:

Step 2.3: Customizing Accent Color

You can set the accent color for the paywall by accessing the accentColor property of the CCPlugin.shared instance and modifying its value.

Refer below example for setting color.

CCPlugin.shared.accentColor = UIColor.red

Step 2.4: Enabling Debug Mode

The debugMode property of the CCPlugin.shared instance can be set to true or false to enable or disable debug mode. When debug mode is enabled, toasts will be shown if the content ID or client ID entered is incorrect. This is useful for development purposes.

CCplugin.shared.debugMode = false

Step 3: Functions

To check if an article/content is free/paid or a payment needs to be done, in your class, use as below sample: Parameters detail can be checked below for more information.

Step 3.1: PayWall Screen

  1. This step is for PayWall Screen

CCplugin.shared.showPayWall(contentID: contentID, viewLayout: ViewLayoutInfo(vc: self, view: self.view), completiondelegate: self, subscriberDelegate: self, signInDelegate: self)

  1. This step is for Embedded Subscription Screen

CCplugin.shared.initSubscriptions(contentID: contentID, viewLayout: ViewLayoutInfo(vc: self, view: self.view), completiondelegate: self)

Parameters Details:

contentID: This will be your article or content ID for which details need to be checked.

ViewLayoutInfo: This is a struct that has two values, vc (View Controller) and view. Pass the view on which you are going to show your content and the View Controller in which the view is present.

delegate: This will be used to handle the success and failure cases. Pass the class as the delegate where you want to handle success or failure. This delegate is of the protocol CCPluginCompletionHandlerDelegate, which has two methods: success and failure that will be triggered in case of success and failure of the process.

success: This is the success callback that will be called for every successful processing. The success method will be triggered in the delegate class.

failure: This is the failure callback that will be called for every failed processing. The failure method will be triggered in the delegate class.

subscriberDelegate: This is an optional callback that will be called if you pass your class as its delegate. It will be triggered when the subscription button is tapped. If you don't pass it in your delegate, it will not show the subscription view.

signInDelegate: This is an optional callback that will be called if you pass your class as its delegate. It will be triggered when the sign-in button is tapped. If you don't pass it in your delegate, it will not show the sign-in view.


Step 4: Final Touches

func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { if let url = URLContexts.first?.url { CCplugin.shared.handleRelaunchApp(url: url) } }

Step 5: Important Points

Loyalty System

const sdk = require('api')('@conscent/v1.0#5zb7qx16lh0lc3b3');


sdk.auth('{API Key}');
sdk.gettingStartedWithYourApi({
  eventType: 'ORDER_PLACED',
  userId: '42bede01c83fa3947'
}, {
  cleint_id: 'client_id',
  accept: 'text/plain'
})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));
const sdk = require('api')('@conscent/v1.0#5zb7qx16lh0lc3b3');


sdk.auth('{API Key}');
sdk.gettingStartedWithYourApi({
  eventType: 'ORDER_PLACED',
  userId: '42bede01c83fa3947'
}, {
  cleint_id: 'client_id',
  accept: 'text/plain'
})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));
const sdk = require('api')('@conscent/v1.0#5zb7qx16lh0lc3b3');


sdk.auth('{API Key}');
sdk.gettingStartedWithYourApi({
  eventType: 'ORDER_PLACED',
  userId: '42bede01c83fa3947'
}, {
  cleint_id: 'client_id',
  accept: 'text/plain'
})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));

Post Event API from Server

This API is used to Post Events from your server directly to BluePine. This is the recommended way of Posting Event.

https://api.conscent.club/reward/{cleint_id}/api/user_event

Node.Js API structure:

AutoLogin Functionality

 csc('auto-login', {
      clientId: clientId,
      token: tokenEntered,
      phone: data?.phoneNumber,
      email: data?.email,
      successCallbackFunction: async (userDetailsObject: any) => {
        setShowLoginDetails(true);
        console.log('Success callback received from conscent auto Login', userDetailsObject);
        alert('login successfull');
      },
      errorCallbackFunction: (errorObject: any) => {
        console.error(errorObject);
        alert('login unsuccessfull');
      },
      unauthorizedCallback: () => {
        console.log('unauthorized callback called');
      },
    });

AutoLogin is a functionality that enables the client to use his own Login sysytem and get their users validated at ConsCent's System.

A temporary token is generated using an API and this token needs to be stored at Client's end.

Implementation

HTTP REQUEST

POST {API_URL}/client/generate-temp-token

Auth required : YES

Mandatory query Parameters

email: Pass email

phoneNumber: Pass phoneNumber

Authorization

Client API Key and API Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

Response

Success Response Code : 200 OK

{ "tempAuthToken": "644a2c13ce90df4882d1787a" }

Country Code List

Afghanistan - AF

Åland Islands - AX

Albania - AL

Algeria - DZ

American Samoa - AS

Andorra - AD

Angola - AO

Anguilla - AI

Antarctica - AQ

Antigua and Barbuda - AG

Argentina - AR

Armenia - AM

Aruba - AW

Australia - AU

Austria - AT

Azerbaijan - AZ

Bahrain - BH

Bahamas - BS

Bangladesh - BD

Barbados - BB

Belarus - BY

Belgium - BE

Belize - BZ

Benin - BJ

Bermuda - BM

Bhutan - BT

Bolivia, Plurinational State of - BO

Bonaire, Sint Eustatius and Saba - BQ

Bosnia and Herzegovina - BA

Botswana - BW

Bouvet Island - BV

Brazil - BR

British Indian Ocean Territory - IO

Brunei Darussalam - BN

Bulgaria - BG

Burkina Faso - BF

Burundi - BI

Cambodia - KH

Cameroon - CM

Canada - CA

Cape Verde - CV

Cayman Islands - KY

Central African Republic - CF

Chad - TD

Chile - CL

China - CN

Christmas Island - CX

Cocos (Keeling) Islands - CC

Colombia - CO

Comoros - KM

Congo - CG

Congo, the Democratic Republic of the - CD

Cook Islands - CK

Costa Rica - CR

Côte d'Ivoire - CI

Croatia - HR

Cuba - CU

Curaçao - CW

Cyprus - CY

Czech Republic - CZ

Denmark - DK

Djibouti - DJ

Dominica - DM

Dominican Republic - DO

Ecuador - EC

Egypt - EG

El Salvador - SV

Equatorial Guinea - GQ

Eritrea - ER

Estonia - EE

Ethiopia - ET

Falkland Islands (Malvinas) - FK

Faroe Islands - FO

Fiji - FJ

Finland - FI

France - FR

French Guiana - GF

French Polynesia - PF

French Southern Territories - TF

Gabon - GA

Gambia - GM

Georgia - GE

Germany - DE

Ghana - GH

Gibraltar - GI

Greece - GR

Greenland - GL

Grenada - GD

Guadeloupe - GP

Guam - GU

Guatemala - GT

Guernsey - GG

Guinea - GN

Guinea-Bissau - GW

Guyana - GY

Haiti - HT

Heard Island and McDonald Islands - HM

Holy See (Vatican City State) - VA

Honduras - HN

Hong Kong - HK

Hungary - HU

Iceland - IS

India - IN

Indonesia - ID

Iran, Islamic Republic of - IR

Iraq - IQ

Ireland - IE

Isle of Man - IM

Israel - IL

Italy - IT

Jamaica - JM

Japan - JP

Jersey - JE

Jordan - JO

Kazakhstan - KZ

Kenya - KE

Kiribati - KI

Korea, Democratic People's Republic of - KP

Korea, Republic of - KR

Kuwait - KW

Kyrgyzstan - KG

Lao People's Democratic Republic - LA

Latvia - LV

Lebanon - LB

Lesotho - LS

Liberia - LR

Libya - LY

Liechtenstein - LI

Lithuania - LT

Luxembourg - LU

Macao - MO

Macedonia, the Former Yugoslav Republic of - MK

Madagascar - MG

Malawi - MW

Malaysia - MY

Maldives - MV

Mali - ML

Malta - MT

Marshall Islands - MH

Martinique - MQ

Mauritania - MR

Mauritius - MU

Mayotte - YT

Mexico - MX

Micronesia, Federated States of - FM

Moldova, Republic of - MD

Monaco - MC

Mongolia - MN

Montenegro - ME

Montserrat - MS

Morocco - MA

Mozambique - MZ

Myanmar - MM

Namibia - NA

Nauru - NR

Nepal - NP

Netherlands - NL

New Caledonia - NC

New Zealand - NZ

Nicaragua - NI

Niger - NE

Nigeria - NG

Niue - NU

Norfolk Island - NF

Northern Mariana Islands - MP

Norway - NO

Oman - OM

Pakistan - PK

Palau - PW

Palestine, State of - PS

Panama - PA

Papua New Guinea - PG

Paraguay - PY

Peru - PE

Philippines - PH

Pitcairn - PN

Poland - PL

Portugal - PT

Puerto Rico - PR

Qatar - QA

Réunion - RE

Romania - RO

Russian Federation - RU

Rwanda - RW

Saint Barthélemy - BL

Saint Helena, Ascension and Tristan da Cunha - SH

Saint Kitts and Nevis - KN

Saint Lucia - LC

Saint Martin (French part) - MF

Saint Pierre and Miquelon - PM

Saint Vincent and the Grenadines - VC

Samoa - WS

San Marino - SM

Sao Tome and Principe - ST

Saudi Arabia - SA

Senegal - SN

Serbia - RS

Seychelles - SC

Sierra Leone - SL

Singapore - SG

Sint Maarten (Dutch part) - SX

Slovakia - SK

Slovenia - SI

Solomon Islands - SB

Somalia - SO

South Africa - ZA

South Georgia and the South Sandwich Islands - GS

South Sudan - SS

Spain - ES

Sri Lanka - LK

Sudan - SD

Suriname - SR

Svalbard and Jan Mayen - SJ

Swaziland - SZ

Sweden - SE

Switzerland - CH

Syrian Arab Republic - SY

Taiwan, Province of China - TW

Tajikistan - TJ

Tanzania, United Republic of - TZ

Thailand - TH

Timor-Leste - TL

Togo - TG

Tokelau - TK

Tonga - TO

Trinidad and Tobago - TT

Tunisia - TN

Turkey - TR

Turkmenistan - TM

Turks and Caicos Islands - TC

Tuvalu - TV

Uganda - UG

Ukraine - UA

United Arab Emirates - AE

United Kingdom - GB

United States - US

United States Minor Outlying Islands - UM

Uruguay - UY

Uzbekistan - UZ

Vanuatu - VU

Venezuela, Bolivarian Republic of - VE

Viet Nam - VN

Virgin Islands, British - VG

Virgin Islands, U.S. - VI

Wallis and Futuna - WF

Western Sahara - EH

Yemen - YE

Zambia - ZM

Zimbabwe - ZW

Errors

The ConsCent API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Invalid API Key & API Secret.
403 Forbidden -- The resource requested is hidden for administrators only.
404 Not Found -- The resource requested could not be found.
405 Method Not Allowed -- You tried to access a resource with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The resource has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many resources! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.