> ## Documentation Index
> Fetch the complete documentation index at: https://traceroot.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a workspace

> Create a workspace administered by the authenticated user.

Idempotent: re-creating a workspace the user already administers under the
same name returns that workspace with ``created: false``.

Args:
    request (Request): Incoming request (rate-limit plumbing).
    response (Response): Outgoing response (rate-limit plumbing).
    auth (AccountStampedAuth): Account-scope user auth (session token or
        CLI access JWT); its resolved ``user_id`` becomes the actor.
    payload (CreateWorkspaceRequest): The workspace to create.
    _live (None): Write-path liveness gate (blocks a revoked JWT session).

Returns:
    CreateWorkspaceResponse: The created (or matched) workspace.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/public/workspaces
openapi: 3.1.0
info:
  title: TraceRoot Public API
  version: 0.1.0
servers:
  - description: TraceRoot Cloud
    url: https://app.traceroot.ai
  - description: Self-hosted
    url: '{baseUrl}'
    variables:
      baseUrl:
        default: http://localhost:8000
        description: Your TraceRoot backend URL
security: []
paths:
  /api/v1/public/workspaces:
    post:
      tags:
        - Account
      summary: Create a workspace
      description: >-
        Create a workspace administered by the authenticated user.


        Idempotent: re-creating a workspace the user already administers under
        the

        same name returns that workspace with ``created: false``.


        Args:
            request (Request): Incoming request (rate-limit plumbing).
            response (Response): Outgoing response (rate-limit plumbing).
            auth (AccountStampedAuth): Account-scope user auth (session token or
                CLI access JWT); its resolved ``user_id`` becomes the actor.
            payload (CreateWorkspaceRequest): The workspace to create.
            _live (None): Write-path liveness gate (blocks a revoked JWT session).

        Returns:
            CreateWorkspaceResponse: The created (or matched) workspace.
      operationId: create_workspace
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWorkspaceRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWorkspaceResponse'
          description: Successful Response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication failed or session revoked
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Insufficient role or wrong credential kind
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Name already used by a workspace the user no longer administers
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Write service unavailable
      security:
        - BearerAuth: []
components:
  schemas:
    CreateWorkspaceRequest:
      description: Body for creating a workspace the caller will administer.
      properties:
        name:
          title: Name
          type: string
      required:
        - name
      title: CreateWorkspaceRequest
      type: object
    CreateWorkspaceResponse:
      description: The created (or idempotently matched) workspace.
      properties:
        created:
          title: Created
          type: boolean
        id:
          title: Id
          type: string
        name:
          title: Name
          type: string
        role:
          title: Role
          type: string
      required:
        - id
        - name
        - role
        - created
      title: CreateWorkspaceResponse
      type: object
    ErrorResponse:
      description: >-
        The canonical public error envelope (matches the gateway's normalized
        shape).
      properties:
        detail:
          title: Detail
          type: string
      required:
        - detail
      title: ErrorResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    BearerAuth:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.