> 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/outbound-campaigns/campaigns

列出工作区的外呼活动，按最新优先排序。

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/campaigns/list

## 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

### Query parameters

- `page_size` (integer, optional, default: 100) — 最多返回的项目数。
- `status` (enum, optional) — 仅处于这些状态之一的活动。
  - Allowed values: `active`, `paused`, `stopping`, `stopped`, `completed`, `failed`, `attention`
- `agent_id` (string, optional) — 仅由此智能体运行的活动。
- `channel` (enum, optional) — 仅此渠道上的活动。
  - Allowed values: `phone`, `whatsapp`
- `mode` (enum, optional) — 仅语音活动或仅消息活动。
  - Allowed values: `voice`, `message`
- `search` (string, optional) — 仅名称包含此文本的活动。
- `cursor` (string, optional) — 用于获取下一页。响应中会返回游标。

## Response

### 200

成功响应

- `campaigns` (list of CampaignResponse, required)
- `has_more` (boolean, required)
- `next_cursor` (string, optional)

## Errors

### 422 Outbound Campaigns List Request Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### CampaignResponse

- `campaign_id` (string, required)
- `call_name` (string, required) — 活动名称。
- `agent_id` (string, required)
- `channel_config` (CampaignResponseChannelConfig, required)
- `status` (enum, required) — `attention` 表示未解决的待处理项会暂停活动中的部分呼叫，其他呼叫继续进行。`stopping` 表示已排队的呼叫会被取消，已发起的呼叫将完成。
  - Allowed values: `active`, `paused`, `stopping`, `stopped`, `completed`, `failed`, `attention`
- `policy` (CampaignPolicySnapshot, required) — 活动创建时采用的策略。
- `variant` (enum, required)
  - Allowed values: `simple`, `advanced`
- `created_at_unix` (integer, required)
- `updated_at_unix` (integer, required)
- `channel` (enum, required)
  - Allowed values: `phone`, `whatsapp`
- `mode` (enum, required)
  - Allowed values: `voice`, `message`
- `counts` (CampaignSummaryCounts, required)
- `agent_name` (string, required, default: )
- `source` (enum, optional) — 活动是在应用中还是通过 API 创建。
  - Allowed values: `ui`, `api`
- `outcome` (CampaignResponseOutcome, optional) — 视为活动呼叫成功的结果。
- `scheduled_time_unix` (integer, optional) — 活动开始呼叫的时间；未设置时，创建后立即开始。
- `branch_id` (string, optional) — 活动呼叫时使用的智能体分支。
- `environment` (string, optional) — 解析智能体环境变量所用的环境。
- `target_concurrency_limit` (integer, optional) — 活动可同时发起的最大呼叫数。

### ValidationError

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

### CampaignResponseChannelConfig

- `channel`: `phone`
  - `agent_phone_number_id` (string, required) — 用于发起呼叫的电话号码。
  - `mode_config` (PhoneVoiceConfigOutput, optional)
- `channel`: `whatsapp`
  - `mode_config` (WhatsAppChannelConfigModeConfig, required)
  - `whatsapp_phone_number_id` (string, required) — 用于拨打 WhatsApp 电话或发送消息的 WhatsApp 电话号码。

### CampaignPolicySnapshot

活动创建时采用的策略，其结构与提交的 `policy` 相同。

- `timezone` (string, required)
- `retry` (RetryPolicy, required)
- `calling_periods` (list of CallingPeriodPolicy, required)
- `data_collection` (DataCollectionPolicy, required)
- `followup_context` (FollowupContextPolicy, required) — 后续呼叫会获取哪些 `campaign__` 动态变量。

### CampaignSummaryCounts

- `leads` (integer, required)
- `terminal_leads` (integer, required) — 不会再次呼叫的潜在客户。
- `open_attention` (integer, required) — 尚未解决的待处理项。
- `delivery` (RecipientDeliveryCounts, optional) — 到达各阶段的消息数量；获取单个消息活动时设置。

### CampaignResponseOutcome

- `type`: `data_collection`
  - `data_collection_id` (string, required) — 成功呼叫会设置的智能体数据收集项。
  - `equals` (list of DataCollectionOutcomeEqualsItem, required) — 视为成功的值，均为该项的类型。
- `type`: `evaluation_criteria`
  - `criteria_id` (string, required) — 成功呼叫满足的智能体评估标准。

### ValidationErrorLocItem

- string
- integer

### PhoneVoiceConfigOutput

- `ringing_timeout_secs` (integer, optional, default: 60) — 放弃前呼叫接收者的响铃时长，单位为秒。此时长还会受服务提供商自身限制。
- `twilio_call_recording_enabled` (boolean, optional, default: false) — 是否使用 Twilio 通话录音录制通话。非 Twilio 服务商将忽略此项。录音存储在 Twilio 账户中。
- `twilio_machine_detection` (TwilioMachineDetectionConfig, optional) — Configuration for Twilio's carrier-level answering machine detection (AMD). Omit or set to null to disable it. Ignored for non-Twilio providers and for inbound calls. The resulting verdict is delivered as its own `answering_machine_detection` webhook event, which requires that event to be enabled on the workspace or agent webhook settings; it is not part of the conversation or the post-call webhook. Detection runs asynchronously so it never delays the start of the conversation, and the verdict can arrive at any point during the call -- with `detect_message_end`, even after it has ended. Twilio bills separately for AMD.
- `mode` ("voice", optional)

### WhatsAppChannelConfigModeConfig

- `mode`: `message`
  - `template` (WhatsAppTemplate, required) — 提交时获批准的 Meta 模板。
- `mode`: `voice`
  - `whatsapp_call_permission_request_template_language_code` (string, required) — 该模板的语言代码。
  - `whatsapp_call_permission_request_template_name` (string, required) — 用于征求联系人呼叫许可的已批准模板。

### RetryPolicy

- `retry_delay_seconds` (integer, optional, default: 600) — 短暂重试前的等待时间。
- `max_short_retries` (integer, optional, default: 1) — 呼叫失败后，一个呼叫时段允许的重试次数。用完后，下次重试会等待下一个时段，并重新开始计算。
- `max_total_calls` (integer, optional, default: 6) — 每位潜在客户最多接收的呼叫次数，包括首次呼叫。
- `max_callbacks` (integer, optional, default: 2) — 同一号码最多可执行的回拨次数。
- `max_redirects` (integer, optional, default: 2) — 潜在客户按请求改拨其他号码的最大次数。
- `interval_placement` (enum, optional, default: start) — 延后的呼叫在后续呼叫时间窗口中的安排位置：在其 `start` 时开始、在 `random` 时间开始，或在该窗口中上次呼叫失败位置之后 `rotate` `rotate_step_seconds`。
  - Allowed values: `start`, `random`, `rotate`
- `rotate_step_seconds` (integer, optional, default: 900) — `rotate` 排序中每次呼叫移动的距离。仅由 `rotate` 使用。
- `max_consecutive_failures_per_number` (integer, optional) — 在潜在客户转而呼叫列表中的下一个号码前，向同一号码连续失败的最大呼叫次数；若没有下一个号码，则结束。呼叫被接听或重定向到新号码时，计数会重置。未设置时仅使用 `max_total_calls`。

### CallingPeriodPolicy

- `weekdays` (list of integer, required)
- `intervals` (list of CallingIntervalPolicy, required) — 这些日期每天的时间窗口。任何一天的时间窗口均不得重叠。

### DataCollectionPolicy

- `callback_time` (string, optional)
- `redirect_phone_number` (string, optional)
- `stop` (string, optional)
- `mappings` (map from string to string, optional) — 将数据收集结果复制到动态变量，以供后续呼叫使用：每个键为数据收集项 ID，值为变量名称。

### FollowupContextPolicy

后续呼叫会获取哪些 `campaign__` 动态变量。

- `call_type` (boolean, optional, default: true) — 将呼叫类型作为 `campaign__call_type` 传递。
- `previous_conversation_id` (boolean, optional, default: true) — 将上次对话的 ID 作为 `campaign__previous_conversation_id` 传递。
- `previous_summary` (boolean, optional, default: true) — 将上次对话的摘要作为 `campaign__previous_summary` 传递。
- `previous_transcript` (boolean, optional, default: true) — 将上次对话的转录文本作为 `campaign__previous_transcript` 传递。

### RecipientDeliveryCounts

- `sent` (integer, optional, default: 0)
- `delivered` (integer, optional, default: 0)
- `read` (integer, optional, default: 0)
- `replied` (integer, optional, default: 0)
- `failed` (integer, optional, default: 0)

### DataCollectionOutcomeEqualsItem

- string
- integer
- double
- boolean

### TwilioMachineDetectionConfig

如何在通话中运行 Twilio 的运营商级答录机检测（AMD）。

- `mode` (enum, optional, default: enable) — 检测的彻底程度。`enable` 会在 Twilio 能够区分人类和机器后立即返回判断结果。`detect_message_end` 还会等待语音信箱问候语结束，从而产生 `machine_end_*` 判断结果，但会更晚返回结果。
  - Allowed values: `enable`, `detect_message_end`
- `actions` (list of TwilioMachineDetectionRule, optional) — 针对每个 AMD 判定结果在通话中采取的操作。每项操作最多只能出现在一条规则中，因此请将其所有判定结果列在一起。没有对应规则的判定结果将使通话继续进行。

### WhatsAppTemplate

- `name` (string, required)
- `language` (string, required) — https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/supported-languages
- `components` (list of WhatsAppTemplateComponent, required)
- `parameter_format` (enum, optional, default: POSITIONAL)
  - Allowed values: `POSITIONAL`, `NAMED`
- `category` (string, optional) — https://developers.facebook.com/docs/graph-api/reference/whats-app-business-account/message_templates/

### CallingIntervalPolicy

- `start` (string, required) — 本地开始时间，格式为 `HH:MM`。
- `end` (string, required) — 本地结束时间，格式为 `HH:MM`；`24:00` 表示在午夜结束。

### TwilioMachineDetectionRule

针对给定 AMD 判定结果，在进行中的通话中采取的操作。

- `action` ("hang_up", required)
- `answered_by` (list of enum, required) — 触发该操作的判定结果。
  - Allowed values: `human`, `fax`, `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`

### WhatsAppTemplateComponent

- `type` (string, required)
- `format` (string, optional)
- `text` (string, optional)
- `buttons` (list of WhatsAppTemplateComponentButton, optional)

### WhatsAppTemplateComponentButton

- `type` (string, required)
- `text` (string, optional)
- `url` (string, optional)

## Examples

**Response**

```json
{
  "campaigns": [
    {
      "campaign_id": "campaign_id",
      "call_name": "call_name",
      "agent_id": "agent_id",
      "channel_config": {
        "channel": "phone",
        "agent_phone_number_id": "agent_phone_number_id"
      },
      "status": "active",
      "policy": {
        "timezone": "timezone",
        "retry": {},
        "calling_periods": [
          {
            "weekdays": [
              1
            ],
            "intervals": [
              {
                "start": "start",
                "end": "end"
              }
            ]
          }
        ],
        "data_collection": {},
        "followup_context": {}
      },
      "variant": "simple",
      "created_at_unix": 1,
      "updated_at_unix": 1,
      "channel": "phone",
      "mode": "voice",
      "counts": {
        "leads": 1,
        "terminal_leads": 1,
        "open_attention": 1
      },
      "agent_name": "agent_name",
      "source": "ui",
      "outcome": {
        "type": "data_collection",
        "data_collection_id": "data_collection_id",
        "equals": [
          "equals"
        ]
      },
      "scheduled_time_unix": 1,
      "branch_id": "branch_id",
      "environment": "environment",
      "target_concurrency_limit": 1
    }
  ],
  "has_more": true,
  "next_cursor": "next_cursor"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/outbound-campaigns/campaigns"

querystring = {"agent_id":"agent_id","channel":"phone","cursor":"cursor","mode":"voice","page_size":"1","search":"search","status":"[\"active\"]"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D';
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/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D"

	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/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D")

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/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D");
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/outbound-campaigns/campaigns?agent_id=agent_id&channel=phone&cursor=cursor&mode=voice&page_size=1&search=search&status=%5B%22active%22%5D")! 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()
```