Search code examples
slackslack-apihubot

Slack API file.upload to a user?


I'm trying to follow the tutorial found here https://api.slack.com/methods/files.upload .

curl -F [email protected] -F "initial_comment=I play the drums." -F channels=C024BE91L -F thread_ts=1532293503.000001 -H "Authorization: Bearer xoxp-xxxxxxxxx-xxxx" https://slack.com/api/files.upload

I'm able to upload files to a specific channel. However, how do I upload files to a user through direct message?


Solution

  • Similar to how sending direct messages work you can simply use the user ID for the channel and the file will be uploaded in a direct message channel between that user and the owner of the token.

    Alternatively you can first open a direct message channel from your app with im.open and then use the channel ID of that IM in files.upload.