# Execute a dashboard action widget

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

`POST /api/dashboards/{id}/widgets/{widgetId}/action`

Validates form values against the action widget schema, evaluates
`arguments_expr`/`args`, then dispatches `run_task`, `job_run`, or
`connector_method`. Creates a `dashboard_action_runs` audit row.
In-flight and cooldown checks apply per dashboard+widget. Open to any
authenticated user.

**Operation ID:** `executeDashboardAction`

## 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
- `widgetId` — `string`, `required`

## Request body

### `application/json`

- Reference: `DashboardActionRequest`
  - Type: `object`
  - Properties:
    - `form` (`object`) — Form field values keyed by field key (validated against the action widget's form schema).
      - Description: Form field values keyed by field key (validated against the action widget's form schema).
      - Additional properties: allowed
    - `row` (`object`) — Optional row context (e.g. from a field_mapping row_action) merged into arguments_expr.
      - Description: Optional row context (e.g. from a field_mapping row_action) merged into arguments_expr.
      - Additional properties: allowed

## Success responses

### 201

Action accepted

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

- Reference: `DashboardActionResponse`
  - Type: `object`
  - Properties:
    - `action_run_id` (`integer`, `required`)
    - `run_id` (`integer`) — Present when kind is run_task
    - `job_run_id` (`integer`) — Present when kind is job_run

## 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"
}
```

### 409

In-flight action or cooldown


## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/dashboards/YOUR_ID/widgets/YOUR_WIDGET_ID/action' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "form": {},
  "row": {}
}'
```

### JavaScript (fetch)

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

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