Direct message to Twitter

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

To send a new Direct Message use POST directmessages/events/new (messagecreate).

Authorization to make this request to the Twitter API should look something like this under the Authorization tab in Qodex:

[oauth in Qodex](https://s3.amazonaws.com/Qodex-static-getQodex-com/Qodex-docs/twitterAuthQodex.png)

In this example, we're sending a Direct Message to ourselves, but we could also send it to our followers as a tweet using a different endpoint. Keep in mind this API is rate-limited if you're doing a lot of testing during development.

Read more about the Twitter API.

See the previous request to set up Twitter Oauth 1.0 in Qodex.

Request Body

{"event"=>{"type"=>"message_create", "message_create"=>{"target"=>{"recipient_id"=>"{{myTwitterId}}"}, "message_data"=>{"text"=>"{{recommendation}}"}}}}

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring

RESPONSES

status: OK

{"event":{"type":"message_create","id":"973361171934818308","created_timestamp":"1520902362222","message_create":{"target":{"recipient_id":"836103728"},"sender_id":"836103728","message_data":{"text":"You should try Sushirrito - Union Square at 226 Kearny St, San Francisco rated 4.3.","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]}}}}}