Create a webhook subscription
curl --request POST \
--url https://agents.assemblyai.com/v1/webhook-subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://your-app.com/webhooks/assemblyai",
"events": [],
"secret": "<string>",
"agent_id": "<string>",
"enabled": true
}
'import requests
url = "https://agents.assemblyai.com/v1/webhook-subscriptions"
payload = {
"url": "https://your-app.com/webhooks/assemblyai",
"events": [],
"secret": "<string>",
"agent_id": "<string>",
"enabled": True
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://your-app.com/webhooks/assemblyai',
events: [],
secret: '<string>',
agent_id: '<string>',
enabled: true
})
};
fetch('https://agents.assemblyai.com/v1/webhook-subscriptions', 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://agents.assemblyai.com/v1/webhook-subscriptions",
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://your-app.com/webhooks/assemblyai',
'events' => [
],
'secret' => '<string>',
'agent_id' => '<string>',
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://agents.assemblyai.com/v1/webhook-subscriptions"
payload := strings.NewReader("{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://agents.assemblyai.com/v1/webhook-subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.assemblyai.com/v1/webhook-subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent_id": "<string>",
"url": "<string>",
"events": [],
"enabled": true,
"secret_version": 1,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}Webhooks
Create a webhook subscription
POST
/
v1
/
webhook-subscriptions
Create a webhook subscription
curl --request POST \
--url https://agents.assemblyai.com/v1/webhook-subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://your-app.com/webhooks/assemblyai",
"events": [],
"secret": "<string>",
"agent_id": "<string>",
"enabled": true
}
'import requests
url = "https://agents.assemblyai.com/v1/webhook-subscriptions"
payload = {
"url": "https://your-app.com/webhooks/assemblyai",
"events": [],
"secret": "<string>",
"agent_id": "<string>",
"enabled": True
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://your-app.com/webhooks/assemblyai',
events: [],
secret: '<string>',
agent_id: '<string>',
enabled: true
})
};
fetch('https://agents.assemblyai.com/v1/webhook-subscriptions', 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://agents.assemblyai.com/v1/webhook-subscriptions",
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://your-app.com/webhooks/assemblyai',
'events' => [
],
'secret' => '<string>',
'agent_id' => '<string>',
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://agents.assemblyai.com/v1/webhook-subscriptions"
payload := strings.NewReader("{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://agents.assemblyai.com/v1/webhook-subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agents.assemblyai.com/v1/webhook-subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://your-app.com/webhooks/assemblyai\",\n \"events\": [],\n \"secret\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent_id": "<string>",
"url": "<string>",
"events": [],
"enabled": true,
"secret_version": 1,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": "Unauthorized"
}{
"detail": "Unauthorized"
}Authorizations
Your AssemblyAI API key in the Authorization header (raw key; a Bearer prefix is also accepted).
Body
application/json
Delivery URL. Must be https and a public host.
Example:
"https://your-app.com/webhooks/assemblyai"
Minimum array length:
1Available options:
session.started, session.completed, call.connected, call.ended, call.failed Signing secret, 32–256 printable ASCII chars (no whitespace). Write-only; never returned.
Required string length:
32 - 256Scope to one agent. Omit for account-wide events.
Response
The created subscription.
A subscription. The signing secret is never returned, only its version.
Was this page helpful?
⌘I