Twitter/X Account Activity API
Endpoints relating to retrieving, managing AAA subscriptions
Documentation
Documentation
https://docs.x.com/x-api/introduction
APIReference
https://docs.x.com/x-api/introduction
Endpoints relating to retrieving, managing AAA subscriptions
openapi: 3.0.0
info:
description: X API v2 available endpoints
version: '2.166'
title: X API v2 Account Activity API
termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
contact:
name: X Developers
url: https://developer.x.com/
license:
name: X Developer Agreement and Policy
url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
url: https://api.x.com
tags:
- name: Account Activity
description: Endpoints relating to retrieving, managing AAA subscriptions
externalDocs:
description: Find out more
url: https://docs.x.com/x-api/enterprise-gnip-2.0/fundamentals/account-activity
paths:
/2/account_activity/subscriptions/count:
get:
security:
- BearerToken: []
tags:
- Account Activity
summary: Get subscription count
description: Retrieves a count of currently active Account Activity subscriptions.
externalDocs:
url: https://docs.x.com/x-api/account-activity/introduction
operationId: getAccountActivitySubscriptionCount
parameters: []
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsCountGetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/account_activity/webhooks/{webhook_id}/subscriptions/all:
get:
security:
- OAuth2UserToken:
- dm.read
- dm.write
- tweet.read
- users.read
- UserToken: []
tags:
- Account Activity
summary: Validate subscription
description: Checks a user’s Account Activity subscription for a given webhook.
externalDocs:
url: https://docs.x.com/x-api/account-activity/introduction
operationId: validateAccountActivitySubscription
parameters:
- name: webhook_id
in: path
description: The webhook ID to check subscription against.
required: true
schema:
$ref: '#/components/schemas/WebhookConfigId'
style: simple
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsGetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
post:
security:
- OAuth2UserToken:
- dm.read
- dm.write
- tweet.read
- users.read
- UserToken: []
tags:
- Account Activity
summary: Create subscription
description: Creates an Account Activity subscription for the user and the given webhook.
externalDocs:
url: https://docs.x.com/x-api/account-activity/introduction
operationId: createAccountActivitySubscription
parameters:
- name: webhook_id
in: path
description: The webhook ID to check subscription against.
required: true
schema:
$ref: '#/components/schemas/WebhookConfigId'
style: simple
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsCreateRequest'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsCreateResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/account_activity/webhooks/{webhook_id}/subscriptions/all/list:
get:
security:
- BearerToken: []
tags:
- Account Activity
summary: Get subscriptions
description: Retrieves a list of all active subscriptions for a given webhook.
externalDocs:
url: https://docs.x.com/x-api/account-activity/introduction
operationId: getAccountActivitySubscriptions
parameters:
- name: webhook_id
in: path
description: The webhook ID to pull subscriptions for.
required: true
schema:
$ref: '#/components/schemas/WebhookConfigId'
style: simple
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsListGetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/account_activity/webhooks/{webhook_id}/subscriptions/{user_id}/all:
delete:
security:
- BearerToken: []
tags:
- Account Activity
summary: Delete subscription
description: Deletes an Account Activity subscription for the given webhook and user ID.
externalDocs:
url: https://docs.x.com/x-api/account-activity/introduction
operationId: deleteAccountActivitySubscription
parameters:
- name: webhook_id
in: path
description: The webhook ID to check subscription against.
required: true
schema:
$ref: '#/components/schemas/WebhookConfigId'
style: simple
- name: user_id
in: path
description: User ID to unsubscribe from.
required: true
schema:
$ref: '#/components/schemas/UserId'
style: simple
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsDeleteResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
components:
schemas:
SubscriptionsCreateResponse:
type: object
properties:
data:
type: object
properties:
subscribed:
type: boolean
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
SubscriptionsDeleteResponse:
type: object
properties:
data:
type: object
properties:
subscribed:
type: boolean
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
Problem:
type: object
description: An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).
required:
- type
- title
properties:
detail:
type: string
status:
type: integer
title:
type: string
type:
type: string
discriminator:
propertyName: type
mapping:
about:blank: '#/components/schemas/GenericProblem'
https://api.twitter.com/2/problems/client-disconnected: '#/components/schemas/ClientDisconnectedProblem'
https://api.twitter.com/2/problems/client-forbidden: '#/components/schemas/ClientForbiddenProblem'
https://api.twitter.com/2/problems/conflict: '#/components/schemas/ConflictProblem'
https://api.twitter.com/2/problems/disallowed-resource: '#/components/schemas/DisallowedResourceProblem'
https://api.twitter.com/2/problems/duplicate-rules: '#/components/schemas/DuplicateRuleProblem'
https://api.twitter.com/2/problems/invalid-request: '#/components/schemas/InvalidRequestProblem'
https://api.twitter.com/2/problems/invalid-rules: '#/components/schemas/InvalidRuleProblem'
https://api.twitter.com/2/problems/noncompliant-rules: '#/components/schemas/NonCompliantRulesProblem'
https://api.twitter.com/2/problems/not-authorized-for-field: '#/components/schemas/FieldUnauthorizedProblem'
https://api.twitter.com/2/problems/not-authorized-for-resource: '#/components/schemas/ResourceUnauthorizedProblem'
https://api.twitter.com/2/problems/operational-disconnect: '#/components/schemas/OperationalDisconnectProblem'
https://api.twitter.com/2/problems/resource-not-found: '#/components/schemas/ResourceNotFoundProblem'
https://api.twitter.com/2/problems/resource-unavailable: '#/components/schemas/ResourceUnavailableProblem'
https://api.twitter.com/2/problems/rule-cap: '#/components/schemas/RulesCapProblem'
https://api.twitter.com/2/problems/streaming-connection: '#/components/schemas/ConnectionExceptionProblem'
https://api.twitter.com/2/problems/unsupported-authentication: '#/components/schemas/UnsupportedAuthenticationProblem'
https://api.twitter.com/2/problems/usage-capped: '#/components/schemas/UsageCapExceededProblem'
SubscriptionsGetResponse:
type: object
properties:
data:
type: object
properties:
subscribed:
type: boolean
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
WebhookConfigId:
type: string
description: The unique identifier of this webhook config.
pattern: ^[0-9]{1,19}$
example: '1146654567674912769'
SubscriptionsListGetResponse:
type: object
properties:
data:
type: object
description: The list of active subscriptions for a specified webhook
required:
- application_id
- webhook_id
- webhook_url
- subscriptions
properties:
application_id:
type: string
description: The application ID
subscriptions:
type: array
description: List of active subscriptions for the webhook
items:
type: object
properties:
user_id:
type: string
description: The ID of the user the webhook is subscribed to
webhook_id:
type: string
description: The associated webhook ID
webhook_url:
type: string
description: The url for the associated webhook
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
SubscriptionsCountGetResponse:
type: object
properties:
data:
type: object
description: The count of active subscriptions across all webhooks
required:
- account_name
- provisioned_count
- subscriptions_count_all
- subscriptions_count_direct_messages
properties:
account_name:
type: string
description: The account name
provisioned_count:
type: string
description: The limit for subscriptions for this app
subscriptions_count_all:
type: string
description: The number of active subscriptions across all webhooks
subscriptions_count_direct_messages:
type: string
description: The number of active direct message subscriptions
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
UserId:
type: string
description: Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
pattern: ^[0-9]{1,19}$
example: '2244994945'
SubscriptionsCreateRequest:
type: object
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
securitySchemes:
BearerToken:
type: http
scheme: bearer
OAuth2UserToken:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.x.com/2/oauth2/authorize
tokenUrl: https://api.x.com/2/oauth2/token
scopes:
block.read: View accounts you have blocked.
bookmark.read: Read your bookmarked Posts.
bookmark.write: Create and delete your bookmarks.
dm.read: Read all your Direct Messages.
dm.write: Send and manage your Direct Messages.
follows.read: View accounts you follow and accounts following you.
follows.write: Follow and unfollow accounts on your behalf.
like.read: View Posts you have liked and likes you can see.
like.write: Like and unlike Posts on your behalf.
list.read: View Lists, members, and followers of Lists you created or are a member of, including private Lists.
list.write: Create and manage Lists on your behalf.
media.write: Upload media, such as photos and videos, on your behalf.
mute.read: View accounts you have muted.
mute.write: Mute and unmute accounts on your behalf.
offline.access: Request a refresh token for the app.
space.read: View all Spaces you have access to.
timeline.read: View all Custom Timelines you can see, including public Custom Timelines from other developers.
tweet.moderate.write: Hide and unhide replies to your Posts.
tweet.read: View all Posts you can see, including those from protected accounts.
tweet.write: Post and repost on your behalf.
users.read: View any account you can see, including protected accounts.
UserToken:
type: http
scheme: OAuth