curl --request POST \
--url https://ai.data.cloud/api/v2/team/datasources \
--header 'Content-Type: application/json' \
--header 'x-pd-api-key: <api-key>' \
--data '
{
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
'import requests
url = "https://ai.data.cloud/api/v2/team/datasources"
payload = {
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
headers = {
"x-pd-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-pd-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'test.csv',
type: 'FILE',
user_id: 'tmm-dafasdfasdfasdf',
file_object_key: '/tmp/sdgsagdsgsadgasdg'
})
};
fetch('https://ai.data.cloud/api/v2/team/datasources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.data.cloud/api/v2/team/datasources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'test.csv',
'type' => 'FILE',
'user_id' => 'tmm-dafasdfasdfasdf',
'file_object_key' => '/tmp/sdgsagdsgsadgasdg'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-pd-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://ai.data.cloud/api/v2/team/datasources"
payload := strings.NewReader("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-pd-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ai.data.cloud/api/v2/team/datasources")
.header("x-pd-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.data.cloud/api/v2/team/datasources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-pd-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"data": {
"id": "ds-cm7aedl58000501fc52hjj5c3",
"name": "ds1.xlsx",
"type": "FILE",
"status": "synched",
"dataset_id": "dset-cm7ae4d77028n01l1cnapd5si"
}
}Create data source without specifying a dataset
Creates a data source without specifying a dataset.
When calling this endpoint, Powerdrill will automatically create a dataset for the new data source. Save the dataset ID returned in the response so that you can associate it with a job and explore the data source.
curl --request POST \
--url https://ai.data.cloud/api/v2/team/datasources \
--header 'Content-Type: application/json' \
--header 'x-pd-api-key: <api-key>' \
--data '
{
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
'import requests
url = "https://ai.data.cloud/api/v2/team/datasources"
payload = {
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
headers = {
"x-pd-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-pd-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'test.csv',
type: 'FILE',
user_id: 'tmm-dafasdfasdfasdf',
file_object_key: '/tmp/sdgsagdsgsadgasdg'
})
};
fetch('https://ai.data.cloud/api/v2/team/datasources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.data.cloud/api/v2/team/datasources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'test.csv',
'type' => 'FILE',
'user_id' => 'tmm-dafasdfasdfasdf',
'file_object_key' => '/tmp/sdgsagdsgsadgasdg'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-pd-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://ai.data.cloud/api/v2/team/datasources"
payload := strings.NewReader("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-pd-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ai.data.cloud/api/v2/team/datasources")
.header("x-pd-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.data.cloud/api/v2/team/datasources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-pd-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"data": {
"id": "ds-cm7aedl58000501fc52hjj5c3",
"name": "ds1.xlsx",
"type": "FILE",
"status": "synched",
"dataset_id": "dset-cm7ae4d77028n01l1cnapd5si"
}
}Headers
Body
Your user ID, which uniquely identifies you within your team. To obtain your ID:
- If you're the team admin, refer to Check user information.
- If you're a system or virtual user, ask your team admin to check your user ID by referring to Check user information.
The object storage path to your locally uploaded file.
You must specify either url or file_object_key, but not both.
Only files with the following extensions are supported: .csv, .tsv, .md, .mdx, .json, .txt, .pdf, .pptx, .docx, .xls, or .xlsx.
How to obtain:
Each time you upload a file through the Upload file endpoint, its file_object_key is returned. For more details, see How to Upload Local Files.
Response
Status code. 0 indicates that the operation is successful. Otherwise, the operation fails. For error troubleshooting, refer to Error Codes.