126

We are trying to setup deep linking into slack, as described here:

https://api.slack.com/docs/deep-linking

The document states that to open a specific team, the following URL should be used:

slack://open?team={TEAM_ID}

Open Slack and switch teams to the specified team. The provided TEAM_ID should be a string, like T12345.

Furthermore, to open a channel in a team, the following URL should be used:

slack://channel?team={TEAM_ID}&id={CHANNEL_ID}

Open the channel specified by the CHANNEL_ID provided in the id field, like C024BE91L. You must also specify the team with a TEAM_ID.

My question is simple. Where can I find out what TEAM_ID I need and what CHANNEL_ID I need?

lfboulanger
  • 1,720
  • 2
  • 15
  • 19
  • Depending on how you're doing it, you should be able to retrieve a POST with all of the info you need: https://api.slack.com/outgoing-webhooks for example – ntgCleaner Dec 02 '16 at 20:31
  • The accepted answer no longer works in 2019. Please consider changing the accepted answer to @SamuelDev response, which does work. https://stackoverflow.com/a/57246565/190298 – Nic Oct 10 '19 at 23:01
  • 1
    Thanks @Nic ! Just did it, sorry for the delay. – lfboulanger Jan 02 '20 at 16:12

10 Answers10

120

Here is the easiest way to manually find the slack IDs

1. Any channel ID

Open the slack webpage (http://yourteam.slack.com) and then simply open the channel. The channel ID is displayed in the browser URL:

get any channel ID


2. Any user ID

To find a user ID you need to open your browser dev-tools console and inspect the user-link in the sidebar. The user ID can be found in the HTML attribute "data-member-id":

get any user ID

Or in slack: (1) Click on the users name and choose (2) "Show Profile". Then open the "..." menu and you see the option (3) "Copy Member-ID ..." - to get your own user ID via the UI, you have to click the Team-Logo in top-left corner and then choose "Profile & Account" (this is not included in the screenshot)

get team members user ID


3. Team ID

Simply open the dev-tools of your browser, switch to the "Console" tab and enter the text boot_data.team_id into the console. This will display your team ID:

get the team ID

Philipp
  • 6,660
  • 5
  • 45
  • 54
  • 3
    Thanks @Paulin'tHout - somehow I confused team-ID with user-ID... I updated the answer to also describe how to quickly get the team ID – Philipp Oct 01 '17 at 11:41
  • 1
    For finding the channel ID and team ID, per the original question, this is definitely the quickest and easiest and should be the accepted answer. – gbe Apr 24 '18 at 14:41
  • 2
    looks like the url formats may have changed to https://app.slack.com/client///details/info – Ralph Callaway Nov 16 '19 at 06:31
  • Hey @Philipp, while this works! The slack developer tool makes this much easier. I would recommend checking my answer [here](https://stackoverflow.com/a/64098359/4047409) and consider including it in your answer, thanks in advance – realappie Feb 22 '21 at 12:29
77

Slightly different answer to the existing ones.

Whenever I wanted to just find out quickly what the relevant ids are for a specific team, I just opened the Slack web client and inspected the relevant elements. (Using Chrome Dev Tools)

https://my.slack.com/messages

The <a> tag that links to a user tends to include a data-member-id attribute, the content of which is the user id.

The same holds true for channels. If you inspect any of the channels in the sidebar, you can see they are ordered as <li> list elements each containing the channel id in the class name.

For the team id, you can open the entire source of the slack web client and CTRL-F for your team_domain (e.g. myslack55 for myslack55.slack.com) and that should find you the team id.

Basically, it's all hidden in plain sight. You just need to know where to look ;)

Wilhelm Klopp
  • 4,157
  • 2
  • 25
  • 32
  • Thanks! Thats the easiest method I have seen so far! – lfboulanger Dec 11 '16 at 17:07
  • the team_domain information is missing :( they might have removed it? – Carlo Dec 21 '16 at 13:39
  • @Carlo I still seem to be able to find it. What exactly are you attempting? :) – Wilhelm Klopp Dec 21 '16 at 15:45
  • Excellent suggestion! I found it hard to parse through all of the HTML elements, especially for the TEAM_ID, but looking at the XHR requests in Chrome Dev Tools found what I needed right away. Check the response from auth.currentSessions for the TEAM_ID and channels.info or pins.list for the CHANNEL_ID. – Nic Benders Jan 11 '17 at 07:25
  • 2
    Very smart solution. I don't see it, though. Navigated to `https://my.slack.com/messages` then Developer > Source (in Chrome). Search shows only this block: `// called by ssb when online var proceedToApp = function(last_team_domain_arg) { // do nothing, we're already in the app }` – mbb Jan 14 '17 at 17:30
  • Ahh sorry I didn't literally mean `team_domain`. I meant the `team_domain` that `my` resolves to in https://my.slack.com/messages – Wilhelm Klopp Jan 14 '17 at 17:44
  • 4
    Even following @WilhelmKlopp reply I had a hard time finding the team ID. For me the easiest way was: 1. search for `api_token` on the page source and copy that code 2. open this in the browser: `https://slack.com/api/auth.test?pretty=1&token=` 3. on the response copy `team_id` value – bsmaniotto Feb 26 '17 at 15:14
  • The above answer no longer works for determining Team ID. Use the answer from @Mbb instead. – Camden S. Apr 03 '17 at 19:51
  • Finding the team_id this way still works for me just FYI. All you need to know is your team_domain, which should be obvious. – Wilhelm Klopp Apr 03 '17 at 20:04
  • 11
    I found `team_id` searching for it in the page source. It was in an object called `boot_data`. – zackdever Jul 07 '17 at 19:42
  • Why is this data not more easily accessible on the website? This makes no sense to me – Amon Feb 14 '18 at 07:34
58

As of July 2019, it seems like the team id and the channel id is already being shown via the web.

enter image description here

As you can see in the screenshot, the 2nd to the last node is the team id (prefixed with "T") and the last node is the channel id (prefixed with "C"). All you have to do is open slack via the web, go to the specific channel, and you can see the url change to something close to the screenshot above.

SamuelDev
  • 812
  • 9
  • 13
  • 1
    This is the only approach that worked for me in 2019. – Nic Oct 10 '19 at 23:02
  • 10
    **NOTE**: you don't _really need_ to fire up the web UI -- just **Copy link** to any message in the public channel of interest in the your client app of choice -- and inspect the resultant URL – Anton K Feb 10 '20 at 14:29
  • 2
    @AntonK hmmm im not sure how to do that though. I tried that in my slack windows app (v4.2.0). I copied a link to one of the messages in one of our public channels, and the URL looked like this: `https://team.slack.com/archives/C########/p################`. I Can probably get the channel id, but not the team id. – SamuelDev Feb 11 '20 at 02:04
40

The answer marked correct here does not work for me, but I may have found an even easier way with test tokens.

  1. Create a test token: https://api.slack.com/docs/oauth-test-tokens

  2. Scroll down to the "try it now!" button. You land on auth.test: https://api.slack.com/methods/auth.test/test

  3. Choose the team you want to test and click Test Method. You can find your team_id (and user_id) there.

  4. Do the same for channels.list. You can click "View Another Method" and search or go to: https://api.slack.com/methods/channels.list/test

  5. Choose the team again and Test Method. Cmd+F through the channels object looking for whatever channel_ids you need.

Pang
  • 8,605
  • 144
  • 77
  • 113
mbb
  • 2,910
  • 1
  • 25
  • 27
28

As of 2017, it looks like slack made it easier to find.

Here is the easiest way to manually find the Team IDs.

Visit your slack room via a web browser. Right Click > "View Source"

And search for Team_id:

Pang
  • 8,605
  • 144
  • 77
  • 113
Rocky Kev
  • 374
  • 8
  • 10
11

You can also simply right-click on the slack channel (or direct message) in the desktop App and select the 'Copy Link' option.

This will give you a URL of the form: https://org.slack.com/messages/[channel-ID]

I attest this works on High Sierra Mac OSX - Slack 3.1.1

Joel
  • 151
  • 1
  • 7
10

The easiest way to get the team and channel id and is to add slack developer tool app to your slack, you can can it here.

After adding it all you simply need to do is go to any channel and choose this command

/sdt whoami

It will output a snippet like this one.

There are much more commands and other things you can perform with this slack app, I would highly recommend it if you're building any integrations for slack.

realappie
  • 3,453
  • 2
  • 22
  • 36
8

If you are using the Slack app you can simply right click on the channel name in the left menu and click Copy link, paste it somewhere and you will see the channel id.

Radu Ciobanu
  • 442
  • 5
  • 8
  • Just to add a little to this answer link will look like thishttps://netmediagroup.slack.com/archives/CHANNELID. This was the easiest for me I didn't want to install an app. Thanks – nzajt Feb 08 '21 at 21:49
3

Team ID

The easiest way to get your team ID is to use the Slack API method auth.test with your access token.

Channel ID

Depends on if you want a public or private channel you can call the respective Slack API method to get a list of all channels incl. their IDs.

Note that you can only see private channels in which the user/bot that belongs to your access token has been invited into.

Accesss Token

To get the access token you can either request a "test token" on the Slack API page under "Test Token" (only recommended for testing purposes by Slack). Or you can create a Slack app and install that app for your Slack team using Oath which will also generate an app specific access token.

Erik Kalkoken
  • 23,798
  • 6
  • 53
  • 81
  • 1
    It's lame that Slack doesn't provide a lookup channels by name method. Their FAQ just suggests itterating over the entire list of channels to find the one you want: See "How do I find a channel's ID if I only have its #name? " at https://api.slack.com/faq – Camden S. May 16 '17 at 13:19
  • @CamdenS.: You can now with the newly added interactive menu feature. Check out my corresponding answer: [Channel auto-complete](http://stackoverflow.com/questions/43813790/slack-channel-auto-complete-search-api/43821284#43821284) – Erik Kalkoken May 16 '17 at 15:37
0

If you've come here looking for how to access these values via the API for a specific user (like me!) using the @slack/bolt package - here's an example of how to do it.

Team ID & Channel ID & User ID

app.message('hello'),
  async ({ say, body, context, message }) => {
  const teamResponse: any = await app.client.team.info({
    token: context.botToken,
    user: message.id,
  });

  // An object containing the team data that Slack has stored
  const team: SlackGeneratedTeam = teamResponse.team;

  // User ID
  console.log(message.id)

  // Team ID
  console.log(team.id)

  // channel ID
  console.log(message.channel)
})