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

# 上传技能

> 上传技能压缩包（.skill/.zip/.tar.gz/.tgz）以创建或覆盖技能。

## 限制说明

| 项目   | 说明                         |
| ---- | -------------------------- |
| 速率限制 | 每个账户 **30 次/分钟**；**3 次/秒** |
| 权限要求 | **Skill 管理**（`ai-sre`）     |

## 使用说明

* 以 `multipart/form-data` 提交，包含 `file` 部分。压缩包最大 100MB。
* 设置 `replace=true` 可覆盖同名技能。
* 每次调用都会记录到账户审计日志。


## OpenAPI

````yaml /api-reference/safari.openapi.zh.json post /safari/skill/upload
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty AI SRE 平台的公开 HTTP API —— 技能、MCP 服务器（连接器）、A2A 智能体与会话。所有接口均使用
    Flashduty 控制台签发的 `app_key` 查询参数进行认证。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: AI SRE/技能
  - name: AI SRE/MCP 服务器
  - name: AI SRE/A2A 智能体
  - name: AI SRE/会话
  - name: AI SRE/自动化
paths:
  /safari/skill/upload:
    post:
      tags:
        - AI SRE/技能
      summary: 上传技能
      description: 上传技能压缩包（.skill/.zip/.tar.gz/.tgz）以创建或覆盖技能。
      operationId: skill-write-upload
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SkillUploadRequest'
            example:
              team_id: 0
              replace: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/SkillItem'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  skill_id: skill_8s7Hn2kLpQ3xYbVc4Wd2m
                  account_id: 10023
                  team_id: 0
                  skill_name: k8s-triage
                  description: >-
                    Diagnose unhealthy Kubernetes workloads from cluster events
                    and pod logs.
                  version: 1.2.0
                  tags:
                    - kubernetes
                    - triage
                  author: sre-team
                  tools:
                    - bash
                    - mcp:prometheus/query
                  status: enabled
                  created_by: 80011
                  created_at: 1716960000000
                  updated_at: 1717046400000
                  can_edit: true
                  update_available: false
                  is_modified: false
                  created: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - AppKeyAuth: []
components:
  schemas:
    SkillUploadRequest:
      type: object
      description: 上传技能压缩包的 multipart 表单。
      properties:
        file:
          type: string
          format: binary
          description: 技能压缩包（.skill / .zip / .tar.gz / .tgz），最大 100MB。
        team_id:
          type: integer
          description: 新技能的团队范围：0 表示账户级。
          format: int64
        replace:
          type: boolean
          description: 为 true 时覆盖同名技能。
        skill_id:
          type: string
          description: 替换指定技能时的技能 ID。
      required:
        - file
    ResponseEnvelope:
      type: object
      description: >-
        Standard response envelope used by every Flashduty public API. On
        success `data` contains the endpoint-specific payload and `error` is
        absent. On failure `error` is present and `data` is absent. `request_id`
        is always present and is also mirrored in the `Flashcat-Request-Id`
        response header.
      properties:
        request_id:
          type: string
          description: >-
            Unique ID for this request. Mirrored in the Flashcat-Request-Id
            header. Include it when reporting issues.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
        data:
          description: Endpoint-specific payload. See each operation's 200 response schema.
      required:
        - request_id
    SkillItem:
      type: object
      description: AI SRE 技能 —— 智能体可加载的 SKILL.md 打包资源。
      properties:
        skill_id:
          type: string
          description: 技能唯一 ID（前缀 `skill_`）。
        account_id:
          type: integer
          description: 所属账户 ID。
          format: int64
        team_id:
          type: integer
          description: 团队范围：0 表示账户级；>0 表示所属团队。
          format: int64
        skill_name:
          type: string
          description: 技能名称，在账户内唯一。
        description:
          type: string
          description: 来自 SKILL.md frontmatter 的可读描述。
        content:
          type: string
          description: 完整的 SKILL.md 内容；列表响应中省略。
        version:
          type: string
          description: frontmatter 中的技能版本。
        tags:
          type: array
          items:
            type: string
          description: 从 frontmatter 解析的标签。
        author:
          type: string
          description: 技能作者。
        license:
          type: string
          description: 技能许可证。
        tools:
          type: array
          items:
            type: string
          description: 所需工具（内置或 `mcp:server/tool`）。
        s3_key:
          type: string
          description: 技能压缩包在对象存储中的 key。
        checksum:
          type: string
          description: 技能压缩包的 SHA-256 校验和。
        status:
          type: string
          description: 技能状态。
          enum:
            - enabled
            - disabled
        created_by:
          type: integer
          description: 创建该技能的成员 ID。
          format: int64
        created_at:
          type: integer
          format: int64
          description: 创建时间，Unix 毫秒时间戳。
        updated_at:
          type: integer
          format: int64
          description: 最近更新时间，Unix 毫秒时间戳。
        can_edit:
          type: boolean
          description: 调用者是否可编辑该技能。
        source_template_name:
          type: string
          description: 该技能安装来源的市场模板名称；自建技能为空。
        source_template_version:
          type: string
          description: 安装时的模板版本。
        update_available:
          type: boolean
          description: 当市场存在更新版本时为 true。
        is_modified:
          type: boolean
          description: 当市场来源技能被本地修改时为 true（自动更新将跳过）。
        created:
          type: boolean
          description: 仅在“从会话安装”响应中出现：true 表示新建，false 表示原地更新。
      required:
        - skill_id
        - account_id
        - team_id
        - skill_name
        - description
        - status
        - created_by
        - created_at
        - updated_at
        - can_edit
        - update_available
        - is_modified
    DutyError:
      type: object
      description: >-
        Error payload inside the response envelope. Present only on non-2xx
        responses.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            Human-readable error message, localized by the caller's
            Accept-Language. May contain field names, IDs, or other context from
            the failing request.
      required:
        - code
        - message
    ErrorResponse:
      type: object
      description: Response envelope for errors. `error` is required; `data` is absent.
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    ErrorCode:
      type: string
      description: >-
        Flashduty error code enum. Every failed API response sets `error.code`
        to one of these values. The value is a stable wire string — not a
        localized message and not a numeric status. HTTP status is
        informational.
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
  responses:
    BadRequest:
      description: Invalid request — usually a missing or malformed parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              summary: Missing required parameter
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter skill_id is not valid.
    Unauthorized:
      description: Missing or invalid app_key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    Forbidden:
      description: The app_key is valid but lacks permission for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            accessDenied:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: AccessDenied
                  message: Access Denied.
    TooManyRequests:
      description: Rate limit hit. Either the global API limit or a per-account limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: Unexpected server-side error. Include the request_id when reporting.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        App key issued from the Flashduty console. Required on every public API
        call. Keep it secret — it grants the same access as the owning account.

````