> This page is for Trading.

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

# Create a workspace

POST https://api.immix.xyz/v1/workspaces
Content-Type: application/json

Creates one of your workspaces: the server mints its id and, unless you supplied one, its slug from the title (`-2`, `-3`, … on a clash with one of yours, so a create without a slug never fails on it). `Idempotency-Key` is required: a retry under the same key with the same body replays the 201 (`Idempotent-Replay: true`), and creates nothing twice.

Reference: https://docs.immix.xyz/trading/api-reference/rest-api/workspaces/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `Idempotency-Key` (string, required) — Required on a write that mints an id: a URL-safe string of 1 to 64 characters from `[A-Za-z0-9._~-]` (a UUID fits), scoped to you, a fresh one per attempt and the same one on a retry. A retry with the same body replays the stored answer (`Idempotent-Replay: true`); the key on another body is 409 `IDEMPOTENCY_KEY_REUSED`. Missing is 400 `MISSING_IDEMPOTENCY_KEY`, malformed 400 `INVALID_IDEMPOTENCY_KEY`.
- `X-Request-Id` (string, optional) — Your own id for the request: 8 to 128 of `[A-Za-z0-9._-]`. It becomes the request's id and is echoed on the response. A value off that grammar is replaced with a fresh id, never refused.

### Body (application/json)

This endpoint expects an object.

- `title` (string, required) — The title, 1 to 100 characters, not blank, with no NUL and no unpaired surrogate.
- `layout` (map from string to any, required) — The layout: a JSON object of at most 256 KiB serialised, yours to shape. Anything but an object is 400; more than 256 KiB is 413 `PAYLOAD_TOO_LARGE`.
- `tags` (list of string, optional) — Tags to list by: at most 50, each 1 to 64 characters of `[A-Za-z0-9:._-]`, lower-cased and de-duplicated on write. Absent, the row carries none.
- `visibility` (string, optional) — Who may read the row: `PRIVATE`, its owner alone; `ORG`, the owner's organisation too, read-only, once organisation admission serves colleagues' rows. `ORG` needs a token that names an organisation: without one it is 400. Append-only: tolerate values you don't know; a write of one this release does not know is 400.
- `slug` (string, optional) — A slug of your own, 1 to 100 characters of `[a-z0-9-]`; one another of your workspaces holds is 409 `SLUG_TAKEN`. Absent, the server mints one from the title, `-2`, `-3`, … on a clash, so a create without one never fails on it.

## Response

### 201

Created, or replayed for a retried key. `Location` is the workspace's URL and the `ETag` its first version.

- `workspaceId` (string, required) — The workspace's id, a UUID. Ids are opaque strings.
- `slug` (string, required) — The slug, 1 to 100 characters of `[a-z0-9-]`, unique among the owner's workspaces: minted from the title on create unless you supplied one, and never changed after, so a page URL outlives a rename.
- `title` (string, required) — The title, 1 to 100 characters, not blank, with no NUL and no unpaired surrogate.
- `layout` (map from string to any, required) — The layout: a JSON object whose shape belongs to the code that renders it (keep your own `schemaVersion` inside it). The API checks that it is an object of at most 256 KiB serialised and never reads inside it; it is served as you last wrote it: the same tree, members in their order, numbers exact.
- `tags` (list of string, required) — Tags to list by: at most 50, each 1 to 64 characters of `[a-z0-9:._-]`, lower-cased on write and unique.
- `visibility` (string, required) — Who may read the row: `PRIVATE`, its owner alone; `ORG`, the owner's organisation too, read-only, once organisation admission serves colleagues' rows. `ORG` needs a token that names an organisation: without one it is 400. Append-only: tolerate values you don't know; a write of one this release does not know is 400.
- `owned` (boolean, required) — Whether you own the row. `false` for a colleague's `ORG` workspace, which you can read but not write. The owner's identity is not on the row.
- `version` (string, required) — The row's version, the `ETag`'s value: send it as `If-Match` on a write. A decimal string from one sequence shared by every row.
- `createdAtNs` (string, required) — When the workspace was created, in epoch nanoseconds; microsecond-exact, so it ends in `000`.
- `updatedAtNs` (string, required) — When the workspace was last written, in epoch nanoseconds; microsecond-exact, so it ends in `000`.

## Errors

### 400 Create Workspaces Request Bad Request Error

The request is malformed: the body is not the record, the layout is not a JSON object, a title, slug or tag is off its grammar, or `ORG` on a token without an organisation; or `MISSING_IDEMPOTENCY_KEY` / `INVALID_IDEMPOTENCY_KEY`.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

### 401 Create Workspaces Request Unauthorized Error

The bearer token is missing or not valid.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

### 409 Create Workspaces Request Conflict Error

`IDEMPOTENCY_KEY_REUSED`: the key names another request of yours; `SLUG_TAKEN`: the slug you supplied is one of yours already; `WORKSPACE_CEILING`: you hold 500 workspaces, or your organisation 2,000 shared ones.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

### 413 Create Workspaces Request Content Too Large Error

`PAYLOAD_TOO_LARGE`: the layout is over 256 KiB serialised, or the body over 528 KiB.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

### 501 Create Workspaces Request Not Implemented Error

`NOT_IMPLEMENTED`: this deployment runs no user-state store, so it serves no workspaces.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

### 503 Create Workspaces Request Service Unavailable Error

`USER_STATE_UNAVAILABLE`: your workspaces cannot be read or written now; retry. `USER_STATE_SCHEMA_BEHIND`: the store is behind this release; a retry does not help until the deployment catches up.

- `error` (ErrorBody, required)
- `currentVersion` (string, optional) — On a 412 `VERSION_CONFLICT` from a conditional write that met a row: the row's current version (the `ETag` carries the same token); re-read, reapply, retry. Absent from every other response, a 412 for a row that no longer exists included.

## Types

### ErrorBody

- `code` (string, required) — Machine-readable, UPPER_SNAKE and append-only; tolerate codes you don't know. Branch on this, never on the message.
- `message` (string, required) — For display only; its wording may change at any time.
- `retryable` (boolean, required) — Whether sending the identical request again, after `Retry-After` or a short pause, can succeed with nothing else changed. `false` where something must change first: the request, the caller's standing, or the platform's own records or deployment.
- `requestId` (string, required) — The request's id, also sent as X-Request-Id; quote it to support.

## Examples

**Request**

```json
{
  "title": "Trading",
  "layout": {
    "key": "value"
  }
}
```

**Response**

```json
{
  "workspaceId": "0192f3a0-7c2e-7d1a-9b3f-4d5e6f708192",
  "slug": "trading",
  "title": "Trading",
  "layout": {
    "key": "value"
  },
  "tags": [
    "desk:rates"
  ],
  "visibility": "visibility",
  "owned": true,
  "version": "7",
  "createdAtNs": "1761264000000000000",
  "updatedAtNs": "1761264000000000000"
}
```

**SDK Code**

```python
import requests

url = "https://api.immix.xyz/v1/workspaces"

payload = {
    "title": "Trading",
    "layout": { "key": "value" }
}
headers = {
    "Idempotency-Key": "Idempotency-Key",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.immix.xyz/v1/workspaces';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'Idempotency-Key',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"title":"Trading","layout":{"key":"value"}}'
};

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.immix.xyz/v1/workspaces"

	payload := strings.NewReader("{\n  \"title\": \"Trading\",\n  \"layout\": {\n    \"key\": \"value\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Idempotency-Key", "Idempotency-Key")
	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.immix.xyz/v1/workspaces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'Idempotency-Key'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"title\": \"Trading\",\n  \"layout\": {\n    \"key\": \"value\"\n  }\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.immix.xyz/v1/workspaces")
  .header("Idempotency-Key", "Idempotency-Key")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"title\": \"Trading\",\n  \"layout\": {\n    \"key\": \"value\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.immix.xyz/v1/workspaces', [
  'body' => '{
  "title": "Trading",
  "layout": {
    "key": "value"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'Idempotency-Key',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.immix.xyz/v1/workspaces");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "Idempotency-Key");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"title\": \"Trading\",\n  \"layout\": {\n    \"key\": \"value\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Idempotency-Key": "Idempotency-Key",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "title": "Trading",
  "layout": ["key": "value"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.immix.xyz/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()
```