Skip to main content
POST
/
v1
/
custom-kpi-datasets
/
{dataset_id}
/
kpis
Create Kpi
const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: '<string>',
    description: '<string>',
    unit: '<string>',
    value_type: 'number',
    required: true,
    sort_order: 0
  })
};

fetch('https://api.dcycle.io/v1/custom-kpi-datasets/{dataset_id}/kpis', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "sort_order": 123,
  "created_at": "2023-11-07T05:31:56Z",
  "description": "<string>",
  "unit": "<string>",
  "value_type": "number",
  "required": true,
  "updated_at": "2023-11-07T05:31:56Z"
}

Authorizations

x-api-key
string
header
required

Headers

x-organization-id
string
x-api-key
string
x-user-id
string

Path Parameters

dataset_id
string<uuid>
required

Body

application/json

Request schema for creating a new KPI within a dataset.

name
string
required

The KPI name.

Required string length: 1 - 255
description
string

The KPI description.

Maximum string length: 2000
unit
string

The measurement unit.

Maximum string length: 50
value_type
enum<string>
default:number

Expected answer type.

Available options:
number,
text,
percentage,
date,
boolean
required
boolean
default:true

Whether a response value is mandatory.

sort_order
integer
default:0

Display order within the dataset.

Required range: x >= 0

Response

Successful Response

Response schema for a KPI definition.

id
string<uuid>
required

The KPI id.

dataset_id
string<uuid>
required

The parent dataset id.

name
string
required
sort_order
integer
required
created_at
string<date-time>
required
description
string
unit
string
value_type
enum<string>
default:number

Expected answer type for a custom KPI definition.

Available options:
number,
text,
percentage,
date,
boolean
required
boolean
default:true
updated_at
string<date-time>