> ## 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.

# Coding Webhook回调

> 接收 Coding Push/Merge Request 事件，自动提取变更 SQL 并触发审核。

**Coding 配置方式**：
1. 在 PawSQL 管理后台创建 SCM 监控配置，获取 webhookToken
2. 在 Coding 项目 → 项目设置 → 开发者选项 → Webhook 中填写 URL：
   `{PAWSQL_SERVER}/api/v1/integrations/coding/webhook/{webhookToken}`
3. 勾选 Push 和 Merge Request 事件

**期望的 HTTP Header**：
- `X-Coding-Event`: 事件类型（push / merge_request）
- `X-Coding-Signature`: 签名（可选）
- `X-Coding-Delivery`: 事件投递 ID

**请求 Body**：Coding Webhook Payload（JSON 格式）




## OpenAPI

````yaml /openapi/pawsql-integration.yaml post /integrations/coding/webhook/{webhookToken}
openapi: 3.0.3
info:
  title: CI/CD 集成
  description: |
    CI/CD 集成 API，供外部平台（蓝鲸、Coding、GitLab 等）对接 SQL 审核能力。

    ## 接口分类

    - **SQL 审核任务**：创建审核任务、查询审核结果、查询工作空间
    - **Webhook 回调**：接收 GitLab/Coding/GitHub 平台推送的代码变更事件，自动触发 SQL 审核

    ## 认证方式

    SQL 审核任务接口无需 userKey，通过 `platformCode` 标识来源平台。
    Webhook 接口通过 URL 中的 `webhookToken` 进行验证。

    ## 典型集成流程

    1. 在 PawSQL 管理后台创建工作空间和审核规则模板
    2. 调用 `/sql-audits/workspace-lookup` 查询 workspaceId 和 ruleTemplateId
    3. 调用 `POST /sql-audits` 创建审核任务（传入 SQL 文本或代码变更信息）
    4. 轮询 `GET /sql-audits/{taskId}` 获取审核结果
    5. 或配置 Webhook，代码推送时自动触发审核
  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: []
tags:
  - name: SQL审核任务
    description: SQL审核任务的创建和查询
  - name: GitLab Webhook
    description: GitLab Webhook 回调
  - name: Coding Webhook
    description: Coding Webhook 回调
  - name: GitHub Webhook
    description: GitHub Webhook 回调
paths:
  /integrations/coding/webhook/{webhookToken}:
    post:
      tags:
        - Coding Webhook
      summary: Coding Webhook回调
      description: |
        接收 Coding Push/Merge Request 事件，自动提取变更 SQL 并触发审核。

        **Coding 配置方式**：
        1. 在 PawSQL 管理后台创建 SCM 监控配置，获取 webhookToken
        2. 在 Coding 项目 → 项目设置 → 开发者选项 → Webhook 中填写 URL：
           `{PAWSQL_SERVER}/api/v1/integrations/coding/webhook/{webhookToken}`
        3. 勾选 Push 和 Merge Request 事件

        **期望的 HTTP Header**：
        - `X-Coding-Event`: 事件类型（push / merge_request）
        - `X-Coding-Signature`: 签名（可选）
        - `X-Coding-Delivery`: 事件投递 ID

        **请求 Body**：Coding Webhook Payload（JSON 格式）
      operationId: codingWebhook
      parameters:
        - name: webhookToken
          in: path
          required: true
          schema:
            type: string
          description: Webhook 验证 token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Coding Webhook Payload，格式参考 Coding 官方文档
      responses:
        '200':
          description: Webhook 处理结果
          content:
            text/plain:
              schema:
                type: string
              examples:
                success:
                  value: Webhook processed successfully
                skipped:
                  value: No SQL changes detected

````