Integration Guide

Eligibility API Integration Examples

Example 1 :- Real Implementation from Reference Beneficiary Toaster Backend (Check eligibility for a given user from the list of benefits)

This example shows the actual implementation of how the beneficiary backend integrates with the Eligibility SDK

Overview

The beneficiary app uses the Eligibility SDK to check if users qualify for various benefit schemes. The integration happens in the ContentService class and is used throughout the application for:

  1. Real-time eligibility checking during benefit application

  2. Batch processing of user eligibility

  3. Form validation and user feedback

  4. Benefit recommendation based on user profile

Service Implementation

ContentService Integration

async checkBenefitsEligibility(userInfo: object, eligibilityData: Array<any>, strictCheck: boolean) {
  const url = `${this.eligibility_base_uri}/check-eligibility?strictChecking=${strictCheck}`;
  
  const response = await this.httpService.axiosRef.post(url, {
    userProfile: userInfo,
    benefitsList: eligibilityData,
  }, {
    headers: { 'Content-Type': 'application/json' }
  });

  return response.data;
}

Input - 1. User Profile Data Structure

The beneficiary app sends user data in this format:

Important Notes:

  • The user object must be flat (no deeply nested structures).

  • The fields may vary depending on the user profile in your application, but the SDK always expects a flat object for userProfile.

  • This is sample data from the reference Beneficiary App — adapt it to your application’s schema.

Input - 2. Benefit Schema Data Structure

The app processes benefit data from Hasura and formats it for the Eligibility SDK:

Important Note:

  • The eligibility criteria in your system may be defined in a different format (e.g. database schema, JSON rules, policy configs). In reference Beneficiary App we are using Strapi to define the benefit schemes, and we format the benefit into the required format and send it to the eligibility SDK.

  • You must translate your eligibility rules into this standardized format before passing them to the SDK so they can be processed.

  • The examples above are taken from the reference Beneficiary App.

Output - Response Structure

The Eligibility SDK returns results in this format:

Example 2: Real Implementation from Reference Provider Backend (Check eligible users for a given application)

This example shows the actual implementation of how the provider backend integrates with the Eligibility SDK to evaluate individual applications against specific benefit criteria.

Overview

The provider app uses the Eligibility SDK to check if individual applications qualify for specific benefit schemes. The integration happens in the ApplicationsService class and is used for:

  • Real-time eligibility checking during application processing

  • Batch processing of pending applications via cron jobs

Service Implementation

Input - 1. User Profile Data Structure

The provider app sends application data in this format:

Important Notes:

  • The user object is flattened from the application's applicationData field

  • Includes application-specific metadata like applicationId and documentVerificationStatus

  • Fields are extracted from the application's stored data and benefit requirements

  • The object structure adapts based on the specific benefit's data requirements

Input - 2. Benefit Schema Data Structure

The app processes benefit eligibility rules from Strapi CMS and formats them for the Eligibility SDK:

Important Notes:

  • Eligibility rules are defined in Strapi CMS for each benefit

  • The provider automatically adds a document verification rule with auto-generated ID

  • Rules are processed and formatted before sending to the SDK

  • Each rule includes id, type, description, evidence, and criteria

Output - Response Structure

The Eligibility SDK returns results in this format:

You can also refer to the Postman collection of the available APIs on the link given below

Multi Language Support

Eligibility SDK: Provides support for responses in Hindi and English, enhancing accessibility for diverse users

Below is the sample CURL command for Eligibility API which gives response in hindi. We can Accept-Language in header of API call as hi or en

Eligibility API Sample CURL for Hindi

Last updated