> For the complete documentation index, see [llms.txt](https://docs.graphite-note.com/graphite-note-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphite-note.com/graphite-note-documentation/rest-api/dataset-api/create.md).

# Create

Use this endpoint to define the columns, types, and other properties for a new dataset tailored to your needs.

### Create a Dataset

To create a new dataset, follow these steps:

```python
url = 'https://app.graphite-note.com/api/dataset-create'
```

1. To create a new dataset, make a POST request to `/dataset-create` with the required parameters in the request body.
2. To specify the dataset structure, include an array of column definitions with each column's name, alias, type, subtype, and optional format.

* **Type** can be:
  * `measure`
  * `dimension`
* **Subtype** can be:
  * `text`
  * `numeric`
  * `date`
  * `datetime`

The response will include key details about the created dataset, including the dataset code, table name, and the number of columns.

***

### **Example Usage**

**Creating a New Dataset**

For example, making a POST request to the following URL with the provided JSON body would result in the response below:\
\
**Request**

```json
POST /dataset-create
Authorization: Bearer YOUR-TENANT-TOKEN

{
  "user-code": "0f02b4d4f9ae",
  "columns": [
    {
      "name": "InvoiceNo",
      "alias": "InvoiceNo",
      "type": "dimension",
      "subtype": "text"
    },
    {
      "name": "StockCode",
      "alias": "StockCode",
      "type": "dimension",
      "subtype": "text"
    },
    {
      "name": "Description",
      "alias": "Description",
      "type": "dimension",
      "subtype": "text"
    },
    {
      "name": "Quantity",
      "alias": "Quantity",
      "type": "measure",
      "subtype": "numeric",
      "format": "#,###.##"
    },
    {
      "name": "InvoiceDate",
      "alias": "InvoiceDate",
      "type": "dimension",
      "subtype": "datetime",
      "format": "Y-d-m H:i:s"
    },
    {
      "name": "UnitPrice",
      "alias": "UnitPrice",
      "type": "measure",
      "subtype": "numeric",
      "format": "#,###.##"
    },
    {
      "name": "CustomerID",
      "alias": "CustomerID",
      "type": "measure",
      "subtype": "numeric",
      "format": "#,###.##"
    }
  ],
  "name": "Client onboarding dataset creation"
}

```

**Response**

```json
{
  "data": {
    "dataset-code": "eca2ad3940e3",
    "table-name": "dataset_csv_eca2ad3940e3",
    "columns": 7
  }
}

```

This request creates a dataset with the specified columns, each having unique names, types, and formats tailored to client onboarding requirements.

### Example Python Implementation

```python
import requests

# Replace with your actual tenant token
tenant_token = YOUR-TOKEN

# Replace with your actual endpoint URL
url = 'https://app.graphite-note.com/api/dataset-create'

# Payload for dataset creation
payload = {
    "user-code": YOUR-CODE,
    "columns": [
        {
            "name": "order",
            "alias": "order",
            "type": "dimension",
            "subtype": "text"
        },
        {
            "name": "customer_id",
            "alias": "customer_id",
            "type": "dimension",
            "subtype": "text"
        },
        {
            "name": "number_of_items",
            "alias": "number_of_items",
            "type": "measure",
            "subtype": "numeric",
            "format": "#,###.##"
        }
    ],
    "name": "API dataset test"
}

# Headers with the bearer token
headers = {
    "Authorization": f"Bearer {tenant_token}",
    "Content-Type": "application/json"
}

# Send the POST request
response = requests.post(url, json=payload, headers=headers)

# Print response
print("Status code:", response.status_code)
print("Response body:", response.json())

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.graphite-note.com/graphite-note-documentation/rest-api/dataset-api/create.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
