Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

Slack API team invitation

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...