> 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/complaints-resolution-v2.10/deploy/setup/production-setup/deploy-complaints-management/alternative-approach/notebook-2-boundary-setup.md).

# Notebook 2: Boundary Setup

## Overview

Create the boundary hierarchy and upload boundary masters for a city tenant.

File: `2_BoundarySetup.ipynb`

Creates:

* Boundary hierarchy definition (example: City → Zone → Ward → Block → Locality)
* Boundary values for all levels

{% hint style="warning" %}
Boundary setup runs at the **city/ULB level**. Re-authenticate using **city tenant** credentials (example tenant: `pg.citya`).
{% endhint %}

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2F9rb2mCm31hlyMSBmtqoI%2Funknown.png?alt=media\&token=675084ff-49e8-4f77-b839-214a325a814d)

## Steps

### Step 1: Open the notebook

* Open Jupyter and go to the `Notebooks` folder.
* Open `2_BoundarySetup.ipynb`.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2F1isMfCnkhNzktdjCM4gp%2Funknown.png?alt=media\&token=f7251495-ef7c-4346-8c88-e3e5842b14e3)

### Step 2: Authenticate (city-level)

Authenticate the same way as Notebook 1, but use the **city tenant** credentials.

Use these typical values:

* **User Type**: `EMPLOYEE`
* **Tenant ID**: `pg.citya` (your city tenant)

### Step 3: Select tenant

Enter your tenant code (example: `pg.citya`).

### Step 4: Create or select the boundary hierarchy

#### Option A: Create a new hierarchy (first-time setup)

1. Select **Create New Hierarchy**.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FSWJlfhIQFDpx1w9dkZjW%2Funknown.png?alt=media\&token=9306db47-990b-4a42-b97b-4dfaab0b5c6d)

2. Enter **Hierarchy type**: `ADMIN`.
3. Define the levels.

<table><thead><tr><th width="316.37890625">Level</th><th>Boundary Type</th></tr></thead><tbody><tr><td>Level 1</td><td>City</td></tr><tr><td>Level 2</td><td>Zone</td></tr><tr><td>Level 3</td><td>Ward</td></tr><tr><td>Level 4</td><td>Block</td></tr><tr><td>Level 5</td><td>Locality</td></tr></tbody></table>

4. Click **Create Hierarchy**.

#### Option B: Use an existing hierarchy

If a hierarchy already exists, select it from the dropdown.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FCP9zrbzF25knNYrm7PNA%2Funknown.png?alt=media\&token=6f200e5b-e185-4df7-810a-65da6cc9490f)

### Step 5: Generate and download the template

1. Click **Generate Boundary Template**.
2. Wait for generation (typically 30–60 seconds).
3. Click **Download Template**.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FxYe65f3mbzeIJMc1muEV%2Funknown.png?alt=media\&token=195e1eab-c0a9-4c3b-bcbf-a5573531c179)

### Step 6: Fill the boundary template

Open the downloaded Excel file and fill in the boundary rows.

Example:

| Code              | Name   | Parent Code   |
| ----------------- | ------ | ------------- |
| PG\_CITYA         | City A | (empty)       |
| PG\_CITYA\_Z1     | Zone 1 | PG\_CITYA     |
| PG\_CITYA\_Z1\_W1 | Ward 1 | PG\_CITYA\_Z1 |

**Rules:**

* Level 1 has **no** parent (leave Parent Code empty).
* All other levels must have a valid Parent Code.
* Codes must be unique.

### Step 7: Upload and process boundaries

1. Upload the filled template.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FQVc0913e6qi8c6aqnxCX%2Funknown.png?alt=media\&token=eb5f50ee-0d61-46b5-a0b1-990ddf8807e3)

2. Click **📤 Upload File**.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FisYExLTBnrjkWEYY6KvV%2Funknown.png?alt=media\&token=7e602434-2c91-463f-af6a-164546934dcf)

3. Click **⚙️ Process Boundaries**.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2Flb60oNL9Usr0UGvXcAIg%2Funknown.png?alt=media\&token=f13dbb8b-2376-42c5-aad5-cb29291c7336)

4. Wait for processing (typically 1–5 minutes).
5. Click **Check processing status**.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2FqtZgqLZa9nl5TJFIyqTk%2Funknown.png?alt=media\&token=9cb082ab-b599-4d99-ba70-c2c43557d3c8)

6. Download the processed template and review the results.

![](https://805553164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FszvWp0bRxYU0P0l6DKOo%2Fuploads%2Fc6VtyAuh0mny1Clhli88%2Funknown.png?alt=media\&token=9bc28a97-39fc-4520-acd5-de1167b9aa1f)

### Step 8: Handle errors (if any)

If any rows fail in the processed file:

* Filter to rows with `FAILED`.
* Read the error message column.
* Fix the source data in those rows.
* Delete the status columns (example: `_STATUS`, `_STATUS_CODE`, `_ERROR_MESSAGE`).
* Re-upload the corrected file.

The system skips rows that were already successful.


---

# 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/complaints-resolution-v2.10/deploy/setup/production-setup/deploy-complaints-management/alternative-approach/notebook-2-boundary-setup.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.
