# Operations (sample payloads)

## Main operations

### Create custom audience

Create a custom audience in your business account.
**Sample Input**

```json
{
    "ad_account_id": "123456789",
    "name": "New Custom Audience",
    "customer_file_source": "USER_PROVIDED_ONLY",
    "description": "A custom audience for our summer campaign",
    "app_ids": [
        "987654321",
        "876543210"
    ],
    "audience_members": {
        "audience_member_list": [
            \{
                "email": "john.doe@example.com",
                "first_name": "John",
                "last_name": "Doe",
                "country_code": "us",
                "city": "New York",
                "zip_code": "10001",
                "phone": "+12125551234",
                "gender": "m",
                "birth_year": "1985",
                "birth_month": "06",
                "birth_day": "15"
            \},
            \{
                "email": "jane.smith@example.com",
                "first_name": "Jane",
                "last_name": "Smith",
                "country_code": "ca",
                "city": "Toronto",
                "phone": "+14165557890",
                "gender": "f",
                "birth_year": "1990",
                "birth_month": "09",
                "birth_day": "22"
            \}
        ]
    }
}
```

**Sample Output**

### Create post

Create a new post.
**Sample Input**
**Sample Output**

```json
{
    "id": "987654321098765"
}
```

### Delete audience members

Remove members from a given audience.
**Sample Input**
**Sample Output**

### Delete custom audience

Delete a custom audience.
**Sample Input**

```json
{
    "custom_audience_id": "23842001234567890"
}
```

**Sample Output**

### Get ad

Retrieve an ad using its ID.
**Sample Input**

```json
{
    "ad_id": "23843234567890123"
}
```

**Sample Output**

```json
{
    "id": "23843234567890123",
    "account_id": "1234567890",
    "adset": {
        "id": "6789012345678901"
    },
    "adset_id": "6789012345678901",
    "bid_type": "LOWEST_COST_WITH_BID_CAP",
    "campaign": {
        "id": "5678901234567890"
    },
    "campaign_id": "5678901234567890",
    "configured_status": "ACTIVE",
    "created_time": "2023-05-15T10:30:00+0000",
    "creative": {
        "id": "7890123456789012"
    },
    "effective_status": "ACTIVE",
    "last_updated_by_app_id": "987654321098765",
    "name": "Summer Sale Promotion",
    "source_ad_id": "23843234567890123",
    "status": "ACTIVE",
    "updated_time": "2023-05-16T14:45:00+0000"
}
```

### Get ad account

Retrieve an ad account using its ID.
**Sample Input**

```json
{
    "ad_account_id": "act_123456789"
}
```

**Sample Output**

### Get ad account insights

Retrieve insights from a specific ad account.
**Sample Input**

```json
\{
    "ad_account_id": "act_123456789",
    "date_preset": "last_30d",
    "level": "account",
    "breakdowns": [
        "age",
        "gender"
    ],
    "action_breakdowns": [
        "action_type"
    ],
    "time_increment": 1,
    "limit": 10
\}
```

**Sample Output**

### Get ad insights

Retrieve insights for a specific ad.
**Sample Input**

```json
\{
    "ad_id": "6273849201234567",
    "action_attribution_windows": [
        "1d_view",
        "28d_click"
    ],
    "action_breakdowns": [
        "action_type",
        "action_device"
    ],
    "breakdowns": [
        "age",
        "gender"
    ],
    "date_preset": "last_30d",
    "level": "ad",
    "limit": 10
\}
```

**Sample Output**

### Get adset

Retrieve an adset using its ID.
**Sample Input**

```json
{
    "adset_id": "23843234567890123"
}
```

**Sample Output**

```json
{
    "id": "23843234567890123",
    "account_id": "1234567890",
    "attribution_spec": [
        \{
            "event_type": "CLICK",
            "window_days": 7
        \},
        \{
            "event_type": "VIEW",
            "window_days": 1
        \}
    ],
    "bid_strategy": "LOWEST_COST_WITHOUT_CAP",
    "billing_event": "IMPRESSIONS",
    "budget_remaining": "5000",
    "campaign": {
        "id": "6789012345678901"
    },
    "campaign_id": "6789012345678901",
    "configured_status": "ACTIVE",
    "created_time": "2023-05-01T10:30:00+0000",
    "daily_budget": "1000",
    "destination_type": "WEBSITE",
    "effective_status": "ACTIVE",
    "is_dynamic_creative": false,
    "lifetime_budget": "50000",
    "lifetime_imps": 1000000,
    "name": "Summer Sale Adset",
    "optimization_goal": "LINK_CLICKS",
    "pacing_type": [
        "standard"
    ],
    "promoted_object": \{
        "pixel_id": "987654321098765",
        "custom_event_type": "PURCHASE",
        "pixel_rule": "page_view"
    \},
    "recurring_budget_semantics": false,
    "source_adset": {
        "id": "12345678901234567"
    },
    "source_adset_id": "12345678901234567",
    "start_time": "2023-05-15T00:00:00+0000",
    "status": "ACTIVE",
    "targeting": {
        "age_max": 65,
        "age_min": 18,
        "excluded_custom_audiences": [
            \{
                "id": "6543210987654321",
                "name": "Existing Customers"
            \}
        ],
        "custom_audiences": [
            \{
                "id": "7654321098765432",
                "name": "Website Visitors"
            \}
        ],
        "geo_locations": \{
            "countries": [
                "US",
                "CA"
            ],
            "location_types": [
                "home",
                "recent"
            ]
        \},
        "targeting_optimization": "expansion_all",
        "publisher_platforms": [
            "facebook",
            "instagram"
        ],
        "facebook_positions": [
            "feed",
            "right_hand_column"
        ],
        "instagram_positions": [
            "stream"
        ],
        "device_platforms": [
            "mobile",
            "desktop"
        ],
        "messenger_positions": [
            "messenger_home"
        ]
    },
    "updated_time": "2023-05-10T15:45:00+0000",
    "use_new_app_click": true
}
```

### Get adset insights

Retrieve insights for a specific adset.
**Sample Input**

```json
\{
    "adset_id": "23843234567890123",
    "limit": 1,
    "date_preset": "last_7d",
    "action_breakdowns": [
        "action_type"
    ],
    "breakdowns": [
        "age",
        "gender"
    ],
    "fields": [
        "impressions",
        "clicks",
        "spend",
        "ctr",
        "actions"
    ]
\}
```

**Sample Output**

```json
{
    "data": [
        {
            "account_currency": "USD",
            "account_id": "1234567890",
            "account_name": "My Ad Account",
            "actions": [
                \{
                    "action_type": "link_click",
                    "value": "42"
                \},
                \{
                    "action_type": "page_engagement",
                    "value": "78"
                \}
            ],
            "adset_id": "23843234567890123",
            "adset_name": "Summer Sale Promotion",
            "age": "25-34",
            "gender": "female",
            "clicks": "65",
            "ctr": "2.5",
            "date_start": "2023-05-01",
            "date_stop": "2023-05-07",
            "impressions": "2600",
            "spend": "150.25"
        }
    ],
    "paging": {
        "cursors": \{
            "before": "MAZDZD",
            "after": "MjQZD"
        \}
    }
}
```

### Get audience

Retrieve a custom audience.
**Sample Input**
**Sample Output**

```json
{
    "id": "6789012345",
    "name": "High-Value Customers",
    "approximate_count": 50000,
    "customer_file_source": "USER_PROVIDED_ONLY",
    "data_source": {
        "type": "FILE_IMPORTED",
        "sub_type": "CUSTOM_AUDIENCE",
        "creation_params": "{\"origin\":\"ui\"}"
    },
    "delivery_status": \{
        "code": 200,
        "description": "Audience is ready and can be used for delivery"
    \},
    "description": "Customers who have made purchases over $1000 in the last 6 months",
    "is_value_based": false,
    "operation_status": \{
        "code": 200,
        "description": "Audience data is processed and ready"
    \},
    "permission_for_actions": \{
        "can_edit": true,
        "can_see_insight": true,
        "can_share": false,
        "subtype_supports_lookalike": true,
        "supports_recipient_lookalike": true
    \},
    "retention_days": 180,
    "subtype": "CUSTOM",
    "time_content_updated": 1623456789,
    "time_created": 1620123456,
    "time_updated": 1623456789
}
```

### Get business user

Retrieve a business user detail using ID.
**Sample Input**
**Sample Output**

### Get campaign

Retrieve a campaign using its ID.
**Sample Input**
**Sample Output**

### Get campaign insights

Retrieve insights for a specific campaign.
**Sample Input**

```json
\{
    "campaign_id": "6273849506172",
    "action_attribution_windows": [
        "1d_view",
        "28d_click"
    ],
    "action_breakdowns": [
        "action_type",
        "action_device"
    ],
    "breakdowns": [
        "age",
        "gender"
    ],
    "date_preset": "last_30d",
    "level": "campaign",
    "time_increment": 7,
    "limit": 10
\}
```

**Sample Output**

```json
{
    "data": [
        {
            "account_currency": "USD",
            "account_id": "1234567890",
            "account_name": "My Ad Account",
            "actions": [
                \{
                    "action_type": "link_click",
                    "value": "1250"
                \},
                \{
                    "action_type": "page_engagement",
                    "value": "3500"
                \}
            ],
            "buying_type": "AUCTION",
            "campaign_id": "6273849506172",
            "campaign_name": "Summer Sale Campaign",
            "clicks": "2800",
            "cost_per_action_type": [
                \{
                    "action_type": "link_click",
                    "value": "0.52"
                \},
                \{
                    "action_type": "page_engagement",
                    "value": "0.18"
                \}
            ],
            "cost_per_inline_link_click": "0.48",
            "cost_per_inline_post_engagement": "0.15",
            "cost_per_unique_click": "0.75",
            "cpc": "0.45",
            "cpm": "5.20",
            "cpp": "3.80",
            "ctr": "2.5",
            "date_start": "2023-05-01",
            "date_stop": "2023-05-07",
            "frequency": "2.8",
            "impressions": "112000",
            "inline_link_click_ctr": "2.2",
            "inline_link_clicks": "2450",
            "inline_post_engagement": "4200",
            "objective": "LINK_CLICKS",
            "reach": "40000",
            "social_spend": "250.00",
            "spend": "1260.00",
            "unique_clicks": "1680",
            "unique_ctr": "1.5",
            "unique_inline_link_click_ctr": "1.8",
            "unique_inline_link_clicks": "2000",
            "unique_link_clicks_ctr": "1.9",
            "website_ctr": [
                \{
                    "action_type": "link_click",
                    "value": "2.2"
                \}
            ]
        }
    ],
    "paging": {
        "cursors": \{
            "before": "MAZDZD",
            "after": "MjQZD"
        \}
    }
}
```

### Get lead

Get data about a specific lead using their ID.
**Sample Input**

```json
{
    "lead_id": "6789012345678901"
}
```

**Sample Output**

```json
{
    "created_time": "2023-05-15T10:30:45+0000",
    "id": "6789012345678901",
    "field_data": [
        \{
            "name": "full_name",
            "values": [
                "John Doe"
            ]
        \},
        \{
            "name": "email",
            "values": [
                "johndoe@example.com"
            ]
        \},
        \{
            "name": "phone_number",
            "values": [
                "+1234567890"
            ]
        \}
    ],
    "ad_id": "1234567890123456",
    "ad_name": "Summer Sale Promotion",
    "adset_id": "2345678901234567",
    "adset_name": "Interest-based Audience",
    "campaign_id": "3456789012345678",
    "campaign_name": "Q2 Sales Campaign",
    "form_id": "4567890123456789",
    "is_organic": false,
    "platform": "facebook"
}
```

### Get page insights

Get insights for a specific page.
**Sample Input**

```json
\{
    "page_id": "123456789012345",
    "metric": [
        "page_impressions",
        "page_engaged_users",
        "page_fans"
    ],
    "date_preset": "last_30d",
    "period": "day",
    "show_description_from_api_doc": true,
    "since": "2023-05-01T00:00:00Z",
    "until": "2023-05-30T23:59:59Z"
\}
```

**Sample Output**

```json
{
    "data": [
        {
            "name": "page_impressions",
            "period": "day",
            "values": [
                \{
                    "value": 1234,
                    "end_time": "2023-05-01T07:00:00+0000"
                \},
                \{
                    "value": 1567,
                    "end_time": "2023-05-02T07:00:00+0000"
                \}
            ],
            "title": "Page Impressions",
            "description": "The number of times any content from your Page or about your Page entered a person's screen.",
            "id": "123456789012345/insights/page_impressions/day"
        },
        {
            "name": "page_engaged_users",
            "period": "day",
            "values": [
                \{
                    "value": 456,
                    "end_time": "2023-05-01T07:00:00+0000"
                \},
                \{
                    "value": 789,
                    "end_time": "2023-05-02T07:00:00+0000"
                \}
            ],
            "title": "Page Engaged Users",
            "description": "The number of people who engaged with your Page. Engagement includes any click or story created.",
            "id": "123456789012345/insights/page_engaged_users/day"
        },
        {
            "name": "page_fans",
            "period": "day",
            "values": [
                \{
                    "value": 10000,
                    "end_time": "2023-05-01T07:00:00+0000"
                \},
                \{
                    "value": 10050,
                    "end_time": "2023-05-02T07:00:00+0000"
                \}
            ],
            "title": "Page Fans",
            "description": "The total number of people who have liked your Page.",
            "id": "123456789012345/insights/page_fans/day"
        }
    ],
    "paging": {}
}
```

### Get post insights

Get insights for a specifc post.
**Sample Input**
**Sample Output**

```json
{
    "data": [
        {
            "name": "post_impressions",
            "period": "day",
            "values": [
                {
                    "value": 1250
                },
                {
                    "value": 1500
                },
                {
                    "value": 1800
                }
            ],
            "title": "Post Impressions",
            "description": "The number of times your post was displayed on screen.",
            "id": "123456789012345/insights/post_impressions/day"
        },
        {
            "name": "post_engagements",
            "period": "day",
            "values": [
                {
                    "value": 75
                },
                {
                    "value": 90
                },
                {
                    "value": 120
                }
            ],
            "title": "Post Engagements",
            "description": "The number of times people engaged with your post through reactions, comments, shares, or clicks.",
            "id": "123456789012345/insights/post_engagements/day"
        },
        {
            "name": "post_reactions_by_type_total",
            "period": "day",
            "values": [
                {
                    "value": \{
                        "like": 45,
                        "love": 15,
                        "wow": 5,
                        "haha": 8,
                        "sorry": 2,
                        "anger": 0
                    \}
                },
                {
                    "value": \{
                        "like": 55,
                        "love": 20,
                        "wow": 7,
                        "haha": 10,
                        "sorry": 1,
                        "anger": 1
                    \}
                },
                {
                    "value": \{
                        "like": 70,
                        "love": 25,
                        "wow": 10,
                        "haha": 12,
                        "sorry": 3,
                        "anger": 0
                    \}
                }
            ],
            "title": "Post Reactions by Type",
            "description": "The number of reactions on your post by type.",
            "id": "123456789012345/insights/post_reactions_by_type_total/day"
        }
    ],
    "paging": \{
        "previous": "https://graph.facebook.com/v12.0/123456789012345/insights?access_token=...",
        "next": "https://graph.facebook.com/v12.0/123456789012345/insights?access_token=..."
    \}
}
```

### Get user

Get data about the user signed in.
**Sample Input**

```json
{}
```

**Sample Output**

```json
\{
    "id": "12345678901234567",
    "name": "John Doe"
\}
```

### List ad accounts

List ad accounts associated with current user.
**Sample Input**

```json
\{
    "fields": [
        "account_id",
        "name",
        "currency",
        "balance",
        "amount_spent"
    ],
    "limit": 2
\}
```

**Sample Output**

```json
{
    "data": [
        \{
            "id": "act_123456789",
            "name": "My First Ad Account",
            "account_id": "123456789",
            "currency": "USD",
            "balance": 1000.5,
            "amount_spent": 5678.9
        \},
        \{
            "id": "act_987654321",
            "name": "My Second Ad Account",
            "account_id": "987654321",
            "currency": "EUR",
            "balance": 2500.75,
            "amount_spent": 1234.56
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "MQZDZD",
            "after": "MjQZD"
        \}
    }
}
```

### List ads in ad account

List ads in a given ad account.
**Sample Input**

```json
\{
    "ad_account_id": "act_123456789",
    "limit": 10
\}
```

**Sample Output**

### List business client ad accounts

List all client-owned ad accounts.
**Sample Input**

```json
\{
    "business_id": "123456789012345",
    "limit": 10,
    "after": "QVFIUjZAaWE5MzZAFZAkFYZD"
\}
```

**Sample Output**

```json
{
    "data": [
        \{
            "account_id": "987654321098765",
            "id": "987654321098765"
        \},
        \{
            "account_id": "876543210987654",
            "id": "876543210987654"
        \},
        \{
            "account_id": "765432109876543",
            "id": "765432109876543"
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUmZA1ZAkFYZD",
            "after": "QVFIUjZAaWE5MzZAFZAkFYZD"
        \}
    }
}
```

### List business users

List all business users associated with this business.
**Sample Input**

```json
\{
    "business_id": "123456789",
    "limit": 3,
    "after": "QVFIUjZAhbXVfZAm9yZA3NhbWpleGFtcGxlY3Vyc29y"
\}
```

**Sample Output**

```json
{
    "data": [
        {
            "id": "987654321",
            "name": "John Doe",
            "business": \{
                "id": "123456789",
                "name": "Acme Corporation"
            \},
            "role": "ADMIN"
        },
        {
            "id": "876543210",
            "name": "Jane Smith",
            "business": \{
                "id": "123456789",
                "name": "Acme Corporation"
            \},
            "role": "EMPLOYEE"
        },
        {
            "id": "765432109",
            "name": "Bob Johnson",
            "business": \{
                "id": "123456789",
                "name": "Acme Corporation"
            \},
            "role": "EMPLOYEE"
        }
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUmV4YW1wbGViZWZvcmVjdXJzb3I=",
            "after": "QVFIUmV4YW1wbGVhZnRlcmN1cnNvcg=="
        \}
    }
}
```

### List campaigns in ad account

List ad campaigns found in an ad account.
**Sample Input**

```json
\{
    "ad_account_id": "act_123456789",
    "limit": 10,
    "after": "QVFIUjZAaZAm5nZAXByZAlZAyOUxr"
\}
```

**Sample Output**

```json
{
    "data": [
        \{
            "id": "6273849201",
            "name": "Summer Sale Campaign"
        \},
        \{
            "id": "6273849202",
            "name": "New Product Launch"
        \},
        \{
            "id": "6273849203",
            "name": "Brand Awareness"
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUmZA3ZAnNkZD",
            "after": "QVFIUjZAaZAm5nZAXByZAlZAyOUxr"
        \}
    }
}
```

### List custom audiences

List custom audience found in an ad account.
**Sample Input**

```json
{
    "ad_account_id": "act_123456789",
    "limit": 2,
    "filtering": [
        \{
            "field": "name",
            "operator": "CONTAIN",
            "value": "Loyal Customers"
        \}
    ],
    "after": "QVFIUjZAaZAm5BZAXlIOWRyZA2Vr"
}
```

**Sample Output**

```json
{
    "data": [
        {
            "id": "6789012345",
            "name": "Loyal Customers 2023",
            "approximate_count": 50000,
            "customer_file_source": "USER_PROVIDED_ONLY",
            "data_source": {
                "type": "FILE_IMPORTED",
                "sub_type": "CUSTOM_AUDIENCE",
                "creation_params": "{\"origin\":\"ui\"}"
            },
            "delivery_status": \{
                "code": 200,
                "description": "Active"
            \},
            "description": "Customers who have made more than 5 purchases in the last year",
            "is_value_based": false,
            "operation_status": \{
                "code": 200,
                "description": "Normal"
            \},
            "permission_for_actions": \{
                "can_edit": true,
                "can_see_insight": true,
                "can_share": true,
                "subtype_supports_lookalike": true,
                "supports_recipient_lookalike": true
            \},
            "retention_days": 180,
            "subtype": "CUSTOM",
            "time_content_updated": 1623456789,
            "time_created": 1623400000,
            "time_updated": 1623456789
        },
        {
            "id": "7890123456",
            "name": "High-Value Loyal Customers",
            "approximate_count": 10000,
            "customer_file_source": "USER_PROVIDED_ONLY",
            "data_source": {
                "type": "FILE_IMPORTED",
                "sub_type": "CUSTOM_AUDIENCE",
                "creation_params": "{\"origin\":\"ui\"}"
            },
            "delivery_status": \{
                "code": 200,
                "description": "Active"
            \},
            "description": "Loyal customers with average order value > $500",
            "is_value_based": true,
            "operation_status": \{
                "code": 200,
                "description": "Normal"
            \},
            "permission_for_actions": \{
                "can_edit": true,
                "can_see_insight": true,
                "can_share": true,
                "subtype_supports_lookalike": true,
                "supports_recipient_lookalike": true
            \},
            "retention_days": 365,
            "subtype": "CUSTOM",
            "time_content_updated": 1623567890,
            "time_created": 1623500000,
            "time_updated": 1623567890
        }
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUmZA3ZAnNyZA2VyOWRyZA2Vr",
            "after": "QVFIUjZAaZAm5BZAXlIOWRyZA2Vr"
        \}
    }
}
```

### List forms in page

List leadgen forms owned by a page.
**Sample Input**

```json
\{
    "page_id": "123456789012345",
    "limit": 10,
    "after": "QVFIUjNfZAm9vZA3NhZAGV2UzZA2ZAkFBZAk1EX01SLXRyZAzZAtOWlpNWVItMzZApZAjRmZAWF5ZAkFBZAk1EX01SLXRyZAzZAtOWlpNWVItMzZApZAjRm"
\}
```

**Sample Output**

```json
{
    "data": [
        \{
            "id": "987654321098765",
            "leadgen_export_csv_url": "https://www.facebook.com/ads/lead_gen/export_csv/?id=987654321098765",
            "locale": "en_US",
            "name": "Newsletter Signup",
            "status": "ACTIVE"
        \},
        \{
            "id": "876543210987654",
            "leadgen_export_csv_url": "https://www.facebook.com/ads/lead_gen/export_csv/?id=876543210987654",
            "locale": "es_ES",
            "name": "Product Inquiry",
            "status": "ACTIVE"
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUjNfZAm9vZA3NhZAGV2UzZA2ZAkFBZAk1EX01SLXRyZAzZAtOWlpNWVItMzZApZAjRmZAWF5ZAkFBZAk1EX01SLXRyZAzZAtOWlpNWVItMzZApZAjRm",
            "after": "QVFIUmZAkNDZD1ZD2VyX01SLXRyZAzZAtOWlpNWVItMzZApZAjRmZAWF5ZAkFBZAk1EX01SLXRyZAzZAtOWlpNWVItMzZApZAjRm"
        \}
    }
}
```

### List leads from ad

List leads from a given ad.
**Sample Input**
**Sample Output**

```json
{
    "data": [
        {
            "created_time": "2023-05-02T14:30:45Z",
            "id": "5678901234567890",
            "field_data": [
                \{
                    "name": "full_name",
                    "values": [
                        "John Doe"
                    ]
                \},
                \{
                    "name": "email",
                    "values": [
                        "johndoe@example.com"
                    ]
                \},
                \{
                    "name": "phone_number",
                    "values": [
                        "+1234567890"
                    ]
                \}
            ]
        },
        {
            "created_time": "2023-05-03T09:15:22Z",
            "id": "6789012345678901",
            "field_data": [
                \{
                    "name": "full_name",
                    "values": [
                        "Jane Smith"
                    ]
                \},
                \{
                    "name": "email",
                    "values": [
                        "janesmith@example.com"
                    ]
                \},
                \{
                    "name": "phone_number",
                    "values": [
                        "+1987654321"
                    ]
                \}
            ]
        }
    ],
    "paging": {
        "cursors": \{
            "before": "MQZDZD",
            "after": "NXYZAB"
        \}
    }
}
```

### List leads from form

List leads from a given form.
**Sample Input**
**Sample Output**

```json
{
    "data": [
        {
            "created_time": "2023-05-15T14:30:22+0000",
            "id": "5678901234567890",
            "field_data": [
                \{
                    "name": "full_name",
                    "values": [
                        "John Doe"
                    ]
                \},
                \{
                    "name": "email",
                    "values": [
                        "johndoe@example.com"
                    ]
                \},
                \{
                    "name": "phone_number",
                    "values": [
                        "+1234567890"
                    ]
                \}
            ]
        },
        {
            "created_time": "2023-05-14T09:45:11+0000",
            "id": "6789012345678901",
            "field_data": [
                \{
                    "name": "full_name",
                    "values": [
                        "Jane Smith"
                    ]
                \},
                \{
                    "name": "email",
                    "values": [
                        "janesmith@example.com"
                    ]
                \},
                \{
                    "name": "phone_number",
                    "values": [
                        "+9876543210"
                    ]
                \}
            ]
        }
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUmZA1ZAjRfZAk1CTmFB",
            "after": "QVFIUjZAaZAm5vZAXNETzZA5UEpSMVBnZAzZArZAzZA5T1BZAZAZA"
        \}
    }
}
```

### List pages managed

List the pages managed by the current user.
**Sample Input**

```json
\{
    "limit": 2,
    "after": "QVFIUjZAaZAnZAyOVpnZAzZAxZAXNERUx1TjZA5UVRyMEpBRTlIOXZAGZAUlCNVRRZA2x2TjZAzOWVQZD"
\}
```

**Sample Output**

### List pending users

List all users invited to access this business, who have not yet accepted their invitation.
**Sample Input**

```json
\{
    "business_id": "123456789",
    "limit": 10,
    "email_address": "john.doe@example.com",
    "after": "QVFIUjNfZAm5vZA3ZAZD"
\}
```

**Sample Output**

```json
{
    "data": [
        \{
            "id": "987654321",
            "role": "ADMIN",
            "email": "john.doe@example.com",
            "invite_link": "https://www.facebook.com/business_locations/?business_id=123456789&invite_id=987654321",
            "status": "PENDING"
        \},
        \{
            "id": "876543210",
            "role": "EMPLOYEE",
            "email": "jane.smith@example.com",
            "invite_link": "https://www.facebook.com/business_locations/?business_id=123456789&invite_id=876543210",
            "status": "PENDING"
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "QVFIUjNfZAm5vZA3ZAZD",
            "after": "QVFIUmZA1X0NUZD"
        \}
    }
}
```

### List posts on page

Retrieve a list of posts associated with a specific page.
**Sample Input**
**Sample Output**

```json
{
    "header": {},
    "body": {
        "data": [
            {
                "created_time": "2023-05-15T14:30:00+0000",
                "from": \{
                    "name": "My Business Page",
                    "id": "123456789012345"
                \},
                "id": "123456789012345_987654321098765",
                "message": "Check out our latest product launch!",
                "is_published": true,
                "is_hidden": false,
                "status_type": "mobile_status_update",
                "updated_time": "2023-05-15T14:30:00+0000"
            },
            {
                "created_time": "2023-05-14T10:15:00+0000",
                "from": \{
                    "name": "My Business Page",
                    "id": "123456789012345"
                \},
                "id": "123456789012345_876543210987654",
                "message": "Don't miss our upcoming sale this weekend!",
                "is_published": true,
                "is_hidden": false,
                "status_type": "mobile_status_update",
                "updated_time": "2023-05-14T10:15:00+0000"
            }
        ],
        "paging": {
            "cursors": \{
                "before": "QVFIUmZAZA3ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD1ZD",
                "after": "QVFIUjNfZAm5nZAXVpZAGVyX2x0UzZA2ZAzZAxZAjZAyZAWRkZD"
            \},
            "next": "https://graph.facebook.com/v12.0/123456789012345/posts?limit=2&after=QVFIUjNfZAm5nZAXVpZAGVyX2x0UzZA2ZAzZAxZAjZAyZAWRkZD"
        }
    }
}
```

### List saved audiences

List all saved audiences.
**Sample Input**

```json
{
    "ad_account_id": "act_123456789",
    "limit": 10,
    "filtering": [
        \{
            "field": "name",
            "operator": "CONTAIN",
            "value": "Summer"
        \}
    ],
    "after": "QVFIUjZAaWE5MzZAFZAkF6WkN0UzZA5R1JCN3RoZAk1SZA2x2TXByZAWRhOUlKZAVhCZAVhB"
}
```

**Sample Output**

### Targeting search

Retrieve target audiences for your ads that match your search query.
**Sample Input**
**Sample Output**

### Update custom audience

Update a custom audience with a new population.
**Sample Input**

```json
{
    "custom_audience_id": "23842001234567",
    "app_ids": [
        "123456789",
        "987654321"
    ],
    "audience_members": {
        "audience_member_list": [
            \{
                "email": "john.doe@example.com",
                "first_name": "John",
                "last_name": "Doe",
                "country_code": "us",
                "city": "New York",
                "us_state": "ny",
                "zip_code": "10001",
                "birth_year": "1985",
                "birth_month": "06",
                "birth_day": "15",
                "gender": "m",
                "phone": "+12125551234"
            \},
            \{
                "email": "jane.smith@example.com",
                "first_name": "Jane",
                "last_name": "Smith",
                "country_code": "ca",
                "city": "Toronto",
                "birth_year": "1990",
                "birth_month": "09",
                "birth_day": "22",
                "gender": "f",
                "phone": "+14165557890"
            \}
        ]
    }
}
```

**Sample Output**

```json
{
    "id": "6070345123456",
    "audience_id": "23842001234567",
    "session_id": "1234567890abcdef",
    "num_received": 2,
    "num_invalid_entries": 0,
    "invalid_entry_samples": {}
}
```

### Update post

Update a post.
**Sample Input**

```json
\{
    "post_id": "123456789012345",
    "message": "Updated message: Check out our latest product launch!",
    "publish": true,
    "scheduled_publish_time": "2023-06-15T14:30:00Z"
\}
```

**Sample Output**

## DDL operations

### List ad accounts (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

**Sample Input**

```json
{}
```

**Sample Output**

```json
[
    \{
        "id": "act_123456789",
        "name": "My Ad Account",
        "account_id": "123456789",
        "account_status": 1,
        "amount_spent": "1000.00",
        "balance": "5000.00",
        "currency": "USD",
        "timezone_name": "America/Los_Angeles",
        "timezone_offset_hours_utc": -7,
        "business_name": "My Business",
        "business_id": "987654321",
        "created_time": "2023-01-15T10:30:00-0700",
        "disable_reason": 0
    \},
    \{
        "id": "act_987654321",
        "name": "Secondary Ad Account",
        "account_id": "987654321",
        "account_status": 1,
        "amount_spent": "500.00",
        "balance": "2500.00",
        "currency": "EUR",
        "timezone_name": "Europe/London",
        "timezone_offset_hours_utc": 1,
        "business_name": "European Branch",
        "business_id": "123123123",
        "created_time": "2023-03-20T14:45:00+0100",
        "disable_reason": 0
    \}
]
```

### List custom audience ad accounts (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

**Sample Input**
**Sample Output**

```json
{
    "data": [
        \{
            "id": "123456789",
            "name": "Main Ad Account",
            "account_id": "987654321",
            "account_status": "ACTIVE",
            "currency": "USD",
            "timezone_name": "America/Los_Angeles",
            "business_name": "My Business",
            "business_id": "1122334455"
        \},
        \{
            "id": "234567890",
            "name": "Secondary Ad Account",
            "account_id": "876543210",
            "account_status": "ACTIVE",
            "currency": "EUR",
            "timezone_name": "Europe/London",
            "business_name": "My Other Business",
            "business_id": "2233445566"
        \}
    ],
    "paging": {
        "cursors": \{
            "before": "MAZDZD",
            "after": "MjQZD"
        \}
    }
}
```
