Skip to main content
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

Authorization
string
header
required

Your AssemblyAI API key in the Authorization header (raw key; a Bearer prefix is also accepted).

Body

application/json
url
string
required

Delivery URL. Must be https and a public host.

Example:

"https://your-app.com/webhooks/assemblyai"

events
enum<string>[]
required
Minimum array length: 1
Available options:
session.started,
session.completed,
call.connected,
call.ended,
call.failed
secret
string
required

Signing secret, 32–256 printable ASCII chars (no whitespace). Write-only; never returned.

Required string length: 32 - 256
agent_id
string | null

Scope to one agent. Omit for account-wide events.

enabled
boolean
default:true

Response

The created subscription.

A subscription. The signing secret is never returned, only its version.

id
string
agent_id
string | null
url
string
events
enum<string>[]
Available options:
session.started,
session.completed,
call.connected,
call.ended,
call.failed
enabled
boolean
secret_version
integer
Example:

1

created_at
string<date-time>
updated_at
string<date-time>