> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://onepin.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/docs/_mcp/server.

# Create Workspace

POST https://api.onepin.ai/api/v1/workspaces
Content-Type: application/json

Create a new workspace owned by the current user.

Workspaces are the top-level container for all resources (workflows,
voices, dictionary entries, members). Every resource is scoped to exactly
one workspace via the `X-Workspace-Id` header on subsequent requests.

The authenticated user becomes the workspace owner and is automatically
added as an `admin` member. An optional `slug` (1–50 characters,
lowercase kebab-case) can be supplied for a human-readable workspace
identifier; if omitted, one is auto-generated from `name`. Returns 409
if the slug is already taken, 422 if the slug format is invalid or uses
a reserved word.

The number of workspaces a user may own is plan-gated. Attempting to
exceed the limit returns 402.

Reference: https://onepin.ai/docs/reference/api-reference/workspaces/create-workspace-api-v-1-workspaces-post

## Authentication

- `Authorization` header (bearer token, required) — Clerk JWT token

## Servers

- `https://api.onepin.ai` (prod, default)
- `https://dev-api.onepin.ai` (dev)

## Request

### Body (application/json)

This endpoint expects a WorkspaceCreate.

- `name` (string, required) — Human-readable workspace name (1–200 characters, non-blank).
- `slug` (string, optional, nullable) — Optional URL-safe identifier (lowercase kebab-case, 1–50 characters). Auto-generated from `name` if omitted. Returns 409 if taken, 422 if invalid or reserved.
- `color_idx` (integer, optional, default: 0) — Index into the workspace color palette (0–6).

## Response

### 201

Successful Response

- `data` (WorkspaceOut, required)
- `meta` (Meta, required)

## Errors

### 409 Conflict Error

Slug already taken (WORKSPACE_SLUG_TAKEN)

- `error` (ApiErrorBody, required)
- `meta` (Meta, required)

### 422 Unprocessable Entity Error

Slug invalid or reserved (WORKSPACE_SLUG_INVALID / WORKSPACE_SLUG_RESERVED)

- `error` (ApiErrorBody, required)
- `meta` (Meta, required)

## Types

### WorkspaceOut

- `id` (string, required) — Unique workspace identifier. Pass as `X-Workspace-Id` header to scope resource requests.
- `name` (string, required) — Human-readable workspace name.
- `slug` (string, required) — URL-safe workspace identifier (lowercase kebab-case).
- `color_idx` (integer, required) — Index into the workspace color palette.
- `created_at` (datetime, required) — When the workspace was created (UTC).
- `updated_at` (datetime, required) — When the workspace was last modified (UTC).
- `routing_price_sensitivity` (double, required) — Voice-selection price/quality balance (0.0 = pure quality, 1.0 = pure price, 0.5 = balanced).
- `routing_llm_fit` (boolean, required) — Whether automatic voice selection also weighs content fit.
- `created_by` (string, optional, nullable) — User ID of the workspace owner. Null for an enterprise org workspace, which is owned by its organization (see organization_id) rather than a user.
- `organization_id` (string, optional, nullable) — Owning organization when this is an enterprise org workspace, else null.

### Meta

- `request_id` (string, required)
- `timestamp` (datetime, required)

### ApiErrorBody

- `code` (string, required)
- `message` (string, required)
- `details` (list of ApiErrorDetail, optional, default: [])

### ApiErrorDetail

- `field` (string, required)
- `message` (string, required)
- `line_numbers` (list of integer, optional, nullable)
- `min_chars` (integer, optional, nullable)

## Examples

**Request**

```json
{
  "name": "string"
}
```

**Response**

```json
{
  "data": {
    "id": "string",
    "name": "string",
    "slug": "string",
    "color_idx": 1,
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-01-15T09:30:00Z",
    "routing_price_sensitivity": 1.1,
    "routing_llm_fit": true,
    "created_by": "string",
    "organization_id": "string"
  },
  "meta": {
    "request_id": "string",
    "timestamp": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.onepin.ai/api/v1/workspaces"

payload = { "name": "string" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.onepin.ai/api/v1/workspaces';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.onepin.ai/api/v1/workspaces"

	payload := strings.NewReader("{\n  \"name\": \"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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.onepin.ai/api/v1/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\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.onepin.ai/api/v1/workspaces")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.onepin.ai/api/v1/workspaces', [
  'body' => '{
  "name": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.onepin.ai/api/v1/workspaces");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["name": "string"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/workspaces")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```