Skip to main content
The Meta Connector API lets an unattended integration deliver audiences to Meta Custom Audiences and send conversion events to Meta’s Conversions API. A person signs in once to create an API key and once to connect your Meta business, and the integration works from the API key after that. Complete the prerequisites and set up API access on this page before you follow either guide.

Choose a guide

Custom Audience delivery

Upload hashed identifiers and deliver them into a new or existing Custom Audience in one ad account.

Conversion events

Send offline conversion events to a Meta dataset through the Conversions API, starting with test events.

Prerequisites

What you need depends on the guide you follow:

API key

Create the key under Settings → API Keys with read and write on datasets and connections, write on uploads, and read on installations. Add write on webhooks if you want delivery notifications. See API Keys for the procedure and the Permissions Reference for what each resource covers. Create it from a shared team account rather than a personal login, so the integration keeps working when someone changes roles.

Facebook Connector installed

The Facebook Connector is app 8. Find your installation of it:
Record the installation ID. If no record has "app_id": 8, install the Facebook Connector from the Narrative Marketplace.

A connected Meta profile

A connector profile holds the Meta credentials that every delivery uses. You create it once per Meta business, in the Narrative UI:
1

Open the connector

In Narrative, go to Installed Apps and select Facebook Connector.
2

Choose a profile type

Choose System user for an integration. With a system-user profile, you name the ad account on each connection.
3

Sign in to Meta

Sign in to Meta in the popup and grant Narrative access to your business.
Every request in these guides then uses the profile ID. Find your profile shows how to look it up.

An eligible ad account

Custom Audiences go into an ad account that belongs to a Business Manager and has accepted Meta’s Custom Audience terms. List your ad accounts shows both. See Ad Account Eligibility for Custom Audiences to fix an account that does not qualify.

A Meta dataset ID

Conversion events go to a Meta dataset, which Events Manager also calls a pixel. Its numeric ID is on the dataset’s page in Events Manager, and List your Meta datasets returns it.

Set up API access

The guides talk to two hosts, and each takes its own credential:

Get an installation token

The Meta connector authenticates requests with an installation token, which you get by exchanging your API key. Use the installation ID from Facebook Connector installed:
Store access_token as $INSTALLATION_TOKEN. It lasts about three hours, so request a new one at the start of each run of your integration. Confirm that both hosts answer:
Send the API key to api.narrative.io and the installation token to facebook.narrativeconnectors.com.
API keys contain characters that shells mangle. Read the key from a file or an environment variable rather than pasting it inline.

Find your profile

GET /profiles lists every Meta profile in your company. To read one:
Use a profile whose status is enabled and whose token.is_valid is true. Record its id.

List your ad accounts

Choose an account where both supports_custom_audiences and user_accepted_custom_audience_tos are true. You can use the ID with or without the act_ prefix.

List your Meta datasets

id is a number. Conversion events carry it in meta_dataset_id.

What the connection does

A connection’s quick_settings pick the interface and set how the connection delivers. The fields depend on the interface.

New Custom Audience (audience_first_party_new)

The connector creates the Custom Audience in Meta when you create the connection.

Existing Custom Audience (audience_first_party_existing)

Conversion events (conversion_events)

Each event names its Meta dataset in meta_dataset_id, so the connection has no Meta dataset setting.

Existing and new rows

A connection delivers every snapshot written to the dataset after the connection is created. The historical_data_enabled quick setting decides whether the connection also delivers data that was already in the dataset when you created it:
  • With historical_data_enabled set to true, the connection first delivers data already in the dataset, then keeps delivering new snapshots as they land.
  • With historical_data_enabled set to false, the connection delivers only snapshots written after it was created.
How far back the first delivery reaches depends on the connector, and each connector’s guide states it. For Meta, historical_data_enabled delivers everything in the dataset when the connection is created. After that, each new snapshot is delivered as it lands. An audience connection adds members and never removes them. A member leaves the Custom Audience when its retention runs out. When you overwrite the dataset, the connection adds the rows in the new snapshot, and members missing from it stay in the audience until their retention ends. A conversion connection sends each event in each snapshot it delivers. Uploading the same events again in a new snapshot sends them again, and so does a second connection with historical_data_enabled set to true.

Delivery notifications

The Facebook Connector reports each delivery as an app webhook event. Subscribe a webhook to app 8 to receive them:
Keep the secret to verify each delivery. The connector sends these events: To stop the notifications, delete the subscription with DELETE /webhooks/{webhook_id}. See App subscription for the subscription fields and Verifying deliveries for checking the secret.

Meta Custom Audiences Connector

Supported identifiers and audience membership duration

Meta Conversions API Connector

Every meta_conversion_event field, event name, and action source

Connector Interfaces

Why a dataset connects to an interface rather than a connector

API Keys

Create and rotate keys for programmatic access