First-party app
Facebook Custom Audiences

Facebook Custom Audiences

Manage Meta custom audiences — customer lists, members and lookalikes — through the Marketing API, with Meta's required SHA-256 customer-data hashing applied in-app.

stable MarketingSocial Media

About

Facebook Custom Audiences ships in the w6w first-party pack. It declares 9 actions, 2 health checks, and the host runs its code in a sandbox that never sees the credential.

App id
io.w6w.facebook-custom-audiences
Version
0.1.0
Author
w6w
Licence
MIT
Categories
Marketing · Social Media

Overview

Custom audiences are the lists of people an advertiser tells Meta to target — or exclude — in its ads. This app creates and manages them on a Meta ad account through the Marketing API: create an empty customer-list audience, add people to it or remove them, rename or delete it, read back its size and delivery status, and build a lookalike audience from it.

Customer contact data (email, phone, name, date of birth, city and so on) is normalised and SHA-256 hashed inside this app before it leaves, following the rules in Meta’s Customer File Custom Audiences guide, so a workflow can pass a plain email address from a CRM or order system without hand-rolling the hashing. Lists larger than 10,000 people are uploaded in batches that share a session id.

This app manages audiences only. It does not create campaigns or ads, send conversion events (that is the Conversions API app) or read Pages and lead forms. Meta publishes no machine-readable status feed, so the health check reports live rate-limit headroom instead.

Build with Facebook Custom Audiences

Three routes to the same 9 actions. The Workflow tab is generated from Facebook Custom Audiences's own manifest and carries its real ids, so it is copy-pasteable; the Code and CLI examples are the same call for any action on any app, so every app-specific value in them is a blank you fill in.

Add Users to Custom Audience

add-users

Add people to a customer-file custom audience from emails, phones, names and other identifiers. Values are normalised and SHA-256 hashed by this app before upload (up to 10,000 per request).

Create Custom Audience

create-custom-audience

Create an empty customer-file custom audience on an ad account. Add members afterwards with Add Users.

Create Lookalike Audience

create-lookalike-audience

Build a lookalike audience from an existing custom audience of at least 100 people. Population takes 1-6 hours.

Delete Custom Audience

delete-custom-audience

Permanently delete a custom audience. Ads using it stop running and cannot be restarted. Fails while lookalikes built from it exist.

Get Custom Audience

get-custom-audience

Read one custom audience: size bounds, delivery status (200 = ready) and operation status of the last upload.

List Ad Accounts

list-ad-accounts

List the ad accounts the connected Facebook user can access. Use `account_id` (or `id`) as the Ad Account ID of every other action.

List Custom Audiences

list-custom-audiences

List the custom audiences (customer lists, website audiences and lookalikes) on an ad account.

Remove Users from Custom Audience

remove-users

Remove people from a customer-file custom audience. Identifiers are normalised and SHA-256 hashed exactly as in Add Users, so the same values match.

Update Custom Audience

update-custom-audience

Rename a custom audience or change its description, opt-out link or file source.

A workflow step names the app and the action, and the editor fills in the connection when you pick one. This is the Step shape from the workflow spec, carrying Facebook Custom Audiences's real ids.

{
  "manifestVersion": "2",
  "name": "facebook-custom-audiences-example",
  "steps": [
    {
      "id": "add-users",
      "uses": {
        "app": "io.w6w.facebook-custom-audiences",
        "action": "add-users",
        "connection": "conn_YOUR_CONNECTION_ID"
      },
      "with": {
        "audienceId": "<audienceId>",
        "users": "<users>"
      }
    }
  ]
}

Here are some of the things you can do

  • Add Users to Custom Audience

    perform
    add-users
  • Create Custom Audience

    perform
    create-custom-audience
  • Create Lookalike Audience

    perform
    create-lookalike-audience
  • Get Custom Audience

    read
    get-custom-audience
  • List Ad Accounts

    read
    list-ad-accounts

+4 more actions available

Every app-specific value here is a blank you have to fill in. An app action is reached through the connection that authenticates it, so the address is a connection id, not the app id — and connections belong to your account, so a public page cannot know yours. Create one for Facebook Custom Audiences, then fill in the three blanks: conn_YOUR_CONNECTION_ID, the action key, and the parameters that action declares. The call itself is real — the shape is transcribed from the studio's own snippet builder, which prints the same kind of blanks — but nothing in it is specific to Facebook Custom Audiences. The Workflow tab is where this app's real ids are.

Install
npm install @w6w/sdk
yarn add @w6w/sdk
pnpm add @w6w/sdk
deno add npm:@w6w/sdk
Code
import { W6wClient, isActionRun } from "@w6w/sdk";

// Reads W6W_BASE_URL and W6W_TOKEN from the environment when omitted.
const client = new W6wClient();

const envelope = await client.run({
  urn: "conn_YOUR_CONNECTION_ID",
  action: "add-users",
  payload: {
    audienceId: "<value>",
    users: "<value>",
    // hashing: "<value>",
    // sessionId: "<value>",
    // batchSeq: "<value>",
    // lastBatch: "<value>",
    // estimatedTotal: "<value>",
  },
});

if (isActionRun(envelope)) console.log(envelope.value);
Install the CLI
npm install -g @w6w/cli
CLI
w6w run conn_YOUR_CONNECTION_ID --action add-users --payload '{"audienceId":"<value>","users":"<value>"}'

Give an AI agent Facebook Custom Audiences — without giving it Facebook Custom Audiences's credentials. One MCP endpoint exposes every app, function and workflow the caller is entitled to, as tools it can discover and run. Access is granted per team while we onboard.

One tool call
{
  "name": "w6w_invoke",
  "arguments": {
    "ref": "app:io.w6w.facebook-custom-audiences#add-users",
    "input": {
      "audienceId": "<audienceId>",
      "users": "<users>"
    }
  }
}

Every tool names its target with a single ref. The app: form above doesn't name a connection at all — the host resolves which of the caller's Facebook Custom Audiences connections to sign with, and refuses rather than guesses when the answer is ambiguous.

What the agent gets

Credentials it can't read

The token is attached host-side, at the moment of the call. It is never a tool argument, never in the model's context, and never in a transcript — so a prompt injection has nothing to exfiltrate.

A tool surface scoped to the caller

Tools are derived per end user from what that person has actually connected and is entitled to — not one shared bot identity carrying the union of everyone's access.

A durable workflow in one call

Multi-step work runs on the workflow engine and returns a run handle the agent can poll — retries, branching and state survive the conversation that started them.

Health-aware discovery

Facebook Custom Audiences's declared health checks are on the surface too, so an agent can tell "the vendor is down" from "your credential expired" before it burns a retry on either.

The MCP surface is part of the hosted platform. Facebook Custom Audiences itself is MIT, and the runtime that executes it is source-available (FSL).

Request MCP access

Health checks

Facebook Custom Audiences declares its own checks, so its health is a property of the app rather than something the host guesses at.

service

Meta platform status

quota

API usage headroom

Percentage of the app's call-count, CPU-time and total-time allowances consumed, read off `X-App-Usage` and `X-Business-Use-Case-Usage`. Meta throttles when any meter reaches 100.