APIs & services / Program TLD (ptld)

Create a new farmer.

Endpointtoday's app
Call
POST /ptld/api/customworknode/v1/worknodeietag/urvi/ie
Service
Program TLD (ptld)
Features
Add/Edit farmer (IE profile)
When
Queued sync (IE POST) after user adds a farmer
Auth
X-SESSIONID stamped when queued (CoreAPI dooWithRetry); X-REQUESTID idempotency key
In the App Service

Use case

Queued create of a new farmer added on the Add Farmer screen (IE POST via IEWorker). The worker builds the IE from the local ie tables and the selected work node; on success IEPostRH writes the server person/profile/address/contact/education/family/identifier ids back, sets the IE id on pending role maps and releases dependent ops (portfolio, inventory, role map). On failure it stays queued and retries.

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.
X-PASS<redacted: hardcoded value at data/src/main/java/org/mindtree/app/agricultor/data/entity/IE.kt:352>Fixed header added only on this create call; purpose unknown.

Parameters

ParamInRequiredExampleNotes
WorkNodeIdqueryYes3501Habitation work node id.
WorkNodeAliasIdHabitationqueryYesHAB-ALIAS-01Habitation alias.
voAliasqueryYesVO-ALIAS-01VO alias of selected work node.
voNamequeryYesVO AVO name.
shgAliasIdqueryNoSHG-ALIAS-01From addressLine2 JSON shgId.
shgNamequeryNoSHG AFrom addressLine2 JSON shgName.

Request

Example request 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
      }
    }
  ],
  "appId": "ie-alias-0001",
  "syncStatus": "SYNC_PENDING"
}
FieldTypeRequiredNotes
aliasIdstringYesClient farmer id (UUID), unique on ie.aliasId; server echoes it.
idstringNoServer IE id ('0'/null on create).
person.personProfile.firstName / lastName / middleName / dateOfBirth / age / gender / maritalStatus / category / occupation / noOfChildrenmixedYesAdd/Edit farmer form.
person.personProfile.notes / person.notes / gapStartDatestringNoMember category path (e.g. 'Member Category/C4') and category last-change date; PATCH_CATEGORY sends only id + these.
person.personContacts[]arrayNoMobile number (CONTACT_TYPE.MOBILE).
person.personAddresses[].addressobjectNoLocation codes from the selected work node; addressLine2 is a JSON string with shgId/shgName (also lifted into shgAliasId/shgName query params).
person.personEducationList[] / personFamilyList[]arrayNoEducation and husband/father details.
person.personIdentifierList[]arrayNoAadhaar (PERSON_IDENTIFIER.AADHAR_ID) and ration card numbers; masked here.
iETaggingList[]arrayNoTenant/work node tagging.
iEStatus, interestedInTrade, onBoardedTenant, caretakerTenantmixedNoStatus and tenant references.
appId, opId, syncStatusstringNoLocal columns 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
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/IE.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/work/IEWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/IEPostRH.kt
  • app/src/main/java/org/platformcommons/urvi/bridge/BridgeSyncHelper.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