curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATASOURCE"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATAMART"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart",
"llmName": "gpt-4o",
"aiCopilotLlms": ["gpt-4o", "gpt-4.1-mini"],
"isEnableMetricSuggestions": true,
"isEnableMetricSummary": true,
"summaryType": "custom",
"customSummaryPrompt": "Summarize weekly KPI shifts with root-cause hypotheses.",
"themeName": "Executive Theme"
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/workspace', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Workspace updated:', result.data.name);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/workspace',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'name': 'Sales Analytics',
'connectionType': 'DATASOURCE',
'datasourceName': 'postgres-production'
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Workspace updated: {result['data']['name']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/workspace')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Workspace updated: #{result['data']['name']}"
end
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class UpdateWorkspace {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String requestBody = """
{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usedatabrain.com/api/v2/workspace"))
.header("Authorization", "Bearer dbn_live_abc123...")
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type WorkspaceUpdateRequest struct {
Name string `json:"name"`
ConnectionType string `json:"connectionType"`
DatasourceName string `json:"datasourceName,omitempty"`
DatamartName string `json:"datamartName,omitempty"`
}
func main() {
reqData := WorkspaceUpdateRequest{
Name: "Sales Analytics",
ConnectionType: "DATASOURCE",
DatasourceName: "postgres-production",
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/workspace",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Workspace updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/workspace';
$data = [
'name' => 'Sales Analytics',
'connectionType' => 'DATASOURCE',
'datasourceName' => 'postgres-production'
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Workspace updated: " . $result['data']['name'];
}
?>
{
"data": {
"name": "Sales Analytics"
},
"error": null
}
{
"error": {
"code": "WORKSPACE_DOES_NOT_EXIST",
"message": "Workspace does not exist"
}
}
{
"error": {
"code": "INVALID_DATASOURCE_NAME",
"message": "Invalid datasource name provided"
}
}
{
"error": {
"code": "INVALID_DATAMART_NAME",
"message": "Invalid datamart name provided"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"connectionType\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATASOURCE"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATAMART"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart",
"llmName": "gpt-4o",
"aiCopilotLlms": ["gpt-4o", "gpt-4.1-mini"],
"isEnableMetricSuggestions": true,
"isEnableMetricSummary": true,
"summaryType": "custom",
"customSummaryPrompt": "Summarize weekly KPI shifts with root-cause hypotheses.",
"themeName": "Executive Theme"
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/workspace', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Workspace updated:', result.data.name);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/workspace',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'name': 'Sales Analytics',
'connectionType': 'DATASOURCE',
'datasourceName': 'postgres-production'
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Workspace updated: {result['data']['name']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/workspace')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Workspace updated: #{result['data']['name']}"
end
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class UpdateWorkspace {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String requestBody = """
{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usedatabrain.com/api/v2/workspace"))
.header("Authorization", "Bearer dbn_live_abc123...")
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type WorkspaceUpdateRequest struct {
Name string `json:"name"`
ConnectionType string `json:"connectionType"`
DatasourceName string `json:"datasourceName,omitempty"`
DatamartName string `json:"datamartName,omitempty"`
}
func main() {
reqData := WorkspaceUpdateRequest{
Name: "Sales Analytics",
ConnectionType: "DATASOURCE",
DatasourceName: "postgres-production",
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/workspace",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Workspace updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/workspace';
$data = [
'name' => 'Sales Analytics',
'connectionType' => 'DATASOURCE',
'datasourceName' => 'postgres-production'
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Workspace updated: " . $result['data']['name'];
}
?>
{
"data": {
"name": "Sales Analytics"
},
"error": null
}
{
"error": {
"code": "WORKSPACE_DOES_NOT_EXIST",
"message": "Workspace does not exist"
}
}
{
"error": {
"code": "INVALID_DATASOURCE_NAME",
"message": "Invalid datasource name provided"
}
}
{
"error": {
"code": "INVALID_DATAMART_NAME",
"message": "Invalid datamart name provided"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"connectionType\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
Workspace APIs
Update Workspace
Update an existing workspace’s connection settings to change datasource, datamart, multi-datasource, or multi-datamart configuration.
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATASOURCE"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATAMART"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart",
"llmName": "gpt-4o",
"aiCopilotLlms": ["gpt-4o", "gpt-4.1-mini"],
"isEnableMetricSuggestions": true,
"isEnableMetricSummary": true,
"summaryType": "custom",
"customSummaryPrompt": "Summarize weekly KPI shifts with root-cause hypotheses.",
"themeName": "Executive Theme"
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/workspace', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Workspace updated:', result.data.name);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/workspace',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'name': 'Sales Analytics',
'connectionType': 'DATASOURCE',
'datasourceName': 'postgres-production'
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Workspace updated: {result['data']['name']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/workspace')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Workspace updated: #{result['data']['name']}"
end
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class UpdateWorkspace {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String requestBody = """
{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usedatabrain.com/api/v2/workspace"))
.header("Authorization", "Bearer dbn_live_abc123...")
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type WorkspaceUpdateRequest struct {
Name string `json:"name"`
ConnectionType string `json:"connectionType"`
DatasourceName string `json:"datasourceName,omitempty"`
DatamartName string `json:"datamartName,omitempty"`
}
func main() {
reqData := WorkspaceUpdateRequest{
Name: "Sales Analytics",
ConnectionType: "DATASOURCE",
DatasourceName: "postgres-production",
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/workspace",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Workspace updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/workspace';
$data = [
'name' => 'Sales Analytics',
'connectionType' => 'DATASOURCE',
'datasourceName' => 'postgres-production'
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Workspace updated: " . $result['data']['name'];
}
?>
{
"data": {
"name": "Sales Analytics"
},
"error": null
}
{
"error": {
"code": "WORKSPACE_DOES_NOT_EXIST",
"message": "Workspace does not exist"
}
}
{
"error": {
"code": "INVALID_DATASOURCE_NAME",
"message": "Invalid datasource name provided"
}
}
{
"error": {
"code": "INVALID_DATAMART_NAME",
"message": "Invalid datamart name provided"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"connectionType\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
PUT
/
api
/
v2
/
workspace
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATASOURCE"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "MULTI_DATAMART"
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/workspace \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Sales Analytics",
"connectionType": "DATAMART",
"datamartName": "sales-datamart",
"llmName": "gpt-4o",
"aiCopilotLlms": ["gpt-4o", "gpt-4.1-mini"],
"isEnableMetricSuggestions": true,
"isEnableMetricSummary": true,
"summaryType": "custom",
"customSummaryPrompt": "Summarize weekly KPI shifts with root-cause hypotheses.",
"themeName": "Executive Theme"
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/workspace', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Workspace updated:', result.data.name);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/workspace',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'name': 'Sales Analytics',
'connectionType': 'DATASOURCE',
'datasourceName': 'postgres-production'
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Workspace updated: {result['data']['name']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/workspace')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Sales Analytics',
connectionType: 'DATASOURCE',
datasourceName: 'postgres-production'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Workspace updated: #{result['data']['name']}"
end
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class UpdateWorkspace {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String requestBody = """
{
"name": "Sales Analytics",
"connectionType": "DATASOURCE",
"datasourceName": "postgres-production"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usedatabrain.com/api/v2/workspace"))
.header("Authorization", "Bearer dbn_live_abc123...")
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type WorkspaceUpdateRequest struct {
Name string `json:"name"`
ConnectionType string `json:"connectionType"`
DatasourceName string `json:"datasourceName,omitempty"`
DatamartName string `json:"datamartName,omitempty"`
}
func main() {
reqData := WorkspaceUpdateRequest{
Name: "Sales Analytics",
ConnectionType: "DATASOURCE",
DatasourceName: "postgres-production",
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/workspace",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Workspace updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/workspace';
$data = [
'name' => 'Sales Analytics',
'connectionType' => 'DATASOURCE',
'datasourceName' => 'postgres-production'
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Workspace updated: " . $result['data']['name'];
}
?>
{
"data": {
"name": "Sales Analytics"
},
"error": null
}
{
"error": {
"code": "WORKSPACE_DOES_NOT_EXIST",
"message": "Workspace does not exist"
}
}
{
"error": {
"code": "INVALID_DATASOURCE_NAME",
"message": "Invalid datasource name provided"
}
}
{
"error": {
"code": "INVALID_DATAMART_NAME",
"message": "Invalid datamart name provided"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"connectionType\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
Update the connection settings of an existing workspace. You can switch between datasource, datamart, multi-datasource, and multi-datamart configurations. Updating a workspace also updates all associated metrics to use the new connection.
Important: Updating a workspace connection will automatically update all metrics in that workspace to use the new datasource or datamart connection. Ensure the new connection has compatible table and column structures to avoid breaking existing metrics.
The workspace name is used to identify which workspace to update and cannot be changed through this endpoint. To rename a workspace, you’ll need to create a new one and migrate your content.
Authentication
This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions. To access your service token:- In Settings page, navigate to the Service Tokens section.
- Click the “Generate Token” button to create a new service token if you don’t have one already.
Headers
Bearer token for API authentication. Use your service token.
Authorization: Bearer dbn_live_abc123...
Must be set to
application/json for all requests.Content-Type: application/json
Request Body
Name of the existing workspace to update. Must match exactly (case-sensitive).
Show Finding workspace names
Show Finding workspace names
- Use the List Workspaces API to get all workspace names
- Names are case-sensitive and must match exactly
- This field identifies which workspace to update
New connection type for the workspace. Must be one of:
DATASOURCE, DATAMART, MULTI_DATASOURCE, or MULTI_DATAMART.Show Connection type details
Show Connection type details
- DATASOURCE: Connect directly to a single datasource
- DATAMART: Connect to a pre-configured datamart
- MULTI_DATASOURCE: Allow connections to multiple datasources within this workspace
- MULTI_DATAMART: Allow switching between multiple datamarts within this workspace
MULTI_DATASOURCE or MULTI_DATAMART, datasourceName and datamartName are optional; the API clears prior single-datasource or single-datamart links and enables the selected multi mode. For DATASOURCE or DATAMART, datasourceName or datamartName is required (respectively), and multi-datasource / multi-datamart modes are turned off.Name of the datasource to connect to this workspace.Required when
connectionType is DATASOURCE.Show Datasource considerations
Show Datasource considerations
- Must be an existing datasource in your organization
- Use the exact name as stored in datasource credentials
- Names are case-sensitive
- All metrics will be updated to use this datasource
Name of the datamart to connect to this workspace.Required when
connectionType is DATAMART.Show Datamart considerations
Show Datamart considerations
- Must be an existing datamart in your organization
- Use the List Datamarts API to find available datamarts
- Names are case-sensitive
- All metrics will be updated to use this datamart’s datasource
Optional primary LLM name for workspace-level AI features. Must match an existing LLM configured in your organization.
Optional list of LLM names available for AI Copilot in this workspace. Every value must match an existing organization LLM name.
Optional flag to enable or disable AI-powered metric suggestions for this workspace.
Optional flag to enable or disable AI-generated metric summaries for this workspace.
Summary mode used when metric summaries are enabled. Must be one of:
technicalAndInsightSummary, forecastAndTrendAnalysis, comparativeAndAnomalyDetection, custom.Required when isEnableMetricSummary is true.Custom summary instruction prompt for AI-generated summaries.Required when
summaryType is custom.Optional workspace theme name. Must match an existing theme configured in your organization.
Response
Contains the updated workspace information on success.
Show data properties
Show data properties
The name of the successfully updated workspace.
Examples
HTTP Status Code Summary
| Status Code | Description |
|---|---|
200 | OK - Workspace updated successfully |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Invalid or missing API key |
500 | Internal Server Error - Server error occurred |
Possible Errors
| Error Code | HTTP Status | Description |
|---|---|---|
INVALID_REQUEST_BODY | 400 | Missing or invalid parameters |
WORKSPACE_DOES_NOT_EXIST | 400 | Workspace not found |
INVALID_DATASOURCE_NAME | 400 | Datasource not found |
INVALID_DATAMART_NAME | 400 | Datamart not found |
INVALID_LLM_NAME | 400 | Invalid LLM name provided |
INVALID_AI_COPILOT_LLMS | 400 | Invalid AI Copilot LLM list |
INVALID_THEME_NAME | 400 | Invalid theme name provided |
INVALID_DATA_APP_API_KEY | 401 | Invalid API key |
INTERNAL_SERVER_ERROR | 500 | Server error |
⌘I

