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

> ## Agent Instructions
> PawSQL 是一个产品：Cloud 是公网部署形态，Engine / Optimizer / Auditor / Advisor / Patroller 是同一产品的组件与交付形态，不是彼此独立的产品。 / PawSQL is a single product: Cloud is the public deployment form, while Engine / Optimizer / Auditor / Advisor / Patroller are components and delivery forms of the same product, not separate products.
> 术语以站内术语表为准：SQL 审核对应英文 SQL Review，查询重写对应 Query Rewrite，索引推荐对应 Index Recommendation；英文内容统一用 Review，不用 Audit。 / Use the site glossary for terminology: 审核 is SQL Review, 重写 is Query Rewrite, 索引推荐 is Index Recommendation; English content uses Review, never Audit.
> 引用能力范围或版本支持时以对应页面为准；标注 unknown、或 status 非 published 的内容表示尚未经产品核实，不应作为事实引用。 / Cite capability scope and version support from the corresponding page; content marked unknown, or with a status other than published, is not yet product-verified and must not be cited as fact.

# Create workspace

> Creates a workspace and returns the workspaceId, supporting offline mode (DDL text) and online mode (database connection).

### Supported dbType values

| dbType | Database |
|--------|----------|
| mysql | MySQL |
| mysql-rds | RDS MySQL |
| gaussdb-mysql | GaussDB for MySQL |
| goldendb | GoldenDB |
| tdsqlx-mysql | TDSQL MySQL (Distributed) |
| tdsql-mysql | TDSQL MySQL (Centralized) |
| oceanbase-mysql | OceanBase (MySQL Mode) |
| oceanbase-oracle | OceanBase (Oracle Mode) |
| polardbx | PolarDB-X 2.0 |
| postgresql | PostgreSQL |
| opengauss | OpenGauss |
| kingbase-es | Kingbase |
| mogdb | MogDB |
| gaussdbx | GaussDB (Distributed) |
| gaussdb-dws | GaussDB for DWS |
| oracle | Oracle |
| tdsqlx-pg | TDSQL PostgreSQL (Distributed) |
| tdsql-pg | TDSQL PostgreSQL (Centralized) |
| mssql | SQLServer |
| db2 | DB2 |
| dameng | Dameng |




## OpenAPI

````yaml /openapi/pawsql-optimization-en.yaml post /createWorkspace
openapi: 3.0.3
info:
  title: PawSQL Optimization
  description: >
    PawSQL SQL optimization service external interfaces.


    The PawSQL optimization engine is a query optimization engine built for
    developers and DBAs, integrating database industry best practices for query
    optimization,

    providing powerful SQL auditing and rewrite optimization capabilities, and
    integrating the Paw Index Advisor index recommendation engine for cost-based
    index recommendations for slow queries.


    ## Authentication


    Most endpoints require authentication via `userKey` (activation code).

    The `userKey` can be obtained through the `/getUserKey` endpoint
    (email/password login).


    ## API Call Flow


    1. Call `/getUserKey` to obtain a userKey

    2. Call `/createWorkspace` to create a workspace (or pass DDL directly in
    `/createAnalysis`)

    3. Call `/createAnalysis` or `/createAnalysisAsync` to create an
    optimization task

    4. Call `/getAnalysisSummary` to obtain the optimization summary

    5. Call `/getStatementDetails` to obtain details for a single SQL statement
  version: 1.0.0
  contact:
    name: PawSQL Team
    url: https://pawsql.com
  license:
    name: PawSQL
    url: https://pawsql.com
servers:
  - url: /api/v1
    description: PawSQL Server
security:
  - userKey: []
tags:
  - name: Authentication
    description: Authentication endpoints
  - name: Workspace
    description: Workspace management endpoints
  - name: Optimization
    description: SQL optimization task endpoints
paths:
  /createWorkspace:
    post:
      tags:
        - Workspace
      summary: Create workspace
      description: >
        Creates a workspace and returns the workspaceId, supporting offline mode
        (DDL text) and online mode (database connection).


        ### Supported dbType values


        | dbType | Database |

        |--------|----------|

        | mysql | MySQL |

        | mysql-rds | RDS MySQL |

        | gaussdb-mysql | GaussDB for MySQL |

        | goldendb | GoldenDB |

        | tdsqlx-mysql | TDSQL MySQL (Distributed) |

        | tdsql-mysql | TDSQL MySQL (Centralized) |

        | oceanbase-mysql | OceanBase (MySQL Mode) |

        | oceanbase-oracle | OceanBase (Oracle Mode) |

        | polardbx | PolarDB-X 2.0 |

        | postgresql | PostgreSQL |

        | opengauss | OpenGauss |

        | kingbase-es | Kingbase |

        | mogdb | MogDB |

        | gaussdbx | GaussDB (Distributed) |

        | gaussdb-dws | GaussDB for DWS |

        | oracle | Oracle |

        | tdsqlx-pg | TDSQL PostgreSQL (Distributed) |

        | tdsql-pg | TDSQL PostgreSQL (Centralized) |

        | mssql | SQLServer |

        | db2 | DB2 |

        | dameng | Dameng |
      operationId: createWorkspace
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiWorkspaceCreate'
            examples:
              offline:
                summary: Offline mode
                value:
                  userKey: CB698418-88B25371-67F15F01-XXXXXXXX
                  mode: offline
                  dbType: mysql
                  ddlText: CREATE TABLE `organization` (`org_id` bigint(20) NOT NULL);
              online:
                summary: Online mode
                value:
                  userKey: CB698418-88B25371-67F15F01-XXXXXXXX
                  mode: online
                  dbType: mysql
                  host: localhost
                  port: '3306'
                  database: pawsql
                  dbUser: root
                  dbPassword: password
      responses:
        '200':
          description: Workspace creation result
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResult'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/WorkspaceCreateResponse'
              examples:
                success:
                  value:
                    code: 200
                    message: Success
                    data:
                      workspaceId: '1730508173442965506'
                failure:
                  value:
                    code: 400
                    message: server.validate.failed
                    data: null
components:
  schemas:
    ApiWorkspaceCreate:
      type: object
      description: Create workspace request
      required:
        - userKey
        - mode
        - dbType
      properties:
        userKey:
          type: string
          description: Activation code
          example: CB698418-88B25371-67F15F01-XXXXXXXX
        mode:
          type: string
          description: 'Workspace mode: online / offline'
          enum:
            - online
            - offline
          example: offline
        dbType:
          type: string
          description: >-
            Database type displayCode, see the dbType table above for supported
            values
          example: mysql
        host:
          type: string
          description: Database host (required in online mode)
          example: localhost
        port:
          type: string
          description: Database port (required in online mode)
          example: '3306'
        schemas:
          type: string
          description: >-
            Schema list, comma-separated, case-sensitive (required for
            pg/opengauss/oracle)
        database:
          type: string
          description: Database name (required in online mode)
          example: pawsql
        dbUser:
          type: string
          description: Database username (required in online mode)
          example: root
        dbPassword:
          type: string
          description: Database password (required in online mode)
          example: password
        ddlText:
          type: string
          description: DDL text (required in offline mode)
          example: CREATE TABLE `organization` (`org_id` bigint(20) NOT NULL);
    ApiResult:
      type: object
      description: Unified response body
      properties:
        code:
          type: integer
          description: Status code, 200 indicates success
          example: 200
        message:
          type: string
          description: Description message
          example: Success
        data:
          description: Response data
    WorkspaceCreateResponse:
      type: object
      description: Create workspace response
      properties:
        workspaceId:
          type: string
          description: Workspace ID
          example: '1730508173442965506'
  securitySchemes:
    userKey:
      type: apiKey
      in: header
      name: userKey
      description: Activation code, obtained via the /getUserKey endpoint

````