# Preview a client template — API reference

> Previews a Client template for a Client using supplied name, slug, contact email and domain values.

Source: https://upfour.io/docs/api/client-templates/preview-a-client-template

[Developers](https://upfour.io/docs/api.md)/[Client templates](https://upfour.io/docs/api/client-templates.md)

Previews a Client template for a Client using supplied name, slug, contact email and domain values.

POST https://app.upfour.io/v1/client-templates/{templateID}/dry-run

scope client.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 200

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `templateID` required | uuid | path parameter |

## Body

`application/json` required 5 fields

client_iduuid (required)

The client to preview the template for.

All other fields4 fields

client_namestring

Fills {{client_name}}.

client_slugstring

Fills {{client_slug}}.

contact_emailstring

Fills {{contact_email}}.

domainstring

Fills {{domain}}. Required when the template uses it.

## Returns

A successful request returns `200` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | TemplateDryRunResult | |
| TemplateDryRunResult · 32 fields FieldTypeDescription `monitors` TemplateMonitorPreview[]  · nullable Each item · 11 fields FieldTypeDescription `alarm_route_status` string one of`configured` `without_alarm_route` `name` string `channels` MaterializedChannel[] Each item · 4 fields FieldTypeDescription `id` uuid `name` string `scope` string `type` string `warnings` MaterializeError[] Each item · 3 fields FieldTypeDescription `kind` string one of`template` `monitor` `monitor_alarm_route` `policy` `status_page` `message` string `name` string `policies` TemplatePolicyPreview[]  · nullable Each item · 7 fields FieldTypeDescription `channels` MaterializedChannel[]  · nullable Each item · 4 fields FieldTypeDescription `id` uuid `name` string `scope` string `type` string `name` string `step_count` integer `status_pages` TemplateStatusPagePreview[]  · nullable Each item · 11 fields FieldTypeDescription `design` TemplateStatusPageDesignPreview  · nullable TemplateStatusPageDesignPreview · 8 fields FieldTypeDescription `apply_assets` boolean `apply_css` boolean `asset_kinds` string[]  · nullable `id` uuid `includes_css` boolean `layout` string `name` string `revision` integer `name` string `subdomain` string | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 409 | [design_template_conflict](https://upfour.io/docs/api/errors#code-design_template_conflict) | The design template was changed after the caller read it. **When:** Updating or applying a design template that was changed after the caller read it. **Fix:** Reload the template and apply the change again. |
| 404 | [design_template_not_found](https://upfour.io/docs/api/errors#code-design_template_not_found) | The design template does not exist or is not visible to the caller. **When:** A design template id in the path or body that is unknown or not visible to the caller. **Fix:** List design templates and use an id from the list. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousDelete a client template](https://upfour.io/docs/api/client-templates/delete-a-client-template.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/client-templates/00000000-0000-4000-8000-000000000001/dry-run" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "client_id": "00000000-0000-4000-8000-000000000002",
    "client_name": "Globex Corporation",
    "domain": "globex.example"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/client-templates/00000000-0000-4000-8000-000000000001/dry-run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    client_id: "00000000-0000-4000-8000-000000000002",
    client_name: "Globex Corporation",
    domain: "globex.example",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/client-templates/00000000-0000-4000-8000-000000000001/dry-run",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "client_id": "00000000-0000-4000-8000-000000000002",
        "client_name": "Globex Corporation",
        "domain": "globex.example",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "client_id": "00000000-0000-4000-8000-000000000002",
  "client_name": "Globex Corporation",
  "domain": "globex.example"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/client-templates/00000000-0000-4000-8000-000000000001/dry-run", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "client_id": "00000000-0000-4000-8000-000000000002",
  "client_name": "Globex Corporation",
  "domain": "globex.example"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/client-templates/00000000-0000-4000-8000-000000000001/dry-run");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{
  "data": {
    "monitors": [
      {
        "alarm_route_status": "configured",
        "channels": [
          {
            "id": "00000000-0000-4000-8000-000000000003",
            "name": "Email · anna@example.com",
            "scope": "organization",
            "type": "email"
          }
        ],
        "name": "globex.example"
      }
    ],
    "policies": [],
    "status_pages": []
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "design_template_not_found",
    "message": "The design template does not exist or is not visible to the caller.",
    "request_id": "req_…"
  }
}
```

### 409

```json
{
  "error": {
    "code": "design_template_conflict",
    "message": "The design template was changed after the caller read it.",
    "request_id": "req_…"
  }
}
```
