# 更新数据库配置

> 更新属于组织或用户的数据库配置。
> Canonical HTML: https://tursodb.cn/zh-cn/docs/api-reference/databases/update-configuration/
> Upstream Source (MIT): https://docs.turso.tech/api-reference/databases/update-configuration
> Language: zh-CN

---
```bash cURL
curl -L -X PATCH 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/configuration' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "size_limit": "500mb",
      "delete_protection": true,
      "block_reads": false,
      "block_writes": false,
      "allowed_ips": ["203.0.113.7", "10.0.0.0/8"],
      "allowed_aws_vpc_ids": ["vpce-0fe6c8807461bba49"]
  }'
```


## OpenAPI

````yaml PATCH /v1/organizations/{organizationSlug}/databases/{databaseName}/configuration
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 的平台 API
security: []
paths:
  /v1/organizations/{organizationSlug}/databases/{databaseName}/configuration:
    patch:
      summary: 更新数据库配置
      description: 更新属于组织或用户的数据库配置。
      operationId: updateDatabaseConfiguration
      parameters:
        - $ref: '#/components/parameters/organizationSlug'
        - $ref: '#/components/parameters/databaseName'
      requestBody:
        description: 要应用到所选数据库的配置。
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatabaseConfigurationInput'
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatabaseConfigurationResponse'
components:
  parameters:
    organizationSlug:
      in: path
      name: organizationSlug
      required: true
      schema:
        type: string
      description: 组织或用户账户的 slug。
    databaseName:
      name: databaseName
      in: path
      required: true
      schema:
        type: string
      description: 数据库的名称。
  schemas:
    DatabaseConfigurationInput:
      type: object
      properties:
        size_limit:
          type: string
          description: >-
            数据库的最大大小，以字节为单位。也接受带单位的值，例如 1mb、256mb、1gb。
        allow_attach:
          type: boolean
          description: 允许或禁止将数据库附加到当前数据库。
          deprecated: true
        block_reads:
          type: boolean
          description: 阻止所有数据库读取。
          example: false
        block_writes:
          type: boolean
          description: 阻止所有数据库写入。
          example: false
        delete_protection:
          type: boolean
          description: 防止数据库被删除。
          example: true
        allowed_ips:
          type: array
          items:
            type: string
          description: >-
            允许的 IP 地址和 CIDR 块列表。仅接受来自这些来源的连接。传入空数组以清空列表。
            省略则保持不变。
          example:
            - 203.0.113.7
            - 10.0.0.0/8
        allowed_aws_vpc_ids:
          type: array
          items:
            type: string
          description: >-
            允许的 AWS VPC 终端节点 ID 列表（vpce-...）。仅接受通过这些终端节点到达的连接。传入空数组
            以清空列表。省略则保持不变。
          example:
            - vpce-0fe6c8807461bba49
    DatabaseConfigurationResponse:
      type: object
      properties:
        size_limit:
          type: string
          description: >-
            数据库的最大大小，以字节为单位。也接受带单位的值，例如 1mb、256mb、1gb。
          example: '10000'
        allow_attach:
          type: boolean
          description: 允许或禁止将数据库附加到当前数据库。
          example: true
          deprecated: true
        block_reads:
          type: boolean
          description: 当前阻止读取的状态。
          example: false
        block_writes:
          type: boolean
          description: 当前阻止写入的状态。
          example: false
        delete_protection:
          type: boolean
          description: 防止数据库被删除。
          example: true
        allowed_ips:
          type: array
          items:
            type: string
          description: >-
            允许的 IP 地址和 CIDR 块列表。为空表示不限制 IP。
          example:
            - 203.0.113.7
            - 10.0.0.0/8
        allowed_aws_vpc_ids:
          type: array
          items:
            type: string
          description: >-
            允许的 AWS VPC 终端节点 ID 列表。为空表示不限制 VPC 终端节点。
          example:
            - vpce-0fe6c8807461bba49

````
