# Execute multiple widget data queries in one request

> Source: https://docs.clonepartner.com/api-reference/dashboards/execute-dashboard-widgets/

`POST /api/dashboards/{id}/widgets/data`

Parses the dashboard YAML once, loads job context once, reuses connector
instances, and runs selected widgets with a concurrency cap. Per-widget
errors are returned inline without failing the whole batch.

**Operation ID:** `executeDashboardWidgets`

## Authentication

### Option 1

- **BearerAuth** (`http bearer`)
  API key token. Create via POST /api/api-keys. Format: `envoy_<hex>`

### Option 2

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Path parameters

- `id` — `integer`, `required`
  Resource ID

## Request body

### `application/json`

- Type: `object`
- Properties:
  - `widget_ids` (`array<string>`) — Subset of widget ids to refresh (defaults to all data widgets)
    - Description: Subset of widget ids to refresh (defaults to all data widgets)
    - Items:
      - Type: `string`

## Success responses

### 200

Per-widget data or errors

**Content type:** `application/json`

- Reference: `WidgetBatchDataResponse`
  - Type: `object`
  - Properties:
    - `widgets` (`object`)
      - Additional properties:
        - Reference: `WidgetBatchItem`
          - Type: `object`
          - Properties:
            - `data` (`unknown`) — Widget-specific payload when the query succeeded
            - `error` (`string`) — Error message when this widget failed (other widgets may still succeed)

## Error responses

### 400

Validation error

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "VALIDATION_ERROR",
  "message": "Invalid input"
}
```

### 404

Resource not found

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "NOT_FOUND",
  "message": "Resource not found"
}
```

## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/dashboards/YOUR_ID/widgets/data' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "widget_ids": [
    "string"
  ]
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/dashboards/YOUR_ID/widgets/data', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "widget_ids": [
      "string"
    ]
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
