How to add a Subscription to Account Activity API

webhooks
account-activity

#1

I am trying to subscribe to screen names for the Account Activity API. I have authenticated and registered the webhook. I tried to use lists/members/create to add to the subscription list. But, it seems that the specified user was saved in a member list of some kind instead. When I get with lists/subscriptions, I only see myself. Also, when I view the subscribers for the Account Activity API, I see 0.

I was interested in using ‘account_activity/all/:env_name/subscriptions’, but I did not see where to put a screen name.

After a lot of searching, I decided to ask here. How do I subscribe to a particular screen name for the Account Activity API? Thanks.


#2

Hi @SamJone73931958 - the Account Activity API is completely separate from the POST lists/members/create and GET lists/subscriptions endpoints. It is therefore not surprising that adding subscriptions did not work.

The former (Account Activity API) is a premium API. I suggest you read through our documentation and follow the steps outlined there to start adding subscriptions: https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference

The latter are two standard endpoints. I would also suggest reading through our documentation on GET lists/subscriptions and POST list/members/create if you are interested in using these. However, using these endpoints will have no impact whatsoever on the Accout Activity API.


#3

Thank you. I read through the documentation on adding subscriptions again located here: https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference. However, it is not clear to me where one would obtain SUBSCRIBING_USER’S_ACCESS_TOKEN for POST account_activity/all/:env_name/subscriptions. All I have is the user’s screen name for who I would like to subscribe. Can you please explain where/how SUBSCRIBING_USER’S_ACCESS_TOKEN is obtained? Thanks.


#4

@SamJone73931958 You need to have the user auth with your app (via oAuth) to obtain that token.


#5

Thank you. I have authenticated my app. So SUBSCRIBING_USER’S_ACCESS_TOKEN is my access token? Where does the screen name of the user that I am subscribing to come in?


#6

You need the access token for any user account(s) you want to have subscribe to your webhook. This means that you must have the user(s) sign-in to your application via the Sign-in With Twitter authorisation flow.

You cannot subscribe arbitrary users to your webhook without their permission or authentication - that would be a privacy issue, as you’d start to receive all of their activity - including Direct Messages, follows, etc - in real time at your webhook. So, ultimately, the screen name of the user that you’d like to subscribe to does not matter, the users themselves need to sign-in to your app in order to grant you access to their activities.

Our Account Activity API Dashboard sample demonstrates the moving parts, if you’re into node.js code.