# Render template as HTML

> **POST** `https://api.us.nylas.com/v3/grants/{grant_id}/templates/render`

Source: https://developer.nylas.com/docs/reference/api/grant-level-templates/render-grant-level-template-html/

Renders the HTML content of a grant-level template using the provided variables and specified
templating engine.

**Authentication:** NYLAS_API_KEY, ACCESS_TOKEN

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `grant_id` | string | Yes | ID of the grant to access. You can also use the email address associated with the grant, or use `/me/` to refer to the grant associated with an access token. |

## Request body

Content-Type: application/json

- `body` (string) **(required)** - The body content of the template, in HTML format.
- `engine` (string) **(required)** - The templating engine to use.
- `strict` (boolean) - When `true`, Nylas returns an error if the template contains variables that aren't defined
in the `variables` object.
- `variables` (object) **(required)** - A set of key/value pairs representing variables to substitute for values in the
template.

## Responses

### 200 - Success. Returns rendered HTML.

- `request_id` (string) **(required)** - The ID of the request.
- `data` (object) **(required)**
  - `body` (string) **(required)** - The rendered HTML with variables substituted.

### 400 - Error: Bad request



## Code samples

### cURL

```bash
curl --request POST \
  --url "https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/templates/render" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "body": "<p>Hello from {{user.name}}, test {{ foo }}</p>",
    "variables": {
      "user": {
        "name": "Nylas",
        "surname": "Tester"
      },
      "foo": "hi"
    },
    "engine": "mustache"
  }'
```
