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

# 向 Devin Connect gateway 添加目标

> 向 gateway 的列表中添加目标，并保留现有目标。

如果目标已通过其他 gateway 路由，则返回 409；
如果添加后 gateway 的目标数量将超过 256，则返回 422。

向 [Devin Connect](https://docs.devin.ai/zh/enterprise/deployment/devin-connect.md) gateway **添加**目标，同时保留其已路由的现有目标。此操作修改的列表与 Web 应用中“添加目标”所编辑的列表相同。如需一次性设置整个列表，请使用[替换 gateway 目标](https://docs.devin.ai/zh/api-reference/v3/devin-connect/put-enterprise-devin-connect-gateway-destinations.md)。

## 权限

需要使用在企业级别拥有 `ManageEnterpriseSettings` 权限的[服务用户](https://docs.devin.ai/zh/api-reference/v3/service-users/members-service-users.md)或[个人访问令牌](https://docs.devin.ai/zh/api-reference/personal-access-tokens.md)。该企业必须已启用 Devin Connect，否则此端点将返回 `403`。

## 行为

* 每个目标可以是 `{"hostname": "scm.corp.example"}` (精确主机名，不支持通配符) ，也可以是 `{"ipv4": "10.20.0.0/16"}` (IPv4 地址或 CIDR) 。主机名会被转换为小写并去除末尾的点，单个地址会转换为 `/32` CIDR。
* gateway 已路由的目标会保持不变，因此可以安全地重复发送请求。
* 一个目标只能属于一个 gateway。添加已由其他 gateway 路由的目标会返回 `409`。
* 一个 gateway 最多容纳 256 个目标。若添加后超出上限，则返回 `422`。
* 将目标加入路由并不意味着会话即可访问该目标，还需会话的[安全 Profile](https://docs.devin.ai/zh/product-guides/security-profiles.md) 允许该目标。有关如何一并完成这两个步骤，请参阅[使用 API 管理目标](https://docs.devin.ai/zh/enterprise/deployment/devin-connect.md#manage-destinations-with-the-api)。
* 您的 gateway 还会强制执行其自身的 `config.yaml`，因此只有在该文件也允许时，新目标才会生效。
* 更改会以 `update_gateway_hostnames` 的形式记录在[审计日志](https://docs.devin.ai/zh/api-reference/v3/audit-logs/enterprise-audit-logs.md)中。


## OpenAPI

````yaml zh/v3-openapi.yaml POST /v3beta1/enterprise/devin-connect/gateways/{gateway_id}/destinations
openapi: 3.1.0
info:
  description: 采用 Service User 身份验证和 RBAC 的 Devin v3 API
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3beta1/enterprise/devin-connect/gateways/{gateway_id}/destinations:
    post:
      tags:
        - devin-connect
      summary: 向 Devin Connect gateway 添加目标
      description: |-
        向 gateway 的列表中添加目标，并保留现有目标。

        如果目标已通过其他 gateway 路由，则返回 409；
        如果添加后 gateway 的目标数量将超过 256，则返回 422。
      operationId: >-
        handle_add_devin_connect_gateway_destinations_v3beta1_enterprise_devin_connect_gateways__gateway_id__destinations_post
      parameters:
        - in: path
          name: gateway_id
          required: true
          schema:
            title: Gateway Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DevinConnectDestinationsAddRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DevinConnectGateway'
          description: 成功响应
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 未授权
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 禁止访问
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 未找到
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 冲突
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 已永久删除
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 无法处理的内容
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 请求过多
components:
  schemas:
    DevinConnectDestinationsAddRequest:
      description: 向一个 gateway 添加目标，并保留其现有目标。
      properties:
        destinations:
          description: >-
            要添加的目标。gateway 中已存在的目标保持不变。gateway 总共最多可包含 256 个目标，且每个目标只能属于一个
            gateway。
          items:
            $ref: '#/components/schemas/DevinConnectDestination'
          title: Destinations
          type: array
      required:
        - destinations
      title: DevinConnectDestinationsAddRequest
      type: object
    DevinConnectGateway:
      description: 一个 Devin Connect gateway 及通过它路由访问的目标。
      properties:
        connected:
          anyOf:
            - type: boolean
            - type: 'null'
          description: 隧道 gateway 当前是否已连接；direct 模式下为 null
          title: Connected
        destinations:
          description: 通过此 gateway 路由访问的目标
          items:
            $ref: '#/components/schemas/DevinConnectDestination'
          title: Destinations
          type: array
        gateway_id:
          description: Gateway ID
          title: Gateway Id
          type: string
        kind:
          description: >-
            tunnel：客户 gateway 主动接入；direct：Devin 主动连接 gateway（例如通过 AWS
            PrivateLink）
          enum:
            - tunnel
            - direct
          title: Kind
          type: string
        last_connected_at:
          anyOf:
            - type: integer
            - type: 'null'
          description: 隧道 gateway 上次报告状态的时间
          title: Last Connected At
        name:
          description: Gateway 名称
          title: Name
          type: string
      required:
        - gateway_id
        - name
        - kind
        - destinations
      title: DevinConnectGateway
      type: object
    ProblemDetail:
      description: >-
        v3 API 的 RFC 9457 application/problem+json 错误响应体。


        detail 沿用自旧版 {"detail": ...} 响应体，以保持向后兼容；其他成员字段为新增字段。errors
        包含字段级验证失败信息（仅 422）。
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: 针对此次具体情况的、便于人理解的说明。
          title: Detail
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          description: 因操作被阻止而拒绝请求时返回的机器可读代码（例如 "user_frozen"、"migrated_session"）。
          title: Error Code
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: 字段级验证错误（仅适用于 422 响应）。
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: 此次出现对应的 URI 引用（请求路径）。
          title: Instance
        status:
          description: HTTP 状态码。
          title: Status
          type: integer
        title:
          description: 对问题类型的简短、便于理解的概述。
          title: Title
          type: string
        type:
          default: about:blank
          description: 用于标识问题类型的 URI 引用。
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
    DevinConnectDestination:
      description: 一个目标：必须且只能指定 ``hostname`` 或 ``ipv4`` 中的一项。
      properties:
        hostname:
          anyOf:
            - type: string
            - type: 'null'
          description: 精确的 DNS 名称（不含通配符），例如 git.corp.example
          title: Hostname
        ipv4:
          anyOf:
            - type: string
            - type: 'null'
          description: IPv4 地址或 CIDR，例如 10.20.0.0/16；不带前缀长度的地址视为 /32
          title: Ipv4
      title: DevinConnectDestination
      type: object
  securitySchemes:
    bearerAuth:
      description: 服务用户凭据（前缀：cog_）
      scheme: bearer
      type: http

````

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