用 curl 创建即时电话
从 shell 环境读取 base URL 和 API key,并把客户端生成的幂等键放在请求 header 里。
: "${AI_CALLS_API_KEY:?set AI_CALLS_API_KEY}"
: "${AI_CALLS_BASE_URL:?set AI_CALLS_BASE_URL}"
curl -sS -X POST "${AI_CALLS_BASE_URL%/}/api/v1/call-tasks" \
-H "authorization: Bearer ${AI_CALLS_API_KEY}" \
-H "content-type: application/json" \
-H "idempotency-key: call-$(date -u +%Y%m%dT%H%M%SZ)-001" \
--data '{
"profileId": "<CALL_PROFILE_ID>",
"countryCode": "US",
"toNumber": "<E164_PHONE_NUMBER>",
"toName": "Example Contact",
"schedule": { "mode": "now" },
"variables": {
"customerName": "Example Contact",
"reason": "appointment reminder"
}
}'