# Create Data Table

`POST /lokta-lms/api/v1/datatables`

Create a new data table and registers it with the application table.

Field Descriptions

Mandatory - datatableName :
The name of the Data Table.

Mandatory - apptableName
Application table name. Must be one of the following:
l_client, l_loan, l_office, l_product_loan, l_wc_loan_product, l_wc_loan

Mandatory - columns
An array of columns in the new Data Table.

Optional - multiRow
Allows to create multiple entries in the Data Table. Optional, defaults to false. If this property is not provided Data Table will allow only one entry.

Field Descriptions - columns

Mandatory - name
Name of the created column. Can contain only alphanumeric characters, underscores and spaces, but cannot start with a number. Cannot start or end with an underscore or space.

Mandatory - type
Column type. Must be one of the following:
Boolean, Date, DateTime, Decimal, Dropdown, Number, String, Text

Mandatory [type = Dropdown] - code
Used in Code description fields. Column name becomes: code_cd_name. Mandatory if using type Dropdown, otherwise an error is returned.

Optional - mandatory
Determines whether this column must have a value in every entry. Optional, defaults to false.

Mandatory [type = String] - length
Length of the text field. Mandatory if type String is used, otherwise an error is returned.

## Request body (application/json)
- `apptableName` (string, required)
- `columns` (array of PostColumnHeaderData, required)
- `datatableName` (string, required)
- `entitySubType` (string)
- `multiRow` (boolean): Allows to create multiple entries in the Data Table. Optional, defaults to false. If this property is not provided Data Table will allow only one entry.

## Responses
- `200`: OK

## Response fields
- `resourceIdentifier` (string)

## Example request (cURL)
```bash
curl -X POST \
  'https://default.lokta.tech/lokta-lms/api/v1/datatables' \
  -u '{username}:{password}' \
  -H 'Tenant-Identifier: default' \
  -H 'Content-Type: application/json' \
  -d '{
  "apptableName": "l_client",
  "columns": [
    {
      "name": "DOB",
      "type": "String",
      "code": "Gender",
      "indexed": true
    }
  ],
  "datatableName": "extra_client_details",
  "entitySubType": "abc",
  "multiRow": true
}'
```

## Example response
```json
{
  "resourceIdentifier": "extra_client_details"
}
```

Interactive: https://developer.lokta.ai/reference#operation/createDatatable
