Twitter Direct Messages API v1.1 - 403 Forbidden

directmessages
api

#1

Regarding the following REST request:

POST https://api.twitter.com/1.1/direct_messages/new.json

I would like to provide an “actionable” error message back to users.

How does one differentiate between: Rate Limiting VS Permission/Blocking

Here are the 2 errors I am seeing frequently:

[Error 1]
HTTP/1.1 403 Forbidden
{“errors”:[{“code”:349,“message”:“You cannot send messages to this user.”}]}

[Error 2]
HTTP/1.1 403 Forbidden
{“errors”:[{“code”:151,“message”:“There was an error sending your message: You can’t send direct messages to this user right now.”}]}

How should I interpret these?

Guessing here:
Error 1 - Sounds like Permission?
Error 2 - The words “right now” alludes to Rate Limiting?


#2

Yes, I think that’s true. I’m actually not certain what circumstances that error would be returned in error code 151. 151 is a code that reflects several transient error states. There’s a possibility that it might be a limiting or temporary network error issue.


#3

Andy - Thank you for the quick response!

This issue appears to have impacted 4 different DM users from 11-23-2016 to 11-27-2016. That was near Thanksgiving, so maybe there were outages/network issues during that time as you said.

I could provide the REST response “x-transaction” IDs if that helps. Otherwise, I might just keep these classified as “system unavailable” (or the like) for our users.

Thanks again for your help!


#4

I cannot be more explicit in terms of those error codes so those existing situations are probably the current ones.