---
title: "Columnlist"
method: GET
path: "/api/new_mdm/column_list/"
tags: ["MDM NEW"]
---

# Columnlist

`GET /api/new_mdm/column_list/`

**Function**: `ColumnList`
**Type**: API Endpoint (GET)

**Purpose**:  
This API endpoint retrieves a paginated list of columns from a specified table for a particular customer based on the provided `customer_key`.

**URL**:  
`GET /api/new_mdm/column_list/?page=<page_num>&limit=<limit_num>`

**Request Headers**:
- **Customer-Key** (Header, required):  
    A base64 encoded string that contains `lscode` and `firmcode`, separated by a pipe (`|`).
- **Table-Name** (Header, required):  
    The name of the table from which to retrieve column details.

**Steps**:
1. **Log Creation**:  
    Generates a unique log ID based on the current timestamp to track each request.
2. **Customer Key Decoding**:  
    The `Customer-Key` is decoded from base64 and split into `lscode` and `firmcode`. 
    If the format is invalid, an error message is returned.
3. **Database Connection**:  
    The `custCursorConnection` function uses `lscode` and `firmcode` to connect to the specific customer’s database.
4. **Query Execution**:  
    Retrieves the column data for the specified `Table_Name` from the `[dbo].[LS_Custom_Columns]` table. 
    Results are filtered by `Active Flag` and paginated based on `page` and `limit` parameters.
5. **Result Processing**:  
    The query results are formatted as a list of dictionaries, handling data types such as `Decimal` and `datetime` for JSON serialization.
6. **Response Construction**:  
    A JSON response is returned with the formatted list of column details.

**Response Example**:
```json
[
    "total_count": <total_count>,
    "table_details": [
        {
            "Table Name": "<Table Name>",
            "Description": "<Description>",
            "Error Type": "<Error Type>",
            "Delete Option": "<Delete Option>"
        }
    ],
    "columns": [
        {
            "LSCode": "<LSCode>",
            "LSFirmCode": "<LSFirmCode>",
            "Table": "<Table>",
            "column_id": "<column_id>",
            "Column Name": "<Column Name>",
            "Data Type": "<Data Type>",
            "Length": "<Length>",
            "Scale": "<Scale>",
            "Required": "<Required>",
            "Column Type": "<Column Type>",
            "Reference Type": "<Reference Type>",
            "Description": "<Description>",
            "Default Value": "<Default Value>",
            "Compute Formula": "<Compute Formula>",
            "Sequence": "<Sequence>",
            "Active Flag": "<Active Flag>",
            "Created By": "<Created By>",
            "Date Of Item Created": "<Date Of Item Created>",
            "Modified By": "<Modified By>",
            "Date of Modification": "<Date of Modification>",
            "Pkey": "<Date of Modification>",
            "Delete_on": "<Delete_on>"
        },
        {
        .....
        },
        .....
    {
]
```

**Error Handling**:
- **Invalid Customer Key**:  
    If `customer_key` decoding fails, an error message with "Invalid Customer Key" is returned.
- **Database Connection/Execution Errors**:  
    Any issues during connection or query execution are caught, rolled back, logged, and returned with a 500 status.

**Error Response Example**:
```json
{
    "status": "failed",
    "message": "Invalid Customer Key"
}
```
```json
{
    "status": "failed",
    "message": {
        "error_type": "OperationalError",
        "message": "table does not exist"
    }
}
```

**Security Considerations**:
- Sensitive data in the `customer_key` (like `lscode` and `firmcode`) is encoded to provide security. 
- The database is accessed only if the `customer_key` is valid and properly formatted.

## Headers

- `Customer-Key` string, required
- `Table-Name` string, required

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi.md) · [All operations](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/leapsurgebi/leapsurgeapi/revisions/5a6b1464bfeb/schema)
