> For a complete page index, fetch https://developer.close.com/llms.txt

# Render an email template

GET https://api.close.com/api/v1/email_template/{id}/render/

Render an email template for the given lead/contact using the current user context.

Accepts two forms of usage:

- Single lead/contact:
  - `lead_id` and `contact_id` is supplied (both required)
- Preview results from a search query
  - `query` (required) contains a search query
  - `entry` (optional, ranges from 0 to 99) specifies the index of the lead/contact that should be rendered.
  - `mode` (optional), which can have a value of:
     - `lead` (default), the first contact of the lead with the index given by `entry` will be rendered (excluding leads that have no email addresses).
     - `contact`, then `entry` refers to the index of the contact (excluding contacts that have no emails). Will return an empty dict if there are no more entries.

Reference: https://developer.close.com/api/resources/email-templates/render

## Authentication

- `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty.
- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `id` (string, required)

### Query parameters

- `email_account_id` (string, optional)
- `bulk_object_type` (enum, optional)
  - Allowed values: `lead`, `contact`
- `contact_id` (string, optional)
- `contact_preference` (enum, optional)
  - Allowed values: `lead`, `contact`, `all`
- `entry` (integer, optional)
- `lead_id` (string, optional)
- `limit` (integer, optional)
- `query` (string, optional)
- `results_limit` (integer, optional)
- `s_query` (string, optional)
- `sender` (string, optional)
- `sort` (list of object, optional)
  - `direction` (enum, required)
    - Allowed values: `asc`, `desc`
  - `field` (string, required)
- `mode` (enum, optional)
  - Allowed values: `lead`, `contact`

## Response

### 200

Successful response

## Errors

### 400 Bad Request Error

Bad request

- `any`

### 401 Unauthorized Error

Unauthorized

- `any`

### 404 Not Found Error

Not found

- `any`

## Examples

**Response**

```json
{
  "body": "Hi John,\n\nI hope you are having a great day.\n\nFrom,\nPhil\nphil@close.com",
  "contact_display_name": "John Smith",
  "contact_id": "cont_NdKMSOuamgB8ZlbNJW2WP17hfL3jQmf0hW6X8ichwQk",
  "email": "john@example.com",
  "lead_display_name": "Bluth Company",
  "lead_id": "lead_vYaUG0D39KdBeqVHbPkmvqaYopsdCBmDXW3tvJgwc2L",
  "subject": "Checking In"
}
```

**SDK Code**

```python email_templates_render_example
import requests

url = "https://api.close.com/api/v1/email_template/id/render/"

response = requests.get(url, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript email_templates_render_example
const url = 'https://api.close.com/api/v1/email_template/id/render/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {method: 'GET', headers: {Authorization: `Basic ${credentials}`}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go email_templates_render_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.close.com/api/v1/email_template/id/render/"

	req, _ := http.NewRequest("GET", url, nil)

	req.SetBasicAuth("<CLOSE_API_KEY>", "")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby email_templates_render_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/email_template/id/render/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")

response = http.request(request)
puts response.read_body
```

```java email_templates_render_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.close.com/api/v1/email_template/id/render/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .asString();
```

```php email_templates_render_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.close.com/api/v1/email_template/id/render/', [
  'headers' => [
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp email_templates_render_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/email_template/id/render/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.GET);

IRestResponse response = client.Execute(request);
```