> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/platform-apis/templates.md).

# Templates

Create, update, and validate pipeline, stage, and step templates with the Harness Templates API.

The Templates API manages the reusable pipeline, stage, and step templates that teams share across projects.

## Request basics

* **API key token**: Send it in the `x-api-key` header on every request. Go to [Manage API keys](https://developer.harness.io/harness-platform/use-harness-platform/automation/api/add-and-manage-api-keys) to create a key and token.
* **Account, organization, and project IDs**: Send `accountIdentifier` as a query parameter on every request. Add `orgIdentifier` and `projectIdentifier` for templates that live in an organization or project. Go to [Organizations and projects](https://developer.harness.io/harness-platform/use-harness-platform/organizations-and-projects) to find these identifiers.
* **Base URL**: Send requests to `https://app.harness.io/gateway/template/api`, followed by the endpoint path.

## Example request

List the stable versions of the templates in a project:

```bash
curl -X POST "https://app.harness.io/gateway/template/api/templates/list-metadata?accountIdentifier=ACCOUNT_ID&orgIdentifier=ORG_ID&projectIdentifier=PROJECT_ID&templateListType=Stable" \
  -H "x-api-key: $HARNESS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filterType": "Template"}'
```

Replace `ACCOUNT_ID`, `ORG_ID`, and `PROJECT_ID` with your own values, and set `HARNESS_API_KEY` to your API key token.

## Find an endpoint

Endpoint paths are relative to the base URL.

* **Templates**: Versioned definitions of a pipeline, stage, step, or step group that other pipelines reference and inherit changes from. List templates with `POST /templates/list-metadata`, read one with `GET /templates/{templateIdentifier}`, and create one with `POST /templates`. Go to [Templates overview](https://developer.harness.io/harness-platform/use-harness-platform/templates/template) to understand how templates work.
* **Template validation**: Checks that a template's inputs still match the pipelines that use it, and updates them when they drift. Check a YAML's template inputs with `GET /refresh-template/validate-template-inputs`, and get the updated YAML with `POST /refresh-template/refreshed-yaml`. Go to [Use a template](https://developer.harness.io/harness-platform/use-harness-platform/templates/use-a-template) to use a template in a pipeline.
* **Template filters**: Saved searches for finding templates by type, scope, or tag. List saved filters with `GET /filters`. Go to [Templates](https://developer.harness.io/harness-platform/use-harness-platform/templates) to find templates.
