30-Day API via twurl



Greetings. I saw this thread:

…Which led me to believe twurl can work with the 30-day search API, per @ryanwi on Nov. 20th.

FWIW, I was able to use twurl for many other searches, no problems there.

I just tried, and I get:

Forbidden: Authentication succeeded but account is not authorized to access this resource.

I’m confident that my dev environment and app are set up correctly. I also tried a full authorize in twurl (twurl -t authorize -u myusername -p mypassword -c myAppsConsumerKey -s myAppsConsumerSecret. twurl responded with: Authorization successful, but I still get the error.

My twurl command: twurl -t -H "api.twitter.com" "/1.1/tweets/search/30day/:label.json?query=from:myTwitterHandle"


Hi there - you’ll first need to apply for access and be approved in order to access and use the premium 30-Day Search API. So while your creds may be valid, it seems that you do not have access for the API resource itself.

How to test proper account setup and endpoint access?

Thanks, @johnd. I did apply and I was granted access. I don’t think I could have set up a dev environment otherwise.

In my Account / Manage subscriptions, I see:
Search Tweets: 30-Days / Sandbox

Edit: To be clear, I’m referring to a different Twitter account than my personal account I’m using here for support.


Hi again,

One thing to confirm is that you are specifying the correct URL. If your dev environment has a “Sandbox” label (case-sensitive), then your search endpoint would be:



Thanks, @snowman. I just tried this in twurl:

twurl -t -H "api.twitter.com" "/1.1/tweets/search/30day/Sandbox.json?query=from:myaccountname"

Unfortunately, I get the same error:

{“error”:{“message”:“Forbidden: Authentication succeeded but account is not authorized to access this resource.”


30-day search uses app-only OAuth with bearer tokens, and twurl does not support that mode of operation (only 3-legged OAuth with user authentication). I’d suggest using curl or httpie to test this out. Check out the examples for curl and httpie in the documentation.

httpie format with GET query parameters:

http 'https://api.twitter.com/1.1/tweets/search/30day/development.json?maxResults=10&query=from:andypiper' 'Authorization:Bearer <your bearer token here>'


Thanks, @andypiper. I appreciate the understanding regarding twurl incompatibility with the Premium (30-Day Search) API, due to bearer tokens.

I will use Fiddler and report my results here.


Excellent, I’ll be curious to know how you get on - more example tools we can refer to will be useful.


The experience with twurl has been pretty inconsistent, so I may have overstated before. Some things do work though. I authorized with the same account that owns the premium search app.

$ twurl authorize --consumer-key [key from apps.twitter.com] --consumer-secret [secret from apps.twitter.com]
Go to https://api.twitter.com/oauth/authorize?oauth_consumer_key=.....&oauth_version=1.0 and paste in the supplied PIN
[go to url and paste pin]
Authorization successful

This fails

$ twurl /1.1/tweets/search/30day/dev.json?maxResults=10&query=from:andypiper
[1] 67656
Ryans-MacBook-Air:~ ryan$ {"error":{"message":"There were errors processing your request: Missing required parameter:'query', Missing required parameter:'query'","sent":"2018-01-11T05:01:29+00:00","transactionId":"00762a1a0018b3b1"}}

This works

$ twurl /1.1/tweets/search/30day/dev.json?query=from:andypiper&maxResults=10
  {"created_at":"Thu Jan 11 04:46:10 +0000 2018","id":951314265822126081,"id_str":"951314265822126081"},
  {"created_at":"Thu Jan 11 04:45:39 +0000 2018","id":951314138256592896,"id_str":"951314138256592896"},

Sounds like there are more consistent options with other tools, but thought I’d share anyway.


Thanks for sharing.


I can successfully query the 30day and fullarchive using C# and Tweetinvi. Of course, Fiddler makes it easy to see what’s happening over the wire.

I retried to get twurl to give me anything other than the originally reported error message (Forbidden: Authentication succeeded but account is not authorized to access this resource.), but that is all I get. Even @ryanwi’s query that worked for him (twurl /1.1/tweets/search/30day/dev.json?query=from:andypiper) gives me the auth error.

How to test proper account setup and endpoint access?

I’m facing the exact same problem as OP.
I’m using postman.
I’ve generated a bearer token and it seems to be fine, since I can query:


with that bearer token.

But when I try to call:


(where :product is replaced with 30day and :label with dev30days, by Postman)

I get the same error as the OP:

    "error": {
        "message": "Forbidden: Authentication succeeded but account is not authorized to access this resource.",
        "sent": "2018-02-24T04:37:13+00:00",
        "transactionId": "0082a21a00d16029"

I have the 30-day/Sandbox and the full archive/Sandbox setted up and I generated the bearer token with the associated twitter app to those environments.


Ah, it seems that Postman wasn’t replacing :label with dev30days in


:product was correctly replaced by 30day.

Watchout if you are using Postman

closed #14