> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Facebook Leads as a data source

> Bring data from Facebook Leads to Nekt.

Facebook Leads is Meta's lead generation platform that helps businesses capture potential customer information through Facebook and Instagram ads. It provides tools for creating lead forms, collecting contact details, and managing prospect data for sales and marketing campaigns.

<img width="200" src="https://mintlify.s3.us-west-1.amazonaws.com/nekt/assets/logo/logo-facebook.png" />

## Configuring Facebook Leads as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the **Facebook Leads** option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

You'll need Page ID and your Access Token. Check the [linked documentation](https://developers.facebook.com/docs/marketing-api/guides/lead-ads) if you need help on finding any of the credentials.

The following configurations are available:

* **Page ID**: The ID of the Facebook Page associated with your lead forms.
* **Access Token**: Your Facebook Graph API access token with the necessary permissions to read lead data.
* **Start Date**: Inform a start date for us to know the date of the earliest record you want to sync with. This will help to avoid processing unnecessary data.

Once you're done, click **Next**.

### 2. Select streams

The next step is letting us know which streams you want to bring. You can select entire groups of streams or only a subset of them.

> Tip: The stream can be found more easily by typing its name.

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: a folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: we suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: you can choose between INCREMENTAL and FULL\_TABLE.
  * Incremental: every time the extraction happens, we'll get only the new data - which is good if, for example, you want to keep every record ever fetched.
  * Full table: every time the extraction happens, we'll get the current state of the data - which is good if, for example, you don't want to have deleted data in your catalog.

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/runs/scheduling-and-triggers), consider how often you want data to be extracted from this source. This decision usually depends on how frequently you need the new table data updated (every day, once a week, or only at specific times).

Optionally, you can define some additional settings:

* Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).
* Determine when to execute an **Additional [Full Sync](https://docs.nekt.com/get-started/core-concepts/types-of-sync#additional-full-sync)**. This will complement the incremental data extractions, ensuring that your data is completely synchronized with your source every once in a while.

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

<Warning>For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.</Warning>

# Streams and Fields

Below you'll find the available data streams from Facebook Leads and their corresponding fields:

<AccordionGroup>
  <Accordion title="Leads">
    Stream containing the information submitted by prospects through Facebook and Instagram lead generation forms.

    **Key fields:**

    | Field                 | Type             | Description                                          |
    | :-------------------- | :--------------- | :--------------------------------------------------- |
    | `id`                  | String           | Unique identifier of the record.                     |
    | `created_time`        | DateTime         | Timestamp when the record was created.               |
    | `form_id`             | String           | Identifier of the associated lead form.              |
    | `campaign_name`       | String           | Name of the ad campaign.                             |
    | `campaign_id`         | String           | Identifier of the associated ad campaign.            |
    | `adset_name`          | String           | Name of the ad set that captured the lead.           |
    | `adset_id`            | String           | Identifier of the associated ad set.                 |
    | `ad_name`             | String           | Name of the ad that captured the lead.               |
    | `ad_id`               | String           | Identifier of the associated ad.                     |
    | `platform`            | String           | Platform where the lead was submitted.               |
    | `field_data`          | Array of Objects | Custom question and answer pairs from the lead form. |
    | `field_data[].name`   | String           | Name of the lead form field.                         |
    | `field_data[].values` | Array of Strings | Submitted answers for the form field.                |
  </Accordion>
</AccordionGroup>

# Implementation Notes

### API Pagination and Discovery

* **Lead Forms Discovery**: The connector automatically handles API pagination through the `leadgen_forms` endpoint, retrieving up to 500 forms per request. This ensures all lead forms associated with your Page ID are successfully discovered and synced, regardless of the account size or previous strict API result limits.

### Reliability and Error Handling

* **Connection Pooling & Retries**: To ensure resilient data extraction, the connector utilizes a shared connection pool and automatic retry logic. It will automatically retry failed requests up to 5 times (with an exponential backoff factor) when encountering API rate limits (HTTP 429) or temporary server errors (HTTP 500, 502, 503, 504), preventing synchronization failures during Facebook Graph API instability.

## Skills for agents

<Snippet file="agent-skills-intro.mdx" />

<Card title="Download Facebook Leads skills file" icon="wand-magic-sparkles" href="/sources/facebook-leads.md">
  Facebook Leads connector documentation as plain markdown, for use in AI agent contexts.
</Card>
