# 還原群組

> 還原過去五天內刪除的群組，以及隨該群組一併刪除的成員資料庫。需要付費方案、組織的管理員或擁有者身分，且該組織已啟用復原功能。若部分資料庫還原失敗，群組仍會變為啟用狀態：請以 Restore Database 逐一重試失敗的資料庫 UUID。
> Canonical HTML: https://tursodb.cn/zh-tw/docs/api-reference/groups/restore/
> Upstream Source (MIT): https://docs.turso.tech/api-reference/groups/restore
> Language: zh-TW

---
<div class="doc-callout doc-callout-info"><div class="doc-callout-title">注意</div><div class="doc-callout-body">

與 v1 端點不同，此端點是以 **UUID** 來識別組織與群組 —— 請使用
[擷取組織](/zh-tw/docs/api-reference/organizations/retrieve/) 回傳的 `id` 欄位，以及
[列出已刪除的群組](/zh-tw/docs/api-reference/groups/list-deleted/) 回傳的 `uuid`
欄位。

</div></div>


```bash cURL
curl -L -X POST 'https://api.turso.tech/v3/organizations/{organizationId}/groups/{groupId}/restore' \
  -H 'Authorization: Bearer TOKEN'
```


## OpenAPI

````yaml POST /v3/organizations/{organizationId}/groups/{groupId}/restore
openapi: 3.0.1
info:
  title: Turso Platform API
  description: 此處為 API 說明
  license:
    name: MIT
  version: 0.1.0
servers:
  - url: https://api.turso.tech
    description: Turso 的 Platform API
security: []
paths:
  /v3/organizations/{organizationId}/groups/{groupId}/restore:
    post:
      summary: 還原群組
      description: >-
        還原過去五天內刪除的群組，以及隨該群組一併刪除的成員資料庫。需要付費方案、組織的管理員或擁有者身分，且該組織已啟用復原功能。若部分資料庫還原失敗，群組仍會變為啟用狀態：請以 Restore Database 逐一重試失敗的資料庫 UUID。
      operationId: restoreGroup
      parameters:
        - $ref: '#/components/parameters/organizationId'
        - $ref: '#/components/parameters/groupId'
      responses:
        '200':
          description: 請求成功
          content:
            application/json:
              schema:
                type: object
                properties:
                  group:
                    $ref: '#/components/schemas/Group'
                    description: 已還原的群組。
                  databases:
                    type: array
                    items:
                      $ref: '#/components/schemas/DeletedDatabase'
                    description: >-
                      隨群組一併還原的成員資料庫，依還原順序排列。
                  failures:
                    type: object
                    additionalProperties:
                      type: string
                    description: >-
                      將資料庫 UUID 對應至錯誤訊息，用於還原失敗的成員。請以 Restore Database 逐一重試這些資料庫。
        '400':
          description: >-
            該組織已停用復原功能，或請求內容無效。
        '403':
          description: >-
            該組織使用免費方案，或呼叫者並非管理員或擁有者。
        '404':
          description: >-
            不存在此 UUID 的已刪除群組，或其復原期限已過。
components:
  parameters:
    organizationId:
      name: organizationId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: >-
        組織的 UUID。可透過 Retrieve Organization 端點取得（即 `id` 欄位）。
    groupId:
      name: groupId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: >-
        群組的 UUID，即列出已刪除群組時所回傳的值（`uuid` 欄位）。
  schemas:
    Group:
      allOf:
        - $ref: '#/components/schemas/BaseGroup'
        - type: object
    DeletedDatabase:
      type: object
      properties:
        Name:
          type: string
          description: 資料庫名稱。
        DbId:
          type: string
          format: uuid
          description: 資料庫 UUID。可用於還原該資料庫。
        Hostname:
          type: string
          description: >-
            該資料庫先前的 DNS 主機名稱，用於用戶端與 HTTP 連線。
        group:
          type: string
          description: 該資料庫所屬群組的名稱。
        group_id:
          type: string
          format: uuid
          description: 該資料庫所屬群組的 UUID。
        organization_id:
          type: string
          format: uuid
          description: 組織的 UUID。
        regions:
          type: array
          items:
            type: string
          description: 該資料庫所在的區域。
        primaryRegion:
          type: string
          description: 該資料庫的主要區域。
        delete_protection:
          type: boolean
          description: 該資料庫是否已啟用刪除保護。
        deleted_at:
          type: string
          format: date-time
          description: 該資料庫的刪除時間。
        group_deleted_at:
          type: string
          format: date-time
          description: >-
            當該資料庫的群組與其一同刪除時會設定此值。還原該資料庫亦會一併還原群組。
    BaseGroup:
      type: object
      properties:
        name:
          type: string
          description: 群組名稱，在您的組織內唯一。
          example: default
        version:
          type: string
          description: >-
            該群組中資料庫目前所執行的 libSQL 伺服器版本。
          example: v0.23.7
          deprecated: true
        uuid:
          type: string
          description: 群組的通用唯一識別碼（UUID）。
          example: 0a28102d-6906-11ee-8553-eaa7715aeaf2
        locations:
          type: array
          items:
            type: string
          description: 該群組所在位置的 location key 陣列。
          example:
            - aws-us-east-1
          deprecated: true
        primary:
          type: string
          description: 主要位置的 location key。
          example: us-east-1
        delete_protection:
          type: boolean
          description: >-
            刪除保護的目前狀態。若啟用，該群組及其所有資料庫皆無法刪除。
          example: false

````
