> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/complaints-management/cms-v2.11/deploy/configure/id-generation-idgen.md).

# ID Generation (IDGen)

## Overview

DIGIT's IDGen service is used to generate unique complaint IDs for every grievance recorded in the system. This ensures that each complaint is distinctly identifiable and traceable throughout its lifecycle. The IDGen service creates these IDs in a predefined format, driven by configurations stored in the Master Data Management Service (MDMS). By using IDGen, complaint records remain consistent, standardised, and easy to reference across channels (web, mobile, kiosks, or call centres).

***

## &#x20;Steps

Below are the steps to configure IDGen.

{% stepper %}
{% step %}

### Configure ID format in MDMS

* Add your ID format in the IDFormat master data (usually inside your MDMS repo):

  Refer to the [link](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/master/utilities/default-data-handler/src/main/resources/mdmsData/common-masters/common-masters.IdFormat.json) here for details.

```
{
  "format": "PB-BTR-[cy:yyyy-MM-dd]-[SEQ_EG_BTR_ID]",
  "idname": "btr.registrationid"
}
```

Here -

* **format:** Controls the structure of the generated ID.
* **idname:** Unique identifier used to reference this format in your application. After adding, restart both the IDGen and MDMS services.
  {% endstep %}

{% step %}

### Port forward the IDGen Service

To access IDGen locally, forward its port:

`kubectl port-forward <IDGEN_SERVICE_POD_NAME> 8285:8080`

Now IDGen is available at: <http://localhost:8285/>

You can also run the IDGen service locally and set the format in application.properties if the DIGIT environment is unavailable.
{% endstep %}

{% step %}

### Test the IDGen Format

{% hint style="info" %}

#### &#x20;🔍 Check if the ID generated matches the format you added. If not, check the MDMS config and logs.

{% endhint %}

Run this curl to test that your format is set up correctly:

```
curl --location --request POST 'http://localhost:8285/egov-idgen/id/_generate' \
--header 'Content-Type: application/json' \
--data-raw '{
  "RequestInfo": {
    "authToken": "REPLACE_WITH_TOKEN",
    "userInfo": {
      "id": 23299,
      "uuid": "e721639b-c095-40b3-86e2-acecb2cb6efb",
      "userName": "9337682030",
      "name": "Abhilash Seth",
      "type": "EMPLOYEE",
      "mobileNumber": "9337682030",
      "emailId": "abhilash.seth@gmail.com",
      "roles": [{
        "id": 281,
        "name": "Employee"
      }]
    }
  },
  "idRequests": [{
    "tenantId": "pg.citya",
    "idName": "pgr.servicerequestid"
  }]
}
```

{% endstep %}

{% step %}

### Integrate IDGen into your application

In your service (e.g., getIdList), call IDGen like this:

```
 private List<String> getIdList(RequestInfo requestInfo, String tenantId, String idKey,
                                   String idformat, int count) {
        List<IdResponse> idResponses = idGenRepository.getId(requestInfo, tenantId, idKey, idformat, count).getIdResponses();

        if (CollectionUtils.isEmpty(idResponses))
            throw new CustomException("IDGEN ERROR", "No ids returned from idgen Service");

        return idResponses.stream()
                .map(IdResponse::getId).collect(Collectors.toList());
    }
```

{% endstep %}

{% step %}

#### Add Properties in application.properties

Ensure the following config is added to your app: properties

`# IDGen Configuration`

`egov.idgen.host=http://localhost:8285/  # Update with your IDGen service host`

`egov.idgen.path=egov-idgen/id/_generate`
{% endstep %}
{% endstepper %}

***

The IDGen service automatically generates unique application numbers.

***

{% hint style="info" %}
**Tips**

* Always match idName with what you configured in MDMS.
* Ensure MDMS and IDGen are restarted after changes.
* Log or debug the IDGen call if you get an empty or incorrect response.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digit.org/complaints-management/cms-v2.11/deploy/configure/id-generation-idgen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
