Skip to main content

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 own from, 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 event in the payload tells you what arrived. For a Messenger connection, the same URL also receives the sendStatus of the messages you send.
  • The change applies immediately. An empty url clears it: from then on, nothing is sent for this connection until you set a URL again.
warning

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:

SettingValue
URLhttps://api.99digital.co.il/facebook/setWebhook
MethodJSON via POST
HeaderYour API key for the service (the apiKey header)

Body:

ParameterDescription / ExampleMandatoryExample
fromThe ID you received for the connection. Works for every connection type (Facebook Pages, Instagram, Facebook Messenger and Instagram Messenger)yes463745743546345
urlYour webhook URL: https:// only, on a public host, up to 2,000 characters (see the URL rules below). Send an empty string "" to clear ityeshttps://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 .localhost or .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:

ParameterDescription
statusOK or FAIL
fromYour ID for the service
timestampTime stamp of the message
urlThe webhook URL that is now saved for this connection. Empty when you cleared it

reason:

ValueInformation
1Not FAIL. The status is OK
2Your "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
3Wrong 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
7The connection is not active (it was disabled)
8'url' is longer than 2,000 characters
9The 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 url of 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​

The request was processed. Both a successful and a failed request answer with HTTP 200 — check status, and reason when it is FAIL.