<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/partners-api/settings/webhook/facebook-event

# Event: Facebook

**Webhook.** Sent to the webhook URL you configure.

For every Facebook event, you will get a webhook (`event` "facebook"). It is sent once, when your client completes the onboarding of a link you created with [Create onboarding Link](https://docs.99digital.co.il/partners-api/facebook/create-onboarding-link) — see [Start Here!](https://docs.99digital.co.il/partners-api/facebook/start-here). `facebook_type` is the type that was onboarded.

- `from` and `apiKey` are the credentials to send outgoing messages and data
  of this connection with our [Facebook API](https://docs.99digital.co.il/facebook-api). If the same
  Facebook page or Instagram account is onboarded again with the same type,
  you get the same `from` and `apiKey`.
- The `instagram_…` fields are sent only for `facebook_type` 2 or 4.
- The page, Instagram and admin details are as they were at the onboarding
  time. A detail that Facebook didn't provide is empty (or 0).

**Settings:**

| Setting | Value |
| --- | --- |
| URL | Your URL — set it with [Set Webhook](https://docs.99digital.co.il/partners-api/settings/webhook/set-webhook) |
| Method | JSON via POST |

**With every Facebook event, you will get some of the following:**

```json
{
  "status": "OK",
  "event": "facebook",
  "facebook_type": 2,
  "facebook_type_name": "Instagram Messenger",
  "facebook_reference": "my-reference",
  "from": "623748845667358",
  "apiKey": "5e2b8d-a1c4f7-09d3e6-b8f2a5-c7e1d4",
  "server": "online.99digital.co.il",
  "account_id": 1,
  "inbox_id": 2,
  "business_id": "184736291045832",
  "business_name": "My Flowers Business Ltd",
  "page_id": "123637468573457",
  "page_name": "My Flowers Business",
  "page_category": "Retail Company",
  "page_link": "https://www.facebook.com/123637468573457",
  "page_about": "Fresh flowers, delivered every day",
  "page_fan_count": 400,
  "page_picture": "https://www.example.com/images/page-picture.jpg",
  "admin_name": "George Levi",
  "admin_email": "george@example.com",
  "instagram_id": "17841463464574680",
  "instagram_username": "george_flowers",
  "instagram_name": "My Flowers Business",
  "instagram_profile_picture": "https://www.example.com/images/instagram-profile.jpg",
  "instagram_followers_count": 530,
  "instagram_media_count": 54,
  "instagram_biography": "This is my flowers shop",
  "instagram_website": "https://www.flowersshop.example.com"
}
```

### Response explained

| Parameter | Description / Example |
| --- | --- |
| `status` | "OK" always. |
| `event` | "facebook" always. |
| `facebook_type` | The type that was onboarded. See the values below. |
| `facebook_type_name` | The same as `facebook_type`, in text. |
| `facebook_reference` | The reference value that was provided by you when creating the onboarding link. Empty when you didn't provide one. |
| `from` | The ID we generate for you, that comes together with the `apiKey` in order to send outgoing messages. It contains 15 digits. |
| `apiKey` | The apiKey for the service — this is how you initiate outgoing messages and data with our Facebook API, together with `from`. |
| `server` | The Online server, if provided when creating the onboarding link. Empty otherwise. |
| `account_id` | The Online account id, if provided when creating the onboarding link. 0 otherwise. |
| `inbox_id` | The Online inbox id, if provided when creating the onboarding link. 0 otherwise. |
| `business_id` | The id of the client's business on Facebook (Meta Business Portfolio). Empty when it isn't available. |
| `business_name` | The name of the client's business on Facebook (Meta Business Portfolio). Empty when it isn't available. |
| `page_id` | The page id of the Facebook account (relevant for all 4 types of onboarding). Even when you connect an Instagram account only, there is still a Facebook page id, since an Instagram account is always connected to a Facebook page. |
| `page_name` | The Facebook page name (of that `page_id`). |
| `page_category` | The category of the page. |
| `page_link` | The Facebook page link URL. |
| `page_about` | The Facebook page about information. |
| `page_fan_count` | The number of fans (followers) of the Facebook page at the onboarding time. |
| `page_picture` | The profile picture of the Facebook page. |
| `admin_name` | The Facebook page admin name — the admin of the client's business on Facebook when it is available, otherwise the Facebook user who completed the onboarding. |
| `admin_email` | The Facebook page admin email address — of the same admin as `admin_name`. Empty when Facebook doesn't provide it. |
| `instagram_id` | The Instagram page id. Sent only for `facebook_type` 2 or 4. |
| `instagram_username` | The Instagram username, without `@`. Sent only for `facebook_type` 2 or 4. |
| `instagram_name` | The Instagram page name. Sent only for `facebook_type` 2 or 4. |
| `instagram_profile_picture` | The Instagram page profile picture. Sent only for `facebook_type` 2 or 4. |
| `instagram_followers_count` | The Instagram page total followers count at the onboarding time. Sent only for `facebook_type` 2 or 4. |
| `instagram_media_count` | Total media uploaded to the Instagram page (total posts). Sent only for `facebook_type` 2 or 4. |
| `instagram_biography` | The biography written on the Instagram page. Sent only for `facebook_type` 2 or 4. |
| `instagram_website` | The website provided on the Instagram page. Sent only for `facebook_type` 2 or 4. |

#### `facebook_type`

| Value | Explanation |
| --- | --- |
| 1 | Facebook Messenger. |
| 2 | Instagram Messenger. |
| 3 | Facebook Page (posts and comments). |
| 4 | Instagram Page (posts and comments). |

## Webhook payload

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string | Yes | "OK" always. One of: `OK`. |
| `event` | string | Yes | "facebook" always. Always `facebook`. |
| `facebook_type` | integer | Yes | The type that was onboarded. One of: `1` — Facebook Messenger; `2` — Instagram Messenger; `3` — Facebook Page (posts and comments); `4` — Instagram Page (posts and comments). Example: `1`. |
| `facebook_type_name` | string | Yes | The same as `facebook_type`, in text. One of: `Facebook Messenger`, `Instagram Messenger`, `Facebook Page (posts & comments)`, `Instagram Page (posts & comments)`. Example: `Facebook Messenger`. |
| `facebook_reference` | string | Yes | The reference value that was provided by you when creating the onboarding link. Empty when you didn't provide one. Example: `my-reference`. |
| `from` | string | Yes | The ID we generate for you, that comes together with the `apiKey` in order to send outgoing messages. It contains 15 digits. Example: `623748845667358`. |
| `apiKey` | string | Yes | The apiKey for the service — this is how you initiate outgoing messages and data with our Facebook API, together with `from`. Example: `5e2b8d-a1c4f7-09d3e6-b8f2a5-c7e1d4`. |
| `server` | string | Yes | The Online server, if provided when creating the onboarding link. Empty otherwise. Example: `online.99digital.co.il`. |
| `account_id` | integer | Yes | The Online account id, if provided when creating the onboarding link. 0 otherwise. Example: `1`. |
| `inbox_id` | integer | Yes | The Online inbox id, if provided when creating the onboarding link. 0 otherwise. Example: `2`. |
| `business_id` | string | Yes | The id of the client's business on Facebook (Meta Business Portfolio). Empty when it isn't available. Example: `184736291045832`. |
| `business_name` | string | Yes | The name of the client's business on Facebook (Meta Business Portfolio). Empty when it isn't available. Example: `My Business Ltd`. |
| `page_id` | string | Yes | The page id of the Facebook account (relevant for all 4 types of onboarding). Even when you connect an Instagram account only, there is still a Facebook page id, since an Instagram account is always connected to a Facebook page. Example: `123637468573457`. |
| `page_name` | string | Yes | The Facebook page name (of that `page_id`). Example: `My Business`. |
| `page_category` | string | Yes | The category of the page. Example: `Retail Company`. |
| `page_link` | string | Yes | The Facebook page link URL. Example: `https://www.facebook.com/123637468573457`. |
| `page_about` | string | Yes | The Facebook page about information. Example: `About my business`. |
| `page_fan_count` | integer | Yes | The number of fans (followers) of the Facebook page at the onboarding time. Example: `400`. |
| `page_picture` | string | Yes | The profile picture of the Facebook page. Example: `https://www.example.com/images/page-picture.jpg`. |
| `admin_name` | string | Yes | The Facebook page admin name — the admin of the client's business on Facebook when it is available, otherwise the Facebook user who completed the onboarding. Example: `George Levi`. |
| `admin_email` | string | Yes | The Facebook page admin email address — of the same admin as `admin_name`. Empty when Facebook doesn't provide it. Example: `george@example.com`. |
| `instagram_id` | string | No | The Instagram page id. Sent only for `facebook_type` 2 or 4. Example: `17841463464574680`. |
| `instagram_username` | string | No | The Instagram username, without `@`. Sent only for `facebook_type` 2 or 4. Example: `george_flowers`. |
| `instagram_name` | string | No | The Instagram page name. Sent only for `facebook_type` 2 or 4. Example: `My Flowers Business`. |
| `instagram_profile_picture` | string | No | The Instagram page profile picture. Sent only for `facebook_type` 2 or 4. Example: `https://www.example.com/images/instagram-profile.jpg`. |
| `instagram_followers_count` | integer | No | The Instagram page total followers count at the onboarding time. Sent only for `facebook_type` 2 or 4. Example: `530`. |
| `instagram_media_count` | integer | No | Total media uploaded to the Instagram page (total posts). Sent only for `facebook_type` 2 or 4. Example: `54`. |
| `instagram_biography` | string | No | The biography written on the Instagram page. Sent only for `facebook_type` 2 or 4. Example: `This is my flowers shop`. |
| `instagram_website` | string | No | The website provided on the Instagram page. Sent only for `facebook_type` 2 or 4. Example: `https://www.flowersshop.example.com`. |

### Example: Facebook

The client connected Instagram Messenger (`facebook_type` 2), so the `instagram_…` fields are included.

For Facebook Messenger (1) and Facebook Page (3), the
`instagram_…` fields are not sent. Here the onboarding link was
created with the `server`, `account_id` and `inbox_id` of an Online
inbox.

```json
{
  "status": "OK",
  "event": "facebook",
  "facebook_type": 2,
  "facebook_type_name": "Instagram Messenger",
  "facebook_reference": "my-reference",
  "from": "623748845667358",
  "apiKey": "5e2b8d-a1c4f7-09d3e6-b8f2a5-c7e1d4",
  "server": "online.99digital.co.il",
  "account_id": 1,
  "inbox_id": 2,
  "business_id": "184736291045832",
  "business_name": "My Flowers Business Ltd",
  "page_id": "123637468573457",
  "page_name": "My Flowers Business",
  "page_category": "Retail Company",
  "page_link": "https://www.facebook.com/123637468573457",
  "page_about": "Fresh flowers, delivered every day",
  "page_fan_count": 400,
  "page_picture": "https://www.example.com/images/page-picture.jpg",
  "admin_name": "George Levi",
  "admin_email": "george@example.com",
  "instagram_id": "17841463464574680",
  "instagram_username": "george_flowers",
  "instagram_name": "My Flowers Business",
  "instagram_profile_picture": "https://www.example.com/images/instagram-profile.jpg",
  "instagram_followers_count": 530,
  "instagram_media_count": 54,
  "instagram_biography": "This is my flowers shop",
  "instagram_website": "https://www.flowersshop.example.com"
}
```

## Responses

### 200 — Received. Answer with a 2xx status (200 OK) within 10 seconds, and process the webhook afterwards. The body of your answer is ignored.

### default — Any other answer, or no answer in time, is a failed delivery. There are no retries: a webhook that was not delivered is not sent again.
