Search code examples
slack-apislack

Sharing image publicly from Slack channel


I have an outgoing webhook that listens to my public channel. When I post an image on the channel, I get a url for that image. However this url cannot be shared publicly since people need to be authenticated to view the message.

Is there any way I can generate a public link using the Slack API or is there no way around doing this manually?


Solution

  • Yes, that should be possible with the API.

    Here is what you need to do to get the public url for an image that was uploaded to a channel by a user:

    1. Get the id of the posted image file with files.list using the user_id and timestamp you received through the outgoing webhook from Slack

    2. Call files.sharedPublicURL to make the file public and receive a public url