Create a dataset using the API
This sections shows how to create a new dataset in DataLinks by calling the REST API directly from Python. You’ll create a dataset namedemployee_records inside a namespace called hr_demo, using the DataLinks Create new dataset API endpoint.
Prerequisites
Before you begin, make sure you have:- A DataLinks account
- A valid bearer token for the DataLinks API
- A Python environment set up for running scripts
- The ability to install Python packages
Step-by-step instructions
Install dependencies
This guide uses direct HTTP calls with Python. Install the or
requests library if you do not already have it available:Configure environment variables
Set the following environment variables so sensitive values are not hardcoded in your script:
- Windows
- Linux
- MacOS
For the current sessionPersist across future sessionsAfter using
setx, open a new PowerShell window before running your script.Create the dataset (Python)
Create a Python file, for example
create_dataset.py, and add the following code:How this works
This request:- Calls
POST /ingest/new/{namespace}/{datasetName}to create a dataset - Authenticates using a bearer token in the
Authorizationheader - Sets dataset visibility to
Private - Supplies optional metadata to help DataLinks understand the dataset structure
The
inferDefinition section is optional, though it is strongly recommended when creating datasets programmatically.Common issues
Authentication errors If the request fails with a 401 error, confirm that:- The token environment variable is set correctly
- The
Authorizationheader uses theBearerformat
- The namespace and dataset name appear in the request URL
- The dataset name follows standard naming conventions, such as lowercase letters and underscores
Create a dataset in the web platform
If you prefer a simple, guided setup, you can create a dataset directly in the DataLinks web platform. To create a dataset in the web platform, follow these steps:- Log in to your DataLinks account.
- In the left navigation menu, click Create a New Dataset.
-
Enter a name for your dataset. Choose something descriptive, such as
customer_transactions_2025Use underscores, not spaces, when creating names. -
Select or enter a namespace to assign the dataset to. The namespace helps organize related datasets and controls access and context. For example,
accounting_2025 - Use the toggle to set visibility to Private or Public.
- Click Create dataset and upload data to finish.