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

# 从集群中移除位置

> 从集群的 `locationIds` 中移除一个位置。这是
`PATCH /clusters/{clusterId}`（使用缩短后的 `locationIds`
数组）的原子化替代方案，因此并发的移除操作不会相互冲突。

集群必须始终至少保留一个成员位置。移除最后一个位置会返回
`400 CLUSTER_EMPTY` 错误。此时请改用
`DELETE /clusters/{clusterId}` 删除整个集群。




## OpenAPI

````yaml api-reference/energy-management/openapi.zh.yaml DELETE /clusters/{clusterId}/locations/{locationId}
openapi: 3.1.0
info:
  title: RiDERgy Energy Management API
  version: '1.0'
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
  description: |
    对位置、单个充电桩、组织以及跨位置集群的充电功率限制进行程序化控制。

    ## 身份验证
    除 `GET /health` 和 `POST /oauth/token` 外，所有接口都需要通过
    OAuth 2.0 client_credentials 流程获取的 Bearer 令牌：

    1. 在 RiDERgy 控制台中创建 OAuth 客户端凭证。
    2. 通过 `POST /oauth/token` 将其兑换为短期访问令牌。
    3. 在每个请求中以 `Authorization: Bearer <token>` 传递令牌。

    令牌在 3600 秒后过期。您的租户信息嵌入在令牌中，
    无法被伪造。一个租户的凭证无法访问另一个租户。

    您的租户必须已启用 Energy Management API 功能，否则
    请求会返回 `403 FEATURE_NOT_ENABLED` 错误。请联系 RiDERgy 以启用该功能。

    ## Scopes
    令牌携带控制可访问接口的 scopes：
    `locations:read`、`locations:write`、`clusters:read`、`clusters:write`、
    `chargers:write`、`org:write`。向需要令牌不具备的 scope 的接口
    发送请求将返回 `403 INSUFFICIENT_SCOPE` 错误。

    ## 优先级模型
    位置和充电桩的限制通过**带优先级时间窗口的配置文件（profile）**进行控制：

    - 优先级范围为 **0（最低）到 10（最高）**，与 OCPP 协议栈风格一致。
    - 一个目标对象（位置或充电桩连接器）最多可以拥有 11 个配置文件，每个
      优先级一个，每个配置文件都有自己的 `[startTime, endTime)` 时间窗口。
    - 在任意时刻，**生效限制**为当前处于激活状态的配置文件中
      优先级最高者的 `limitKw`。
    - 如果没有配置文件处于激活状态，位置会回退到其 `permanentLimitKw`。
    - 在某个目标对象的某个优先级上已存在配置文件时，再次提交该优先级的配置文件
      将**替换**原有配置文件。
    - 配置文件会在其 `startTime`/`endTime` 自动应用并撤销。配置文件创建后
      无需进行额外的 API 调用。配置文件记录永远不会被删除，因此历史记录
      始终可查询。

    ## 错误
    所有错误均采用以下结构：

    ```json
    {
      "error": {
        "code": "LOCATION_NOT_FOUND",
        "message": "Location 123 was not found for the provided tenant",
        "requestId": "b1f6e6b0-..."
      }
    }
    ```
servers:
  - url: https://api.ridergy.com/v1
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Auth
    description: 用于 client_credentials 授权的 OAuth 2.0 令牌端点。
  - name: Health
    description: 无需身份验证的服务健康检查。
  - name: Locations
    description: 读取并设置位置级别的功率限制和优先级配置文件。
  - name: Chargers
    description: 在指定时间窗口内将单个充电桩连接器锁定为固定功率限制。
  - name: Organizations
    description: 租户范围内的总量限额配置文件（仅记录，尚未启用强制执行）。
  - name: Clusters
    description: 将多个位置归入一个共享 kW 上限的集群，并对其应用调度计划。
paths:
  /clusters/{clusterId}/locations/{locationId}:
    delete:
      tags:
        - Clusters
      summary: Remove a location from a cluster
      description: |
        从集群的 `locationIds` 中移除一个位置。这是
        `PATCH /clusters/{clusterId}`（使用缩短后的 `locationIds`
        数组）的原子化替代方案，因此并发的移除操作不会相互冲突。

        集群必须始终至少保留一个成员位置。移除最后一个位置会返回
        `400 CLUSTER_EMPTY` 错误。此时请改用
        `DELETE /clusters/{clusterId}` 删除整个集群。
      operationId: removeClusterLocation
      parameters:
        - $ref: '#/components/parameters/ClusterId'
        - $ref: '#/components/parameters/LocationId'
      responses:
        '200':
          description: 位置已移除，返回更新后的集群
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cluster'
        '400':
          description: 集群仅剩一个位置
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                clusterEmpty:
                  summary: CLUSTER_EMPTY
                  value:
                    error:
                      code: CLUSTER_EMPTY
                      message: >-
                        Cannot remove the last location from a cluster; delete
                        the cluster instead
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/FeatureNotEnabled'
        '404':
          description: 未找到集群，或该位置不是其成员
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                clusterNotFound:
                  summary: CLUSTER_NOT_FOUND
                  value:
                    error:
                      code: CLUSTER_NOT_FOUND
                      message: Cluster clst_20260612_a1b2c3d4 not found
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
                clusterLocationNotFound:
                  summary: CLUSTER_LOCATION_NOT_FOUND
                  value:
                    error:
                      code: CLUSTER_LOCATION_NOT_FOUND
                      message: >-
                        Location 3632155 is not a member of cluster
                        clst_20260612_a1b2c3d4
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
components:
  parameters:
    ClusterId:
      name: clusterId
      description: 该集群的唯一标识符，创建集群时返回。
      in: path
      required: true
      schema:
        type: string
      example: clst_20260612_a1b2c3d4
    LocationId:
      name: locationId
      description: 该位置的唯一标识符。
      in: path
      required: true
      schema:
        type: string
      example: '3632155'
  schemas:
    Cluster:
      type: object
      properties:
        clusterId:
          type: string
          example: clst_20260612_a1b2c3d4
        tenantUuid:
          type: string
        name:
          type: string
          example: North Campus
        locationIds:
          type: array
          items:
            type: string
          example:
            - '3632155'
            - '3632156'
        limitKw:
          type:
            - number
            - 'null'
          example: 200
        status:
          type: string
          enum:
            - ACTIVE
            - INACTIVE
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: LOCATION_NOT_FOUND
            message:
              type: string
              example: Location 123 was not found for the provided tenant
            requestId:
              type: string
              format: uuid
  responses:
    Unauthorized:
      description: 缺少 Bearer 令牌，或令牌无效/已过期
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthorized:
              value:
                error:
                  code: UNAUTHORIZED
                  message: Invalid or expired token
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
    FeatureNotEnabled:
      description: 该租户未启用 Energy Management API
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            featureNotEnabled:
              value:
                error:
                  code: FEATURE_NOT_ENABLED
                  message: >-
                    The Energy Management API is not enabled for your account.
                    Contact RiDERgy to enable this feature.
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        通过 `POST /oauth/token` 使用 client_credentials 授权获取的 OAuth 2.0 访问令牌。
        租户和 scopes 嵌入在 JWT 中。无需额外的请求头。

````

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