---
title: "Templates"
description: "<p>Create, manage, and test templates.</p>"
url: "https://www.contentstack.com/docs/developers/apis/lytics-api/templates"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# Templates

Create, manage, and test templates.

## List templates

### List templates

**GET** `/v2/template`

undefined

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "author_id": "string",
      "created": "string",
      "description": "string",
      "desired_format": "string",
      "field_filter": [
        "string"
      ],
      "id": "string",
      "lytics_managed": true,
      "name": "string",
      "reference_tables": [
        "string"
      ],
      "target": "string",
      "type": "string",
      "updated": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Create a template

### Create a template

**POST** `/v2/template`

undefined

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.
- **name** (required)
  The template name
- **description** (optional)
  A description of the template
- **reference_tables** (optional)
  Reference table slugs a js1 template may read via lytics.ref (max 5); sending the param empty clears them
- **type** (required)
  The template type

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "author_id": "string",
    "created": "string",
    "description": "string",
    "desired_format": "string",
    "field_filter": [
      "string"
    ],
    "id": "string",
    "lytics_managed": true,
    "name": "string",
    "reference_tables": [
      "string"
    ],
    "target": "string",
    "type": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Test a template

### Test a template

**POST** `/v2/template/test`

undefined

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
"string"
```

## Get a template

### Get a template

**GET** `/v2/template/{id}`

undefined

#### URL Parameters

- **id** (required)
  The template ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "author_id": "string",
    "created": "string",
    "description": "string",
    "desired_format": "string",
    "field_filter": [
      "string"
    ],
    "id": "string",
    "lytics_managed": true,
    "name": "string",
    "reference_tables": [
      "string"
    ],
    "target": "string",
    "type": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Update a template

### Update a template

**POST** `/v2/template/{id}`

undefined

#### URL Parameters

- **id** (required)
  The template id

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.
- **name** (required)
  The template name
- **description** (optional)
  A description of the template
- **reference_tables** (optional)
  Reference table slugs a js1 template may read via lytics.ref (max 5); sending the param empty clears them
- **type** (required)
  The template type

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "author_id": "string",
    "created": "string",
    "description": "string",
    "desired_format": "string",
    "field_filter": [
      "string"
    ],
    "id": "string",
    "lytics_managed": true,
    "name": "string",
    "reference_tables": [
      "string"
    ],
    "target": "string",
    "type": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Delete template

### Delete template

**DELETE** `/v2/template/{id}`

undefined

#### URL Parameters

- **id** (required)
  The template ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {},
  "request_id": "string",
  "status": 0
}
```

## Get a template definition

### Get a template definition

**GET** `/v2/template/{id}/definition`

undefined

#### URL Parameters

- **id** (required)
  The template ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": "string",
  "request_id": "string",
  "status": 0
}
```

## Test a template

### Test a template

**POST** `/v2/template/{id}/test`

undefined

#### URL Parameters

- **id** (required)
  The template id

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
"string"
```