Updated June 1, 2015
API access to update this setting has been restricted to whitelist access only. If your app requires access, you can apply for “can_dm” access using this form. The setting can still be accessed by the user through their settings on twitter.com.
Today we’re updating the Direct Messages experience on the Twitter iPhone app, Android app and Twitter.com to enable users to create private conversations on Twitter more easily. More specifically, we are giving users the option to receive DMs from anyone, and to always be able to reply once a message is received.
We believe these features are useful for a variety of use cases. Journalists and newsrooms can open up a more private, direct relationship to their viewers and constituencies. Likewise, brands can offer their customers faster and more responsive support.
These changes will be reflected via the API, as well. When sending DMs, the API will simply respect the user’s setting of accept/don’t accept DMs from anyone.
A few specific behaviors in the API to note, for advanced developers:
The account settings object has an allow_dms_from field which
indicates who can DM a user, either in a private one-on-one thread or
in a group thread. Possible values include “following” (only users
you are following are allowed to DM you) and “all” (allow any user
on Twitter to DM you).
The API endpoint /account/settings.json allows the logged in user to
set the values for allow_dms_from. This endpoint returns the
current values as well. Editing this permission requires the “Read,
Write and Access direct messages” permission in you app. An example request and response are below.
To prevent DMs from a particular user, you must block that user. This
removes the user-to-user association on our side, preventing future
DMs. A following un-block will still respect the no-DM state.un-block
will still respect the no-DM state.
"name": "San Francisco",
"country": "United States",