Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack API team invitation

Tags:

slack-api

I am looking for a call which could send a Slack team invitation email to a new user from my application. I searched it in the SlackAPI but I didn't find anything. Is it possible to create an application which would sent invitations on my behalf?
I'm currently using slacker as a Python wrapper, but if there is any better library which provides invitations I can start using it.

like image 596
warownia1 Avatar asked Jun 20 '15 15:06

warownia1


People also ask

Does Slack support API calls?

You can integrate your calls with Slack so that they're more interactive, less intrusive, and easier for users to join. Your call app will appear in the Slack client natively, under the Call icon if you choose.

Is Slack API free?

Is the Slack API free? Yes. There are no charges to build apps that use the Slack API, and there are no Slack charges to install apps that use the Slack API.

How do I find team ID in Slack?

First, you can find your Team ID in the browser URL path once you open Slack in any browser. Open any web browser and log in to your Slack account. Next, go to your workspace main page and check the URL in the search bar at the top.


1 Answers

Invite new users via API

There is an undocumented method in the Slack API that allows you to programmatically invite new users to your Slack workspace:

  • method name: users.admin.invite
  • arguments: token, email, channels
  • token: your slack API "test" token (required)
  • email: email address, e.g. [email protected] (required)
  • channels: comma separated list of channels the new user will auto-join. channels are specified by ID. e.g. channels=C000000001,C000000002(optional)

full example:

https://slack.com/api/users.admin.invite?token=XXX&[email protected]&channels=C000000001,C000000002 

Note that this API method only works with legacy type tokens.

I started documenting the "undocumented" Slack API methods I know about including users.admin.invite. Check out the documentation on github.

Create new users via API

Alternatively there is an endpoint in the SCIM API to directly create new users:

POST /Users

However the SCIM API with all its endpoints is only available to Slack workspaces on the Plus plan or Enterprise Grid.

Important Update

Slack has decided to remove legacy tokens from their API. It will no longer be possible to create new legacy tokens as of May 5th, 2020 (Source). If you have a working legacy token you should be able to continue using the undocumented API methods, but new users will not. Please take this into consideration when deciding about using any of the methods from this repo in your apps.

like image 106
Erik Kalkoken Avatar answered Sep 29 '22 15:09

Erik Kalkoken