# 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 %}

![](/files/U7pvbujJ5vHe6yIQtZAQ)

## Steps

### Step 1: Open the notebook

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

![](/files/2k4F1JBZ9aAprXGFAl1R)

### 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**.

![](/files/T1SOj3oItOpjw39gN6dX)

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.

![](/files/p7U5G6qNEbCaQQdBvJRP)

### Step 5: Generate and download the template

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

![](/files/bgp7rA7203jF36K7sLpn)

### 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.

![](/files/BNtE80Vsjbzb5RFXJ6pj)

2. Click **📤 Upload File**.

![](/files/lMqAgZoPpORz1auyb6m7)

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

![](/files/PZw3TDUccGdm6LZknYH0)

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

![](/files/evjWujGz7ibvGKvpzsFf)

6. Download the processed template and review the results.

![](/files/uFD7JXwOMOm4V81lz5Ey)

### 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
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>
```

The question should be specific, self-contained, and written in natural language.
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.
