# Preview a widget without saving it

> Source: https://elaichi.ai/docs/api-reference/dashboards/dashboard/previewdashboardwidget/

`POST /dashboard/preview-widget`

Resource: **Dashboard** · API: **Dashboards**

## Query parameters

- **`tz`** _(string)_

## Request body

- **`widget`** _(unknown)_

## Response body

- **`widget_key`** _(string)_
- **`kind`** _(string)_
  Allowed: `metric`, `chart`, `table`, `markdown`
- **`state`** _(string)_
  Allowed: `ok`, `empty`, `no_access`, `source_error`
- **`data`** _(unknown)_
- **`disclosure`** _(object,null)_
- **`table_page`** _(object,null)_
- **`row_visibility`** _(string,null)_
- **`fetched_at`** _(string,null)_
- **`expires_at`** _(string,null)_
- **`cached`** _(boolean)_
- **`stale`** _(boolean)_
- **`throttled`** _(boolean)_
- **`error`** _(object,null)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/dashboard/preview-widget' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### JavaScript

```javascript
const body = {};

const response = await fetch('https://api.elaichi.ai/dashboard/preview-widget', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import os
import requests

url = "https://api.elaichi.ai/dashboard/preview-widget"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```
