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

# 重新激活激活码

将已使用（已核销）的激活码重置为未使用状态。请求体需包含 `code`（必需），可选 `reactivated_by`、`reason`。仅当激活码处于已使用、未禁用、未过期且项目启用时可重新激活。适用于用户退款、误核销回滚等场景。响应中 `success=true` 表示成功，否则查看 `error_code`（如 `CODE_ALREADY_UNUSED`、`CODE_EXPIRED`）。


## OpenAPI

````yaml api-reference/endpoint/api-reference/openapi.json post /api/v1/projects/{project_id}/codes/reactivate
openapi: 3.1.0
info:
  title: CodeGate SDK API
  description: CodeGate 激活码管理服务 SDK API - 使用 API Key + HMAC-SHA256 签名认证
  license:
    name: Apache-2.0
  version: 1.0.0
servers:
  - url: https://api.example.com
    description: CodeGate API 服务器
security:
  - apiKeyAuth: []
paths:
  /api/v1/projects/{project_id}/codes/reactivate:
    post:
      summary: 重新激活激活码
      operationId: reactivateCode
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - code
              properties:
                code:
                  type: string
                reactivated_by:
                  type: string
                reason:
                  type: string
      responses:
        '200':
          description: 重新激活结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReactivateResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    ReactivateResponse:
      type: object
      properties:
        success:
          type: boolean
        code_id:
          type: string
          nullable: true
        code:
          type: string
        reactivated_at:
          type: integer
          nullable: true
        message:
          type: string
        error_code:
          type: string
          nullable: true
  responses:
    Unauthorized:
      description: 认证失败（API Key、签名、时间戳、项目状态）
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
    Forbidden:
      description: project_id 与 API Key 绑定的项目不匹配
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API Key + X-Timestamp + X-Signature（HMAC-SHA256）

````