# List templates

GET https://services.leadconnectorhq.com/emails/locations/{locationId}/templates

Get list of templates by location

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `emails/templates.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | number | No | Number of templates to return |
| `offset` | number | No | Number of templates to skip |
| `search` | string | No | Search by template name |
| `sortBy` | string | No | Field to sort by |
| `sortOrder` | string | No | Sort direction |
| `archived` | boolean | No | Return archived templates |
| `folderId` | string | No | Folder to list templates from. Use 'root' for top-level listing. |
| `include` | string | No | Whether to include templates, folders, or both in the response. `templates` will return only templates, `folders` will return only folders, and `all` will return both. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/emails/locations/{locationId}/templates": {
      "get": {
        "summary": "List templates",
        "operationId": "listTemplates",
        "description": "Get list of templates by location",
        "parameters": [
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location ID",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of templates to return",
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "default": 10,
              "example": 10,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Number of templates to skip",
            "schema": {
              "minimum": 0,
              "default": 0,
              "example": 0,
              "type": "number"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Search by template name",
            "schema": {
              "example": "newsletter",
              "type": "string"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Field to sort by",
            "schema": {
              "default": "updatedAt",
              "example": "updatedAt",
              "enum": [
                "updatedAt"
              ],
              "type": "string"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction",
            "schema": {
              "default": "desc",
              "example": "desc",
              "enum": [
                "asc",
                "desc"
              ],
              "type": "string"
            }
          },
          {
            "name": "archived",
            "required": false,
            "in": "query",
            "description": "Return archived templates",
            "schema": {
              "default": false,
              "example": false,
              "type": "boolean"
            }
          },
          {
            "name": "folderId",
            "required": false,
            "in": "query",
            "description": "Folder to list templates from. Use 'root' for top-level listing.",
            "schema": {
              "example": "root",
              "type": "string"
            }
          },
          {
            "name": "include",
            "required": false,
            "in": "query",
            "description": "Whether to include templates, folders, or both in the response. `templates` will return only templates, `folders` will return only folders, and `all` will return both.",
            "schema": {
              "default": "all",
              "example": "all",
              "enum": [
                "all",
                "templates",
                "folders"
              ],
              "type": "string"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListTemplatesPublicV2ResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "403": {
            "description": "The token does not have access to this location",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvalidLocationDTO"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "emails/templates.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "ListTemplatesPublicV2ResponseDto": {
        "type": "object",
        "properties": {
          "items": {
            "description": "List of template and folder resources",
            "example": [
              {
                "id": "67f15c2ae99226d5bcccb8f3",
                "name": "February Newsletter",
                "type": "template"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Resource ID",
                  "example": "67f15c2ae99226d5bcccb8f3"
                },
                "name": {
                  "type": "string",
                  "description": "Resource name",
                  "example": "February Newsletter"
                },
                "type": {
                  "type": "string",
                  "description": "Resource type",
                  "enum": [
                    "template",
                    "folder"
                  ],
                  "example": "template"
                },
                "isPlainText": {
                  "type": "boolean",
                  "description": "Whether template is plain text",
                  "example": false
                },
                "updatedAt": {
                  "type": "string",
                  "description": "Last updated timestamp",
                  "example": "2026-02-09T04:49:12.322Z"
                },
                "createdAt": {
                  "type": "string",
                  "description": "Created timestamp",
                  "example": "2025-07-24T11:55:43.598Z"
                },
                "previewUrl": {
                  "type": "string",
                  "description": "Preview URL",
                  "example": "https://example.com/preview"
                },
                "editorType": {
                  "type": "string",
                  "description": "Editor type for template resources",
                  "enum": [
                    "html",
                    "builder",
                    "text"
                  ],
                  "example": "builder"
                },
                "childCount": {
                  "type": "number",
                  "description": "Children count for folder resources",
                  "example": 3
                },
                "hasChildren": {
                  "type": "boolean",
                  "description": "Whether folder has child resources",
                  "example": true
                },
                "parentFolderId": {
                  "type": "string",
                  "description": "Parent folder ID",
                  "example": "67f15c2ae99226d5bcccb8f0"
                }
              },
              "required": [
                "id",
                "name",
                "type"
              ],
              "title": "TemplateListItemPublicV2Dto"
            }
          },
          "total": {
            "type": "number",
            "description": "Total count of templates and folders",
            "example": 25
          },
          "traceId": {
            "type": "string",
            "description": "Trace ID of the request",
            "example": "019e4ef5-a65e-4198-8cf9-8e93dca9bda4"
          }
        },
        "required": [
          "items",
          "total"
        ],
        "title": "ListTemplatesPublicV2ResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "InvalidLocationDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for invalid location access",
            "example": 403
          },
          "message": {
            "type": "string",
            "description": "Error message describing the location access failure",
            "example": "The token does not have access to this location"
          }
        },
        "title": "InvalidLocationDTO"
      },
      "NotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for not found",
            "example": 404
          },
          "message": {
            "type": "string",
            "description": "Error message describing the not found failure",
            "example": "Not Found"
          },
          "error": {
            "type": "string",
            "description": "Error type identifier",
            "example": "The requested resource was not found"
          }
        },
        "title": "NotFoundDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/emails/locations/<locationId>/templates' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/emails/locations/<locationId>/templates', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/emails/locations/{locationId}/templates"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

response = requests.get(url, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/emails/locations/<locationId>/templates',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/emails/locations/<locationId>/templates")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/emails/locations/<locationId>/templates"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/emails/locations/<locationId>/templates")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/emails/locations/<locationId>/templates' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
