开发Twitter推文调度应用:如何获取所需account_id?
Hey there! Let me break down what the account_id is and how you can get it for your scheduled tweets app.
What is account_id in the Twitter Ads API?
The account_id is a unique numerical identifier tied to your Twitter Ads account (not your regular personal Twitter user account). Even if you're only scheduling organic (non-ad) tweets, this endpoint lives under the Ads API ecosystem, so you need to link your request to a valid Ads account ID.
How to retrieve your account_id
You have two reliable methods to get this ID:
1. Through the Twitter Ads Dashboard (UI)
- Log into your Twitter Ads dashboard
- Check the browser's address bar once you're logged in. It will look similar to this:
https://ads.twitter.com/accounts/123456789/campaigns - The numerical string right after
/accounts/is youraccount_id(in this example, it's123456789)
2. Programmatically via the Ads API
If you want to fetch it through code, make a GET request to the Accounts endpoint:
GET https://ads-api.twitter.com/2/accounts
You'll need to authenticate using valid OAuth credentials or a bearer token that's associated with your Twitter Ads account. The response will return a list of accounts linked to your authenticated user, and each entry will include an id field—that's your target account_id.
Quick note: If you don't have a Twitter Ads account yet, you can create one for free (even if you don't intend to run paid ads) to access this endpoint.
内容的提问来源于stack exchange,提问作者Aditya

