> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/admin/templates/list-email-templates-with-their-metadata.md).

# List email templates with their metadata

Returns every email template the platform sends, each with the metadata needed to manage it: its name, its type, the path of its body and subject templates, the dynamic variables usable inside it, and the timestamps of the stored override that backs it (if any).

`type` groups the templates by the message they belong to — for example `order` for order-related mails, `account` for account mails such as the password reset, and `loyalty`, `user`, `promotions`, `tradein`, `wishlists` or `agreement` for the rest. It is derived from the template path and is fixed by the platform.

`subject` and `subject_path` describe the paired subject-line template, matched to the body template by the `<name>-subject.<extension>` convention. They are `null` when a template has no paired subject template (for example, a subject template listed in its own right).

`available_variables` maps each dynamic variable the platform passes into that template's render context to its accessible-field schema, so an editor knows both what may be referenced and which sub-fields each variable exposes. Object variables map to a nested object of their fields (a one-element array for collections); scalar variables map to a plain placeholder.

Subject templates are not returned as their own rows; each body template carries its paired subject in `subject` and `subject_path`.

`created_at` and `updated_at` are taken from the stored template override whose name matches the path (see the **Store a template** endpoint). They are `null` when no override is stored — the template is then served from the file on disk, which carries no such timestamps.

`product_data_schema` at the top level describes the product-card structure that order emails can reference for each product, as a nested field schema in the same shape as a template's `available_variables`, so hidden or unwanted fields can be managed against a known shape.

The response is not paginated and does not accept parameters.

```json
{"openapi":"3.1.0","info":{"title":"Admin API","version":"1.0.0"},"tags":[{"name":"Templates","description":"Administrative endpoints for **stored templates** — the template sources kept in the database and rendered in place of the template files shipped with the project. They are how the markup of an email, an SMS message or a storefront page is changed for a single store, or per language, without a deployment.\n\nA stored template does not introduce a new template: it overrides an existing one. Its `name` is the path of the template file it stands in for — `emails/orders/completed.html`, for example — and each record is bound to one language and to one or more sites. When that template is rendered, the stored source is used if a record matches the name, the language of the request and the current site; otherwise the file on disk is used, so removing or deactivating a record restores the original template.\n\n## Core Capabilities\n\n**1. Listing & Filtering**\n* Retrieve a paginated list of stored templates, ordered by name ascending unless the `sort` parameter says otherwise.\n* Filter by name, by active state and by site. Names match the whole value exactly; a partial name returns an empty page.\n* Deactivated templates stay in the list — filter on `is_active` to separate them from the ones in use.\n\n**2. Full CRUD**\n* Store a template for a language and one or more sites, fully or partially update it, and deactivate it.\n* `DELETE` **deactivates** the record rather than removing it. See **Deleting a Template** for what that means for the name.\n\n**3. Overridable Template Names**\n* The names of the email and SMS templates the platform sends are listed by a dedicated operation, so a client does not have to know the template paths in advance.\n\n**4. Site & Language Binding**\n* A name is normally stored once per language and site, which is what allows one store to override a template for one language only. See **Uniqueness** for the case where that rule is not enforced.\n\n## How a Stored Template Is Used\n\nStoring a record is not by itself enough for it to be rendered. All of the following must hold at the moment the template is rendered:\n\n| Condition | Detail |\n|-----------|--------|\n| The database loader is enabled | The template engine of the deployment must be configured to look in the database. See **Dynamic Settings & Environment Variables** — in a deployment that is not configured for it, stored templates are accepted by these endpoints but never rendered. |\n| The name matches exactly | The `name` must equal the path of the template being rendered, extension included. A name that differs by a character, or that is missing the extension, overrides nothing. |\n| The record is active | A record whose `is_active` is `false` is skipped, and the template file is used instead. |\n| A site matches | The record must list the site the request is served for. A record with no sites is never rendered. |\n| The language matches | The record must be stored for the language of the request. When no record exists for that language, the record stored for the default language of the deployment is used; when there is none, the template file is used. |\n\nTwo further points are worth knowing:\n\n* **Names beginning with `admin/` are never served from the database.** Management-panel templates are always read from disk.\n* **Changes are not visible immediately.** The lookup is cached — for up to five minutes in a standard deployment — so a newly stored, updated or deactivated template takes a few minutes to take effect on the storefront. This applies to deactivation as well. A deployment that also configures the shorter cache layers of the platform stacks a one-minute and a three-minute layer in front of that one, which can stretch the wait further.\n\n## Fields\n\n| Field | Description |\n|-------|-------------|\n| `pk` | Unique identifier of the record. Assigned by the server; ignored if sent. |\n| `name` | The path of the template being overridden, at most 100 characters. Required. Surrounding whitespace and any leading slashes are removed before the value is stored, so `/emails/base.html` is stored as `emails/base.html`. |\n| `content` | The template source. Required and may not be empty. It is stored as sent and is not checked for syntax errors, so a record with a broken template is accepted here and fails when the template is rendered. |\n| `language` | The language the record applies to. Required, and must be one of the languages configured for the deployment. |\n| `is_active` | Whether the record is used when the template is rendered. Optional; defaults to `true`. |\n| `sites` | The sites the record applies to, given as an array of site identifiers. Optional — see **Site Binding** for what omitting it means on each operation. |\n| `created_date` | When the record was created. Read-only. |\n| `modified_date` | When the record was last modified. Read-only. |\n\n## Site Binding\n\nThe `sites` array behaves differently on each operation, and an empty array is not a way to clear it:\n\n| Operation | Behaviour when `sites` is omitted or empty |\n|-----------|-------------------------------------------|\n| Create | The record is bound to the current site of the request. |\n| Full and partial update | The stored sites are left untouched. There is no way to unbind every site through these endpoints; send the sites the record should apply to instead. |\n\nA non-empty array replaces the stored sites completely rather than adding to them. Every identifier must belong to an existing site; an unknown identifier fails the request.\n\n## Uniqueness\n\nA name is meant to be stored only once per site and language. A create or update that repeats an existing combination is rejected with a message naming the site and the language that conflict; the message is returned in the language of the request, so match on the response status rather than on its wording.\n\nThe check covers deactivated records too, so a name occupied by a deactivated record cannot be stored again — see **Deleting a Template**.\n\nWhich sites the check runs against depends on the request:\n\n| Request | Sites checked |\n|---------|---------------|\n| Create without `sites` | The current site of the request. |\n| Create or update with a non-empty `sites` | The sites in the request. |\n| Update without `sites` | The sites the record is already bound to. |\n| Any request with an empty `sites` array | None — and with no site to check against, **the check is skipped entirely**. |\n\n> **Important:** Send these requests as JSON. A form-encoded request always carries `sites` as an empty array, even when the field is left out of the form, and the uniqueness check is therefore never applied to it: the duplicate is accepted and stored. Two records with the same name, language and site break the storefront lookup for that template, because the lookup expects at most one.\n\n## Deleting a Template\n\n> **Important:** `DELETE` does not remove the record. It sets `is_active` to `false` and returns `204 No Content`; the record keeps appearing in the list and can be retrieved by its identifier.\n\nTwo consequences follow. The template file on disk takes over again once the cached lookup expires, which is the intended effect. But the name stays occupied: storing the same name for the same site and language again is rejected, and the way to bring the template back is to set `is_active` to `true` on the existing record rather than to create a new one.\n\n## Partially Updating a Name\n\nWhen a partial update changes `name`, include `language` in the same request. A partial update that sends `name` without `language` cannot complete the uniqueness check and fails with a server error — unless there is no site to check against, in which case the check does not run and the request succeeds. A full update is unaffected, because `language` is required there.\n\n## Sorting\n\nThe `sort` parameter accepts `pk`, `name`, `content`, `language`, `is_active`, `created_date` and `modified_date`. Prefix a field with a hyphen for descending order. Any other value is ignored and the default ordering by name is kept.\n\n> **Do not sort by `sites`.** The value is accepted, but a record bound to several sites is then repeated once per site while the page count keeps counting records rather than rows — so the page fills up with repetitions and other records fall off it entirely.\n\nSorting by `content` is accepted too and orders records by their raw template source, which rarely produces a useful order.\n\n## Dynamic Settings & Environment Variables\n\nNo dynamic setting changes the behaviour of the endpoints described here: every action stays available and behaves identically regardless of how the settings are configured. The two settings below relate to the templates managed here at the point where they are **used**.\n\n| Key | Type | Default | Effect |\n|-----|------|---------|--------|\n| `DB_TEMPLATES_PREFIXES` | array of strings | `[\"emails\", \"sms\"]` | **Deprecated and without effect.** It once did two things: it rejected a `name` whose first path segment was not one of these prefixes, and it kept the database from being consulted for any other template. Both checks were removed, and the value is no longer read anywhere — a name under any prefix is stored and overrides its template all the same. |\n| `DISABLED_EMAIL_TEMPLATES` | object mapping a template path (without its extension) to a boolean | every email template enabled, except the order-preparing email, which is disabled | A per-template kill switch for outbound emails. It does not affect these endpoints — a template stored for a disabled email is created and returned normally — but the email is never sent, so the stored template is never rendered. |\n\n**Environment variables:** The following deployment configuration decides whether and how stored templates are used. None of it is read by these endpoints themselves, so a misconfigured deployment gives no error here.\n\n| Variable | Effect |\n|----------|--------|\n| `TEMPLATE_LOADER` | **Decides whether stored templates are used at all.** The database is consulted only while this is set to the loader that reads templates from the database and falls back to the files on disk (`omnicore.dbtemplates.jinja_loaders.DatabaseAndFileSystemLoader`); that is the default in a cloud-mode deployment. In a deployment that keeps the file-system-only loader — which is the default outside cloud mode — records created through these endpoints are stored but never rendered. |\n| `LANGUAGES` | The languages a record may be stored for. A `language` outside this list fails validation. Given as comma-separated `code=name` pairs, for example `tr-tr=Turkish,en-us=English`. |\n| `LANGUAGE_CODE` | The default language of the deployment, used as the fallback when no record is stored for the language of the request. |\n| `DB_TEMPLATES_MODEL` | Selects which record type these endpoints manage. Unlike the three above it is not read from an environment variable but from the deployment configuration itself, and it is left unset in a standard deployment — the templates of the content-management module are managed then. |"}],"servers":[{"description":"Omnitron Remote Proxy (external access — recommended)","url":"https://{omnitron_url}/api/v1/remote/{channel_id}","variables":{"omnitron_url":{"default":"sandbox.akinon.com","description":"Omnitron server URL (e.g., {omnitron.akinon.com})"},"channel_id":{"default":"1","description":"The channel identifier the remote request is routed through"}}},{"description":"Commerce API Server (internal / direct access only)","url":"https://{commerce_url}/api/v1","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Internal commerce server URL, reachable only from within the Omnitron network"}}}],"security":[{"tokenAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token credential sent in the Authorization header, in the form: `Token <your-token>`. Requires a staff (admin) account."}},"schemas":{"EmailTemplateCatalog":{"type":"object","description":"Every email template with its metadata, plus the field list of the product-card structure order emails can reference.","properties":{"product_data_schema":{"type":"object","description":"The product-card structure available to order emails, as a nested field schema in the same shape as a template's `available_variables`: nested objects expand to their fields, collections to a one-element array of the item schema, and scalar fields to a placeholder string.","additionalProperties":true},"templates":{"type":"array","description":"The email templates and their metadata.","items":{"$ref":"#/components/schemas/EmailTemplateDetail"}}},"required":["product_data_schema","templates"]},"EmailTemplateDetail":{"type":"object","description":"One email template and the metadata needed to manage it.","properties":{"name":{"type":"string","description":"The template key."},"type":{"type":"string","description":"The message group the template belongs to, derived from its path."},"path":{"type":"string","description":"The path of the body template. This is also the `name` to store as an override."},"subject":{"type":["string","null"],"description":"A human-readable description of the paired subject-line template, or `null` when there is none."},"subject_path":{"type":["string","null"],"description":"The path of the paired subject-line template, or `null` when there is none."},"created_at":{"type":["string","null"],"format":"date-time","description":"When the stored override for this path was first created, or `null` when no override is stored."},"updated_at":{"type":["string","null"],"format":"date-time","description":"When the stored override for this path was last updated, or `null` when no override is stored."},"available_variables":{"type":"object","description":"Maps each dynamic variable usable inside the template to its accessible-field schema. Object variables map to a nested object of their fields (a one-element array for a collection); scalar variables map to a plain placeholder string.","additionalProperties":true}},"required":["name","type","path","subject","subject_path","created_at","updated_at","available_variables"]},"Error":{"type":"object","description":"An error response.","properties":{"detail":{"type":"string","description":"A human-readable description of the error."}},"additionalProperties":true}},"responses":{"Unauthorized":{"description":"Authentication credentials were not provided or are invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"The authenticated user does not have administrator privileges.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/templates/email_templates/":{"get":{"tags":["Templates"],"operationId":"listEmailTemplates","summary":"List email templates with their metadata","description":"Returns every email template the platform sends, each with the metadata needed to manage it: its name, its type, the path of its body and subject templates, the dynamic variables usable inside it, and the timestamps of the stored override that backs it (if any).\n\n`type` groups the templates by the message they belong to — for example `order` for order-related mails, `account` for account mails such as the password reset, and `loyalty`, `user`, `promotions`, `tradein`, `wishlists` or `agreement` for the rest. It is derived from the template path and is fixed by the platform.\n\n`subject` and `subject_path` describe the paired subject-line template, matched to the body template by the `<name>-subject.<extension>` convention. They are `null` when a template has no paired subject template (for example, a subject template listed in its own right).\n\n`available_variables` maps each dynamic variable the platform passes into that template's render context to its accessible-field schema, so an editor knows both what may be referenced and which sub-fields each variable exposes. Object variables map to a nested object of their fields (a one-element array for collections); scalar variables map to a plain placeholder.\n\nSubject templates are not returned as their own rows; each body template carries its paired subject in `subject` and `subject_path`.\n\n`created_at` and `updated_at` are taken from the stored template override whose name matches the path (see the **Store a template** endpoint). They are `null` when no override is stored — the template is then served from the file on disk, which carries no such timestamps.\n\n`product_data_schema` at the top level describes the product-card structure that order emails can reference for each product, as a nested field schema in the same shape as a template's `available_variables`, so hidden or unwanted fields can be managed against a known shape.\n\nThe response is not paginated and does not accept parameters.","responses":{"200":{"description":"The email templates and the product-card field list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailTemplateCatalog"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/admin/templates/list-email-templates-with-their-metadata.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
