Create webhook endpoint
curl --request POST \
--url https://api.social-api.ai/v1/webhooks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
"comment.received",
"dm.received"
],
"url": "https://example.com/webhooks/socialapi"
}
'import requests
url = "https://api.social-api.ai/v1/webhooks"
payload = {
"events": ["comment.received", "dm.received"],
"url": "https://example.com/webhooks/socialapi"
}
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({
events: ['comment.received', 'dm.received'],
url: 'https://example.com/webhooks/socialapi'
})
};
fetch('https://api.social-api.ai/v1/webhooks', 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.social-api.ai/v1/webhooks",
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([
'events' => [
'comment.received',
'dm.received'
],
'url' => 'https://example.com/webhooks/socialapi'
]),
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://api.social-api.ai/v1/webhooks"
payload := strings.NewReader("{\n \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\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://api.social-api.ai/v1/webhooks")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/webhooks")
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 \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\n}"
response = http.request(request)
puts response.read_body{
"events": [
"comment.received",
"dm.received"
],
"id": "wh_01HZ9X3Q4R5M6N7P8V2K0W1J",
"message": "Store the secret securely. It will not be shown again.",
"secret": "4f3c2a1b9e8d7c6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2",
"url": "https://example.com/webhooks/socialapi"
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Webhooks
Create webhook endpoint
Registers a new webhook endpoint and performs a live reachability ping. If the endpoint is unreachable or returns an unexpected response, the request fails with 400 (webhook_verification_failed). The generated secret is returned once - store it securely.
POST
/
webhooks
Create webhook endpoint
curl --request POST \
--url https://api.social-api.ai/v1/webhooks \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
"comment.received",
"dm.received"
],
"url": "https://example.com/webhooks/socialapi"
}
'import requests
url = "https://api.social-api.ai/v1/webhooks"
payload = {
"events": ["comment.received", "dm.received"],
"url": "https://example.com/webhooks/socialapi"
}
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({
events: ['comment.received', 'dm.received'],
url: 'https://example.com/webhooks/socialapi'
})
};
fetch('https://api.social-api.ai/v1/webhooks', 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.social-api.ai/v1/webhooks",
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([
'events' => [
'comment.received',
'dm.received'
],
'url' => 'https://example.com/webhooks/socialapi'
]),
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://api.social-api.ai/v1/webhooks"
payload := strings.NewReader("{\n \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\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://api.social-api.ai/v1/webhooks")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/webhooks")
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 \"events\": [\n \"comment.received\",\n \"dm.received\"\n ],\n \"url\": \"https://example.com/webhooks/socialapi\"\n}"
response = http.request(request)
puts response.read_body{
"events": [
"comment.received",
"dm.received"
],
"id": "wh_01HZ9X3Q4R5M6N7P8V2K0W1J",
"message": "Store the secret securely. It will not be shown again.",
"secret": "4f3c2a1b9e8d7c6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2",
"url": "https://example.com/webhooks/socialapi"
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Authorizations
Prefix your API key with "Bearer ". Example: Authorization: Bearer sapi_key_...
Body
application/json
Endpoint config
Events is the list of event types to subscribe to.
Available options:
post.scheduled, post.published, post.failed, post.partial, post.updated, post.deleted, post.unpublished, post.retried, comment.received, dm.received, dm.sent, dm.referral, dm.postback, dm.status.sent, dm.status.delivered, dm.status.read, dm.status.failed, review.received, review.updated, mention.received, account.connected, account.disconnected, account.updated, page.removed Example:
["comment.received", "dm.received"]
URL is the HTTPS endpoint that will receive webhook POST requests.
Example:
"https://example.com/webhooks/socialapi"
Response
Endpoint created
Example:
["comment.received", "dm.received"]
Example:
"wh_01HZ9X3Q4R5M6N7P8V2K0W1J"
Example:
"Store the secret securely. It will not be shown again."
Example:
"4f3c2a1b9e8d7c6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2"
Example:
"https://example.com/webhooks/socialapi"