[[render-search-template-api]]
=== Render search template API
++++
Render search template
++++
Renders a <> as a <>.
////
[source,console]
----
PUT _scripts/my-search-template
{
  "script": {
    "lang": "mustache",
    "source": {
      "query": {
        "match": {
          "message": "{{query_string}}"
        }
      },
      "from": "{{from}}",
      "size": "{{size}}"
    },
    "params": {
      "query_string": "My query string"
    }
  }
}
----
// TESTSETUP
////
[source,console]
----
POST _render/template
{
  "id": "my-search-template",
  "params": {
    "query_string": "hello world",
    "from": 20,
    "size": 10
  }
}
----
[[render-search-template-api-request]]
==== {api-request-title}
`GET _render/template`
`GET _render/template/`
`POST _render/template`
`POST _render/template/`
[[render-search-template-api-prereqs]]
==== {api-prereq-title}
* If the {es} {security-features} are enabled, you must have the `read`
<> for at least one index pattern.
[[render-search-template-api-path-params]]
==== {api-path-parms-title}
``::
(Required*, string) ID of the search template to render. If no `source` is
specified, this or the `id` request body parameter is required.
[[render-search-template-api-request-body]]
==== {api-request-body-title}
`id`::
(Required*, string) ID of the search template to render. If no `source` is
specified, this or the `` request path parameter is required. If
you specify both this parameter and the `` parameter, the API uses
only ``.
`params`::
(Optional, object) Key-value pairs used to replace Mustache variables in the
template. The key is the variable name. The value is the variable value.
`source`::
(Required*, object) An inline search template. Supports the same parameters as
the <>'s request body. These parameters also support
https://mustache.github.io/[Mustache] variables. If no `id` or ``
is specified, this parameter is required.