Create a workspace

:::openapi-operation POST /api/v1/workspaces AUTH bearerAuth :::

Creates a workspace in the org of the key. When the org reviews changes from agent keys, only a publishing key can create a workspace with access_mode public or listed true, and other keys get 403 review_required.

:::codesamples open Code examples

curl -X POST "https://contextowl.co/api/v1/workspaces" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  --data '{
  "access_mode": "string",
  "color": "string",
  "listed": true,
  "llms_txt": true,
  "name": "string"
}'
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
  public static void main(String[] args) throws Exception {
    var client = HttpClient.newHttpClient();
    var request = HttpRequest.newBuilder()
        .uri(URI.create("https://contextowl.co/api/v1/workspaces"))
        .header("Accept", "application/json")
        .header("Authorization", "Bearer <token>")
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString("{\n  \"access_mode\": \"string\",\n  \"color\": \"string\",\n  \"listed\": true,\n  \"llms_txt\": true,\n  \"name\": \"string\"\n}"))
        .build();

    var response = client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.statusCode());
    System.out.println(response.body());
  }
}
import urllib.request

url = "https://contextowl.co/api/v1/workspaces"
headers = {
    "Accept": "application/json",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json",
}
data = "{\n  \"access_mode\": \"string\",\n  \"color\": \"string\",\n  \"listed\": true,\n  \"llms_txt\": true,\n  \"name\": \"string\"\n}".encode("utf-8")
req = urllib.request.Request(url, data=data, headers=headers, method="POST")
with urllib.request.urlopen(req) as res:
    print(res.status)
    print(res.read().decode())
const response = await fetch("https://contextowl.co/api/v1/workspaces", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "access_mode": "string",
    "color": "string",
    "listed": true,
    "llms_txt": true,
    "name": "string"
  })
});

console.log(response.status);
console.log(await response.json());
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
	"time"
)

func main() {
	body := strings.NewReader(`{
  "access_mode": "string",
  "color": "string",
  "listed": true,
  "llms_txt": true,
  "name": "string"
}`)
	req, err := http.NewRequest("POST", "https://contextowl.co/api/v1/workspaces", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Accept", "application/json")
	req.Header.Set("Authorization", "Bearer <token>")
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	bodyBytes, err := io.ReadAll(io.LimitReader(res.Body, 10<<20))
	if err != nil {
		panic(err)
	}
	fmt.Println(res.StatusCode)
	fmt.Println(string(bodyBytes))
}
// cargo add reqwest --features blocking
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::blocking::Client::new();
    let response = client.request(reqwest::Method::POST, "https://contextowl.co/api/v1/workspaces")
        .header("Accept", "application/json")
        .header("Authorization", "Bearer <token>")
        .header("Content-Type", "application/json")
        .body("{\n  \"access_mode\": \"string\",\n  \"color\": \"string\",\n  \"listed\": true,\n  \"llms_txt\": true,\n  \"name\": \"string\"\n}")
        .send()?;

    println!("{}", response.status());
    println!("{}", response.text()?);
    Ok(())
}

:::

:::details open Request body (required)

application/json

FIELD TYPE REQUIRED DESCRIPTION
access_mode string no public, internal or private. public opens the docs to everyone, internal asks visitors to sign in, and private hides the workspace from visitors. The default is internal.
color string no Accent color as #rrggbb. The default is #6b7280.
listed boolean no Show this public workspace in the workspace switcher. The default is false.
llms_txt boolean no Include the public articles in llms.txt. The default is true.
name string yes Display name of the workspace
{
  "access_mode": "string",
  "color": "string",
  "listed": true,
  "llms_txt": true,
  "name": "string"
}

:::

:::details open Success responses (201)

201

Success

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
accessMode string yes -
aiAgents boolean yes -
aiSearch boolean yes -
aiTraining boolean yes -
color string yes -
id string yes -
listed boolean yes -
llmsTxt boolean yes -
name string yes -
{
  "accessMode": "string",
  "aiAgents": true,
  "aiSearch": true,
  "aiTraining": true,
  "color": "string",
  "id": "string",
  "listed": true,
  "llmsTxt": true,
  "name": "string"
}

:::

:::details Error responses (400, 401, 402, 403, 429, 500)

400

invalid_request: a parameter or the body is not valid.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

401

unauthorized: the access key is missing, invalid or expired.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

402

upgrade_required: the plan of the org does not include this operation.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

403

permission_denied: the key lacks the permission. two_factor_required: the org requires admins to turn on two-factor authentication. key_scoped: the key is bound to a workspace. review_required: the org reviews changes from agent keys, so only a publishing key can create a public or listed workspace.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

429

rate_limited: too many requests. Wait for the time in the Retry-After header.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

500

internal: the server failed.

Content-Type: application/json

FIELD TYPE REQUIRED DESCRIPTION
error object yes -
{
  "error": {
    "code": "string",
    "details": null,
    "message": "string",
    "status": 0
  }
}

:::