Trouble Accessing Data on Ads API (using PHP)



I’ve been trying to access data on a particular account that I have access to via the ADs API but keep getting either “UNAUTHORIZED ACCESS” or “ACTION_NOT_ALLOWED” error messages when I try to make certain calls.

Calls That I’ve Tried so far:
/accounts/ == Works as expected.
/accounts/XXXXXX/promoted_tweets == ACTION_NOT_ALLOWED
/stats/jobs/accounts/XXXXXX?entity=account == UNAUTHORIZED_ACCESS

I’m 99.9% sure I have the coding and auth settings correct because it’s working fine with this call:
…but not on any of the others listed.

The consumer key, secret, account id, etc are def all correct in the code. The only thing I can think of that I haven’t tried is that the access level of the authenticated user to get this info needs to be higher than an Analyst? Or do we need to regenerate all the keys and secrets again?

Just a little extra background:

  • I see the correct account id that I’m trying to access in the response from the “/accounts/” call.
  • The app information we’re using is from an approved one (for ads api) and our level of access is an Analyst.

Attached are screenshots of the response messages I’m seeing:


Hi @thomasdintrone, as you suspected you will need higher level of access for this account to be able to use the API to pull this data. Some info at the link below:


@joncipriano, thanks for the quick response. We upgraded our account and I’m now seeing new information but certain other calls I’m still getting the UNAUTHORIZED_ACCESS Error. Any thoughts?

Example Call:


Hi @thomasdintrone ,

I see you masked your Ads account ID on that screen shot. Providing your Ads account ID here (publicly) is totally safe. Could you tell us your Ads account ID so that we can get more insight for this issue?



Hi @jrsyo, ah ok I wasn’t sure so thought it was a safe bet to leave it out. The account ID is aefe1



Thanks. Please check this post:

Are you encoding your OAuth header strings?



I was able to figure this out using a different twitter library, which one your other developers created I believe (

I do have another question though. I was told that there is some organic tweet data available using the Ads API. Can you tell me, or guide me to the developer that created it on how to actually get the organic data from that library?

been trying to figure that part out but I’m hitting a brick wall at the moment. Thanks!


Hi @jrsyo, just wanted to make sure you saw my above comment. Thanks!

@AdsAPI @hector_borras


Hi @thomasdintrone How are you?

Making calls to organic tweet data is not currently available.

I’m working in a new version of the library with this option



@hector_borras Thanks appreciate your reply. There may not be built in functions in your library to get it but can you refer me to how I can get that organic info? We really needs this info and perhaps I can customize the library on my own to get it.

I was having trouble finding exactly how in the api docs online.


@thomasdintrone Hi, I’m sorry I missed this topic.

See above. POST stats/jobs/accounts/:account_id, that is.
You can specify entity= ORGANIC_TWEET in your request parameter. Please note that we normally recommend using asynchronous endpoints to avoid hitting our rate-limit restriction.


@jrsyo, No worries! Ok thanks, I’ll give this a try!


@jrsyo @hector_borras, Thanks again for your help. Ok I think I’m very close to getting this but it’s asking for “entity_ids” as a required parameter. Can you tell me wha those actually are and where do i get that info from?


Hi @thomasdintrone,

Here you haven an example of how do it with TWURL in a syncronous way (not recommended)

twurl -H "" "/4/stats/accounts/ACCOUNTID?entity=ORGANIC_TWEET&start_time=2018-12-13T23:00:00Z&end_time=2018-12-19T23:00:00Z&granularity=TOTAL&placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT&entity_ids=ENTITY_IDS"  |  jq .

Where ACCOUNTID is the id of your account and ENTITY_IDS are TWEET_IDS separated by commas

Hope this can help you.