# Create a dashboard on a job

> Source: https://docs.clonepartner.com/api-reference/dashboards/create-job-dashboard/

`POST /api/jobs/{jobId}/dashboards`

Create a dashboard on a job

**Operation ID:** `createJobDashboard`

## 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

- `jobId` — `integer`, `required`

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `name` (`string`, `required`)
  - `description` (`string`)
  - `yaml_content` (`string`, `required`)
  - `dashboard_template_id` (`integer`)

## Success responses

### 201

Dashboard created

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

- Reference: `Dashboard`
  - Type: `object`
  - Properties:
    - `id` (`integer`)
    - `job_id` (`integer`)
    - `dashboard_template_id` (`integer | null`)
      - Nullable: yes
    - `name` (`string`)
    - `description` (`string | null`)
      - Nullable: yes
    - `status` (`string`)
    - `has_share_link` (`boolean`)
    - `created_at` (`string`)
      - Format: `date-time`
    - `updated_at` (`string | null`)
      - Format: `date-time`
      - Nullable: yes

## 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/jobs/YOUR_JOB_ID/dashboards' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "yaml_content": "string"
}'
```

### JavaScript (fetch)

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

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