curl --request POST \
--url https://api.thoughtly.com/webhooks/subscribe \
--header 'Content-Type: application/json' \
--header 'team_id: <api-key>' \
--header 'x-api-token: <api-key>' \
--data '
{
"type": "NEW_RESPONSE",
"url": "<string>",
"data": "<string>"
}
'import requests
url = "https://api.thoughtly.com/webhooks/subscribe"
payload = {
"type": "NEW_RESPONSE",
"url": "<string>",
"data": "<string>"
}
headers = {
"x-api-token": "<api-key>",
"team_id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-token': '<api-key>',
team_id: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({type: 'NEW_RESPONSE', url: '<string>', data: '<string>'})
};
fetch('https://api.thoughtly.com/webhooks/subscribe', 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://api.thoughtly.com/webhooks/subscribe",
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([
'type' => 'NEW_RESPONSE',
'url' => '<string>',
'data' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"team_id: <api-key>",
"x-api-token: <api-key>"
],
]);
$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://api.thoughtly.com/webhooks/subscribe"
payload := strings.NewReader("{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
req.Header.Add("team_id", "<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://api.thoughtly.com/webhooks/subscribe")
.header("x-api-token", "<api-key>")
.header("team_id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.thoughtly.com/webhooks/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
request["team_id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {},
"error": {}
}Subscribe to webhook
This endpoint allows you to subscribe to a specific webhook event (e.g., new call responses or phone transfers). You must provide the event type and a callback URL.
curl --request POST \
--url https://api.thoughtly.com/webhooks/subscribe \
--header 'Content-Type: application/json' \
--header 'team_id: <api-key>' \
--header 'x-api-token: <api-key>' \
--data '
{
"type": "NEW_RESPONSE",
"url": "<string>",
"data": "<string>"
}
'import requests
url = "https://api.thoughtly.com/webhooks/subscribe"
payload = {
"type": "NEW_RESPONSE",
"url": "<string>",
"data": "<string>"
}
headers = {
"x-api-token": "<api-key>",
"team_id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-token': '<api-key>',
team_id: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({type: 'NEW_RESPONSE', url: '<string>', data: '<string>'})
};
fetch('https://api.thoughtly.com/webhooks/subscribe', 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://api.thoughtly.com/webhooks/subscribe",
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([
'type' => 'NEW_RESPONSE',
'url' => '<string>',
'data' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"team_id: <api-key>",
"x-api-token: <api-key>"
],
]);
$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://api.thoughtly.com/webhooks/subscribe"
payload := strings.NewReader("{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
req.Header.Add("team_id", "<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://api.thoughtly.com/webhooks/subscribe")
.header("x-api-token", "<api-key>")
.header("team_id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.thoughtly.com/webhooks/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
request["team_id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"NEW_RESPONSE\",\n \"url\": \"<string>\",\n \"data\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {},
"error": {}
}Authorizations
API key for the user making the request. This can be found via the Developer Settings page in the dashboard.
Team identifier, used to scope requests to a specific team. This can be found via the Developer Settings page in the dashboard.
Body
The type of webhook event to subscribe to. Choose 'NEW_RESPONSE' for new call responses or 'PHONE_TRANSFER' for phone call transfers.
NEW_RESPONSE, PHONE_TRANSFER "NEW_RESPONSE"
The callback URL where the webhook should send the event.
Additional data that can be included with the webhook event. This is optional.
Response
Successful response
The generic response format for all API requests. This structure ensures consistency in how success and error information is returned to the caller.
Contains the response data for the successful request. This field will vary based on the specific API endpoint being called and contains the main data returned from the API. For example, it may include information about a created contact, agent, or webhook subscription.
An object containing error details, if any. This field will be populated if the API request fails or encounters an error. If the request is successful, this field will be null or omitted.
Was this page helpful?