APIs & services / Program TLD (ptld)

Create the full server-side farmer (IE) from the flat record; also used as get-or-create when a farmer is opened.

Endpointtoday's app
Call
POST /ptld/api/customworknode/v1/worknodeietag/urvi
Service
Program TLD (ptld)
Features
Farmer hub (option tiles), Farmer list & search, Add/Edit farmer (IE profile)
When
Queued sync (IE_FLAT POST) after farmer create/edit/open; also online when a farmer detail is opened
Auth
X-SESSIONID stamped when queued (CoreAPI dooWithRetry); X-REQUESTID idempotency key
In the App Service

Use case

Get-or-create of the full server farmer (IE) from the flat downloaded record. Queued (IE_FLAT POST via IEFlatWorker) when a farmer is opened/edited before it has a server IE; also called online (dooNowOrThrow) by IeRepositoryImpl.fetchFlatIeDataNow when a farmer detail is opened and no local IE exists. The returned IE is saved to the ie tables, its ids are written back to the flat row (IEOLTPId, Aadhaar) and dependent queued ops are released. Queue failures retry later; a 403 after more than 2 attempts for a flat row that already has an IEOLTPId is dropped (TryAgain.NEVER) and logged to Firestore.

Headers

HeaderValueNotes
X-SESSIONID<session token>Stamped when the operation is queued (dooWithRetry) and re-set by CoreAPI at send time; refreshed on 401.
X-REQUESTID<uuid v4>Idempotency key generated by OperationManagerImpl.createOperation for POST/PUT/PATCH when the op enters the offline queue.
X-ACK-REQUESTID<X-REQUESTID of an earlier completed op>Added by SyncQueueProcessor for POST/PUT/PATCH: acknowledges a request id the device already saw succeed.
Content-Typeapplication/jsonAdded by CoreAPI.

Parameters

ParamInRequiredExampleNotes
WorkNodeIdqueryYes3501Selected habitation work node id.
WorkNodeAliasIdHabitationqueryYesHAB-ALIAS-01Habitation alias id.

Request

Example request body (synthetic data)
{
  "VO_id": "VO-0001",
  "REMARK": null,
  "Village_Phase": "PHASE_1",
  "uuid": "ie-alias-0001",
  "District_name": "District A",
  "MandalOLTPId": "3001",
  "maritalStatusCode": "MARITAL_STATUS.MARRIED",
  "DOB": "1985-01-01",
  "PanchayatOLTPId": "3101",
  "id": 1,
  "SHGOLTPId": "3201",
  "DistrictOLTPId": "3301",
  "relationshipCode": "RELATIONSHIP.HUSBAND",
  "Member_Reg_Date": "2020-01-01",
  "Husband_father_Name_Surname": "A",
  "educationalQualificationCode": "EDUCATION.PRIMARY",
  "Member_ID": "MEMBER-0001",
  "District_code": "D001",
  "Mandal_code": "M001",
  "Member_Age": "41",
  "Maritual_status": "Married",
  "Habitation_code": "H001",
  "member_phno": "9XXXXXXXX1",
  "Member_Name": "Farmer",
  "Village_code": "V001",
  "Educational_Qualification": "Primary",
  "IS_Active_": "Y",
  "Village_name": "Village A",
  "Category_ID": "4",
  "SHG_ID": "SHG-ALIAS-01",
  "IEOLTPId": "0",
  "Panchayat_code": "P001",
  "VOOLTPId": "3401",
  "Member_gender": "F",
  "IS_disabled": "N",
  "Panchayat_Name": "Panchayat A",
  "Habitation_name": "Habitation A",
  "Member_Surname": "A",
  "categoryCode": "CATEGORY.SC",
  "Category_Name": "Member Category/C4",
  "Aadhar_no": "XXXX-XXXX-1234",
  "SHG_Name": "SHG A",
  "wellbeing_code": "WB.POOR",
  "Ration_card_number": "XXXXXXXX1234",
  "HabitationOLTPId": "3501",
  "Mandal_Name": "Mandal A",
  "VO_Name": "VO A",
  "VO_Formation_date": "2015-01-01",
  "VillageOLTPId": "3601",
  "SHG_Registration_Date": "2016-01-01",
  "Husband_father_Name": "Relative A",
  "lifeStatus": "LIFE_STATUS.ALIVE",
  "inActiveReason": null,
  "annualActionPlanData": null,
  "annualActionPlanData2526": null,
  "NFCategory2526": "C4",
  "NFJourney": null,
  "opId": null,
  "syncStatus": "SYNC_PENDING",
  "interestedInTrade": false,
  "currentCategory": "C4",
  "endorsementStatus": null,
  "endorsedBy": null,
  "endorsedTime": null,
  "hasATM": false,
  "hasAGrade": false,
  "hasCompactBlock": false,
  "hasSyncErrors": false,
  "appCreatedAt": "1780000000000",
  "gapStartDate": "2026-06-01",
  "isLandAssetFetched": false,
  "isPortfolioFetched": false,
  "isATMFetched": false,
  "assessmentDone": false,
  "hasPortfolio": false,
  "assessmentFetchStatus": false,
  "isAllDataLoaded": false
}
FieldTypeRequiredNotes
uuidstringYesFarmer alias (ie_flat_entity.uuid).
IEOLTPIdstringNoServer IE id if known, '0' otherwise.
Member_Name / Member_Surname / Member_gender / DOB / Member_Age / member_phnostringYesDownloaded SERP member record (masked here).
Aadhar_no / Ration_card_numberstringNoIdentifiers from the member master.
VO_* / SHG_* / Village_* / Habitation_* / Mandal_* / Panchayat_* / District_* (+OLTPId codes)stringYesLocation and group hierarchy.
Category_Name / categoryCode / NFCategory2526 / currentCategory / gapStartDatestringNoMember category.
lifeStatus (serialised name), inActiveReason, REMARKstringNoFarmer status.
local flags (hasATM, hasAGrade, isPortfolioFetched, syncStatus, ...)mixedNoLocal columns also serialised by Gson; ignored by server.

Response

Example response body (synthetic data)
{
  "aliasId": "ie-alias-0001",
  "iconpic": null,
  "id": "40001",
  "interestedInTrade": false,
  "idString": null,
  "iEStatus": {
    "dataCode": "IE_STATUS.ACTIVE"
  },
  "onBoardedTenant": {
    "loginName": "tenant_a",
    "id": 11
  },
  "caretakerTenant": {
    "loginName": "tenant_a",
    "id": 11
  },
  "person": {
    "id": 50001,
    "notes": "C4",
    "aliasId": "ie-alias-0001",
    "personProfile": {
      "lastName": "A",
      "occupation": "Farming",
      "caste": null,
      "noOfChildren": 2,
      "dateOfBirth": "1985-01-01",
      "religion": null,
      "firstName": "Farmer",
      "middleName": null,
      "id": 60001,
      "age": 41,
      "notes": "Member Category/C4",
      "inActiveReason": null,
      "gapStartDate": "2026-06-01",
      "lifeStatus": {
        "dataCode": "LIFE_STATUS.ALIVE"
      },
      "gender": {
        "dataCode": "GENDER.FEMALE"
      },
      "disabilityStatus": {
        "dataCode": "DISABILITY_STATUS.NO"
      },
      "avgMonthlyIncome": {
        "id": 0,
        "value": 5000,
        "currency": {
          "code": "INR"
        }
      },
      "bloodGroup": null,
      "salutation": null,
      "maritalStatus": {
        "dataCode": "MARITAL_STATUS.MARRIED"
      },
      "category": {
        "dataCode": "CATEGORY.SC"
      }
    },
    "personContacts": [
      {
        "iEId": "ie-alias-0001",
        "isPrimary": true,
        "id": 0,
        "contact": {
          "contactValue": "9XXXXXXXX1",
          "id": 0,
          "contactType": {
            "dataCode": "CONTACT_TYPE.MOBILE"
          }
        }
      }
    ],
    "personAddresses": [
      {
        "iEId": "ie-alias-0001",
        "isPrimary": true,
        "id": 0,
        "address": {
          "id": 0,
          "pinCode": "5XXXX1",
          "addressLine1": "Habitation A",
          "addressLine2": "{\"shgId\":\"SHG-ALIAS-01\",\"shgName\":\"SHG A\"}",
          "state": {
            "dataCode": "STATE.AP"
          },
          "city": null,
          "village": {
            "dataCode": "VILLAGE.V001"
          },
          "panchayat": {
            "dataCode": "PANCHAYAT.P001"
          },
          "district": {
            "dataCode": "DISTRICT.D001"
          },
          "country": {
            "dataCode": "COUNTRY.IN"
          },
          "town": null,
          "taluk": {
            "dataCode": "MANDAL.M001"
          }
        }
      }
    ],
    "personEducationList": [
      {
        "iEId": "ie-alias-0001",
        "education": "Primary",
        "id": 0,
        "isActive": true,
        "educationCategory": {
          "dataCode": "EDUCATION.PRIMARY"
        }
      }
    ],
    "personFamilyList": [
      {
        "iEId": "ie-alias-0001",
        "age": 45,
        "id": 0,
        "isActive": true,
        "memberName": "Relative A",
        "occupation": "Farming",
        "notes": null,
        "contact": {
          "contactValue": "9XXXXXXXX2",
          "id": 0,
          "isActive": true,
          "contactType": {
            "dataCode": "CONTACT_TYPE.MOBILE"
          }
        },
        "relationship": {
          "dataCode": "RELATIONSHIP.HUSBAND"
        }
      }
    ],
    "personIdentifierList": [
      {
        "iEId": "ie-alias-0001",
        "id": 0,
        "personIdentifierNumber": "XXXX-XXXX-1234",
        "identifierType": {
          "dataCode": "PERSON_IDENTIFIER.AADHAR_ID"
        },
        "isActive": true
      }
    ]
  },
  "iETaggingList": [
    {
      "iEId": "ie-alias-0001",
      "id": 0,
      "taggingType": {
        "dataCode": "TAGGING_TYPE.WORKNODE"
      },
      "taggedToTenant": {
        "loginName": "tenant_a",
        "id": 11
      }
    }
  ]
}
FieldTypeRequiredNotes
idstringServer IE id -> ie.id and ie_flat_entity.IEOLTPId (updateIEOLTPIdRH); also patched into pending role maps / portfolios.
aliasIdstringMatches the local farmer row.
person.id / person.personProfile.idintegerSaved via updateIEIds.
person.personAddresses[].id / address.idintegerSaved via updateAddressIds.
person.personContacts[].id / contact.id / contact.contactType.dataCodemixedSaved via updateContactId.
person.personEducationList[].id, personFamilyList[].id/contact.id/relationship, personIdentifierList[].id/identifierTypemixedChild ids written back; Aadhaar number re-read to update the flat row.
person.personProfile.gapStartDatestringIE_FLAT only: written to ie_flat_entity.gapStartDate.

Errors

StatusWhenWhat the app does
403Server refuses (e.g. farmer already linked elsewhere) after > 2 attempts and IEOLTPId is setOp dropped (TryAgain.NEVER) and mirrored to Firestore.
online path failurefetchFlatIeDataNowcallback(false); farmer detail opens with local data only.
401Session token expired or invalidCoreAPI invalidates the session id and retries once immediately; if still failing the op stays in the queue (TryAgain.LATER).
500Server error on a /gateway URLBaseResponseHandler fetches a new session id (first 5 attempts) and returns TryAgain.LATER; retried per RetryScheduler policy (retry threshold/delay come from app config).
503Service unavailableCoreAPI retries once immediately, then the op is retried later by the sync queue.
any non-2xxAny other failureHandler onError -> TryAgain.LATER (op stays queued and is visible in Pending Sync); a row is written to the local error_log table (Sync Error Log screen) with URL, body, headers and raw response; every 10th attempt the op is mirrored to Firestore for support.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/entity/IEFlatEntity.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/work/IEFlatWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/IEFlatPostRH.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/repository/impl/IeRepositoryImpl.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/manager/CoreAPIManager.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/BaseResponseHandler.kt
  • offline-core/src/main/java/com/mindtree/bridge/coreapi/offline/SyncQueueProcessor.java
  • offline-core/src/main/java/com/mindtree/bridge/coreapi/offline/manager/OperationManagerImpl.java
  • core-api/src/main/java/com/mindtree/bridge/coreapi/impl/CoreAPIDefaultImpl.java