Skip to main content

V2 Account Activity API

Account Activity API v2 is now available on Pro!

Overview

The Account Activity API (AAA) provides a way to receive real-time events related to X user accounts via webhooks. By subscribing specific user accounts to a pre-configured webhook, your application can be notified of various activities such as Posts, Direct Messages, Likes, Follows, Blocks, and more, from one or more of your owned or subscribed accounts through a single connection.
This API is commonly used to build applications that need to react instantly to user actions or maintain an up-to-date state based on user activity. You will receive all related activities below for each user subscription on your webhook registration:

Activity Types

  • Posts (by user)
  • Post deletes (by user)
  • @mentions (of user)
  • Replies (to or from user)
  • Reposts (by user or of user)
  • Quote Posts (by user or of user)
  • Reposts of Quoted Posts (by user or of user)
  • Likes (by user or of user)
  • Follows (by user or of user)
  • Unfollows (by user or of user)
  • Blocks (by user or of user)
  • Unblocks (by user or of user)
  • Mutes (by user or of user)
  • Unmutes (by user or of user)
  • Direct Messages sent (by user)
  • Direct Messages received (by user)
  • Typing indicators (to user)
  • Read receipts (to user)
  • Subscription revokes (by user)
Note: We do not deliver home timeline data via the Account Activity API. Use the User Posts timeline by User ID endpoint to pull this data.

Feature Summary

This document focuses on managing user subscriptions associated with your webhooks using v2 Account Activity API endpoints.

Manage Subscriptions

The Account Activity API provides webhook-based JSON messages any time there are events associated with X accounts subscribed to your service. X delivers those activities to your registered webhook. In the following steps, you will learn how to set up and manage subscriptions for user accounts.
Account Activity API v2 currently does not support User Auth 2.0. We are working on fixing this and will update our docs when OAuth 2.0 is supported.

1. Create an X App

Create an X app with an approved developer account from the developer portal. If creating the app on behalf of your company, use a corporate X account.
  • Enable “Read, Write, and Access direct messages” on the permissions tab of your app page.
  • On the “Keys and Access Tokens” tab, note your app’s Consumer Key (API Key), Consumer Token (API Secret), and Bearer Token.
  • Generate your app’s Access Token and Access Token Secret. These are needed to subscribe to user accounts.
  • Review Obtaining Access Tokens if unfamiliar with X Sign-in and user contexts.
  • Note your app’s numeric ID from the “Apps” page in the developer portal. This is required when applying for Account Activity API access.

2. Get Account Activity API Access

The Account Activity API is available only on the Enterprise tier. Submit an application for Enterprise access via the developer portal.

3. Register a Webhook

To receive Account Activity events, you must register a webhook with a publicly accessible HTTPS URL. See the V2 Webhooks API documentation for details on developing a webhook consumer app, registering a webhook, securing it, and handling Challenge-Response Checks (CRC).
  • Ensure your webhook is configured to handle POST requests with JSON-encoded event payloads.
  • Obtain the webhook_id from the webhook registration response, as it is required for managing subscriptions.

4. Validate Setup

To validate that your app and webhook are configured correctly:
  • Subscribe a user account to your webhook (see “Adding a Subscription” below).
  • Favorite a Post posted by one of the X accounts your app is subscribed to.
  • You should receive a favorite_events payload via a POST request to your webhook URL.
  • Note: It may take up to 10 seconds for events to start being delivered after adding a subscription.

Important Notes

  • Authentication: When subscribing users, use the consumer key, consumer secret, access token, and access token secret for the user’s account.
  • Direct Messages: All incoming and outgoing Direct Messages (sent via POST /2/dm_conversations/with/:participant_id/messages) are delivered via webhooks to keep your app aware of all DM activity.
  • Event Duplication:
    • If two subscribed users are in the same DM conversation, your webhook receives duplicate events (one per user). Use the for_user_id field to distinguish them.
    • If multiple apps share the same webhook URL and user, events are sent multiple times (once per app).
    • Your app should deduplicate events using the event ID to handle occasional duplicates.
  • Example Code: See the Account Activity API Setup for a web app that displays webhook events.

Managing Subscribed Users (v2 API)

Once you have a registered webhook with a valid webhook_id, you can manage user subscriptions to receive their account activities. Use the following endpoints to add, view, or remove subscriptions.

Adding a Subscription

Endpoint: POST /2/account_activity/webhooks/:webhook_id/subscriptions/all
Description: Subscribes the authenticating user to receive events via the specified webhook.
Authentication: OAuthUser (3-legged OAuth flow required, representing the user being subscribed).
  • Consumer Key: e.g., xvz1evFS…
  • Access Token: e.g., 370773112-GmHxMAgYyLbN…
Path Parameters: Request:
bash
Responses:
  • Success (200 OK):
  • json
  • Failure (400 Bad Request):

Checking a Subscription

Endpoint: GET /2/account_activity/webhooks/:webhook_id/subscriptions/all
Description: Checks if the authenticating user is subscribed to the specified webhook.
Authentication: OAuthUser (3-legged OAuth flow required).
Path Parameters:
Request:
bash
Responses:
  • Success (200 OK):
  • json
  • Failure (400 Bad Request):

Removing Subscriptions

Endpoint: DELETE /2/account_activity/webhooks/:webhook_id/subscriptions/:user_id/all
Description: Deactivates the subscription for a specific user ID, stopping event delivery to the webhook.
Authentication: OAuth2 App Only Bearer Token.
  • Bearer Token: e.g., AAAAAAAAAAAA0%2EUifi76ZC9Ub0wn…
Path Parameters: Request:
bash
Responses:
  • Success (200 OK):
  • json
  • Failure (400 Bad Request):

Viewing all Subscriptions

Endpoint: GET /2/account_activity/webhooks/:webhook_id/subscriptions/all/list
Description: Retrieves a list of all user IDs currently subscribed to the specified webhook.
Authentication: OAuth2 App Only Bearer Token.
Path Parameters:
Request:
bash
Responses:
  • Success (200 OK):
  • json
  • Failure (400 Bad Request):

Subscriptions Count

Endpoint: GET /2/account_activity/subscriptions/count
Description: Returns the total count of active subscriptions and the provisioned limit for the authenticating application.
Authentication: OAuth2 App Only Bearer Token.
Request:
bash
Responses:
  • Success (200 OK):
  • json

Replay

AAAv2 provides replay functionality that allows you to retrieve past events for a specified time range and re-deliver them to your webhook. This is useful for recovering missed events due to downtime. Endpoint: POST /2/account_activity/replay/webhooks/:webhook_id/subscriptions/all Description: Initiates a replay job Authentication: OAuth2 App Only Bearer Token Path Parameters: Query Parameters: Responses: Success:
Failures:

Job Completed Messages

Once your replay job successfully completes, X will deliver the following job completion event. Once you receive this event, the job has finished running and another can be submitted.
In the event your job does not complete successfully, we will return the following message encouraging you to retry your Replay Job. Once you receive this event, the job has finished running and another can be submitted.

Account Activity Data Object Structure

Available Activities

Payload Examples

Below are example payloads for each Account Activity event.

tweet_create_events (Posts, Retweets, Replies, QuoteTweets)

tweet_create_events (@mentions)

favorite_events

follow_events

unfollow_events

block_events

unblock_events

mute_events

unmute_events

user_event

direct_message_events

direct_message_indicate_typing_events

direct_message_mark_read_events

tweet_delete_events

Support for Longform Posts

The V2 Account Activity API now supports longform posts, which are posts exceeding 280 characters. When a longform post is included in a tweet_create_events payload, the text field contains the first 140 characters (or fewer), and the truncated field is set to true. The full post content is delivered in the extended_tweet object, which includes:
  • full_text: The complete text of the post, including all characters beyond the 280-character limit.
  • entities: Any entities (e.g., hashtags, URLs, user mentions, symbols) appearing in the full text, including those after the 280th character.
  • display_text_range: The range of characters to display, accounting for the full text.
This ensures that applications can process the entire content of longform posts, including mentions or other entities that appear later in the text. Below is an example of a tweet_create_events payload for a longform post:

Account Activity API Migrating from Legacy Enterprise to v2

See our Migration Guide!

Frequently Asked Questions

What are the advantages of using the Account Activity API? The Account Activity API uses webhooks, delivering data in real-time without requiring an open connection (unlike streaming APIs) or frequent polling (unlike REST APIs). Benefits include:
  • Speed: Delivers data at the speed of X.
  • Simplicity: Provides all account events through a single webhook connection, including Posts, @mentions, Replies, Reposts, Quote Tweets, Likes, DMs, Follows, Blocks, and Mutes.
  • Scale: Supports all activities for managed accounts without rate limits or event caps (Enterprise tier).
I need development, staging, and production environments for Account Activity API, is this possible? Yes! Tou can register multiple webhook URLs and manage subscriptions separately via the V2 Webhooks API. Do you have any step-by-step guides on how to get set up with the Account Activity API? Yes! See the Getting Started with Webhooks guide and the Account Activity API Sample Application. What authentication do I have to use with the Account Activity API? Authentication requirements are specified per endpoint. Review the Authentication section for details. Will I get duplicate activities if subscribed to users that are interacting with each other? Yes. If your app has subscriptions for User A and User B, and User A mentions User B in a Post, your webhook receives two events (one per user). Use the for_user_id field to identify the subscription. When I make a subscription to my webhook, can I replace the /all/ portion of the endpoint with other account activity data objects to limit the activities delivered? No. The /all/ product is the only option, delivering all supported event types. If I have access to three webhooks, can I use three webhooks for each of the apps that I have registered for enterprise use? The webhook limit is set at the account level, not per app. For example, with three webhooks and two apps, you could use two webhooks for one app and one for the other, but not three per app.

Account Activity API Reference Index

For webhook management endpoints (register, view, validate, delete), see the V2 Webhooks API documentation