# User-defined Templates

User-defined templates allow you create a set of tests, alert rules, dashboards, and tags from a single template configuration file that you define. The ThousandEyes platform supports many monitoring scenarios and third-party applications, such as Microsoft 365, Webex, and others using a predefined set of certified templates. You may, however, have additional needs that are not covered. You can use user-defined templates to support monitoring use cases that the ThousandEyes platform doesn't currently offer through its certified offerings. For more information about templates, see [Templates](https://docs.thousandeyes.com/product-documentation/tests/templates).

## Permissions

When you create a template, all users within your account group can have the option to select it when deploying a new test template. To grant access to users in your account group, enable the `View Test Templates` permission for each user. Users will also need the "Edit Tests" permission to deploy the templates. If the template has other assets, such as alert rules, tags, or dashboards, users in the account group will also need to have the respective edit permission for each asset type. For more information about template permissions, see [ThousandEyes Developer Reference: Templates](https://developer.cisco.com/docs/thousandeyes/templates-api-overview/).

## Creating Your Own Template in the ThousandEyes UI

To create your own template in the ThousandEyes UI:

1. Navigate to **Network & App Synthetics > Test Settings**.
2. Click on the button on the right side of the screen that says **+ Build Your Own Template**.
3. Paste the JSON schema into the text box that appears. For an example schema see the section [Example Schema](#example-schema). Click **Next**.
4. Fill out the additional information, such as providing a name for your template, and click **Confirm & Publish**
5. A screen appears reporting the setup was successful. To use your template, return the main template list and select it.

## Creating Your Own Template with the ThousandEyes API

If this is your first time using the ThousandEyes API, see [Thousand Eyes Developer Reference: Overview](https://developer.cisco.com/docs/thousandeyes/v7/) to get started. For an overview of the ThousandEyes TestTemplates API, see [ThousandEyes Developer Reference: Test Templates](https://developer.cisco.com/docs/thousandeyes/templates-api-overview/).

### Using `createTemplate`

To create a new template, use the `createTemplate` endpoint (`https://api.thousandeyes.com/v7/templates`). To review the API specification for `createTemplate`, see the [API Reference](https://developer.cisco.com/docs/thousandeyes/v7/create-template/).

### Assets

Templates currently support configuring tags, tests, alert rules, and dashboards. Each of these assets is configured using a schema you can specify in your configuration file. The API documentation for each type of asset is listed in the table below. Examples of each asset's configuration are in the next section, [Example Schema](https://docs.thousandeyes.com/product-documentation/tests/templates/user-defined-templates#example-schema).

The table below lists where you can find a reference to the schema for each type of asset:

| Asset Type               | Schema Reference Link                                                                         |
| ------------------------ | --------------------------------------------------------------------------------------------- |
| Tags (formerly "Labels") | [Tags](https://developer.cisco.com/docs/thousandeyes/v7/#!tag)                                |
| Tests                    | [Tests](https://developer.cisco.com/docs/thousandeyes/v7/tests-api-overview/) (under `Model`) |
| Alert Rules              | [Alert Rule](https://developer.cisco.com/docs/thousandeyes/v7/#!rules)                        |
| Dashboards               | [Dashboards](https://developer.cisco.com/docs/thousandeyes/v7/#!dashboard)                    |

You can also reference the id of another type of asset within each schema you define for each asset. For example, to assign an alert rule asset to a test asset, you can reference the id of a test you are already defining in the configuration file for the template you are creating. Because the ThousandEyes platform creates each template asset type in a specific order, an asset can only reference other assets that are created before it.

The order the ThousandEyes platform creates template assets is:

1. Tags (formerly "Labels")
2. Tests
3. Alert Rules
4. Dashboards

The following table illustrates which assets of a different type each asset can reference:

| Asset Type  | Can Reference            |
| ----------- | ------------------------ |
| Tags        | none                     |
| Tests       | Tags                     |
| Alert Rules | Tags, Tests              |
| Dashboards  | Tags, Tests, Alert Rules |

#### Example Schema

The template schema below describes a straightforward Slack monitor that includes an HTTP server, API test, and DNS test. The target is automatically determined from the Slack tenant name, and the DNS test will automatically determine the name servers.

For more details on each field in the schema below, see the `Model` subsection of the [API Reference](https://developer.cisco.com/docs/thousandeyes/v7/templates-api-overview/).

```
{
    "name": "Slack",
    "description": "Template for creating a set of tests to monitor Slack; will monitor your Slack vanity URL (&lt;tenant&gt;.slack.com), Slack DNS servers, and the Slack API (api.slack.com).",
    "summary": "A template for monitoring your <tenant>.slack.com instance and api.slack.com includes Network, DNS, and Web tests",
    "icon": "slack",
    "isBuiltIn": false,
    "certificationLevel": "user",
    "userInputs": {
        "tenant": {
            "name": "Slack Tenant Name",
            "title": "",
            "description": "Your Slack tenant name; will be used to determine target as &lt;tenant&gt;.slack.com",
            "type": "string"
        },
        "agents": {
            "name": "Which agents should we run tests from?",
            "title": "",
            "type": "any"
        }
    },
    "tests": {
        "apiTest": {
            "interval": 60,
            "type": "http-server",
            "url": "https://api.slack.com",
            "testName": "{{name}} - {{userInputs.tenant}} - API",
            "agents": "{{userInputs.agents}}"
        },
        "tenantTest": {
            "httpInterval": 60,
            "interval": 60,
            "type": "page-load",
            "url": "https://{{userInputs.tenant}}.slack.com",
            "testName": "{{name}} - {{userInputs.tenant}} - Web",
            "agents": "{{userInputs.agents}}"
        },
        "dnsTest": {
            "domain": "{{userInputs.tenant}}.slack.com A",
            "interval": "60",
            "type": "dns-server",
            "dnsServers": [],
            "testName": "{{name}} - {{userInputs.tenant}} - DNS",
            "agents": "{{userInputs.agents}}"
        }
    },
    "labels": {},
    "tags": {},
    "alertRules": {},
    "dashboards": {}
}
```

## User-Defined Templates in ThousandEyes

To view a list of available templates in ThousandEyes, navigate to **Cloud and Enterprise Agents > Test Settings** and click on the **Start Monitoring** button. A list of available templates appears under the section **Start with templates**. For more information about selecting a template, see [Set Up Tests Using Templates](https://docs.thousandeyes.com/product-documentation/tests#set-up-tests-using-templates).

From the list of templates, you can add a new template, duplicate a template, and edit and/or delete user-defined templates your team has created.

### Creating a User-defined Template from Scratch

To define your own template from scratch, navigate to **Cloud and Enterprise Agents > Test Settings** and click on the **Start Monitoring** button. Click on **Build your own template** and specify a JSON schema for your template in the text field.

For more information about creating a template schema, see [Example Schema](https://docs.thousandeyes.com/product-documentation/tests/templates/user-defined-templates#example-schema).

![Create New Template dialog](/files/5Y1xeMEpv6JgXCbE2CHG)

You can preview the template in the next screen. Click the `Confirm & Publish` button to make the template available to users in your account group.

## Creating a User-defined Template from an Existing Template

You don't have to create a template from scratch. You can duplicate an existing template and modify it instead.

1. Find the template you want to duplicate and click the `...` button. Select `Duplicate`. ![Duplicate Template menu](/files/RmL65HWB3Zpeb1w9IYKe)
2. Modify the JSON schema and click `Preview` to preview the template. ![Duplicate Template JSON dialog](/files/qWxAQ07ZY2pOnVsncBFL)
3. Click the `Confirm & Publish` button to make the template available to users in your account group.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thousandeyes.com/product-documentation/tests/templates/user-defined-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
