Create Webhook

πŸ”” Add a Webhook

Create a new webhook to receive notifications when transcriptions are complete.

Endpoint

POST https://api.tor.app/developer/integrations/webhooks

POST Body Parameters

  • url (string, required): The web address where notifications are sent.
  • export_format (string, optional): Choose the transcript format: Txt, Json, or Csv. Default: Txt.
  • include_timestamps (boolean, optional): Set to true to add timestamps. Default: false.
  • include_speaker_names (boolean, optional): Set to true to include speaker names. Default: false.
  • merge_same_speaker_segments (boolean, optional): Set to true to combine parts by the same speaker. Default: false.
  • is_single_paragraph (boolean, optional): Set to true for one big paragraph. Default: false.
  • paragraph_size (integer, optional): Lines per paragraph (if not single paragraph). Suggested: 1, 2, 4, or 8. Default: 1.
  • folder_id (string, optional): Send notifications only for transcriptions in this folder. Default: none.

Responses

201 Created
{
    "message": "Webhook registered.",
    "webhookType": "wh 2025-05-02 12:34:56"
}
        
400 Bad Request
"Invalid or missing webhook URL."
        
409 Conflict
"Webhook already exists."
        
500 Internal Server Error
"Failed to register webhook."
        

Notes

  • Save the webhookType to manage the webhook later.
  • Notifications sent to the url include details like file ID and name.
import requests
import json

api_key = "YOUR_API_KEY"
url = "https://api.tor.app/developer/integrations/webhooks"
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}
data = {
    "url": "https://your-webhook-url.com",
    "export_format": "Txt",
    "include_timestamps": False,
    "include_speaker_names": False,
    "merge_same_speaker_segments": False,
    "is_single_paragraph": False,
    "paragraph_size": 1
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.status_code)
print(response.json())

const axios = require("axios");

const api_key = "YOUR_API_KEY";
const url = "https://api.tor.app/developer/integrations/webhooks";

const headers = {
  "Authorization": `Bearer ${api_key}`,
  "Content-Type": "application/json"
};

const data = {
  url: "https://your-webhook-url.com",
  export_format: "Txt",
  include_timestamps: false,
  include_speaker_names: false,
  merge_same_speaker_segments: false,
  is_single_paragraph: false,
  paragraph_size: 1
};

axios.post(url, data, { headers })
  .then(response => {
    console.log(response.status);
    console.log(response.data);
  })
  .catch(error => {
    console.error(error.response ? error.response.data : error.message);
  });

import okhttp3.*;
import org.json.JSONObject;

public class AddWebhook {
    public static void main(String[] args) throws Exception {
        String api_key = "YOUR_API_KEY";
        String url = "https://api.tor.app/developer/integrations/webhooks";
        OkHttpClient client = new OkHttpClient();

        JSONObject data = new JSONObject();
        data.put("url", "https://your-webhook-url.com");
        data.put("export_format", "Txt");
        data.put("include_timestamps", false);
        data.put("include_speaker_names", false);
        data.put("merge_same_speaker_segments", false);
        data.put("is_single_paragraph", false);
        data.put("paragraph_size", 1);

        RequestBody body = RequestBody.create(data.toString(), MediaType.parse("application/json"));

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", "Bearer " + api_key)
                .addHeader("Content-Type", "application/json")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            System.out.println(response.code());
            System.out.println(response.body().string());
        }
    }
}

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

class Program {
    static async Task Main(string[] args) {
        string api_key = "YOUR_API_KEY";
        string url = "https://api.tor.app/developer/integrations/webhooks";
        using HttpClient client = new HttpClient();

        client.DefaultRequestHeaders.Add("Authorization", $"Bearer {api_key}");

        var data = new {
            url = "https://your-webhook-url.com",
            export_format = "Txt",
            include_timestamps = false,
            include_speaker_names = false,
            merge_same_speaker_segments = false,
            is_single_paragraph = false,
            paragraph_size = 1
        };

        string json = JsonSerializer.Serialize(data);
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync(url, content);
        Console.WriteLine((int)response.StatusCode);
        string responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseBody);
    }
}

package main

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

func main() {
    api_key := "YOUR_API_KEY"
    url := "https://api.tor.app/developer/integrations/webhooks"

    data := map[string]interface{}{
        "url":                        "https://your-webhook-url.com",
        "export_format":              "Txt",
        "include_timestamps":         false,
        "include_speaker_names":      false,
        "merge_same_speaker_segments": false,
        "is_single_paragraph":        false,
        "paragraph_size":             1,
    }

    jsonData, _ := json.Marshal(data)
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer "+api_key)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    fmt.Println("Status Code:", resp.StatusCode)
    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result)
}

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

api_key = "YOUR_API_KEY"
url = URI("https://api.tor.app/developer/integrations/webhooks")
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"

data = {
  url: "https://your-webhook-url.com",
  export_format: "Txt",
  include_timestamps: false,
  include_speaker_names: false,
  merge_same_speaker_segments: false,
  is_single_paragraph: false,
  paragraph_size: 1
}
request.body = data.to_json

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

<?php
$api_key = "YOUR_API_KEY";
$url = "https://api.tor.app/developer/integrations/webhooks";

$data = [
    "url" => "https://your-webhook-url.com",
    "export_format" => "Txt",
    "include_timestamps" => false,
    "include_speaker_names" => false,
    "merge_same_speaker_segments" => false,
    "is_single_paragraph" => false,
    "paragraph_size" => 1
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer $api_key",
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "Status Code: $status_code\n";
echo $response;
?>

import okhttp3.*
import org.json.JSONObject

fun main() {
    val api_key = "YOUR_API_KEY"
    val url = "https://api.tor.app/developer/integrations/webhooks"
    val client = OkHttpClient()

    val data = JSONObject().apply {
        put("url", "https://your-webhook-url.com")
        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)
    }

    val body = RequestBody.create(
        MediaType.parse("application/json"),
        data.toString()
    )

    val request = Request.Builder()
        .url(url)
        .addHeader("Authorization", "Bearer $api_key")
        .addHeader("Content-Type", "application/json")
        .post(body)
        .build()

    client.newCall(request).execute().use { response ->
        println("Status Code: ${response.code()}")
        println(response.body()?.string())
    }
}

import Foundation

let api_key = "YOUR_API_KEY"
let url = URL(string: "https://api.tor.app/developer/integrations/webhooks")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(api_key)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

let data: [String: Any] = [
    "url": "https://your-webhook-url.com",
    "export_format": "Txt",
    "include_timestamps": false,
    "include_speaker_names": false,
    "merge_same_speaker_segments": false,
    "is_single_paragraph": false,
    "paragraph_size": 1
]

let jsonData = try! JSONSerialization.data(withJSONObject: data)
request.httpBody = jsonData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error.localizedDescription)")
        return
    }
    if let httpResponse = response as? HTTPURLResponse {
        print("Status Code: \(httpResponse.statusCode)")
    }
    if let data = data, let responseString = String(data: data, encoding: .utf8) {
        print(responseString)
    }
}
task.resume()

import 'dart:convert';
import 'dart:io';

void main() async {
  final api_key = "YOUR_API_KEY";
  final url = Uri.parse("https://api.tor.app/developer/integrations/webhooks");
  final client = HttpClient();

  final data = {
    "url": "https://your-webhook-url.com",
    "export_format": "Txt",
    "include_timestamps": false,
    "include_speaker_names": false,
    "merge_same_speaker_segments": false,
    "is_single_paragraph": false,
    "paragraph_size": 1
  };

  try {
    final request = await client.postUrl(url);
    request.headers.set("Authorization", "Bearer $api_key");
    request.headers.set("Content-Type", "application/json");
    request.add(utf8.encode(jsonEncode(data)));

    final response = await request.close();
    final responseBody = await response.transform(utf8.decoder).join();
    print("Status Code: ${response.statusCode}");
    print(responseBody);
  } catch (e) {
    print("Error: $e");
  } finally {
    client.close();
  }
}