> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.templated.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# "Managing Templates via API: Create, Update, Delete Layers, Clone, Duplicate, Folders and Tags"

Besides rendering, the Templated API lets you manage your templates. All requests use `https://api.templated.io` and the header `Authorization: Bearer YOUR_API_KEY`.

## Create a template

`POST /v1/template` with `name`, `width`, `height` and a `layers` array (or a `pages` array for multi-page templates). Each layer needs a `layer` (its name) and a `type` (`text`, `image`, `shape`...).

```json
{
  "name": "Social Post",
  "width": 1080,
  "height": 1080,
  "layers": [
    { "layer": "title", "type": "text", "text": "Hello", "x": 80, "y": 80, "width": 920, "height": 200, "font_size": "64px", "color": "#000000" },
    { "layer": "photo", "type": "image", "image_url": "https://example.com/photo.jpg", "x": 0, "y": 400, "width": 1080, "height": 680 }
  ]
}
```

- Maximum width and height: 5000 px.
- New templates count toward your plan's template limit. If you are at the limit, the API returns 403 "You've reached your template limit."
- Docs: https://templated.io/docs/templates/create/

## Update a template

`PUT /v1/template/{id}`. By default this is a partial update: only the layers you send are changed or added. Other layers stay as they are.

Tips for reliable updates:

- For each layer you send, include `layer` and `type`.
- When you move a layer, send both `x` and `y`.
- Check the result with `GET /v1/template/{id}/layers`.

You can also set `min_font_size`, `max_font_size` (for autofit) and `locked` on a layer. If you leave one of these out, it keeps its current value.

For multi-page templates, use the `pages` array. A page name that does not exist yet is added to the template.

Docs: https://templated.io/docs/templates/update/

## Delete a layer

There is no "delete layer" endpoint. Use a full replace:

`PUT /v1/template/{id}?replaceLayers=true`

With `replaceLayers=true`, any layer not included in your request is removed. Send every layer you want to keep.

To remove a whole page from a multi-page template, send that page in the `pages` array with `"hide": true`. This deletes the page from the template.

## Delete a template

`DELETE /v1/template/{id}` returns `204 No Content`. Deleting via API is permanent. If you deleted a template by mistake, ask in the chat with your account email and the template ID. The team will check if it can be restored.

## Clone a template

`POST /v1/template/{id}/clone` (optional `?name=`).

- A clone is a copy linked to the original through `sourceTemplateId`.
- Clones **do not count** toward your template limit.
- Clones **are not shown in the dashboard**. List them with `GET /v1/templates/clones`.
- Docs: https://templated.io/docs/templates/clone/

## Duplicate a template

`POST /v1/template/{id}/duplicate` (optional `?name=`).

- A duplicate is a normal template. It shows in your dashboard and counts toward your template limit.
- Docs: https://templated.io/docs/templates/duplicate/

**Clone or duplicate?** Use a clone for per-customer or per-user copies that live only in your app. Use a duplicate when you want a new template to edit in the dashboard.

## Create a template from a render

`POST /v1/template/from-render/{renderId}` creates a clone of the template with all the changes of that render applied. Useful to adjust one render (move a text, crop an image) and render it again. It is free (no credits) and the result is a clone. Docs: https://templated.io/docs/templates/create-from-render/

## Folders

- Create a folder: `POST /v1/folder` with `{ "name": "My Folder" }`
- List folders: `GET /v1/folders`
- List templates in a folder: `GET /v1/folder/{folderId}/templates`
- Move a template to a folder: `PUT /v1/folder/{folderId}/template/{templateId}`
- Docs: https://templated.io/docs/folders/create/

Subfolders are not supported. Use tags for extra organization.

### Duplicate a whole folder

There is no single endpoint for this. Do it in three steps:

1. Create the new folder with `POST /v1/folder`.
2. List the templates of the original folder with `GET /v1/folder/{folderId}/templates`.
3. For each template, call `POST /v1/template/{id}/duplicate`, then move the copy with `PUT /v1/folder/{newFolderId}/template/{newTemplateId}`.

Each duplicate counts toward your template limit.

## Tags

- Add tags: `POST /v1/template/{id}/tags` with an array of strings, for example `["summer", "instagram"]`
- Remove tags: `DELETE /v1/template/{id}/tags`
- Replace all tags: `PUT /v1/template/{id}/tags`
- Filter templates by tags: `GET /v1/templates?tags=summer,instagram`
- Docs: https://templated.io/docs/templates/add-tags/

## Locked layers

Lock a layer to keep the structure of a template fixed (backgrounds, logos, frames).

- Locked layers cannot be moved or edited in the editor.
- Locked layers are **not returned** by `GET /v1/template/{id}/layers` and `GET /v1/template/{id}/pages`. Add `?includeLockedLayers=true` to include them.
- Lock or unlock via API with `"locked": true` or `"locked": false` when creating or updating a template. It has no effect in render requests.

## FAQ

Q: How do I delete a layer from a template via API?
A: Call `PUT /v1/template/{id}?replaceLayers=true` and send all the layers you want to keep. Layers not included are removed.

Q: Do cloned templates count toward my template limit?
A: No. Clones do not count and are not shown in the dashboard. Duplicates do count.

Q: Where are my cloned templates?
A: Clones are only available through the API. List them with `GET /v1/templates/clones`.

Q: Can I create subfolders?
A: No. Use tags to organize templates inside a folder.

Q: How do I copy a whole folder?
A: Create a new folder, list the templates of the old folder, duplicate each template and move each copy to the new folder.

Q: Why is a layer missing from the layers endpoint?
A: It is probably locked. Add `?includeLockedLayers=true`.

Q: Can I edit a render and render it again?
A: Yes. Use `POST /v1/template/from-render/{renderId}`, update the new template, then render it.

Q: I deleted a template by mistake. Can it be restored?
A: Ask in the chat with your account email and the template ID. The team will check.