送信先を追加する
curl --request POST \
--url https://api.ai-call.co/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhooks/ai-call",
"events": []
}
'import requests
url = "https://api.ai-call.co/webhooks"
payload = {
"url": "https://example.com/webhooks/ai-call",
"events": []
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com/webhooks/ai-call', events: []})
};
fetch('https://api.ai-call.co/webhooks', 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.ai-call.co/webhooks",
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([
'url' => 'https://example.com/webhooks/ai-call',
'events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.ai-call.co/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.ai-call.co/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ai-call.co/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"created_at": "2023-11-07T05:31:56Z",
"secret": "whsec_…"
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}Webhook
送信先を追加する
通話の結果を受け取るURLを追加します。署名用のシークレット(secret)はこの応答でだけ返ります。1アカウント5件まで。
POST
/
webhooks
送信先を追加する
curl --request POST \
--url https://api.ai-call.co/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhooks/ai-call",
"events": []
}
'import requests
url = "https://api.ai-call.co/webhooks"
payload = {
"url": "https://example.com/webhooks/ai-call",
"events": []
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com/webhooks/ai-call', events: []})
};
fetch('https://api.ai-call.co/webhooks', 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.ai-call.co/webhooks",
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([
'url' => 'https://example.com/webhooks/ai-call',
'events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.ai-call.co/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.ai-call.co/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ai-call.co/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com/webhooks/ai-call\",\n \"events\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"created_at": "2023-11-07T05:31:56Z",
"secret": "whsec_…"
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}{
"error": {
"code": "do_not_call",
"message": "この番号は架電しない設定です。"
}
}Authorizations
管理画面「設定 → API」で作成したAPIキー(aic_sk_…)。
Body
application/json