Documentazione ›
Webhook di stato › Webhook di stato — SMS
POST
Webhook di stato — SMS
POSThttps://app.sendapp.ai/api/sms/set_webhook
Registra (POST) un URL sul tuo server per ricevere in tempo reale gli eventi SMS (sms_received, device.disconnected, device.reconnected, device.deleted). Ogni evento viene inoltrato al tuo URL via HTTP POST. Usa DELETE per rimuovere il webhook.
Il tuo server deve rispondere con HTTP 200 entro 5 secondi. Gli errori sul tuo endpoint vengono ignorati silenziosamente.
Parametri
apikey
obbligatorio
La tua API Key.
token
obbligatorio
Token dell'account.
url
opzionale
Il tuo URL server (HTTPS). Non necessario per la DELETE.
Richiesta
# Registra il webhook
curl -X POST 'https://app.sendapp.ai/api/sms/set_webhook' \
-H 'Content-Type: application/json' \
-d '{ "apikey": "YOUR_API_KEY", "token": "YOUR_ACCOUNT_TOKEN", "url": "https://your-server.com/sms-webhook" }'
# Rimuovi il webhook
curl -X DELETE 'https://app.sendapp.ai/api/sms/set_webhook' \
-H 'Content-Type: application/json' \
-d '{ "apikey": "YOUR_API_KEY", "token": "YOUR_ACCOUNT_TOKEN" }'<?php
$ch = curl_init('https://app.sendapp.ai/api/sms/set_webhook');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'apikey' => 'YOUR_API_KEY',
'token' => 'YOUR_ACCOUNT_TOKEN',
'url' => 'https://your-server.com/sms-webhook',
]),
]);
echo curl_exec($ch);
curl_close($ch);const res = await fetch('https://app.sendapp.ai/api/sms/set_webhook', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
apikey: 'YOUR_API_KEY',
token: 'YOUR_ACCOUNT_TOKEN',
url: 'https://your-server.com/sms-webhook'
})
});
console.log(await res.json());Risposta (200 OK)
{
"status": "success",
"message": "Webhook URL saved successfully."
}Errore
{
"status": "error",
"message": "Instance not found"
}