# Twitter / X

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

> Tool types for drafting, publishing, syncing, and measuring tweets through a Twitter/X connector.

# Twitter / X

Draft tweets into a reviewable AutessaDB table, publish approved drafts to X, pull the account's existing tweets into the same table, and read engagement metrics per tweet.

Every tool on this page requires a Twitter/X connector (see
[Connectors](/docs/guide/connectors.md)); pass its ID as `connectorId`. Tweets
live as rows in an AutessaDB table the connector provisions: agent-written
drafts start at `status = DRAFT`, publishing flips the row to `PUBLISHED` and
records the `tweet_id`, and the sync tool imports tweets posted outside
Autessa so the table stays the single picture of the account.

## Create a draft **TOOL** `TWITTER_CREATE_DRAFT`

Inserts a new draft row with `status = DRAFT` — nothing is posted to X yet.
`tweetContent` is capped at 280 characters, and the optional `mediaUrl`
image is stored on the row and only uploaded to X at publish time. Returns
the new `recordId` for use with the update, publish, and stats tools.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_CREATE_DRAFT",
  "connectorId": "V1StGXR8Z5",
  "tweetContent": "@@{TWEET_CONTENT}",
  "mediaUrl": "@@{IMAGE_URL}"
}
```

> 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.
- `tweetContent` (string) — Max 280 characters
- `mediaUrl` (string · optional) — Optional - URL of image to attach

## Update a draft **TOOL** `TWITTER_UPDATE_DRAFT`

Edits an existing draft row in place; `tweetContent` (still max 280
characters) and `mediaUrl` are both optional and only the provided fields
change. This edits the AutessaDB row only — it cannot modify a tweet that
has already been published.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_UPDATE_DRAFT",
  "connectorId": "V1StGXR8Z5",
  "recordId": 42,
  "tweetContent": "@@{REVISED_TWEET}"
}
```

> 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
- `tweetContent` (string · optional) — New content (optional - only updates if provided, max 280 chars)
- `mediaUrl` (string · optional) — New image URL (optional - only updates if provided)

## Publish a tweet **TOOL** `TWITTER_PUBLISH_TWEET`

Reads the draft row, uploads its media if a `media_url` is set, and posts
the tweet to the connected X account. The row must still be in `DRAFT`
status — republishing fails with `ALREADY_PUBLISHED`. On success the row is
updated to `status = PUBLISHED` with the new `tweet_id` stored for later
stats lookups.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_PUBLISH_TWEET",
  "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 tweet stats **TOOL** `TWITTER_GET_TWEET_STATS`

Looks up the `tweet_id` on a published row and fetches live engagement
metrics from the X API: likes, retweets, replies, quotes, bookmarks, and
impressions, plus URL clicks and profile clicks when the account has access
to non-public metrics. When impressions are available the tool also computes
`totalEngagements` and an `engagementRate` percentage, and it returns a
direct `tweetUrl` to the post.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_GET_TWEET_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 to get tweet_id from

## Get all tweets **TOOL** `TWITTER_GET_ALL_TWEETS`

Lists rows from the connector's tweets table — drafts and published tweets
together by default, or filtered with `status` (`DRAFT`, `PUBLISHED`,
`SCHEDULED`). `pageSize` defaults to 50 and caps at 100. This reads the
AutessaDB table, so it reflects synced tweets as well as agent-created ones.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_GET_ALL_TWEETS",
  "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, SCHEDULED
- `pageSize` (integer · optional) — Optional - max tweets to retrieve (default 50, max 100)

## Get tweet by ID **TOOL** `TWITTER_GET_TWEET_BY_ID`

Fetches a single row from the tweets table by its AutessaDB `rowId`,
returning the tweet's content, status, media URL, and stored `tweet_id`.
Use it to inspect one specific draft or published tweet without paging
through the full list.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_GET_TWEET_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) — Required - the AutessaDB row ID of the tweet to fetch

## Sync tweets **TOOL** `TWITTER_SYNC_TWEETS`

Imports the connected account's timeline from the X API into the AutessaDB
table as `PUBLISHED` rows, skipping tweets that are already present. Results
are cached for 24 hours — a second sync inside that window returns the
cached summary unless `forceRefresh` is `true`. Large backfills that exceed
the execution window continue as a background job (`backgroundJob: true` in
the response); the summary reports `syncedCount`, `newTweetsCount`, and
`skippedCount`.

### Example

```json title="Tool config"
{
  "toolType": "TWITTER_SYNC_TWEETS",
  "connectorId": "V1StGXR8Z5",
  "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.
- `forceRefresh` (boolean · optional) — Optional: bypass daily cache if true

## Related

- [Tool Types overview](/docs/tools.md)
- [Tools guide](/docs/guide/agentic/tools.md)
- [Connectors guide](/docs/guide/connectors.md)
- [Bluesky tool types](/docs/tools/bluesky.md)
- [Threads tool types](/docs/tools/threads.md)
- [LinkedIn tool types](/docs/tools/linkedin.md)

