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:
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.
The returned Posts from Account Activity API count towards the monthly Post cap.
Tier | Pricing | Number of Unique Subscriptions | Number of Webhooks |
---|---|---|---|
Self-Serve Pro | $5000/mo | 1 | 1 |
Enterprise | Contact sales | 5000+ | 5+ |
This document focuses on managing user subscriptions associated with your webhooks using v2 Account Activity API endpoints.
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.
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.
The Account Activity API is available only on the Enterprise tier. Submit an application for Enterprise access via the developer portal.
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).
To validate that your app and webhook are configured correctly:
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.
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).
Path Parameters:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to associate the subscription with. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
DuplicateSubscriptionFailed | A subscription for this user already exists for the specified webhook_id. |
SubscriptionLimitExceeded | The application has reached its subscription limit across all webhooks. |
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to check. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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.
Path Parameters:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook containing the subscription. |
user_id | The numerical ID of the user to unsubscribe. |
Request:
bash
Responses:
Reason | Description |
---|---|
SubscriptionNotFound | No subscription exists for the specified user_id on the given webhook_id. |
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to list subscriptions for. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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:
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to begin replay |
Query Parameters:
Parameter | Description |
---|---|
from_date | The oldest (starting) UTC timestamp from which the events will be provided, must be in ‘yyyymmddhhmm’ format. Timestamp is in minute granularity and is inclusive (i.e. 12:00 includes the 00 minute). Valid times must be within the last 24 hours, UTC time, and no more recent than 31 minutes before the current point in time. It’s recommended that the from_date and to_date should be within ~2 hours. |
to_date | The latest (ending) UTC timestamp to which the event will be provided, must be in ‘yyyymmddhhmm’ format. Timestamp is in minute granularity and is exclusive (i.e. 12:30 does not include the 30th minute of the hour). Valid times must be within the last 24 hours, UTC time, and no more than 10 minutes before the current point in time. |
Responses:
Success:
Failures:
Reason | Description |
---|---|
QueryParamInvalid | from_date is older than 24 hours from the current time. |
QueryParamInvalid | from_date is more recent than to_date. |
QueryParamInvalid | from_date is in the future. |
QueryParamInvalid | to_date is in the future. |
QueryParamInvalid | from_date or to_date is not in the correct format. |
CrcValidationFailed | Incorrect response received from the webhook URL during CRC validation. |
ReplayConflictError | A replay job is already in progress for the specified webhook. |
WebhookIdInvalid | The provided webhook_id is invalid or not associated with the app. |
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.
Object | Details |
---|---|
for_user_id | Identifies the user subscription that the event is related to. |
is_blocked_by | (Conditional) Shown only for Post mention events if the mentioning user is blocked by the subscribed user. |
source | The user performing the activity (e.g., the user following, blocking, or muting). |
target | The user the activity applies to (e.g., the user being followed, blocked, or muted). |
Message Type | Details |
---|---|
tweet_create_events | Post status for Posts, Retweets, Replies, @mentions , Quote Tweets, or Retweet of Quote Tweets. |
favorite_events | Like event with user and target. |
follow_events | Follow event with user and target. |
unfollow_events | Unfollow event with user and target. |
block_events | Block event with user and target. |
unblock_events | Unblock event with user and target. |
mute_events | Mute event with user and target. |
unmute_events | Unmute event with user and target. |
user_event | Revoke events when a user removes app authorization (subscription auto-deleted). |
direct_message_events | DM status for sent or received messages. |
direct_message_indicate_typing_events | DM typing event with user and target. |
direct_message_mark_read_events | DM read event with user and target. |
tweet_delete_events | Notice of deleted Posts for compliance. |
spaces_events | Not currently supported. Coming soon. |
Below are example payloads for each Account Activity event.
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:
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:
See our Migration Guide!
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:
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.
Purpose | V2 Endpoint |
---|---|
Subscribes an application to an account’s events | POST /2/account_activity/webhooks/:webhook_id/subscriptions/all |
Returns a count of currently active subscriptions | GET /2/account_activity/subscriptions/count |
Checks if a webhook is subscribed to an account | GET /2/account_activity/webhooks/:webhook_id/subscriptions/all |
Returns a list of currently active subscriptions | GET /2/account_activity/webhooks/:webhook_id/subscriptions/all/list |
Deactivates a subscription using app-only OAuth | DELETE /2/account_activity/webhooks/:webhook_id/subscriptions/:user_id/all |
Creates a replay job | POST /2/account_activity/replay/webhooks/:webhook_id/subscriptions/all |
For webhook management endpoints (register, view, validate, delete), see the V2 Webhooks API documentation
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:
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.
The returned Posts from Account Activity API count towards the monthly Post cap.
Tier | Pricing | Number of Unique Subscriptions | Number of Webhooks |
---|---|---|---|
Self-Serve Pro | $5000/mo | 1 | 1 |
Enterprise | Contact sales | 5000+ | 5+ |
This document focuses on managing user subscriptions associated with your webhooks using v2 Account Activity API endpoints.
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.
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.
The Account Activity API is available only on the Enterprise tier. Submit an application for Enterprise access via the developer portal.
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).
To validate that your app and webhook are configured correctly:
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.
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).
Path Parameters:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to associate the subscription with. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
DuplicateSubscriptionFailed | A subscription for this user already exists for the specified webhook_id. |
SubscriptionLimitExceeded | The application has reached its subscription limit across all webhooks. |
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to check. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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.
Path Parameters:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook containing the subscription. |
user_id | The numerical ID of the user to unsubscribe. |
Request:
bash
Responses:
Reason | Description |
---|---|
SubscriptionNotFound | No subscription exists for the specified user_id on the given webhook_id. |
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to list subscriptions for. |
Request:
bash
Responses:
Reason | Description |
---|---|
WebhookIdInvalid | The provided webhook_id was not found or is not associated with the app. |
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:
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:
Parameter | Description |
---|---|
webhook_id | The ID of the webhook to begin replay |
Query Parameters:
Parameter | Description |
---|---|
from_date | The oldest (starting) UTC timestamp from which the events will be provided, must be in ‘yyyymmddhhmm’ format. Timestamp is in minute granularity and is inclusive (i.e. 12:00 includes the 00 minute). Valid times must be within the last 24 hours, UTC time, and no more recent than 31 minutes before the current point in time. It’s recommended that the from_date and to_date should be within ~2 hours. |
to_date | The latest (ending) UTC timestamp to which the event will be provided, must be in ‘yyyymmddhhmm’ format. Timestamp is in minute granularity and is exclusive (i.e. 12:30 does not include the 30th minute of the hour). Valid times must be within the last 24 hours, UTC time, and no more than 10 minutes before the current point in time. |
Responses:
Success:
Failures:
Reason | Description |
---|---|
QueryParamInvalid | from_date is older than 24 hours from the current time. |
QueryParamInvalid | from_date is more recent than to_date. |
QueryParamInvalid | from_date is in the future. |
QueryParamInvalid | to_date is in the future. |
QueryParamInvalid | from_date or to_date is not in the correct format. |
CrcValidationFailed | Incorrect response received from the webhook URL during CRC validation. |
ReplayConflictError | A replay job is already in progress for the specified webhook. |
WebhookIdInvalid | The provided webhook_id is invalid or not associated with the app. |
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.
Object | Details |
---|---|
for_user_id | Identifies the user subscription that the event is related to. |
is_blocked_by | (Conditional) Shown only for Post mention events if the mentioning user is blocked by the subscribed user. |
source | The user performing the activity (e.g., the user following, blocking, or muting). |
target | The user the activity applies to (e.g., the user being followed, blocked, or muted). |
Message Type | Details |
---|---|
tweet_create_events | Post status for Posts, Retweets, Replies, @mentions , Quote Tweets, or Retweet of Quote Tweets. |
favorite_events | Like event with user and target. |
follow_events | Follow event with user and target. |
unfollow_events | Unfollow event with user and target. |
block_events | Block event with user and target. |
unblock_events | Unblock event with user and target. |
mute_events | Mute event with user and target. |
unmute_events | Unmute event with user and target. |
user_event | Revoke events when a user removes app authorization (subscription auto-deleted). |
direct_message_events | DM status for sent or received messages. |
direct_message_indicate_typing_events | DM typing event with user and target. |
direct_message_mark_read_events | DM read event with user and target. |
tweet_delete_events | Notice of deleted Posts for compliance. |
spaces_events | Not currently supported. Coming soon. |
Below are example payloads for each Account Activity event.
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:
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:
See our Migration Guide!
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:
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.
Purpose | V2 Endpoint |
---|---|
Subscribes an application to an account’s events | POST /2/account_activity/webhooks/:webhook_id/subscriptions/all |
Returns a count of currently active subscriptions | GET /2/account_activity/subscriptions/count |
Checks if a webhook is subscribed to an account | GET /2/account_activity/webhooks/:webhook_id/subscriptions/all |
Returns a list of currently active subscriptions | GET /2/account_activity/webhooks/:webhook_id/subscriptions/all/list |
Deactivates a subscription using app-only OAuth | DELETE /2/account_activity/webhooks/:webhook_id/subscriptions/:user_id/all |
Creates a replay job | POST /2/account_activity/replay/webhooks/:webhook_id/subscriptions/all |
For webhook management endpoints (register, view, validate, delete), see the V2 Webhooks API documentation