跳轉到主要內容
POST
/
project
/
{projectId}
/
integration
/
phone
/
call
/
outbound
建立通話
curl --request POST \
  --url https://api.pathors.com/project/{projectId}/integration/phone/call/outbound \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "fromNumber": "<string>",
  "toNumber": "<string>",
  "dynamicVariables": {}
}
'
import requests

url = "https://api.pathors.com/project/{projectId}/integration/phone/call/outbound"

payload = {
"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({fromNumber: '<string>', toNumber: '<string>', dynamicVariables: {}})
};

fetch('https://api.pathors.com/project/{projectId}/integration/phone/call/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/project/{projectId}/integration/phone/call/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([
'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/project/{projectId}/integration/phone/call/outbound"

payload := strings.NewReader("{\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/project/{projectId}/integration/phone/call/outbound")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"fromNumber\": \"<string>\",\n \"toNumber\": \"<string>\",\n \"dynamicVariables\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.pathors.com/project/{projectId}/integration/phone/call/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 \"fromNumber\": \"<string>\",\n \"toNumber\": \"<string>\",\n \"dynamicVariables\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "success": true
}
已棄用。 此端點已棄用,將於 2026-07-11 下架。在此之前仍可使用。請改用 V1 路徑—完整的新舊路徑對照見遷移指南
建立外撥電話,從已設定的電話號碼向目標號碼發起電話通話。

基礎 URL

https://api.pathors.com

端點

POST https://api.pathors.com/project/{projectId}/integration/phone/call/outbound

路徑參數

projectId
string
必填
您的專案 ID

請求標頭

Authorization
string
必填
使用您的 Project API Key(以 sk_ 開頭)進行 Bearer 令牌認證。格式:Bearer {your-api-key}

請求體

fromNumber
string
必填
撥打電話的來源號碼。此號碼必須在您專案的 SIP 中繼設定中配置,且外呼狀態設為 ‘active’
toNumber
string
必填
要撥打的目標電話號碼。應使用 E.164 格式(例如:+1234567890)。台灣電話號碼請使用本地格式,無需 +886 國家碼前綴(例如:0912345678)。
dynamicVariables
object
可選的動態變數,傳遞給通話流程。這些變數可在您的通話流程配置中使用
請求範例:
curl -X POST \
  -H "Authorization: Bearer <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "fromNumber": "+1234567890",
    "toNumber": "+0987654321",
    "dynamicVariables": {
      "customerName": "John Doe",
      "orderId": "12345"
    }
  }' \
  https://api.pathors.com/project/proj_abc123/integration/phone/call/outbound

回應

返回成功回應,表示外呼電話事件已建立。
success
boolean
指示通話事件是否成功建立
回應範例:
{
  "success": true
}

錯誤回應

狀態碼描述
400缺少必要欄位(fromNumbertoNumber)或請求體無效
401無效的身份驗證(API 金鑰無效或缺失)
404指定的電話號碼(fromNumber)未配置為外呼電話,或外呼狀態未啟用
409目標電話號碼(toNumber)已在通話佇列中
500內部伺服器錯誤
錯誤回應範例:
{
  "error": "The given phone number is not configured for outbound"
}

使用說明

  • 電話號碼配置fromNumber 必須在您專案的 SIP 中繼設定中配置,且需滿足:
    • 外呼 SIP 狀態設為 ‘active’
  • 通話佇列:每個 toNumber 在佇列中一次只能有一個活動通話。如果您嘗試建立一個已存在於佇列中的號碼通話,將收到 409 錯誤。
  • 動態變數:使用 dynamicVariables 將自訂資料傳遞給您的通話流程。這些變數在整個通話會話中可用,可用於個人化或通話路由邏輯。