Create a folder
curl --request POST \
--url https://api.varg.ai/v2/workspaces \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Campaign assets"
}
'import requests
url = "https://api.varg.ai/v2/workspaces"
payload = { "name": "Campaign assets" }
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({name: 'Campaign assets'})
};
fetch('https://api.varg.ai/v2/workspaces', 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://api.varg.ai/v2/workspaces",
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' => 'Campaign assets'
]),
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://api.varg.ai/v2/workspaces"
payload := strings.NewReader("{\n \"name\": \"Campaign assets\"\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://api.varg.ai/v2/workspaces")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Campaign assets\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/workspaces")
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 \"name\": \"Campaign assets\"\n}"
response = http.request(request)
puts response.read_body{
"workspace": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Campaign assets",
"slug": "campaign-assets-3f9a1c2e",
"visibility": "private",
"team_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"file_count": 123
}
}{
"error": {
"code": "invalid_request",
"message": "Body validation failed (text: Required)"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key or JWT"
}
}{
"error": {
"code": "workspace_owner_unresolvable",
"message": "This account has no app user to own a folder. Create the folder from the dashboard, or use a key belonging to a user account."
}
}Folders
Create a folder
Creates a folder. It is the same object the dashboard shows. There is no delete endpoint; remove folders from the dashboard.
Fails with 422 workspace_owner_unresolvable when the account has no
app user to own the folder (for example a service account).
POST
/
workspaces
Create a folder
curl --request POST \
--url https://api.varg.ai/v2/workspaces \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Campaign assets"
}
'import requests
url = "https://api.varg.ai/v2/workspaces"
payload = { "name": "Campaign assets" }
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({name: 'Campaign assets'})
};
fetch('https://api.varg.ai/v2/workspaces', 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://api.varg.ai/v2/workspaces",
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' => 'Campaign assets'
]),
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://api.varg.ai/v2/workspaces"
payload := strings.NewReader("{\n \"name\": \"Campaign assets\"\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://api.varg.ai/v2/workspaces")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Campaign assets\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/workspaces")
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 \"name\": \"Campaign assets\"\n}"
response = http.request(request)
puts response.read_body{
"workspace": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Campaign assets",
"slug": "campaign-assets-3f9a1c2e",
"visibility": "private",
"team_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"file_count": 123
}
}{
"error": {
"code": "invalid_request",
"message": "Body validation failed (text: Required)"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key or JWT"
}
}{
"error": {
"code": "workspace_owner_unresolvable",
"message": "This account has no app user to own a folder. Create the folder from the dashboard, or use a key belonging to a user account."
}
}Authorizations
varg API key (varg_...). Get one at app.varg.ai
or run bunx vargai login. App sessions may alternatively send a
Supabase JWT.
Body
application/json
Response
Folder created
A folder that groups files. Folders are shared with the dashboard, so a folder created through the API appears in the web app.
Show child attributes
Show child attributes
Was this page helpful?