> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Dashboard

> Create a new dashboard for a project

# Create Dashboard

Create a new dashboard for a project in your organization. The project must belong to the organization specified in the header.

<Note>
  You can create the dashboard empty (widgets and layouts default to empty) and add widgets later via the [Update Dashboard](/api-reference/dashboards/update) endpoint.
</Note>

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Body Parameters

<ParamField body="project_id" type="string" required>
  UUID of the project to create the dashboard for. The project must belong to your organization.

  **Example:** `"a8315ef3-dd50-43f8-b7ce-d839e68d51fa"`
</ParamField>

<ParamField body="widgets" type="array" default="[]">
  Initial list of widget configurations. Each widget has an `id`, `name`, `type`, and `config`.
</ParamField>

<ParamField body="layouts" type="object" default="{}">
  Responsive grid layouts. Keys are breakpoints: `lg`, `md`, `sm`, `xs`, `xxs`. Each contains an array of layout items with `i` (widget ID), `x`, `y`, `w`, `h`.
</ParamField>

## Response

Returns the created dashboard object with HTTP 201.

<ResponseField name="id" type="string">
  Dashboard UUID (auto-generated)
</ResponseField>

<ResponseField name="project_id" type="string">
  UUID of the associated project
</ResponseField>

<ResponseField name="widgets" type="array">
  List of widget configurations (empty if not provided)
</ResponseField>

<ResponseField name="layouts" type="object">
  Responsive grid layouts (empty breakpoints if not provided)
</ResponseField>

<ResponseField name="created_at" type="datetime">
  Creation timestamp (ISO 8601)
</ResponseField>

<ResponseField name="updated_at" type="datetime | null">
  Last update timestamp (ISO 8601)
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v2/dashboard" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "project_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa"
    }'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      "Content-Type": "application/json",
  }

  response = requests.post(
      "https://api.dcycle.io/v2/dashboard",
      headers=headers,
      json={"project_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa"},
  )

  dashboard = response.json()
  print(f"Dashboard created: {dashboard['id']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
    'Content-Type': 'application/json',
  };

  axios.post('https://api.dcycle.io/v2/dashboard', {
    project_id: 'a8315ef3-dd50-43f8-b7ce-d839e68d51fa',
  }, { headers })
  .then(response => console.log(`Created: ${response.data.id}`));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "project_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
  "widgets": [],
  "layouts": {
    "lg": [],
    "md": [],
    "sm": [],
    "xs": [],
    "xxs": []
  },
  "created_at": "2024-11-24T10:30:00Z",
  "updated_at": "2024-11-24T10:30:00Z"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The user is not a member of the organization, or the project does not belong to your organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Project doesn't belong to organization."
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Update Dashboard" icon="pencil" href="/api-reference/dashboards/update">
    Add widgets and configure layouts
  </Card>

  <Card title="List Dashboards" icon="table-columns" href="/api-reference/dashboards/list">
    View all dashboards
  </Card>
</CardGroup>
