Register Webhook
π Set Up Transcription Completion Webhook
Configure a webhook to receive notifications when transcriptions are completed. Customize the export format and metadata to fit your needs.
Webhook Configuration Parameters
- url (string): The callback URL to receive notifications upon transcription completion.
- export_format (string): Choose the export format:
Txt
,Srt
,Pdf
, orDocx
. - include_timestamps (boolean): Set to
true
to include timestamps in the export. - include_speaker_names (boolean): Set to
true
to include speaker labels. - merge_same_speaker_segments (boolean): Set to
true
to combine segments spoken by the same speaker. - is_single_paragraph (boolean): Set to
true
to export the transcript as a single paragraph. - paragraph_size (integer): Controls paragraph size when
is_single_paragraph
isfalse
. Acceptable values: 1, 2, 4, or 8. - folder_id (string, optional): If provided, the webhook only triggers for transcriptions in this folder. Defaults to "Recent Files" if omitted.
import requests
import json
url = "https://api.tor.app/developer/integrations/webhooks/transcription_completed"
api_key = "your_api_key" # Replace with your actual API key
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
"Accept": "application/json",
}
# Define the request body parameters
# If you specify a folder_id, the webhook will only be triggered for transcriptions in that folder
# If you do not specify a folder_id, the webhook will be triggered for the transcriptions in "Recent Files" folder
body = {
"url": "https://your-callback-url.com/webhook",
"export_format": "Txt",
"include_timestamps": False,
"include_speaker_names": False,
"merge_same_speaker_segments": False,
"is_single_paragraph": False,
"paragraph_size": 1,
"folder_id": "your_folder_id_here", # Optional, specify if needed
}
# Send the POST request
resp = requests.post(url, headers=headers, data=json.dumps(body))
# Print the response status and body
print(resp.status_code)
print(resp.text)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const body = {
url: "https://your-callback-url.com/webhook",
export_format: "Txt",
include_timestamps: false,
include_speaker_names: false,
merge_same_speaker_segments: false,
is_single_paragraph: false,
paragraph_size: 1,
folder_id: "your_folder_id_here" // Optional, specify if needed
};
axios.post("https://api.tor.app/developer/integrations/webhooks/transcription_completed", body, { headers })
.then(response => {
console.log(response.status);
console.log(response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
import org.json.JSONObject;
public class SetupWebhook {
private static final String API_KEY = "your_api_key";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/integrations/webhooks/transcription_completed";
JSONObject body = new JSONObject();
body.put("url", "https://your-callback-url.com/webhook");
body.put("export_format", "Txt");
body.put("include_timestamps", false);
body.put("include_speaker_names", false);
body.put("merge_same_speaker_segments", false);
body.put("is_single_paragraph", false);
body.put("paragraph_size", 1);
body.put("folder_id", "your_folder_id_here");
RequestBody requestBody = RequestBody.create(body.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println("Status Code: " + response.code());
System.out.println("Response Body: " + response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/integrations/webhooks/transcription_completed";
var payload = new
{
url = "https://your-callback-url.com/webhook",
export_format = "Txt",
include_timestamps = false,
include_speaker_names = false,
merge_same_speaker_segments = false,
is_single_paragraph = false,
paragraph_size = 1,
folder_id = "your_folder_id_here"
};
var jsonPayload = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.PostAsync(url, jsonPayload);
Console.WriteLine("Status Code: " + response.StatusCode);
Console.WriteLine("Response Body: " + await response.Content.ReadAsStringAsync());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
func main() {
url := "https://api.tor.app/developer/integrations/webhooks/transcription_completed"
body := map[string]interface{}{
"url": "https://your-callback-url.com/webhook",
"export_format": "Txt",
"include_timestamps": false,
"include_speaker_names": false,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
"folder_id": "your_folder_id_here",
}
payloadBytes, _ := json.Marshal(body)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
fmt.Printf("Status Code: %d\n", resp.StatusCode)
var response map[string]interface{}
json.NewDecoder(resp.Body).Decode(&response)
fmt.Println("Response Body:", response)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
url = URI("https://api.tor.app/developer/integrations/webhooks/transcription_completed")
body = {
"url" => "https://your-callback-url.com/webhook",
"export_format" => "Txt",
"include_timestamps" => false,
"include_speaker_names" => false,
"merge_same_speaker_segments" => false,
"is_single_paragraph" => false,
"paragraph_size" => 1,
"folder_id" => "your_folder_id_here"
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = body.to_json
response = http.request(request)
puts "Status Code: #{response.code}"
puts "Response Body: #{response.body}"
<?php
$apiKey = "your_api_key";
$url = "https://api.tor.app/developer/integrations/webhooks/transcription_completed";
$payload = json_encode([
"url" => "https://your-callback-url.com/webhook",
"export_format" => "Txt",
"include_timestamps" => false,
"include_speaker_names" => false,
"merge_same_speaker_segments" => false,
"is_single_paragraph" => false,
"paragraph_size" => 1,
"folder_id" => "your_folder_id_here"
]);
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status Code: $httpCode\n";
echo "Response Body: $response\n";
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val url = "https://api.tor.app/developer/integrations/webhooks/transcription_completed"
val payload = JSONObject().apply {
put("url", "https://your-callback-url.com/webhook")
put("export_format", "Txt")
put("include_timestamps", false)
put("include_speaker_names", false)
put("merge_same_speaker_segments", false)
put("is_single_paragraph", false)
put("paragraph_size", 1)
put("folder_id", "your_folder_id_here")
}
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println("Status Code: ${response.code()}")
println("Response Body: ${response.body()?.string()}")
}
}
import Foundation
let apiKey = "your_api_key"
let url = URL(string: "https://api.tor.app/developer/integrations/webhooks/transcription_completed")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"url": "https://your-callback-url.com/webhook",
"export_format": "Txt",
"include_timestamps": false,
"include_speaker_names": false,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
"folder_id": "your_folder_id_here"
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let httpResponse = response as? HTTPURLResponse {
print("Status Code: \(httpResponse.statusCode)")
let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: [])
print("Response Body:", jsonResponse ?? "Failed to parse response")
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
final url = Uri.parse('https://api.tor.app/developer/integrations/webhooks/transcription_completed');
final payload = jsonEncode({
"url": "https://your-callback-url.com/webhook",
"export_format": "Txt",
"include_timestamps": false,
"include_speaker_names": false,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
"folder_id": "your_folder_id_here"
});
final request = await HttpClient().postUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print("Status Code: ${response.statusCode}");
print("Response Body: $responseBody");
} else {
print("Request failed with status: ${response.statusCode}");
final responseBody = await response.transform(utf8.decoder).join();
print("Response Body: $responseBody");
}
}
Updated about 1 month ago