curl --request POST \
--url https://charts.basedash.com/api/public/organizations/{orgId}/charts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>"
}
'import requests
url = "https://charts.basedash.com/api/public/organizations/{orgId}/charts"
payload = {
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
dashboardId: '<string>',
dashboardTabId: '<string>',
layout: {x: 1, y: 1, width: 2, height: 2},
name: '<string>',
description: '<string>',
chartType: 'TABLE',
sqlQuery: '<string>',
drilldownSqlQuery: '<string>',
databaseConnectionId: '<string>',
xAxisProperty: '<string>',
xAxisSecondaryProperty: '<string>',
yAxisProperty: '<string>',
staticContent: '<string>'
})
};
fetch('https://charts.basedash.com/api/public/organizations/{orgId}/charts', 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://charts.basedash.com/api/public/organizations/{orgId}/charts",
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([
'dashboardId' => '<string>',
'dashboardTabId' => '<string>',
'layout' => [
'x' => 1,
'y' => 1,
'width' => 2,
'height' => 2
],
'name' => '<string>',
'description' => '<string>',
'chartType' => 'TABLE',
'sqlQuery' => '<string>',
'drilldownSqlQuery' => '<string>',
'databaseConnectionId' => '<string>',
'xAxisProperty' => '<string>',
'xAxisSecondaryProperty' => '<string>',
'yAxisProperty' => '<string>',
'staticContent' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://charts.basedash.com/api/public/organizations/{orgId}/charts"
payload := strings.NewReader("{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://charts.basedash.com/api/public/organizations/{orgId}/charts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://charts.basedash.com/api/public/organizations/{orgId}/charts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"organizationId": "<string>",
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"imageUrl": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "RateLimitExceeded",
"detail": "<string>",
"retryAfterMs": 123
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}Create a chart
Creates a new chart on a dashboard. The chart is placed on the specified tab (or the first tab by default) at the bottom of the tab unless a layout is provided. Requires admin access to the organization.
curl --request POST \
--url https://charts.basedash.com/api/public/organizations/{orgId}/charts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>"
}
'import requests
url = "https://charts.basedash.com/api/public/organizations/{orgId}/charts"
payload = {
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
dashboardId: '<string>',
dashboardTabId: '<string>',
layout: {x: 1, y: 1, width: 2, height: 2},
name: '<string>',
description: '<string>',
chartType: 'TABLE',
sqlQuery: '<string>',
drilldownSqlQuery: '<string>',
databaseConnectionId: '<string>',
xAxisProperty: '<string>',
xAxisSecondaryProperty: '<string>',
yAxisProperty: '<string>',
staticContent: '<string>'
})
};
fetch('https://charts.basedash.com/api/public/organizations/{orgId}/charts', 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://charts.basedash.com/api/public/organizations/{orgId}/charts",
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([
'dashboardId' => '<string>',
'dashboardTabId' => '<string>',
'layout' => [
'x' => 1,
'y' => 1,
'width' => 2,
'height' => 2
],
'name' => '<string>',
'description' => '<string>',
'chartType' => 'TABLE',
'sqlQuery' => '<string>',
'drilldownSqlQuery' => '<string>',
'databaseConnectionId' => '<string>',
'xAxisProperty' => '<string>',
'xAxisSecondaryProperty' => '<string>',
'yAxisProperty' => '<string>',
'staticContent' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://charts.basedash.com/api/public/organizations/{orgId}/charts"
payload := strings.NewReader("{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://charts.basedash.com/api/public/organizations/{orgId}/charts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://charts.basedash.com/api/public/organizations/{orgId}/charts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dashboardId\": \"<string>\",\n \"dashboardTabId\": \"<string>\",\n \"layout\": {\n \"x\": 1,\n \"y\": 1,\n \"width\": 2,\n \"height\": 2\n },\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"chartType\": \"TABLE\",\n \"sqlQuery\": \"<string>\",\n \"drilldownSqlQuery\": \"<string>\",\n \"databaseConnectionId\": \"<string>\",\n \"xAxisProperty\": \"<string>\",\n \"xAxisSecondaryProperty\": \"<string>\",\n \"yAxisProperty\": \"<string>\",\n \"staticContent\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"dashboardId": "<string>",
"dashboardTabId": "<string>",
"organizationId": "<string>",
"name": "<string>",
"description": "<string>",
"chartType": "TABLE",
"sqlQuery": "<string>",
"drilldownSqlQuery": "<string>",
"databaseConnectionId": "<string>",
"xAxisProperty": "<string>",
"xAxisSecondaryProperty": "<string>",
"yAxisProperty": "<string>",
"staticContent": "<string>",
"layout": {
"x": 1,
"y": 1,
"width": 2,
"height": 2
},
"imageUrl": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}{
"error": {
"title": "RateLimitExceeded",
"detail": "<string>",
"retryAfterMs": 123
}
}{
"error": {
"title": "<string>",
"detail": "<string>"
}
}Authorizations
API key authentication using Bearer token format: Bearer <basedash_api_key>
Path Parameters
Organization ID
Body
ID of the dashboard to place the chart on
1ID of the dashboard tab to place the chart on. Defaults to the first tab.
Position and size of the chart on the dashboard grid. Defaults to the bottom of the tab.
Show child attributes
Show child attributes
Name of the chart
1Description of the chart
Type of the chart
TABLE SQL query powering the chart
SQL query used for chart drill-downs
ID of the data source the SQL query runs against
Result column used for the x-axis
Result column used to break down the x-axis into segments
Result column used for the y-axis
Static content for DASHBOARD_HEADER and DASHBOARD_TEXT chart types
Response
Chart created successfully
Show child attributes
Show child attributes
Was this page helpful?