> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paymentkit.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paymentkit.com/_mcp/server.

# Render a dunning email as the customer would receive it

GET https://app.paymentkit.com/api/{account_id}/dunning/email-preview

Render one dunning email in one language, using this account's branding.

Reference: https://docs.paymentkit.com/api-reference/api-reference/dunning-emails/preview-dunning-email

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://app.paymentkit.com` (Production, default)
- `https://staging.paymentkit.com` (Staging)

## Request

### Path parameters

- `account_id` (string, required)

### Query parameters

- `email_type` (enum, required) — Which dunning email to render. Must be a localized type.
  - Allowed values: `dunning.payment_failed`, `dunning.payment_failed_2`, `dunning.payment_failed_3`, `dunning.payment_failed_4`, `dunning.update_payment_method`, `dunning.final_retry_warning`, `dunning.subscription_cancelled`, `dunning.subscription_past_due`, `dunning.payment_recovered`, `dunning.action_required_1_soft`, `dunning.action_required_2_soft`, `dunning.action_required_3_soft`, `dunning.urgent_soft`, `dunning.action_required_1_hard`, `dunning.action_required_2_hard`, `dunning.action_required_3_hard`, `dunning.urgent_hard`, `dunning.confirmation_cancelled`, `dunning.confirmation_paused_no_cta`, `dunning.confirmation_paused_with_cta`, `dunning.confirmation_active_at_risk`, `dunning.confirmation_active_overdue`
- `language` (string, optional, nullable) — ISO 639-1 code. Defaults to 'en'.

## Response

### 200

Successful Response

- `email_type` (string, required)
- `language` (string, required)
- `language_reviewed` (boolean, required)
- `subject` (string, required)
- `html` (string, required)
- `text` (string, required)
- `available_languages` (list of PreviewLanguage, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### PreviewLanguage

- `code` (string, required) — ISO 639-1 primary subtag, e.g. 'es'
- `label` (string, required) — The language's own name (endonym)
- `reviewed` (boolean, required) — True when a human has signed off this catalog and customers can receive it. False means preview-only: the send path falls back to English.

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "email_type": "string",
  "language": "string",
  "language_reviewed": true,
  "subject": "string",
  "html": "string",
  "text": "string",
  "available_languages": [
    {
      "code": "string",
      "label": "string",
      "reviewed": true
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.paymentkit.com/api/account_id/dunning/email-preview"

querystring = {"email_type":"dunning.payment_failed"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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

```go
package main

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

func main() {

	url := "https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed"

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

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

url = URI("https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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

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

HttpResponse<String> response = Unirest.get("https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.paymentkit.com/api/account_id/dunning/email-preview?email_type=dunning.payment_failed")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```