Set Webhook
POST/facebook/setWebhook
This endpoint allows you to set (or clear) the webhook URL of a connection, where we send you what happens on your Facebook Page or Instagram account.
What we send to this URL, and when, is explained on the Webhook Events page, with one page for every kind of event: Facebook Comment, Facebook Post, Facebook Lead, Instagram Comment and Instagram Post.
- The webhook URL belongs to one connection (one
from). A Facebook Page connection and an Instagram connection each have their ownfrom, so each one needs its own call: you can give them different URLs, or the same URL. - Everything we send for a connection goes to its one URL, and
eventin the payload tells you what arrived. For a Messenger connection, the same URL also receives thesendStatusof the messages you send. - The change applies immediately. An empty
urlclears it: from then on, nothing is sent for this connection until you set a URL again.
When a connection is onboarded again (for example, to renew its access),
you keep the same from and apiKey, but its webhook URL is erased. Call
Set Webhook again right after every onboarding, or you stop receiving
webhooks for that connection.
Settings:
| Setting | Value |
|---|---|
| URL | https://api.99digital.co.il/facebook/setWebhook |
| Method | JSON via POST |
| Header | Your API key for the service (the apiKey header) |
Body:
| Parameter | Description / Example | Mandatory | Example |
|---|---|---|---|
| from | The ID you received for the connection. Works for every connection type (Facebook Pages, Instagram, Facebook Messenger and Instagram Messenger) | yes | 463745743546345 |
| url | Your webhook URL: https:// only, on a public host, up to 2,000 characters (see the URL rules below). Send an empty string "" to clear it | yes | https://your-server.example.com/99digital/facebook-webhook |
URL rules (a URL that breaks them is not saved, and you get reason 9):
- It must start with
https://.http://and every other scheme are refused. - The host can't be
localhost, a name that ends with.localhostor.internal, or a private, loopback or link-local IP address (10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.0/8,169.254.0.0/16,0.0.0.0/8,::1,::,fc00::/7,fe80::/10, also when written as an IPv4-mapped IPv6 address such as::ffff:10.0.0.1). - An IPv4 address must be in the normal dotted form (
203.0.113.10). Short, decimal, hex or octal forms (127.1,2130706433,0x7f000001) are refused. IPv6 addresses are accepted unless they are in a blocked range: loopback (::1), private (unique-local,fc00::/7), link-local (fe80::/10), unspecified (::), or an IPv4-mapped address of a blocked IPv4 range (::ffff:10.0.0.1). - A host name must exist, and none of its addresses may be in the ranges above: if even one of them is, the URL is refused.
- A host name with non-English letters must be sent in its punycode form
(
xn--…).
Response:
{
"status": "OK",
"from": "463745743546345",
"timestamp": 1795600000,
"reason": 1,
"url": "https://your-server.example.com/99digital/facebook-webhook"
}
Response-Explain:
| Parameter | Description |
|---|---|
| status | OK or FAIL |
| from | Your ID for the service |
| timestamp | Time stamp of the message |
| url | The webhook URL that is now saved for this connection. Empty when you cleared it |
reason:
| Value | Information |
|---|---|
| 1 | Not FAIL. The status is OK |
| 2 | Your "from" account does not exist (for example, its onboarding is not finished yet) or is missing, or JSON syntax error. Also when the check of your host name's DNS was slow or failed for a moment: send the same request again |
| 3 | Wrong apiKey (the apiKey header is missing or wrong) |
| 5 | 'url' is missing (or is not a string), or it is not a valid URL: for example, it has no scheme or no host, or it has spaces, backslashes or control characters |
| 7 | The connection is not active (it was disabled) |
| 8 | 'url' is longer than 2,000 characters |
| 9 | The URL is not allowed: it is not https://, or its host is (or resolves to) a private or internal address, or the host name does not exist. See the URL rules above |
Remarks:
- A
urlof spaces only is the same as an empty string: it clears the URL. - Events that happen while no URL is set are not sent to you, not even after you set one.
Request
Responses
- 200
The request was processed. Both a successful and a failed request answer with HTTP 200 — check status, and reason when it is FAIL.