# LitmusEdgeManager 2.31.x API Documentation/Edge Lifecycle Management/Templates - LE, LEM, LUNS API Docs

## Templates List

**GET** `{{LEM_URL}}/api/v1/template/list?companyName={{company_name}}&limit=10&projectId={{project_id}}`

# Templates List

Returns the templates available in one company / project. A **template** is a saved configuration snapshot (devices, flows, analytics processors, integrations, digital twin models) that can be applied to new devices during onboarding.
## Endpoint

```http
GET {{LEM_URL}}/api/v1/template/list?companyName={{company_name}}&limit=10&projectId={{project_id}}
```
## Authentication

HTTP Basic Auth. **Username** is your API token, **password** is empty. Tokens are managed under `System > Access Control > Tokens`.
## Response

`200 OK` -- `application/json`. Each entry: `companyName`, `projectId`, `deviceId`, `scope`, `timestamp`, `name`, `desc`, `parameterized`, `stat` (JSON-encoded stats string).

## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Response

**Status**: 200 OK

```json
[
    {
        "companyName": "Litmus",
        "projectId": "231234adf323424124445",
        "deviceId": "231234adf323424124445",
        "scope": "COMPANY",
        "timestamp": 1523234233,
        "name": "Litmus/<project ID>/<device ID>/PROJECT/1523234233",
        "desc": "Template for Siemens devices",
        "parameterized": false,
        "stat":"{\"devices\":8,\"flows\":2,\"marketplace\":{\"marketplaces\":3,\"applications\":1,\"registries\":15},\"connectors\":3,\"analytics\":62,\"dtwin\":{\"instances\":3,\"models\":2}}"
    }
]
```

---

## Template Composition

**GET** `{{LEM_URL}}/api/v1/template/composition?projectId={{project_id}}&deviceId={{device_id}}`

# Template Composition

Returns the **composition catalog** for a device -- what is available to include in a new template (auth providers, connectors, devices, country, etc.). Use this as the basis for the `creationOptions` body of `Create Template`.
## Endpoint

```http
GET {{LEM_URL}}/api/v1/template/composition?projectId={{project_id}}&deviceId={{device_id}}
```
## Authentication

HTTP Basic Auth. **Username** is your API token, **password** is empty. Tokens are managed under `System > Access Control > Tokens`.
## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Response

**Status**: 200 OK

```json
{
    "auth": {
        "providers": null
    },
    "connectors": [
        {
            "id": "843e6ca7-f995-4a5b-80ad-29610230cb7b",
            "name": "data-rate-test",
            "provider": "gcloud-pubsub"
        },
        {
            "id": "c1736c10-804d-4d6e-9cbc-ba5f2cb7d4c0",
            "name": "ClarifyIOssl",
            "provider": "generic-mqtt-ssl"
        }
    ],
    "country": false,
    "devices": [
        {
            "id": "41FBD12E-C6CD-4539-AD50-336D278B207C",
            "name": "Rack 2b M258"
        },
        {
            "id": "474E42B0-C7B8-42DE-8DE2-FFED7030A563",
            "name": "DTA windows tia"
        },
        {
            "id": "4C4B9CCC-F5E4-4C2E-A4C0-EAF5C32B0D1A",
            "name": "AB CLX API testing"
        },
        {
            "id": "779F42F3-54FC-4A87-B9A6-CD39CFA4A97D",
            "name": "Simulator2"
        },
        {
            "id": "89C52E9A-0901-4D8D-B842-7B533F64E1B7",
            "name": "ClassificationSimulator"
        },
        {
            "id": "BAFD349E-21B6-408A-AE2F-B9C682912571",
            "name": "Boiler"
        },
        {
            "id": "CDC283FB-72E2-42DF-A587-4D6299D70C9A",
            "name": "sim1"
        }
    ],
    "dns": false,
    "docker": false,
    "dtwin": {
        "instances": [
            {
                "id": "d0c8844d-ef72-4933-bb5e-b74372b33f4b",
                "name": "Instance1"
            },
            {
                "id": "5992744a-65b9-431f-880c-4efa2644a57f",
                "name": "apiInstance"
            }
        ],
        "models": [
            {
                "id": "d9117ae5-3f3e-4436-9a2a-6dd725fbd8fb",
                "name": "Digital-Twin-1"
            },
            {
                "id": "3a923971-5dfc-4633-b5af-a6bf8c0b60e9",
                "name": "apiTest"
            }
        ]
    },
    "flows": [
        {
            "id": "1",
            "label": "flow-1"
        },
        {
            "id": "4",
            "label": "videoprocessing"
        }
    ],
    "groups": [
        {
            "name": "default"
        },
        {
            "name": "ml-classification"
        },
        {
            "name": "sensorAnalytics"
        }
    ],
    "marketplace": {
        "catalogs": [
            {
                "applications": null,
                "id": "2de5c161-1a8d-11ed-8d9d-94c6911b9c77",
                "name": "Solutions Catalog"
            },
            {
                "applications": [
                    {
                        "id": "ca877b46-1a8c-11ed-8791-94c6911b9c77",
                        "name": "MySQL"
                    }
                ],
                "id": "c93dbe1b-1a8c-11ed-8d9d-94c6911b9c77",
                "name": "Catalog Applications"
            },
            {
                "applications": null,
                "id": "default-marketplace",
                "name": "Default Marketplace Catalog"
            }
        ],
        "registries": [
            {
                "id": "06c1831c-e1c3-4dec-9462-927045c68cc5",
                "name": "Elastic docker registry"
            },
            {
                "id": "1c3e352b-18d9-476c-bffb-c2d6860b91af",
                "name": "GOOGLE REGISTRY"
            },
            {
                "id": "37089c8a-a4bf-4743-ba91-a308a3d2879b",
                "name": "Elastic docker registry"
            },
            {
                "id": "4eb828ff-ada3-404c-ad0b-63551ee1e42f",
                "name": "Public Docker Hub"
            },
            {
                "id": "507380c5-e3a9-475c-9b8f-8dcfef9f6bc1",
                "name": "Microsoft Docker Container registry"
            },
            {
                "id": "619022b2-2144-4bd0-9d24-18c0be55d158",
                "name": "Microsoft Docker Container registry"
            },
            {
                "id": "694a9804-4a20-4d61-bbef-c5c72e969a94",
                "name": "Elastic public docker registry"
            },
            {
                "id": "6a77715d-0ade-4040-bae0-f41568d07e8c",
                "name": "Public docker repository"
            },
            {
                "id": "70f7c354-af13-4768-b6a5-ff969e2f1a5f",
                "name": "Elastic docker repository"
            },
            {
                "id": "8e22251d-d304-11ec-a0f9-94c6911b9c77",
                "name": "litmusjupyter"
            },
            {
                "id": "b90acb33-a037-4f84-8311-e17ffabe8ccf",
                "name": "Public docker hub"
            },
            {
                "id": "d6ea3123-d2d2-49a7-82e3-5fc9ff4aefdc",
                "name": "GCR-solutions-registry"
            },
            {
                "id": "e2d72df6-50df-11ee-abb6-94c6911b9c77",
                "name": ""
            },
            {
                "id": "eb33db83-3bfd-4eff-8a6f-a7ca72cebaab",
                "name": "Microsoft Docker Container registry"
            },
            {
                "id": "faedaf64-acdd-4a34-8238-3003e8ad77c5",
                "name": "Public docker hub"
            }
        ]
    },
    "ntp": false,
    "opcua": [
        {
            "name": "EdgeDevice",
            "type": "FOLDER"
        },
        {
            "name": "Users",
            "type": "CONFIG"
        },
        {
            "name": "Modes",
            "type": "CONFIG"
        },
        {
            "name": "Policies",
            "type": "CONFIG"
        },
        {
            "name": "Enabled",
            "type": "CONFIG"
        },
        {
            "name": "Certificates",
            "type": "CONFIG"
        }
    ],
    "timezone": false
}
```

---

## List all Variables of Template

**GET** `{{LEM_URL}}/api/v1/template/list-variables?templateName={{template_name}}`

# List all Variables of Template

Returns the variables declared in one template. Variables are placeholders that get substituted when the template is applied to a new device.
## Endpoint

```http
GET {{LEM_URL}}/api/v1/template/list-variables?templateName={{template_name}}
```
## Authentication

HTTP Basic Auth. **Username** is your API token, **password** is empty. Tokens are managed under `System > Access Control > Tokens`.
## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Response

**Status**: 200 OK

```json
[
    {
        "name": "Variable name",
        "type": "String value",
        "description": "Variable description"
    }
]
```

---

## Create Template

**POST** `{{LEM_URL}}/api/v1/template/create`

# Create Template

Creates a new template from one source device. The body specifies which categories (`auth`, `connectors`, `devices`, `country`, ...) to include.
## Endpoint

```http
POST {{LEM_URL}}/api/v1/template/create
```
## Authentication

HTTP Basic Auth. **Username** is your API token, **password** is empty. Tokens are managed under `System > Access Control > Tokens`.
## Request body

```json
{
  "deviceId": "1a5wiavluwxuhwai5leb1v0hc",
  "templateDescription": "newTemplate",
  "creationOptions": {
    "auth": { "providers": [] },
    "connectors": ["843e6ca7-..."],
    "country": true,
    "devices": ["41FBD12E-..."]
  }
}
```

## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Request Body

```json
{
    "deviceId": "1a5wiavluwxuhwai5leb1v0hc",
    "templateDescription": "newTemplate",
    "creationOptions": {
        "auth": {
            "providers": []
        },
        "connectors": [
            "843e6ca7-f995-4a5b-80ad-29610230cb7b",
            "c1736c10-804d-4d6e-9cbc-ba5f2cb7d4c0"
        ],
        "country": true,
        "devices": [
            "41FBD12E-C6CD-4539-AD50-336D278B207C",
            "474E42B0-C7B8-42DE-8DE2-FFED7030A563",
            "4C4B9CCC-F5E4-4C2E-A4C0-EAF5C32B0D1A",
            "779F42F3-54FC-4A87-B9A6-CD39CFA4A97D",
            "89C52E9A-0901-4D8D-B842-7B533F64E1B7",
            "BAFD349E-21B6-408A-AE2F-B9C682912571",
            "CDC283FB-72E2-42DF-A587-4D6299D70C9A"
        ],
        "dns": true,
        "docker": true,
        "digitalTwin": {
            "instances": [
                {
                    "id": "d0c8844d-ef72-4933-bb5e-b74372b33f4b",
                    "name": "Instance1"
                },
                {
                    "id": "5992744a-65b9-431f-880c-4efa2644a57f",
                    "name": "apiInstance"
                }
            ],
            "models": [
                {
                    "id": "d9117ae5-3f3e-4436-9a2a-6dd725fbd8fb",
                    "name": "Digital-Twin-1"
                },
                {
                    "id": "3a923971-5dfc-4633-b5af-a6bf8c0b60e9",
                    "name": "apiTest"
                }
            ]
        },
        "flows": [
            "1",
            "4"
        ],
        "groups": [
            "default",
            "ml-classification",
            "sensorAnalytics"
        ],
        "marketplace": {
            "catalogs": [
                {
                    "id": "2de5c161-1a8d-11ed-8d9d-94c6911b9c77",
                    "name": "Solutions Catalog",
                    "applications": []
                },
                {
                    "id": "c93dbe1b-1a8c-11ed-8d9d-94c6911b9c77",
                    "name": "Catalog Applications",
                    "applications": [
                        {
                            "id": "ca877b46-1a8c-11ed-8791-94c6911b9c77",
                            "name": "MySQL"
                        }
                    ]
                },
                {
                    "id": "default-marketplace",
                    "name": "Default Marketplace Catalog",
                    "applications": []
                }
            ],
            "registries": [
                {
                    "id": "06c1831c-e1c3-4dec-9462-927045c68cc5",
                    "name": "Elastic docker registry"
                },
                {
                    "id": "1c3e352b-18d9-476c-bffb-c2d6860b91af",
                    "name": "GOOGLE REGISTRY"
                },
                {
                    "id": "37089c8a-a4bf-4743-ba91-a308a3d2879b",
                    "name": "Elastic docker registry"
                },
                {
                    "id": "4eb828ff-ada3-404c-ad0b-63551ee1e42f",
                    "name": "Public Docker Hub"
                },
                {
                    "id": "507380c5-e3a9-475c-9b8f-8dcfef9f6bc1",
                    "name": "Microsoft Docker Container registry"
                },
                {
                    "id": "619022b2-2144-4bd0-9d24-18c0be55d158",
                    "name": "Microsoft Docker Container registry"
                },
                {
                    "id": "694a9804-4a20-4d61-bbef-c5c72e969a94",
                    "name": "Elastic public docker registry"
                },
                {
                    "id": "6a77715d-0ade-4040-bae0-f41568d07e8c",
                    "name": "Public docker repository"
                },
                {
                    "id": "70f7c354-af13-4768-b6a5-ff969e2f1a5f",
                    "name": "Elastic docker repository"
                },
                {
                    "id": "8e22251d-d304-11ec-a0f9-94c6911b9c77",
                    "name": "litmusjupyter"
                },
                {
                    "id": "b90acb33-a037-4f84-8311-e17ffabe8ccf",
                    "name": "Public docker hub"
                },
                {
                    "id": "d6ea3123-d2d2-49a7-82e3-5fc9ff4aefdc",
                    "name": "GCR-solutions-registry"
                },
                {
                    "id": "e2d72df6-50df-11ee-abb6-94c6911b9c77",
                    "name": ""
                },
                {
                    "id": "eb33db83-3bfd-4eff-8a6f-a7ca72cebaab",
                    "name": "Microsoft Docker Container registry"
                },
                {
                    "id": "faedaf64-acdd-4a34-8238-3003e8ad77c5",
                    "name": "Public docker hub"
                }
            ]
        },
        "ntp": true,
        "opcua": [
            {
                "name": "EdgeDevice",
                "type": "FOLDER"
            },
            {
                "name": "Users",
                "type": "CONFIG"
            },
            {
                "name": "Modes",
                "type": "CONFIG"
            },
            {
                "name": "Policies",
                "type": "CONFIG"
            },
            {
                "name": "Enabled",
                "type": "CONFIG"
            },
            {
                "name": "Certificates",
                "type": "CONFIG"
            }
        ],
        "timezone": true
    }
}
```

### Response

**Status**: 200 OK

```json
{
    "code": "S",
    "message": null,
    "messageDetails": null
}
```

---

