# Facebook

Source: https://docs.autessa.com/docs/tools/facebook

> Tool types for drafting and publishing Facebook posts, syncing Page content, and reading Page and ads insights.

# Facebook

Draft Facebook posts into a reviewable AutessaDB table, publish them to a profile, Page, or group, sync a Page's existing posts, and pull Page and Ads insights for reporting.

Every tool on this page requires a Facebook connector (see
[Connectors](/docs/guide/connectors.md)); pass its ID as `connectorId`. Posts
live as rows in an AutessaDB table the connector provisions: drafts start at
`status = DRAFT` and carry a publish target (`PROFILE`, `PAGE`, or `GROUP`),
and publishing flips the row to `PUBLISHED` with the Facebook post ID stored
for stats lookups. The insights tools are read-only reporting calls against
the Graph API and the Marketing API.

## Create a draft post **TOOL** `FACEBOOK_CREATE_DRAFT_POST`

Inserts a new draft row with `status = DRAFT` — nothing is posted to
Facebook yet. Alongside `postContent` and the optional `mediaUrl` image, the
draft records where it will be published: `targetType` is `PROFILE`, `PAGE`,
or `GROUP`, with `targetId` holding the Page or group ID (`null` for
`PROFILE`) and `targetName` a human-readable label for reviewers. Returns
the new `recordId`.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_CREATE_DRAFT_POST",
  "connectorId": "V1StGXR8Z5",
  "postContent": "@@{POST_CONTENT}",
  "mediaUrl": "@@{IMAGE_URL}",
  "targetType": "PAGE",
  "targetId": "104857361234567",
  "targetName": "Acme Robotics"
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `postContent` (string) — The post text content
- `mediaUrl` (string · optional) — Optional - URL of image to attach
- `targetType` (string) — PROFILE, PAGE, or GROUP
- `targetId` (string) — Page or Group ID (null for PROFILE)
- `targetName` (string) — Display name for the target

## Update a draft post **TOOL** `FACEBOOK_UPDATE_DRAFT_POST`

Edits an existing draft row in place. Content, media, and all three target
fields are optional — only the fields you provide change, so you can retarget
a draft from one Page to another without rewriting it. This edits the
AutessaDB row only; it cannot modify a post that has already been published.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_UPDATE_DRAFT_POST",
  "connectorId": "V1StGXR8Z5",
  "recordId": 42,
  "postContent": "@@{REVISED_CONTENT}"
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `recordId` (integer) — AutessaDB record ID of the draft to update
- `postContent` (string · optional) — Optional - new post content
- `mediaUrl` (string · optional) — Optional - new URL of image to attach
- `targetType` (string · optional) — Optional - PROFILE, PAGE, or GROUP
- `targetId` (string · optional) — Optional - new Page or Group ID
- `targetName` (string · optional) — Optional - new display name for the target

## Publish a post **TOOL** `FACEBOOK_PUBLISH_POST`

Reads the draft row and publishes it to the target recorded on the row —
Page posts are made with the Page's own access token, and `PAGE`/`GROUP`
targets require a target ID. The row must still be in `DRAFT` status;
republishing fails with `ALREADY_PUBLISHED`. On success the row is updated
to `status = PUBLISHED` with the Facebook post ID stored for later stats
lookups.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_PUBLISH_POST",
  "connectorId": "V1StGXR8Z5",
  "recordId": 42
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `recordId` (integer) — AutessaDB record ID of the draft to publish

## Get post stats **TOOL** `FACEBOOK_GET_POST_STATS`

Looks up the Facebook post ID on a published row and fetches live engagement
from the Graph API — like and comment totals plus the post's message and
created time. Only works for rows that have been published (or synced) and
therefore carry a Facebook post ID.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_GET_POST_STATS",
  "connectorId": "V1StGXR8Z5",
  "recordId": 42
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `recordId` (integer) — AutessaDB record ID of the published post

## Get all posts **TOOL** `FACEBOOK_GET_ALL_POSTS`

Lists rows from the connector's posts table — drafts and published posts
together by default, or filtered with `status` (`DRAFT`, `PUBLISHED`).
`pageSize` defaults to 50 and caps at 100. Reads the AutessaDB table, so
results include synced Page posts as well as agent-created drafts.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_GET_ALL_POSTS",
  "connectorId": "V1StGXR8Z5",
  "status": "DRAFT",
  "pageSize": 50
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `status` (string · optional) — Optional - filter by status: DRAFT, PUBLISHED
- `pageSize` (integer · optional) — Optional - max posts to retrieve (default 50, max 100)

## Get post by ID **TOOL** `FACEBOOK_GET_POST_BY_ID`

Fetches a single row from the posts table by its AutessaDB `rowId`,
returning content, status, media URL, target details, and the stored
Facebook post ID. Use it to inspect one specific draft or published post
without paging through the full list.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_GET_POST_BY_ID",
  "connectorId": "V1StGXR8Z5",
  "rowId": 42
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `rowId` (integer) — AutessaDB row ID of the post to retrieve

## Sync posts **TOOL** `FACEBOOK_SYNC_POSTS`

Imports a Page's existing posts from the Graph API into the AutessaDB table
as `PUBLISHED` rows, skipping posts that are already present. Results are
cached for 24 hours — a second sync inside that window returns the cached
summary unless `forceRefresh` is `true`. Run this once after connecting so
the table reflects the Page's history, then periodically to pick up posts
made outside Autessa.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_SYNC_POSTS",
  "connectorId": "V1StGXR8Z5",
  "pageId": "104857361234567",
  "forceRefresh": false
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `pageId` (string) — The Facebook Page ID to sync posts from
- `forceRefresh` (boolean · optional) — Optional: bypass daily cache if true

## Get Page insights **TOOL** `FACEBOOK_GET_PAGE_INSIGHTS`

Fetches Page-level metrics from the Graph API Insights endpoint: unique
impressions, post engagements, daily new follows, and video views —
the set of metrics Meta still supports after its 2024–2025 insights
deprecations. `period` buckets the numbers by `day`, `week`, or `days_28`,
and the optional `datePreset` (for example `last_30d`) selects the reporting
window.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_GET_PAGE_INSIGHTS",
  "connectorId": "V1StGXR8Z5",
  "pageId": "104857361234567",
  "period": "day",
  "datePreset": "last_30d"
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `pageId` (string) — Facebook Page ID to get insights for
- `period` (string) — Period for metrics: day, week, days_28 (default: day)
- `datePreset` (string · optional) — Optional: today, yesterday, this_week, last_week, this_month, last_month, last_7d, last_30d, last_90d

## List ad accounts **TOOL** `FACEBOOK_LIST_AD_ACCOUNTS`

Lists the ad accounts the connected user can access, including each
account's ID (the `act_...` form the other ads tools expect), name, and
status. This is the usual first step of an ads-reporting flow: find the
account, then list its campaigns or pull insights.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_LIST_AD_ACCOUNTS",
  "connectorId": "V1StGXR8Z5"
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.

## List campaigns **TOOL** `FACEBOOK_LIST_CAMPAIGNS`

Lists campaigns in an ad account, optionally filtered by `status`
(`ACTIVE`, `PAUSED`, `DELETED`, `ARCHIVED`), up to `limit` (default 50).
Each campaign's ID can be passed to the ads-insights tool for per-campaign
performance.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_LIST_CAMPAIGNS",
  "connectorId": "V1StGXR8Z5",
  "adAccountId": "act_123456789",
  "status": "ACTIVE",
  "limit": 50
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `adAccountId` (string) — Ad account ID (e.g., "act_123456789")
- `status` (string · optional) — Optional - filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED
- `limit` (integer · optional) — Optional - max campaigns to retrieve (default 50)

## Get ads insights **TOOL** `FACEBOOK_GET_ADS_INSIGHTS`

Pulls performance metrics from the Marketing API for any level of the ads
hierarchy — pass an ad account, campaign, ad set, or ad ID as `objectId`.
Returns spend, impressions, clicks, CTR, CPC, CPM, reach, and frequency,
plus action breakdowns (conversions and cost per action) when available.
`datePreset` selects the window (for example `last_30d` or `lifetime`) and
`level` re-aggregates account-level queries by `campaign`, `adset`, or `ad`.

### Example

```json title="Tool config"
{
  "toolType": "FACEBOOK_GET_ADS_INSIGHTS",
  "connectorId": "V1StGXR8Z5",
  "objectId": "act_123456789",
  "datePreset": "last_30d",
  "level": "campaign"
}
```

> This tool type requires a connected external account. Pass the connector's ID as `connectorId` in the tool configuration.

**Configuration fields**

- `connectorId` (string (ID)) — Required string (ID) value. References a connector by ID.
- `objectId` (string) — Ad account ID, campaign ID, ad set ID, or ad ID
- `datePreset` (string · optional) — Optional: today, yesterday, this_week, last_week, last_7d, last_14d, last_30d, last_90d, this_month, last_month, lifetime
- `level` (string · optional) — Optional: account, campaign, adset, ad (default: derives from objectId type)

## Related

- [Tool Types overview](/docs/tools.md)
- [Tools guide](/docs/guide/agentic/tools.md)
- [Connectors guide](/docs/guide/connectors.md)
- [Instagram tool types](/docs/tools/instagram.md)
- [Threads tool types](/docs/tools/threads.md)
- [Google Analytics tool types](/docs/tools/google-analytics.md)

