---
search:
  tags:
    - Themes
    - POST
seo:
  description: >-
    Creates a new template file inside the theme. The file_name determines the…
    Reference for the POST /themes/{theme_id}/templates endpoint in the Bolder
    API v2.
sidebar:
  label: Create a template
  badge: POST
title: Create a template
type: openapi-operation
---
Creates a new template file inside the theme. The `file_name` determines
the template type (e.g. `layout.html`, `product.html`, `custom.css`).

`POST /themes/{theme_id}/templates`

**Request body** (`application/json`, required)

- `file_name` (string, required) — Template filename (determines type)
- `body` (string) — Template source code

Request body example:

```json
{
  "file_name": "collection.html",
  "body": "<h1>{{ collection.name }}</h1>"
}
```

**Responses**

- `201` — Template created
- `401` — Unauthorized
- `403` — Access denied
- `422` — Validation error

Response example, 201:

```json
{
  "_links": {
    "property1": {
      "href": "string",
      "templated": true,
      "method": "get",
      "title": "string",
      "type": "string"
    },
    "property2": {
      "href": "string",
      "templated": true,
      "method": "get",
      "title": "string",
      "type": "string"
    }
  },
  "id": "string",
  "file_name": "layout.html",
  "path": "string",
  "body": "string",
  "is_section": true,
  "schema": {},
  "parent_commit": "string",
  "updated_on": "2019-08-24T14:15:22Z"
}
```
