Registering a Webhook

📡 Register a Webhook

You can register a webhook to get notified when a transcription is ready.

Parameter Guidelines

  • 'export_format': Desired format of the transcript: txt, srt, pdf, docx.
  • 'include_speaker_names': Boolean ('True'/'False') to include speaker identification.
  • 'include_timestamps': Boolean ('True'/'False') to add timestamps showing when each text segment was spoken.
  • 'merge_same_speaker_segments': Boolean ('True'/'False') to merge segments from the same speaker into one paragraph.
  • 'single_paragraph': Boolean ('True'/'False') to output the transcript as a single paragraph.
  • 'paragraph_size': Control the size of paragraphs: 1, 2, 4, 8.
  • 'folder_id': Include the id of the folder you want to monitor for new transcriptions. ⚠️ Warning: Do not include folder id in your request if you want to monitor changes in "Recent Files" section.
import requests

url = "https://api.tor.app/integrations/register-webhook"

# Replace the YOUR_API_KEY with your own api key
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
}
body = {
    "url": "https://example.com/my-test-webhook",
    "export_format": "txt",
    "include_timestamps": "true",
    "include_speaker_names": "true",
    "merge_same_speaker_segments": "false",
    "single_paragraph": "false",
    "paragraph_size": "4",
    "folder_id": "123456789ABCD" # Do not include folder_id if you want to monitor changes for "Recent Files"
}

resp = requests.post(url, json=body, headers=headers)

print(resp.status_code)
print(resp.text)

const url = "https://api.tor.app/integrations/register-webhook";

// Replace YOUR_API_KEY with your own API key
const headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
};

const body = {
    "url": "https://example.com/my-test-webhook",
    "export_format": "txt",
    "include_timestamps": "true",
    "include_speaker_names": "true",
    "merge_same_speaker_segments": "false",
    "single_paragraph": "false",
    "paragraph_size": "4",
  	"folder_id": "123456789ABCD"
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(body)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) {
        try {
            String url = "https://api.tor.app/integrations/register-webhook";
            URL obj = new URL(url);
            HttpURLConnection con = (HttpURLConnection) obj.openConnection();

            // Replace YOUR_API_KEY with your own API key
            con.setRequestProperty("Authorization", "Bearer YOUR_API_KEY");
            con.setRequestProperty("Content-Type", "application/json");
            con.setRequestMethod("POST");

            String jsonInputString = "{"
                + "\"url\": \"https://example.com/my-test-webhook\","
                + "\"export_format\": \"txt\","
                + "\"include_timestamps\": \"true\","
                + "\"include_speaker_names\": \"true\","
                + "\"merge_same_speaker_segments\": \"false\","
                + "\"single_paragraph\": \"false\","
                + "\"paragraph_size\": \"4\","
              	+ "\"folder_id\": \"123456789ABCD\""
                + "}";

            con.setDoOutput(true);
            try (OutputStream os = con.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }

            int responseCode = con.getResponseCode();
            System.out.println("POST Response Code :: " + responseCode);

            if (responseCode == HttpURLConnection.HTTP_OK) { // success
                System.out.println("POST request worked");
            } else {
                System.out.println("POST request did not work");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var url = "https://api.tor.app/integrations/register-webhook";

        // Replace YOUR_API_KEY with your own API key
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

        var body = new
        {
            url = "https://example.com/my-test-webhook",
            export_format = "txt",
            include_timestamps = "true",
            include_speaker_names = "true",
            merge_same_speaker_segments = "false",
            single_paragraph = "false",
            paragraph_size = "4",
            folder_id = "123456789ABCD"
        };

        var json = Newtonsoft.Json.JsonConvert.SerializeObject(body);
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        var response = await client.PostAsync(url, content);
        var responseString = await response.Content.ReadAsStringAsync();

        Console.WriteLine(response.StatusCode);
        Console.WriteLine(responseString);
    }
}

package main

import (
    "bytes"
    "fmt"
    "net/http"
)

func main() {
    url := "https://api.tor.app/integrations/register-webhook"

    jsonStr := `{
        "url": "https://example.com/my-test-webhook",
        "export_format": "txt",
        "include_timestamps": "true",
        "include_speaker_names": "true",
        "merge_same_speaker_segments": "false",
        "single_paragraph": "false",
        "paragraph_size": "4",
        "folder_id":"123456789ABCD"
    }`

    req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(jsonStr)))
    if err != nil {
        panic(err)
    }

    // Replace YOUR_API_KEY with your own API key
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Println("Status:", resp.Status)
}

require 'net/http'
require 'uri'
require 'json'

url = URI("https://api.tor.app/integrations/register-webhook")

# Replace YOUR_API_KEY with your own API key
headers = {
  'Authorization' => 'Bearer YOUR_API_KEY',
  'Content-Type' => 'application/json'
}

body = {
  url: "https://example.com/my-test-webhook",
  export_format: "txt",
  include_timestamps: "true",
  include_speaker_names: "true",
  merge_same_speaker_segments: "false",
  single_paragraph: "false",
  paragraph_size: "4",
  folder_id: "123456789ABCD"
}.to_json

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url, headers)
request.body = body

response = http.request(request)
puts response.code
puts response.body

<?php

$url = "https://api.tor.app/integrations/register-webhook";

// Replace YOUR_API_KEY with your own API key
$headers = [
    "Authorization: Bearer YOUR_API_KEY",
    "Content-Type: application/json"
];

$body = [
    "url" => "https://example.com/my-test-webhook",
    "export_format" => "txt",
    "include_timestamps" => "true",
    "include_speaker_names" => "true",
    "merge_same_speaker_segments" => "false",
    "single_paragraph" => "false",
    "paragraph_size" => "4",
    "folder_id" => "123456789ABCD",
];

$options = [
    "http" => [
        "header"  => implode("\r\n", $headers),
        "method"  => "POST",
        "content" => json_encode($body),
    ],
];

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);

if ($response === FALSE) {
    die('Error');
}

var_dump($http_response_header);
var_dump($response);
?>

import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets

fun main() {
    val url = URL("https://api.tor.app/integrations/register-webhook")

    val jsonInputString = """
        {
            "url": "https://example.com/my-test-webhook",
            "export_format": "txt",
            "include_timestamps": "true",
            "include_speaker_names": "true",
            "merge_same_speaker_segments": "false",
            "single_paragraph": "false",
            "paragraph_size": "4",
            "folder_id": "123456789ABCD"
        }
    """.trimIndent()

    with(url.openConnection() as HttpURLConnection) {
        requestMethod = "POST"

        // Replace YOUR_API_KEY with your own API key
        setRequestProperty("Authorization", "Bearer YOUR_API_KEY")
        setRequestProperty("Content-Type", "application/json")

        doOutput = true
        outputStream.use { os ->
            val input = jsonInputString.toByteArray(StandardCharsets.UTF_8)
            os.write(input, 0, input.size)
        }

        println("Response Code: $responseCode")
        inputStream.bufferedReader().use {
            println(it.readText())
        }
    }
}

import Foundation

let url = URL(string: "https://api.tor.app/integrations/register-webhook")!

var request = URLRequest(url: url)
request.httpMethod = "POST"

// Replace YOUR_API_KEY with your own API key
request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = [
    "url": "https://example.com/my-test-webhook",
    "export_format": "txt",
    "include_timestamps": "true",
    "include_speaker_names": "true",
    "merge_same_speaker_segments": "false",
    "single_paragraph": "false",
    "paragraph_size": "4",
    "folder_id":"123456789ABCD"
]

request.httpBody = try! JSONSerialization.data(withJSONObject: body, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else {
        print("Error: \(error?.localizedDescription ?? "Unknown error")")
        return
    }
    if let httpResponse = response as? HTTPURLResponse {
        print("Response Code: \(httpResponse.statusCode)")
    }
    print(String(data: data, encoding: .utf8)!)
}

task.resume()

import 'dart:convert';
import 'package:http/http.dart' as http;

void main() async {
  var url = Uri.parse('https://api.tor.app/integrations/register-webhook');

  // Replace YOUR_API_KEY with your own API key
  var headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  };

  var body = jsonEncode({
    'url': 'https://example.com/my-test-webhook',
    'export_format': 'txt',
    'include_timestamps': 'true',
    'include_speaker_names': 'true',
    'merge_same_speaker_segments': 'false',
    'single_paragraph': 'false',
    'paragraph_size': '4',
    'folder_id': '123456789ABCD'
  });

  var response = await http.post(url, headers: headers, body: body);

  print('Response status: ${response.statusCode}');
  print('Response body: ${response.body}');
}