---
title: "Add template file"
type: reference
method: POST
path: /rest-api/template/template-file/edit.do
tag: "Templates"
---

# Add template file

`POST https://YOUR-NETWORK-DOMAIN/rest-api/template/template-file/edit.do`

Uploads and attaches a new file to the specified template using a multipart form submission. The file is stored with its original filename, MIME content type, and an MD5 checksum for integrity verification. The macro key for the file must be unique within the template and must not conflict with any reserved system macros or existing property keys. The template version is automatically incremented after the file is added. Requires edit permission on the template.

## Query params

| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| `templateId` | integer | yes | `300` | Unique numeric identifier of the template to add the file to |
| `key` | string | no | `$$LOGO$$` | File key used in template content (format: $$KEY$$) |

## Body

A multipart form: `commonsMultipartFile` (file).

## Responses

- `200` — Operation result with success status
- `400` — Bad request — invalid or missing parameters
- `401` — Authentication error
- `403` — Forbidden — insufficient permissions

## Example request

```bash
curl --request POST \
  --url 'https://YOUR-NETWORK-DOMAIN/rest-api/template/template-file/edit.do?templateId=300&key=%24%24LOGO%24%24' \
  --header 'X-Api-Key: YOUR_API_KEY' \
  --form 'commonsMultipartFile=@logo.png'
```

Source: https://epom.com/ad-server/docs/api/templates/post-template-template-file-edit