Skip to main content
This guide shows you how to build an unattended integration that uploads an audience to Narrative and delivers it into a Custom Audience in one Meta ad account. You can create a new Custom Audience or add to one that already exists. Before you start, complete the prerequisites and set up API access. You need a profile ID and an eligible ad account ID, which works with or without the act_ prefix.

1. Create the dataset

The dataset must carry at least one identifier column that Meta can match on. Required columns lists them.
Record the id in the response.

Required columns

Both audience interfaces take the same schema. The dataset needs at least one of these identifier columns: Each identifier column is named after its Rosetta Stone attribute, and the connector matches on that column name. A column holds either a plain string or an object. In the dataset schema, declare a string column with "type": "string", and declare an object column with "type": "object" and its properties:
Send an object column as an object in each row:
See your connector’s reference page for the attributes it accepts and their exact shapes. See Supported identifiers for how Meta matches each identifier.

2. Activate the dataset

The response is 201 with the dataset, now "status": "active". Activation locks the schema, so activate only once the shape is settled.

3. Upload and ingest your file

Each line of the file is one row that matches the schema you declared in step 1. For the columns Meta accepts and their shapes, see Supported identifiers and Required columns. You can load a file into a dataset over the API in two ways:
  • Signed-URL upload. Your integration uploads one file of up to 3 GB, then asks Narrative to ingest it.
  • Managed S3 bucket. You write files to an S3 bucket that Narrative manages, and Narrative ingests each batch on its own. Use a managed bucket for files larger than 3 GB, or for files that another system delivers on a schedule.

Choose a file format

The dataset’s file_config.type sets the format of every file you load into it. Parquet and JSON Lines both hold object columns, which nest properties inside one column:
  • Parquet (parquet) is the most compatible format for connector datasets. It stores nested struct columns and their types natively, and Narrative matches columns to the schema by name at every level.
  • JSON Lines (json) holds one JSON object per line. Narrative matches each nested object to the schema by name.
CSV datasets (flat) hold only scalar columns, so they can’t carry object columns.

Upload a file with a signed URL

Request an upload URL, then send the file straight to storage:
The upload URL is valid for 30 minutes and carries its own signature, so send no authorization header with the PUT.
Keep the path from the response. Narrative assigns its own storage path, which does not match the name you requested, and the ingest request needs Narrative’s path rather than yours.
Then ingest the file into the dataset, passing that path as source_file:
Ingestion runs in the background. Watch the record count on the dataset to know when it has finished:
The count moves from zero to your row count, typically within a couple of minutes. Each ingested file adds a new snapshot to the dataset, and every active connection on the dataset delivers that snapshot.

Write files to a managed S3 bucket

A managed bucket is an S3 bucket that Narrative creates for your company. You write each batch of files into its own folder under the dataset’s path in the bucket, then write an empty _NIO_COMMIT file into that batch folder. Narrative ingests every file in the batch folder when the commit file appears, so you make no upload or ingest request. A file can be as large as S3 accepts. See Ingesting Files from a Managed S3 Bucket to create the bucket, grant your AWS account access, and lay out the folders.

4. Confirm Meta accepts the dataset

Before you create a connection, ask Narrative which connector interfaces the dataset satisfies:
The response checks the dataset’s schema against every interface of the connectors your company has installed, and sorts the results into two lists:
  • accepted lists each interface you can connect the dataset to, by the connector’s app_id and the interface_id.
  • errors lists each interface the schema does not satisfy. Its details hold the reason, such as "required property '<column>' not found".
Add ?tags=<tag> to check only the interfaces that carry that tag. When the interface you want is under errors, the dataset’s schema doesn’t meet what the interface needs, for example a missing column or property. Activation locks the schema, so create a new dataset that fixes what the error names. For Meta, look for the Facebook Connector ("app_id": 8) in accepted. Add ?tags=audience_delivery to check only audience interfaces.
audience_first_party_new creates a new Custom Audience, and audience_first_party_existing adds to one you already have.

5. Deliver to a new Custom Audience

Create a connection. The connector creates the Custom Audience in Meta before it answers, so the audience exists in Ads Manager once you get 201.
Both type fields are required. The outer one identifies what you are connecting, and the one inside quick_settings selects the delivery interface. What the connection does describes every field, its allowed values, and its default. Record the connection id. You need it to stop the delivery.

6. Confirm the connection

The response lists the connection with "status": "active". In Ads Manager, under Audiences, the audience appears as a Customer List Custom Audience with the name you gave it, marked Populating while Meta matches the members. Its Audience ID column holds the ID you use in the next step.

7. Deliver to an existing Custom Audience

To send another dataset into an audience that already exists, whether Narrative created it or not, connect with the audience’s Meta ID from the Audience ID column in Ads Manager. The request uses 12346 as an example ID for an existing dataset, which you create and load the same way as in steps 1 to 3:
The audience must belong to an ad account the profile can reach. It keeps the membership duration it already has.

Keeping the audience current

Write new data to the dataset. The connection keeps running, so new rows reach the Custom Audience without further calls.

Stopping delivery

Deleting the connection archives it and stops further deliveries. The Custom Audience stays in Meta with its members. Delete it in Ads Manager if you no longer want it.

Troubleshooting

Getting help

Contact your Narrative relationship manager with your company ID, the dataset ID, and the failing request and response.

Sending conversion events via the API

Send offline conversions to a Meta dataset

Meta Custom Audiences Connector

Supported identifiers and audience membership duration

Connector Interfaces

Why a dataset connects to an interface rather than a connector

API Keys

Create and rotate keys for programmatic access