Skip to main content
POST
/
v1
/
calls
/
outbound
建立外撥電話
curl --request POST \
  --url https://api.pathors.com/v1/calls/outbound \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "projectId": "<string>",
  "fromNumber": "<string>",
  "toNumber": "<string>",
  "dynamicVariables": {}
}
'
import requests

url = "https://api.pathors.com/v1/calls/outbound"

payload = {
"projectId": "<string>",
"fromNumber": "<string>",
"toNumber": "<string>",
"dynamicVariables": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
projectId: '<string>',
fromNumber: '<string>',
toNumber: '<string>',
dynamicVariables: {}
})
};

fetch('https://api.pathors.com/v1/calls/outbound', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pathors.com/v1/calls/outbound",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '<string>',
'fromNumber' => '<string>',
'toNumber' => '<string>',
'dynamicVariables' => [

]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api.pathors.com/v1/calls/outbound"

payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"fromNumber\": \"<string>\",\n \"toNumber\": \"<string>\",\n \"dynamicVariables\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")

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

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

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.pathors.com/v1/calls/outbound")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"fromNumber\": \"<string>\",\n \"toNumber\": \"<string>\",\n \"dynamicVariables\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.pathors.com/v1/calls/outbound")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"fromNumber\": \"<string>\",\n \"toNumber\": \"<string>\",\n \"dynamicVariables\": {}\n}"

response = http.request(request)
puts response.read_body
建立外撥電話請求。電話會進入佇列並由外撥排程器派送;此端點在請求被接受時即回傳,而非在電話接通時。 用於通話的 Agent 會自動從專案解析得出 — 沒有 Agent 選擇器。每個專案對應一個 Agent。

請求

POST https://api.pathors.com/v1/calls/outbound

標頭

Authorization
string
required
使用您的 Developer Key(dk_...)進行 Bearer 令牌認證。

請求主體

projectId
string
required
將擁有此通話的專案。已認證的使用者必須是此專案的成員。
fromNumber
string
required
來源電話號碼。必須在已認證使用者所屬的號碼池中處於 active 狀態,且必須已設定外撥中繼線(trunk)。
toNumber
string
required
目的地電話號碼,採用 E.164 格式(例如 +886912345678)。
dynamicVariables
object
選填的鍵值對應,會作為執行時變數注入 Agent 會話。這些值可從您的路徑與提示中引用。

範例

curl -X POST https://api.pathors.com/v1/calls/outbound \
  -H "Authorization: Bearer dk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "projectId": "proj_abc123",
    "fromNumber": "+886912345678",
    "toNumber": "+886987654321",
    "dynamicVariables": {
      "customerName": "Jane Doe",
      "orderId": "12345"
    }
  }'

回應

當通話請求被接受進入派送佇列後,回傳 200 OK
{
  "success": true
}

錯誤

狀態碼時機
400驗證錯誤,或 fromNumber 存在但並非 active
401缺少或無效的 Developer Key
402專案點數不足以發起外撥電話
403使用者無權存取 projectId,或 fromNumber 不屬於使用者所屬的號碼池
404找不到 fromNumber,或未設定外撥中繼線
409已有一通撥往此 toNumber 的外撥電話正在進行中
500內部伺服器錯誤

說明

  • Agent:Agent 會自動從 projectId 解析得出。該專案所設定的 Agent 會負責處理此通話。
  • 來源號碼的擁有權:呼叫者(Developer Key 使用者)必須是擁有 fromNumber 的號碼池成員。projectId 的專案成員資格則會分開檢查。
  • 變數dynamicVariables 會被字串化後寫入 LiveKit 房間的 metadata,並在整個會話期間提供給 Agent 使用。
  • 並行:同一個 toNumber 在同一時間內無法有超過一通進行中的外撥電話。請等待前一通通話完成後再重試。