Slack.Web.Admin.Users (SlackKit v1.0.0-alpha.0)

View Source

Summary

Functions

Add an Enterprise user to a workspace.

Fetches the expiration timestamp for a guest

List users on a workspace

Remove a user from a workspace.

Set an existing regular user or owner to be a workspace or org admin.

Set an existing regular user or admin to be a workspace or org owner.

Set an existing guest user, admin user, or owner to be a regular user.

Functions

assign(team_id, user_id, optional_params \\ %{})

Add an Enterprise user to a workspace.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • team_id - The ID (T1234) of the workspace.
  • user_id - The ID of the user to add to the workspace.

Optional Params

  • channel_ids - Comma separated values of channel IDs to add user in the new workspace. ex: C123,C3456
  • is_restricted - True if user should be added to the workspace as a guest. ex: true
  • is_ultra_restricted - True if user should be added to the workspace as a single-channel guest. ex: true

Errors the API can return:

  • feature_not_enabled - The Admin APIs feature is not enabled for this team
  • invalid_role_for_user - The requested status is incompatible with the user's role on another workspace.
  • invited_user_not_created - The invited user could not be created.
  • invited_user_not_reactivated - The invited user could not be reactivated.
  • invitor_cannot_see_channel - The invitor is not part of one or many channels that the user was requested to be added to
  • not_an_admin - This method wasn't called by an admin.
  • team_not_found - `team_id was not found.
  • user_already_team_member - The given user is already active on the given team.
  • user_is_bot - The given user is a bot from an app. This api only works with humans.
  • user_not_found - user_id was not found.

See the Common Errors guide for errors returned by every Web API method.

get_expiration(optional_params \\ %{})

Fetches the expiration timestamp for a guest

API reference

Rate limit: Tier 4: 100+ per minute
Scopes:

View on docs.slack.dev ↗

Optional Params

  • target_team - If an org token is passed in and this team is on the org, it will operate on the workspace level on the specified team. Otherwise it will operate on the org or team in context. ex: T123ABC456
  • user_id - The ID of the guest user to get the expiration for. ex: U123ABC456

Errors the API can return:

  • no_perms - User does not have appropriate permissions.
  • not_permitted - This action is not permitted
  • paid_teams_only - This feature is only accessible to paid teams
  • target_team_not_on_org - Target team specified is not on the org in context
  • team_not_found - Team not found
  • user_is_not_guest - The user is not a guest
  • user_not_found - User not found

See the Common Errors guide for errors returned by every Web API method.

invite(channel_ids, email, team_id, optional_params \\ %{})

Invite a user to a workspace.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • channel_ids - A comma-separated list of channel_ids for this user to join. At least one channel is required. ex: C1A2B3C4D,C26Z25Y24
  • email - The email address of the person to invite. ex: joe@email.com
  • team_id - The ID (T1234) of the workspace.

Optional Params

  • custom_message - An optional message to send to the user in the invite email. ex: Come and join our team!
  • email_password_policy_enabled - Allow invited user to sign in via email and password. Only available for Enterprise org teams via admin invite. ex: true
  • guest_expiration_ts - Timestamp when guest account should be disabled. Only include this timestamp if you are inviting a guest user and you want their account to expire on a certain date. ex: 0123456789.012345
  • is_restricted - Is this user a multi-channel guest user? (default: false)
  • is_ultra_restricted - Is this user a single channel guest user? (default: false)
  • real_name - Full name of the user. ex: {"full_name":"Joe Smith"}
  • resend - Allow this invite to be resent in the future if a user has not signed up yet. Resending can only be done via the UI and has no expiration. (default: false) ex: true

Errors the API can return:

  • already_in_team - The user is already on the team.
  • already_in_team_invited_user - The user has already been invited to the team.
  • failed_looking_up_user - We couldn't find the requested user.
  • failed_to_send_invite - The invite failed to send.
  • failed_to_validate_caller - The token calling this method doesn't have permission to invite a user.
  • failed_to_validate_channels - channel_ids was invalid.
  • failed_to_validate_custom_message - extra_message was invalid.
  • failed_to_validate_expiration - expiration_ts was invalid.
  • failed_to_validate_team - The team calling this method was invalid.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • invalid_email - Email address was not valid.
  • not_an_admin - The user token does not have admin privileges.
  • team_not_found - team_id was not found.
  • user_disabled - The user is disabled.

See the Common Errors guide for errors returned by every Web API method.

list(optional_params \\ %{})

List users on a workspace

API reference

Rate limit: Tier 4: 100+ per minute
Scopes:

View on docs.slack.dev ↗

Optional Params

  • cursor - Set cursor to next_cursor returned by the previous call to list items in the next page. ex: 5c3e53d5
  • include_admins - If true, only admin users will be returned (excludes owners). Returns all admins and owners when combined with include_owners. Cannot be used together with only_guests.
  • include_deactivated_user_workspaces - Only applies with org token and no team_id. If true, return workspaces for a user even if they may be deactivated on them. If false, return workspaces for a user only when user is active on them. Default is false.
  • include_owners - If true, only owner users will be returned. Cannot be used together with only_guests.
  • is_active - If true, only active users will be returned. If false, only deactivated users will be returned. Default is true.
  • limit - Limit for how many users to be retrieved per page ex: 50
  • only_guests - If true, returns only guests and their expiration dates that belong to the team_id
  • team_id - The ID (T1234) of a workspace. Filters results to just the specified workspace.

Errors the API can return:

  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • include_deactivated_user_workspaces_invalid - include_deactivated_user_workspaces only applies with org token and no team_id.
  • invalid_cursor - The passed cursor could not be validated.
  • team_not_found - team_id was not found.

See the Common Errors guide for errors returned by every Web API method.

remove(team_id, user_id, optional_params \\ %{})

Remove a user from a workspace.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • team_id - The ID (T1234) of the workspace.
  • user_id - The ID of the user to remove. ex: W12345678

Errors the API can return:

  • cannot_modify_primary_owner - The primary owner cannot be modified.
  • failed_to_remove_user_from_workspace - Removing this user from the workspace failed.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • invalid_permissions - This method is only accessible by org owners and admins.
  • team_not_found - team_id was not found.
  • user_already_deleted - The requested user has already been marked as deleted.
  • user_not_found - The user was not found.

See the Common Errors guide for errors returned by every Web API method.

set_admin(team_id, user_id, optional_params \\ %{})

Set an existing regular user or owner to be a workspace or org admin.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • team_id - The ID of the workspace or organization. ex: T12345678
  • user_id - The ID of the user to designate as an admin. ex: W12345678

Errors the API can return:

  • cannot_modify_primary_owner - The primary owner cannot be modified.
  • failed_to_set_admin_on_workspaces - Failed to set the user as an admin on all workspaces.
  • failed_to_set_user_to_admin - Designating this user as an admin failed.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • invalid_permissions - This method is only accessible by org owners and admins.
  • invalid_role_for_user - The user cannot be made into an admin.
  • not_an_admin - This method can only be accessed by org owners and admins.
  • team_not_found - team_id was not found.
  • user_not_found - The user was not found.

See the Common Errors guide for errors returned by every Web API method.

set_expiration(expiration_ts, user_id, optional_params \\ %{})

Set an expiration for a guest user

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • expiration_ts - Epoch timestamp in seconds when guest account should be disabled. ex: 1234567890
  • user_id - The ID of the user to set an expiration for. ex: W12345678

Optional Params

  • team_id - The ID (T1234) of the workspace.

Errors the API can return:

  • failed_looking_up_user - We couldn't find the requested user.
  • failed_to_set_expiration - The expiration could not be set for the user.
  • failed_to_validate_caller - The token calling this method doesn't have permission to invite a user.
  • failed_to_validate_expiration - expiration_ts was invalid.
  • failed_to_validate_team - The team calling this method was invalid.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • team_id_required_for_enterprise - Team ID required.
  • team_not_found - team_id was not found.
  • user_is_already_deleted - The user has already been deleted and disabled.
  • user_is_deactivated - User has been deactivated.
  • user_is_not_a_guest - The passed user_id does not belong to a guest user.
  • user_not_found - The user could not be found.

See the Common Errors guide for errors returned by every Web API method.

set_owner(team_id, user_id, optional_params \\ %{})

Set an existing regular user or admin to be a workspace or org owner.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • team_id - The ID of the workspace or organization. ex: T12345678
  • user_id - ID of the user to promote to owner. ex: W12345678

Errors the API can return:

  • cannot_modify_primary_owner - The primary owner cannot be modified.
  • failed_to_set_owner_on_workspaces - Failed to set the user as an owner on all workspaces.
  • failed_to_set_user_to_owner - The change to the user's role failed.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • invalid_role_for_user - The user cannot be made into an owner.
  • not_an_admin - This method can only be accessed by org owners and admins.
  • not_an_owner - This method can only be accessed by org owners. The app's installing user must retain org owner status for this method to function.
  • not_supported - This is not a supported action.
  • team_not_found - team_id was not found.
  • user_must_be_in_workspace - This user must be a member of at least one workspace.
  • user_not_found - The requested user was not found.

See the Common Errors guide for errors returned by every Web API method.

set_regular(team_id, user_id, optional_params \\ %{})

Set an existing guest user, admin user, or owner to be a regular user.

API reference

Rate limit: Tier 2: 20+ per minute
Scopes:

View on docs.slack.dev ↗

Required Params

  • team_id - The ID of the workspace or organization. ex: T12345678
  • user_id - The ID of the user to designate as a regular user. ex: W12345678

Errors the API can return:

  • cannot_modify_primary_owner - The primary owner cannot be modified.
  • cannot_set_org_admin_to_regular_at_workspace_level - Org admins cannot be set to regular at the workspace level. Change their user type at the org level instead.
  • cannot_set_this_guest_to_regular_at_team_level - This guest cannot be set to regular because they are active on multiple workspaces.
  • failed_to_set_user_to_regular - Changing a user to a regular member failed.
  • feature_not_enabled - The Admin APIs feature is not enabled for this team.
  • not_an_admin - This method can only be accessed by org owners and admins.
  • team_not_found - team_id was not found.
  • user_not_found - The requested user was not found.

See the Common Errors guide for errors returned by every Web API method.