> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 获取智能体分支

GET https://api.elevenlabs.io/v1/convai/agents/{agent_id}/branches/{branch_id}

获取单个智能体分支的信息

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/agents/branches/get

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `agent_id` (string, required) — 智能体 ID。创建智能体时返回此值。
- `branch_id` (string, required) — 分支的唯一标识符。

## Response

### 200

成功响应

- `id` (string, required)
- `name` (string, required)
- `agent_id` (string, required)
- `description` (string, required)
- `created_at` (integer, required)
- `last_committed_at` (integer, required)
- `is_archived` (boolean, required)
- `protection_status` (enum, optional, default: writer_perms_required)
  - Allowed values: `writer_perms_required`, `admin_perms_required`
- `auto_rebase` (boolean, optional, default: false)
- `access_info` (ResourceAccessInfo, optional) — 分支访问信息
- `current_live_percentage` (double, optional, default: 0) — 分支上已上线的流量百分比
- `parent_branch` (AgentBranchBasicInfo, optional) — 该分支的父分支
- `most_recent_versions` (list of AgentVersionMetadata, optional) — 分支上的最新版本

## Errors

### 422 Branches Get Request Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### ResourceAccessInfo

- `is_creator` (boolean, required) — 发出请求的用户是否为该智能体的创建者
- `creator_name` (string, required) — 智能体创建者名称
- `creator_email` (string, required) — 智能体创建者的邮箱
- `role` (enum, required) — 发出请求的用户角色
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `anonymous_access_level_override` (enum, optional) — 匿名用户的访问级别。若为 None，该资源不会公开共享。
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `access_source` (enum, optional) — 请求用户拥有此资源访问权限的原因。'creator' = 调用者是所有者。'explicit' = 调用者（或其所属的某个工作区群组）列于 role_to_group_ids 中，且不包括工作区范围的所有人群组。'workspace_default' = 工作区范围的所有人群组列于 role_to_group_ids 中（所有非匿名工作区成员，包括管理员，均可查看此资源）。'workspace_admin' = 调用者是工作区管理员，且管理员席位是 *唯一* 的访问路径；此项仅用于其他人均无法查看的文档。这样 UI 可说明管理员绕过权限的查看者为何能看到未明确向其共享的文档。
  - Allowed values: `creator`, `explicit`, `workspace_admin`, `workspace_default`

### AgentBranchBasicInfo

- `id` (string, required)
- `name` (string, required)

### AgentVersionMetadata

- `id` (string, required)
- `agent_id` (string, required)
- `branch_id` (string, required)
- `version_description` (string, required)
- `seq_no_in_branch` (integer, required)
- `time_committed_secs` (integer, required)
- `parents` (AgentVersionParents, required)
- `access_info` (ResourceAccessInfo, optional)
- `merged_authors` (list of ResourceAccessInfo, optional) — 对于合并到主分支的操作，指在源分支上发布合并更改的人员（access_info 为执行合并的人员）。未记录时为 Null。

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### AgentVersionParents

- `in_branch_parent_id` (string, optional)
- `out_of_branch_parent_id` (string, optional)
- `merged_into_branch_id` (string, optional)
- `merged_from_branch_id` (string, optional)
- `merged_from_version_id` (string, optional)
- `rebased_from_version_id` (string, optional)

### ValidationErrorLocItem

- string
- integer

## Examples

**Response**

```json
{
  "id": "id",
  "name": "name",
  "agent_id": "agent_id",
  "description": "description",
  "created_at": 1,
  "last_committed_at": 1,
  "is_archived": true,
  "protection_status": "writer_perms_required",
  "auto_rebase": true,
  "access_info": {
    "is_creator": true,
    "creator_name": "John Doe",
    "creator_email": "john.doe@example.com",
    "role": "admin",
    "anonymous_access_level_override": "admin",
    "access_source": "creator"
  },
  "current_live_percentage": 1.1,
  "parent_branch": {
    "id": "id",
    "name": "name"
  },
  "most_recent_versions": [
    {
      "id": "id",
      "agent_id": "agent_id",
      "branch_id": "branch_id",
      "version_description": "version_description",
      "seq_no_in_branch": 1,
      "time_committed_secs": 1,
      "parents": {},
      "access_info": {
        "is_creator": true,
        "creator_name": "John Doe",
        "creator_email": "john.doe@example.com",
        "role": "admin",
        "access_source": "creator"
      },
      "merged_authors": [
        {
          "is_creator": true,
          "creator_name": "John Doe",
          "creator_email": "john.doe@example.com",
          "role": "admin",
          "access_source": "creator"
        }
      ]
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/agents/agent_3701k3ttaq12ewp8b7qv5rfyszkz/branches/agtbranch_0901k4aafjxxfxt93gd841r7tv5t")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```