Linking Twitter (X) as a source

Let AI connect your sources for you

Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog.

Learn more
PostHog Wizard hedgehog

Alpha release

This source is currently in alpha. The interface and available tables may change.

The Twitter (X) connector syncs one X account's profile, posts, mentions, likes, followers, following, and owned lists into PostHog. Use it to join social reach and engagement to your product and revenue data, so you can see which posts bring in signups.

This connector reads organic account data. For ad spend and campaign performance, use the Twitter Ads source instead.

X charges you for this data

X bills your own developer project for every post this source reads, at the rate X publishes on its API pricing page. PostHog does not resell or mark up that access, and you buy the credits directly from X. A table you sync often, or an account with a large timeline or follower list, costs more. See Sync modes before you pick a sync frequency.

Prerequisites

You need an app in the X developer portal with:

  • A project the app is attached to. A standalone app cannot call the v2 API.
  • API credits on the project. X bills reads per post, so a project with no credits cannot sync anything.
  • The app's Bearer Token, from the app's Keys and tokens tab.

If your app's API access does not cover an endpoint, X returns a permission error for that table, and PostHog marks the table unavailable when you pick your schemas. You can leave those tables unselected and sync the rest.

Adding a data source

  1. In PostHog, go to the Sources tab of the data pipeline section.
  2. Click + New source and click Link next to this source.
  3. Enter your credentials (see Configuration below) and click Next.
  4. Select the tables you want to sync, choose a sync method and frequency, then click Import.

Once the syncs are complete, you can start querying this data in PostHog.

You need two values:

  • Bearer token: the app's bearer token from the X developer portal.
  • Account handle: the handle of the account to sync, such as posthog. Leave off the @ and the profile URL.

The handle decides whose data is synced. To sync more than one account, add one source per account and give each a different table prefix.

Sync modes

Each table can be synced in one of several modes, depending on what the source supports:

  • Webhook (when available) – the source pushes changes to PostHog in real time. Fastest freshness, lowest ongoing cost, and the only mode that reliably captures updates and deletes.
  • Incremental – only new or updated rows are synced on each run, using a cursor field (such as an updated_at timestamp). Cheaper than a full refresh, but deletes aren't captured.
  • Append only – new rows are appended using a cursor field; existing rows are never updated. Ideal for immutable, append-only tables like event logs.
  • Full refresh – the whole table is reloaded on every sync. Use it when a table has no reliable cursor or when you need deletions reflected.

See sync methods for a full explanation of how each mode works and how to choose between them.

Posts and Mentions support incremental syncs on created_at, because X lets PostHog ask for posts after a given time. Every other table is a full refresh: X has no time filter on those endpoints, so an "incremental" sync would still read the whole list on every run.

Every post PostHog reads costs you credits, and X caps pay-per-usage projects at 3 million post reads per billing cycle. X charges a repeated read of the same resource once per UTC day, so a sync that runs more than once a day costs little more than one that runs daily.

Reads also count against a rate limit whose windows are 15 minutes wide. On a large account, prefer a daily sync over an hourly one, and only select the tables you query.

Configuration

OptionTypeRequired
Bearer tokenpasswordYes
Account handletextYes

Supported tables

TableDescriptionSync methodIncremental fieldPrimary key
Profile

The public profile of the X account this source is connected to, one row per sync.

Full refresh——
Posts

Posts composed by the connected account, including replies and reposts.

Incremental, Full refreshcreated_at—
Mentions

Posts by other accounts that mention the connected account.

Incremental, Full refreshcreated_at—
LikedPosts

Posts the connected account has liked.

Full refresh——
Followers

Accounts that follow the connected account, one row per follower.

Full refresh——
Following

Accounts the connected account follows, one row per followed account.

Full refresh——
OwnedLists

Lists owned by the connected account.

Full refresh——

Troubleshooting

"X rejected the bearer token": the token was revoked or regenerated. Copy the current one from the app's Keys and tokens tab and reconnect the source.

"Your X app's API access doesn't cover this endpoint": your app cannot read that table. Check the project's API access and credit balance in the X developer portal, or turn off syncing for that table.

"X has no account with the handle": check the handle for typos. A suspended or deleted account also reports as missing.

Fewer posts than expected: X limits how far back a timeline goes, so the first sync may not reach the account's oldest posts.

If your sync is failing or data looks wrong, see the Data warehouse troubleshooting guide. If that doesn't help, contact support – we're happy to help.

Still have questions?

Was this page useful?