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

# Get Dataset

> Retrieve a single custom KPI dataset with its KPI definitions

# Get Dataset

Retrieve a single custom KPI dataset by ID, including all its KPI definitions and their options.

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

### Path Parameters

<ParamField path="dataset_id" type="string" required>
  UUID of the dataset

  **Example:** `"a1b2c3d4-e5f6-7890-abcd-ef1234567890"`
</ParamField>

## Response

Returns the dataset object with nested KPI definitions (HTTP 200).

<ResponseField name="id" type="string">
  Dataset UUID.
</ResponseField>

<ResponseField name="organization_id" type="string">
  UUID of the organization that owns this dataset.
</ResponseField>

<ResponseField name="name" type="string">
  Dataset display name.
</ResponseField>

<ResponseField name="description" type="string | null">
  Dataset description.
</ResponseField>

<ResponseField name="created_by" type="string | null">
  UUID of the user who created the dataset.
</ResponseField>

<ResponseField name="updated_by" type="string | null">
  UUID of the user who last updated the dataset.
</ResponseField>

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

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

<ResponseField name="kpis" type="array[object]">
  KPI definitions belonging to this dataset.

  <Expandable title="KPI Object">
    <ResponseField name="id" type="string">
      KPI UUID.
    </ResponseField>

    <ResponseField name="dataset_id" type="string">
      Parent dataset UUID.
    </ResponseField>

    <ResponseField name="name" type="string">
      KPI display name.
    </ResponseField>

    <ResponseField name="description" type="string | null">
      KPI description.
    </ResponseField>

    <ResponseField name="unit" type="string | null">
      Measurement unit (e.g. `m³`, `kWh`, `%`).
    </ResponseField>

    <ResponseField name="value_type" type="string">
      Data type: `number`, `text`, `percentage`, `date`, `boolean`, or `select`.
    </ResponseField>

    <ResponseField name="required" type="boolean">
      Whether a response value is mandatory.
    </ResponseField>

    <ResponseField name="sort_order" type="integer">
      Display order within the dataset.
    </ResponseField>

    <ResponseField name="options" type="array[object]">
      Available choices for `select`-type KPIs. Empty array for other types.

      <Expandable title="Option Object">
        <ResponseField name="id" type="string">
          Option UUID.
        </ResponseField>

        <ResponseField name="label" type="string">
          Display label for this option.
        </ResponseField>

        <ResponseField name="sort_order" type="integer">
          Display order within the options list.
        </ResponseField>
      </Expandable>
    </ResponseField>

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

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

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/custom-kpi-datasets/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

  ```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"),
  }

  dataset_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

  response = requests.get(
      f"https://api.dcycle.io/v1/custom-kpi-datasets/{dataset_id}",
      headers=headers,
  )

  dataset = response.json()
  print(f"{dataset['name']} — {len(dataset['kpis'])} KPIs")
  for kpi in dataset["kpis"]:
      print(f"  [{kpi['value_type']}] {kpi['name']}")
  ```

  ```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,
  };

  const id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';

  axios.get(`https://api.dcycle.io/v1/custom-kpi-datasets/${id}`, { headers })
    .then(response => {
      const ds = response.data;
      console.log(`${ds.name}: ${ds.kpis.length} KPIs`);
    });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
  "name": "Water Usage Survey",
  "description": "Monthly water consumption across facilities",
  "created_by": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "updated_by": null,
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": null,
  "kpis": [
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "dataset_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Total water consumed",
      "description": null,
      "unit": "m³",
      "value_type": "number",
      "required": true,
      "sort_order": 0,
      "options": [],
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": null
    },
    {
      "id": "d4e5f6a7-b8c9-0123-defa-234567890123",
      "dataset_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Water source",
      "description": null,
      "unit": null,
      "value_type": "select",
      "required": true,
      "sort_order": 1,
      "options": [
        {"id": "e5f6a7b8-c9d0-1234-efab-345678901234", "label": "Municipal supply", "sort_order": 0},
        {"id": "f6a7b8c9-d0e1-2345-fabc-456789012345", "label": "Well water", "sort_order": 1},
        {"id": "a7b8c9d0-e1f2-3456-abcd-567890123456", "label": "Rainwater harvesting", "sort_order": 2}
      ],
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": null
    }
  ]
}
```

## 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 authenticated user is not a member of the organization

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

### 404 Not Found

**Cause:** Dataset not found

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Dataset not found"
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Update Dataset" icon="pencil" href="/api-reference/custom-kpi/update-dataset">
    Modify dataset name or description
  </Card>

  <Card title="Delete Dataset" icon="trash" href="/api-reference/custom-kpi/delete-dataset">
    Remove an unused dataset
  </Card>
</CardGroup>
