Skip to content
pkg
slack

slack

Explore the following sections to learn more:

slack

import "github.com/gemini-oss/rego/pkg/slack"

pkg/slack/admin.go

pkg/slack/audit.go

pkg/slack/bot.go

pkg/slack/chat.go

pkg/slack/entities.go

pkg/slack/scim.go

pkg/slack/slack.go

pkg/slack/users.go

Index

Constants

const (
    // SCIMBaseURL is the base URL for Slack SCIM 2.0 API (separate from Web API)
    SCIMBaseURL = "https://api.slack.com/scim/v2"

    // SCIM User endpoints
    // https://docs.slack.dev/reference/scim-api/users
    SCIMUsers = "%s/Users" // https://docs.slack.dev/reference/scim-api/users
)

const (
    BaseURL      = "https://slack.com/api"          // https://slack.com/api/METHOD_FAMILY.method?pretty=1
    AuditBaseURL = "https://api.slack.com/audit/v1" // AuditBaseURL is the base URL for Slack Audit Logs API (separate from Web API)
)

Variables

var (
    // Admin User endpoints (Tier 2 - 20/min)
    // https://api.slack.com/methods#admin.users
    AdminUsersList       = fmt.Sprintf("%s/admin.users.list", BaseURL)
    AdminUsersAssign     = fmt.Sprintf("%s/admin.users.assign", BaseURL)
    AdminUsersInvite     = fmt.Sprintf("%s/admin.users.invite", BaseURL)
    AdminUsersRemove     = fmt.Sprintf("%s/admin.users.remove", BaseURL)
    AdminUsersSetAdmin   = fmt.Sprintf("%s/admin.users.setAdmin", BaseURL)
    AdminUsersSetOwner   = fmt.Sprintf("%s/admin.users.setOwner", BaseURL)
    AdminUsersSetRegular = fmt.Sprintf("%s/admin.users.setRegular", BaseURL)

    // Admin Session endpoints
    // https://api.slack.com/methods#admin.users.session
    AdminUsersSessionReset      = fmt.Sprintf("%s/admin.users.session.reset", BaseURL)
    AdminUsersSessionResetBulk  = fmt.Sprintf("%s/admin.users.session.resetBulk", BaseURL)
    AdminUsersSessionInvalidate = fmt.Sprintf("%s/admin.users.session.invalidate", BaseURL)
    AdminUsersSessionList       = fmt.Sprintf("%s/admin.users.session.list", BaseURL)

    // Admin Teams endpoints
    // https://api.slack.com/methods#admin.teams
    AdminTeams       = fmt.Sprintf("%s/admin.teams.list", BaseURL)
    AdminTeamsCreate = fmt.Sprintf("%s/admin.teams.create", BaseURL)
)

var (
    // Audit Logs endpoints (Tier 3 - 50/min, org-wide)
    // https://docs.slack.dev/reference/audit-logs-api/methods-actions-reference
    AuditLogs    = "%s/logs"    // GET https://api.slack.com/audit/v1/logs
    AuditSchemas = "%s/schemas" // GET https://api.slack.com/audit/v1/schemas
    AuditActions = "%s/actions" // GET https://api.slack.com/audit/v1/actions
)

var (
    // Chat endpoints (Special rate limits - 1 msg/sec per channel)
    // https://api.slack.com/methods#chat
    ChatPostMessage   = fmt.Sprintf("%s/chat.postMessage", BaseURL)
    ChatUpdate        = fmt.Sprintf("%s/chat.update", BaseURL)
    ChatDelete        = fmt.Sprintf("%s/chat.delete", BaseURL)
    ChatPostEphemeral = fmt.Sprintf("%s/chat.postEphemeral", BaseURL)
    ChatGetPermalink  = fmt.Sprintf("%s/chat.getPermalink", BaseURL)
)

var (
    // User endpoints (Tier 3 - 50/min)
    // https://api.slack.com/methods#users
    SlackUsers              = fmt.Sprintf("%s/users.list", BaseURL)
    SlackUsersInfo          = fmt.Sprintf("%s/users.info", BaseURL)
    SlackUsersLookupByEmail = fmt.Sprintf("%s/users.lookupByEmail", BaseURL)
    SlackUsersConversations = fmt.Sprintf("%s/users.conversations", BaseURL)
    SlackUsersSetPresence   = fmt.Sprintf("%s/users.setPresence", BaseURL)
)

# ErrorDetails is a map of error codes to error messages. - For errors that are not listed in the ErrorDetails map, you can refer to the source at https://api.slack.com/methods/chat.postMessage to understand the possible causes of the error.

var ErrorDetails = map[string]string{
    "as_user_not_supported":                    "The as_user parameter does not function with workspace apps.",
    "channel_not_found":                        "Value passed for channel was invalid.",
    "duplicate_channel_not_found":              "Channel associated with client_msg_id was invalid.",
    "duplicate_message_not_found":              "No duplicate message exists associated with client_msg_id.",
    "ekm_access_denied":                        "Administrators have suspended the ability to post a message.",
    "invalid_blocks":                           "Blocks submitted with this message are not valid",
    "invalid_blocks_format":                    "The blocks is not a valid JSON object or doesn't match the Block Kit syntax.",
    "invalid_metadata_format":                  "Invalid metadata format provided",
    "invalid_metadata_schema":                  "Invalid metadata schema provided",
    "is_archived":                              "Channel has been archived.",
    "message_limit_exceeded":                   "Members on this team are sending too many messages. For more details, see https://slack.com/help/articles/115002422943-Usage-limits-for-free-workspaces",
    "messages_tab_disabled":                    "Messages tab for the app is disabled.",
    "metadata_must_be_sent_from_app":           "Message metadata can only be posted or updated using an app token",
    "metadata_too_large":                       "Metadata exceeds size limit",
    "msg_too_long":                             "Message text is too long",
    "no_text":                                  "No message text provided",
    "not_in_channel":                           "Cannot post user messages to a channel they are not in.",
    "rate_limited":                             "Application has posted too many messages, read the Rate Limit documentation for more information",
    "restricted_action":                        "A workspace preference prevents the authenticated user from posting.",
    "restricted_action_non_threadable_channel": "Cannot post thread replies into a non_threadable channel.",
    "restricted_action_read_only_channel":      "Cannot post any message into a read-only channel.",
    "restricted_action_thread_locked":          "Cannot post replies to a thread that has been locked by admins.",
    "restricted_action_thread_only_channel":    "Cannot post top-level messages into a thread-only channel.",
    "slack_connect_canvas_sharing_blocked":     "Admin has disabled Canvas File sharing in all Slack Connect communications",
    "slack_connect_file_link_sharing_blocked":  "Admin has disabled Slack File sharing in all Slack Connect communications",
    "team_access_not_granted":                  "The token used is not granted the specific workspace access required to complete this request.",
    "too_many_attachments":                     "Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message.",
    "too_many_contact_cards":                   "Too many contact_cards were provided with this message. A maximum of 10 contact cards are allowed on a message.",
    "cannot_reply_to_message":                  "This message type cannot have thread replies.",
    "access_denied":                            "Access to a resource specified in the request is denied.",
    "account_inactive":                         "Authentication token is for a deleted user or workspace when using a bot token.",
    "deprecated_endpoint":                      "The endpoint has been deprecated.",
    "enterprise_is_restricted":                 "The method cannot be called from an Enterprise.",
    "invalid_auth":                             "Some aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.",
    "method_deprecated":                        "The method has been deprecated.",
    "missing_scope":                            "The token used is not granted the specific scope permissions required to complete this request.",
    "not_allowed_token_type":                   "The token type used in this request is not allowed.",
    "not_authed":                               "No authentication token provided.",
    "no_permission":                            "The workspace token used in this request does not have the permissions necessary to complete the request. Make sure your app is a member of the conversation it's attempting to post a message to.",
    "org_login_required":                       "The workspace is undergoing an enterprise migration and will not be available until migration is complete.",
    "token_expired":                            "Authentication token has expired",
    "token_revoked":                            "Authentication token is for a deleted user or workspace or the app has been removed when using a user token.",
    "two_factor_setup_required":                "Two factor setup is required.",
    "accesslimited":                            "Access to this method is limited on the current network",
    "fatal_error":                              "The server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.",
    "internal_error":                           "The server could not complete your operation(s) without encountering an error, likely due to a transient issue on our end. It's possible some aspect of the operation succeeded before the error was raised.",
    "invalid_arg_name":                         "The method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
    "invalid_arguments":                        "The method was either called with invalid arguments or some detail about the arguments passed is invalid, which is more likely when using complex arguments like blocks or attachments.",
    "invalid_array_arg":                        "The method was passed an array as an argument. Please only input valid strings.",
    "invalid_charset":                          "The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
    "invalid_form_data":                        "The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
    "invalid_post_type":                        "The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/json application/x-www-form-urlencoded multipart/form-data text/plain.",
    "missing_post_type":                        "The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
    "ratelimited":                              "The request has been ratelimited. Refer to the Retry-After header for when you may make your next request.",
    "request_timeout":                          "The method was called via a POST request, but the POST data was either missing or truncated.",
    "service_unavailable":                      "The service is temporarily unavailable",
    "team_added_to_org":                        "The workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
    "user_access_not_granted":                  "The user token used in this request does not have the permissions necessary to complete the request.",
}

var WarningDetails = map[string]string{
    "message_truncated":   "The text field of a message should have no more than 40,000 characters. We truncate really long messages.",
    "missing_charset":     "The method was called via a POST request, and recommended practice for the specified Content-Type is to include a charset parameter. However, no charset was present. Specifically, non-form-data content types (e.g. text/plain) are the ones for which charset is recommended.",
    "superfluous_charset": "The method was called via a POST request, and the specified Content-Type is not defined to understand the charset parameter. However, charset was in fact present. Specifically, form-data content types (e.g. multipart/form-data) are the ones for which charset is superfluous.",
}

type AdminClient

AdminClient for Enterprise Grid admin operations

type AdminClient struct {
    *Client
}

func (*AdminClient) ListActiveUsers

func (c *AdminClient) ListActiveUsers(teamID string) (*AdminUsers, error)

* # List active users only in an Enterprise Grid organization

func (*AdminClient) ListAllUsers

func (c *AdminClient) ListAllUsers(teamID string) (*AdminUsers, error)

* # List all users in an Enterprise Grid organization

func (*AdminClient) ResetUserSession

func (c *AdminClient) ResetUserSession(userID string, opts ...SessionResetOption) error

* # Reset a single user’s sessions

func (*AdminClient) ResetUserSessionsBulk

func (c *AdminClient) ResetUserSessionsBulk(userIDs []string, opts ...SessionResetOption) error

* # Reset sessions for multiple users in bulk

type AdminUser

AdminUser from Enterprise Grid API https://api.slack.com/methods/admin.users.list

type AdminUser struct {
    ID                string   `json:"id"`                      // User ID
    Email             string   `json:"email"`                   // User email
    IsAdmin           bool     `json:"is_admin"`                // Whether user is admin
    IsOwner           bool     `json:"is_owner"`                // Whether user is owner
    IsPrimaryOwner    bool     `json:"is_primary_owner"`        // Whether user is primary owner
    IsRestricted      bool     `json:"is_restricted"`           // Whether user is a guest
    IsUltraRestricted bool     `json:"is_ultra_restricted"`     // Whether user is a single-channel guest
    IsBot             bool     `json:"is_bot"`                  // Whether user is a bot
    IsActive          bool     `json:"is_active"`               // Whether user is active
    Username          string   `json:"username"`                // User's username
    FullName          string   `json:"full_name,omitempty"`     // User's full name
    DateCreated       int64    `json:"date_created,omitempty"`  // Account creation timestamp
    ExpirationTS      int64    `json:"expiration_ts,omitempty"` // Guest expiration timestamp
    HasFiles          bool     `json:"has_files,omitempty"`     // Whether user has files
    Has2FA            bool     `json:"has_2fa,omitempty"`       // Whether user has 2FA enabled
    Workspaces        []string `json:"workspaces,omitempty"`    // Workspaces user belongs to
}

type AdminUserQuery

AdminUserQuery for admin.users.list https://api.slack.com/methods/admin.users.list

type AdminUserQuery struct {
    Cursor                           string `json:"cursor,omitempty" url:"cursor,omitempty"`                                                           // Pagination cursor
    IsActive                         *bool  `json:"is_active,omitempty" url:"is_active,omitempty"`                                                     // Filter by active status
    Limit                            int    `json:"limit,omitempty" url:"limit,omitempty"`                                                             // Max 1000, default 100
    TeamID                           string `json:"team_id,omitempty" url:"team_id,omitempty"`                                                         // Required: Workspace ID
    IncludeDeactivatedUserWorkspaces bool   `json:"include_deactivated_user_workspaces,omitempty" url:"include_deactivated_user_workspaces,omitempty"` // Include deactivated
}

func (*AdminUserQuery) SetCursor

func (q *AdminUserQuery) SetCursor(cursor string)

type AdminUsers

### Slack Admin Structs (Enterprise Grid) --------------------------------------------------------------------- AdminUsers from admin.users.list https://api.slack.com/methods/admin.users.list

type AdminUsers struct {
    OK               bool             `json:"ok"`
    Users            []*AdminUser     `json:"users,omitempty"`
    ResponseMetadata ResponseMetadata `json:"response_metadata,omitzero"`
    Error            string           `json:"error,omitempty"`
}

func (AdminUsers) Append

func (a AdminUsers) Append(other AdminUsers) AdminUsers

Implement SlackAPIResponse interface for AdminUsers

func (AdminUsers) NextCursor

func (a AdminUsers) NextCursor() string

type AuditAccountTypeRole

AuditAccountTypeRole represents an account type role in audit log events

type AuditAccountTypeRole struct {
    ID   string `json:"id,omitempty"`   // Account type role ID
    Name string `json:"name,omitempty"` // Account type role name
}

type AuditActionsResponse

AuditActionsResponse represents the response from the audit/v1/actions endpoint

type AuditActionsResponse struct {
    Actions map[string][]string `json:"actions,omitempty"` // Actions grouped by category
}

type AuditActor

AuditActor represents the user who performed an audit action

type AuditActor struct {
    Type string     `json:"type,omitempty"` // Always "user"
    User *AuditUser `json:"user,omitempty"` // User details
}

type AuditApp

AuditApp represents an app in audit log events

type AuditApp struct {
    ID                  string   `json:"id,omitempty"`                    // App ID
    Name                string   `json:"name,omitempty"`                  // App name
    IsDistributed       bool     `json:"is_distributed,omitempty"`        // Whether the app is distributed
    IsDirectoryApproved bool     `json:"is_directory_approved,omitempty"` // Whether the app is directory-approved
    IsWorkflowApp       bool     `json:"is_workflow_app,omitempty"`       // Whether this is a workflow app
    Scopes              []string `json:"scopes,omitempty"`                // OAuth scopes
}

type AuditChannel

AuditChannel represents a channel in audit log events

type AuditChannel struct {
    ID                         string   `json:"id,omitempty"`                            // Channel ID
    Privacy                    string   `json:"privacy,omitempty"`                       // Channel privacy (public, private)
    Name                       string   `json:"name,omitempty"`                          // Channel name
    IsShared                   bool     `json:"is_shared,omitempty"`                     // Whether the channel is shared
    IsOrgShared                bool     `json:"is_org_shared,omitempty"`                 // Whether the channel is org-shared
    TeamsSharedWith            []string `json:"teams_shared_with,omitempty"`             // Teams shared with
    OriginalConnectedChannelID string   `json:"original_connected_channel_id,omitempty"` // Original connected channel ID
    IsSalesforceChannel        bool     `json:"is_salesforce_channel,omitempty"`         // Whether this is a Salesforce channel
}

type AuditClient

AuditClient for Audit Logs API operations (organization-wide audit trail)

type AuditClient struct {
    *Client
    AuditBaseURL string
}

func (*AuditClient) BuildURL

func (c *AuditClient) BuildURL(endpoint string, identifiers ...interface{}) string

BuildURL builds a URL for a given Audit Logs resource and identifiers.

func (*AuditClient) FindByUserAgent

func (c *AuditClient) FindByUserAgent(pattern string, oldest, latest int64) (*AuditLogsResponse, error)

* # Search audit log events by user agent substring

  • GET /audit/v1/logs
  • - https://docs.slack.dev/reference/audit-logs-api/methods-actions-reference *
  • Retrieves all audit events within the time range, then filters client-side
  • for entries where the context user agent contains the given pattern (case-insensitive). *
  • Example: Find all actions performed from an iPad on February 5th, 2026: *
  • start := time.Date(2026, time.February, 5, 0, 0, 0, 0, time.UTC)
  • end := time.Date(2026, time.February, 5, 23, 59, 59, 0, time.UTC)
  • logs, err := client.Audit().FindByUserAgent(“iPad”, start.Unix(), end.Unix())

func (*AuditClient) FindEmojiByName

func (c *AuditClient) FindEmojiByName(name string, oldest, latest int64) (*AuditLogsResponse, error)

* # Search for a specific emoji by name in audit logs

  • GET /audit/v1/logs?action=emoji_added,emoji_removed
  • - https://docs.slack.dev/reference/audit-logs-api/methods-actions-reference *
  • Retrieves all emoji_added and emoji_removed events within the time range,
  • then filters client-side for entries matching the given emoji name.
  • The Audit Logs API does not support server-side filtering by details.name. *
  • The name should be the emoji shortcode without colons (e.g., “american_flag” not “:american_flag:”). *
  • Example: Find who added/removed :american_flag: on February 5th, 2026: *
  • start := time.Date(2026, time.February, 5, 0, 0, 0, 0, time.UTC)
  • end := time.Date(2026, time.February, 5, 23, 59, 59, 0, time.UTC)
  • logs, err := client.Audit().FindEmojiByName(“american_flag”, start.Unix(), end.Unix())

func (*AuditClient) GetActions

func (c *AuditClient) GetActions() (*AuditActionsResponse, error)

* # List available audit log actions

func (*AuditClient) GetAllLogs

func (c *AuditClient) GetAllLogs(query *AuditQuery) (*AuditLogsResponse, error)

* # Retrieve all audit log events with automatic cursor-based pagination

func (*AuditClient) GetEmojiChanges

func (c *AuditClient) GetEmojiChanges(oldest, latest int64) (*AuditLogsResponse, error)

* # Retrieve emoji change events within a time range

  • GET /audit/v1/logs?action=emoji_added,emoji_removed
  • - https://docs.slack.dev/reference/audit-logs-api/methods-actions-reference *
  • Returns all emoji_added and emoji_removed audit events between the given
  • Unix timestamps. Automatically paginates through all matching results. *
  • Example: Get emoji changes on February 5th, 2026: *
  • start := time.Date(2026, time.February, 5, 0, 0, 0, 0, time.UTC)
  • end := time.Date(2026, time.February, 5, 23, 59, 59, 0, time.UTC)
  • logs, err := client.Audit().GetEmojiChanges(start.Unix(), end.Unix())

func (*AuditClient) GetLogs

func (c *AuditClient) GetLogs(query *AuditQuery) (*AuditLogsResponse, error)

* # Retrieve audit log events with optional filtering

func (*AuditClient) GetSchemas

func (c *AuditClient) GetSchemas() (*AuditSchemasResponse, error)

* # List available audit log schemas

type AuditContext

AuditContext represents the location and environment where an audit action occurred

type AuditContext struct {
    Location  *AuditLocation `json:"location,omitempty"`   // Workspace or enterprise where the action occurred
    UA        string         `json:"ua,omitempty"`         // User agent string
    IPAddress string         `json:"ip_address,omitempty"` // IP address of the actor
    SessionID int64          `json:"session_id,omitempty"` // Session identifier
    App       *AuditApp      `json:"app,omitempty"`        // App details if action was performed via an app
}

type AuditConversationPref

AuditConversationPref represents a conversation preference in audit details

type AuditConversationPref struct {
    Type []string `json:"type,omitempty"` // Preference types
    User []string `json:"user,omitempty"` // User IDs
}

type AuditDetails

AuditDetails contains additional event-specific information Fields are populated based on the action type; most will be empty for any given event

type AuditDetails struct {
    // Value changes
    Name          string `json:"name,omitempty"`           // Name associated with the event
    NewValue      string `json:"new_value,omitempty"`      // New value after the change
    PreviousValue string `json:"previous_value,omitempty"` // Previous value before the change

    // Session/Access
    ExpiresOn  int64 `json:"expires_on,omitempty"`  // Expiration timestamp
    MobileOnly bool  `json:"mobile_only,omitempty"` // Whether action applies to mobile only
    WebOnly    bool  `json:"web_only,omitempty"`    // Whether action applies to web only

    // Type/Classification
    Type       string `json:"type,omitempty"`        // Type of the detail
    IsWorkflow bool   `json:"is_workflow,omitempty"` // Whether related to a workflow

    // User references
    Inviter      *AuditUser `json:"inviter,omitempty"`        // User who sent the invitation
    Kicker       *AuditUser `json:"kicker,omitempty"`         // User who kicked another user
    TargetUser   string     `json:"target_user,omitempty"`    // Target user ID
    TargetUserID string     `json:"target_user_id,omitempty"` // Target user ID (alternate field)

    // Sharing/Collaboration
    SharedTo        string               `json:"shared_to,omitempty"`        // Where something was shared to
    Reason          generics.StringSlice `json:"reason,omitempty"`           // Reason for the action (string or array depending on action type)
    OriginTeam      string               `json:"origin_team,omitempty"`      // Origin team ID
    TargetTeam      string               `json:"target_team,omitempty"`      // Target team ID
    SourceTeam      string               `json:"source_team,omitempty"`      // Source team ID
    DestinationTeam string               `json:"destination_team,omitempty"` // Destination team ID

    // App/Scope changes
    AppOwnerID     string   `json:"app_owner_id,omitempty"`    // App owner's user ID
    AppID          string   `json:"app_id,omitempty"`          // App ID
    BotScopes      []string `json:"bot_scopes,omitempty"`      // Bot token scopes
    NewScopes      []string `json:"new_scopes,omitempty"`      // Newly granted scopes
    PreviousScopes []string `json:"previous_scopes,omitempty"` // Previously granted scopes
    Scopes         []string `json:"scopes,omitempty"`          // Current scopes

    // Channel/Conversation
    Channels   []string               `json:"channels,omitempty"`     // Affected channel IDs
    ChannelID  string                 `json:"channel_id,omitempty"`   // Channel ID
    WhoCanPost *AuditConversationPref `json:"who_can_post,omitempty"` // Who can post preference
    CanThread  *AuditConversationPref `json:"can_thread,omitempty"`   // Thread preference

    // Permissions
    Permissions        []string `json:"permissions,omitempty"`         // Permissions involved
    ChangedPermissions []string `json:"changed_permissions,omitempty"` // Changed permissions
    Resolution         string   `json:"resolution,omitempty"`          // Resolution of the action

    // Feature toggles
    EnableAtHere    *AuditFeatureEnable `json:"enable_at_here,omitempty"`    // @here enablement
    EnableAtChannel *AuditFeatureEnable `json:"enable_at_channel,omitempty"` // @channel enablement
    CanHuddle       *AuditFeatureEnable `json:"can_huddle,omitempty"`        // Huddle enablement

    // Retention policies
    OldRetentionPolicy *AuditRetentionPolicy `json:"old_retention_policy,omitempty"` // Previous retention policy
    NewRetentionPolicy *AuditRetentionPolicy `json:"new_retention_policy,omitempty"` // New retention policy

    // Profile changes
    PreviousProfile *AuditProfile `json:"previous_profile,omitempty"` // Previous profile
    NewProfile      *AuditProfile `json:"new_profile,omitempty"`      // New profile

    // External/Slack Connect
    ExternalOrgID     string `json:"external_organization_id,omitempty"` // External organization ID
    ExternalUserID    string `json:"external_user_id,omitempty"`         // External user ID
    ExternalUserEmail string `json:"external_user_email,omitempty"`      // External user email

    // Misc references
    Trigger              string      `json:"trigger,omitempty"`                // Trigger for the action
    ExportType           string      `json:"export_type,omitempty"`            // Type of export
    Duration             int64       `json:"duration,omitempty"`               // Duration of the action
    InviteID             string      `json:"invite_id,omitempty"`              // Invitation ID
    AddedTeamID          string      `json:"added_team_id,omitempty"`          // Added team ID
    URLPrivate           string      `json:"url_private,omitempty"`            // Private URL
    SucceededUsers       []string    `json:"succeeded_users,omitempty"`        // Users that succeeded
    FailedUsers          []string    `json:"failed_users,omitempty"`           // Users that failed
    Enterprise           string      `json:"enterprise,omitempty"`             // Enterprise ID
    Subteam              string      `json:"subteam,omitempty"`                // Subteam ID
    Action               string      `json:"action,omitempty"`                 // Sub-action
    IDPGroupMemberCount  int         `json:"idp_group_member_count,omitempty"` // IDP group member count
    WorkspaceMemberCount int         `json:"workspace_member_count,omitempty"` // Workspace member count
    IDPConfigID          interface{} `json:"idp_config_id,omitempty"`          // IDP config ID (number or string depending on action)
    ConfigType           string      `json:"config_type,omitempty"`            // Config type
    Label                string      `json:"label,omitempty"`                  // Label
    SpaceFileID          string      `json:"space_file_id,omitempty"`          // Space file ID
    TargetEntity         string      `json:"target_entity,omitempty"`          // Target entity
    TargetEntityID       string      `json:"target_entity_id,omitempty"`       // Target entity ID
    DatastoreName        string      `json:"datastore_name,omitempty"`         // Datastore name
    EntityType           string      `json:"entity_type,omitempty"`            // Entity type
    AccessLevel          string      `json:"access_level,omitempty"`           // Access level
    IsChannelCanvas      bool        `json:"is_channel_canvas,omitempty"`      // Whether this is a channel canvas
    LinkedChannelID      string      `json:"linked_channel_id,omitempty"`      // Linked channel ID
}

type AuditEntity

AuditEntity represents the target of an audit action The populated sub-field corresponds to the Type value

type AuditEntity struct {
    Type            string                   `json:"type,omitempty"`              // Entity type (user, channel, file, app, workspace, enterprise, message, huddle, barrier, role, account_type_role, workflow, workflow_v2, usergroup, list)
    User            *AuditUser               `json:"user,omitempty"`              // User entity
    Workspace       *AuditLocation           `json:"workspace,omitempty"`         // Workspace entity
    Enterprise      *AuditLocation           `json:"enterprise,omitempty"`        // Enterprise entity
    Channel         *AuditChannel            `json:"channel,omitempty"`           // Channel entity
    File            *AuditFile               `json:"file,omitempty"`              // File entity
    App             *AuditApp                `json:"app,omitempty"`               // App entity
    Message         *AuditMessage            `json:"message,omitempty"`           // Message entity
    Huddle          *AuditHuddle             `json:"huddle,omitempty"`            // Huddle entity
    Role            *AuditRole               `json:"role,omitempty"`              // Role entity
    Usergroup       *AuditUsergroup          `json:"usergroup,omitempty"`         // User group entity
    Workflow        *AuditWorkflow           `json:"workflow,omitempty"`          // Workflow entity
    Barrier         *AuditInformationBarrier `json:"barrier,omitempty"`           // Information barrier entity
    WorkflowV2      *AuditWorkflowV2         `json:"workflow_v2,omitempty"`       // Workflow v2 entity
    AccountTypeRole *AuditAccountTypeRole    `json:"account_type_role,omitempty"` // Account type role entity
    List            *AuditSlackList          `json:"list,omitempty"`              // Slack list entity
}

type AuditEntry

AuditEntry represents a single audit log event Every event is composed of an actor taking an action on an entity within a context

type AuditEntry struct {
    ID         string        `json:"id,omitempty"`          // Unique identifier for the audit event
    DateCreate int64         `json:"date_create,omitempty"` // Unix timestamp of when the event occurred
    Action     string        `json:"action,omitempty"`      // The action that was performed (e.g., "user_login", "emoji_added")
    Actor      AuditActor    `json:"actor,omitzero"`        // The user who performed the action
    Entity     AuditEntity   `json:"entity,omitzero"`       // The object acted upon
    Context    AuditContext  `json:"context,omitzero"`      // The location where the action took place
    Details    *AuditDetails `json:"details,omitempty"`     // Additional event-specific details
}

type AuditFeatureEnable

AuditFeatureEnable represents a feature enablement toggle in audit details

type AuditFeatureEnable struct {
    Enabled bool `json:"enabled,omitempty"` // Whether the feature is enabled
}

type AuditFile

AuditFile represents a file in audit log events

type AuditFile struct {
    ID       string `json:"id,omitempty"`       // File ID
    Name     string `json:"name,omitempty"`     // File name
    Filetype string `json:"filetype,omitempty"` // File type
    Title    string `json:"title,omitempty"`    // File title
}

type AuditHuddle

AuditHuddle represents a huddle in audit log events

type AuditHuddle struct {
    ID           string   `json:"id,omitempty"`           // Huddle ID
    DateStart    int64    `json:"date_start,omitempty"`   // Start timestamp
    DateEnd      int64    `json:"date_end,omitempty"`     // End timestamp
    Participants []string `json:"participants,omitempty"` // Participant user IDs
}

type AuditInformationBarrier

AuditInformationBarrier represents an information barrier in audit log events

type AuditInformationBarrier struct {
    ID                      string   `json:"id,omitempty"`                        // Barrier ID
    PrimaryUsergroup        string   `json:"primary_usergroup,omitempty"`         // Primary user group
    BarrieredFromUsergroups []string `json:"barriered_from_usergroups,omitempty"` // Barriered from user groups
    RestrictedSubjects      []string `json:"restricted_subjects,omitempty"`       // Restricted subjects
}

type AuditLocation

AuditLocation represents a workspace or enterprise in audit logs

type AuditLocation struct {
    Type   string `json:"type,omitempty"`   // "workspace" or "enterprise"
    ID     string `json:"id,omitempty"`     // Workspace/enterprise ID
    Name   string `json:"name,omitempty"`   // Workspace/enterprise name
    Domain string `json:"domain,omitempty"` // Workspace/enterprise domain
}

type AuditLogsResponse

AuditLogsResponse represents the response from the audit/v1/logs endpoint https://docs.slack.dev/admins/audit-logs-api/

type AuditLogsResponse struct {
    Entries          []AuditEntry     `json:"entries,omitempty"`          // Audit log entries
    ResponseMetadata ResponseMetadata `json:"response_metadata,omitzero"` // Pagination cursor
}

func (AuditLogsResponse) Append

func (a AuditLogsResponse) Append(other AuditLogsResponse) AuditLogsResponse

Implement SlackAPIResponse interface for AuditLogsResponse

func (AuditLogsResponse) NextCursor

func (a AuditLogsResponse) NextCursor() string

type AuditMessage

AuditMessage represents a message in audit log events

type AuditMessage struct {
    Channel   string `json:"channel,omitempty"`   // Channel ID
    Team      string `json:"team,omitempty"`      // Team ID
    Timestamp string `json:"timestamp,omitempty"` // Message timestamp
}

type AuditProfile

AuditProfile represents a user profile snapshot in audit details

type AuditProfile struct {
    RealName    string `json:"real_name,omitempty"`    // Real name
    FirstName   string `json:"first_name,omitempty"`   // First name
    LastName    string `json:"last_name,omitempty"`    // Last name
    DisplayName string `json:"display_name,omitempty"` // Display name
}

type AuditQuery

AuditQuery for GET /audit/v1/logs https://docs.slack.dev/reference/audit-logs-api/methods-actions-reference All filters are optional and combined with AND logic

type AuditQuery struct {
    Latest int64  `url:"latest,omitempty"` // Unix timestamp (inclusive) for most recent event
    Oldest int64  `url:"oldest,omitempty"` // Unix timestamp (inclusive) for oldest event
    Limit  int    `url:"limit,omitempty"`  // Results to return, maximum 9,999
    Action string `url:"action,omitempty"` // Action name(s), comma-separated (max 30)
    Actor  string `url:"actor,omitempty"`  // User ID who initiated the action
    Entity string `url:"entity,omitempty"` // Target entity ID (channel, workspace, file, etc.)
    Cursor string `url:"cursor,omitempty"` // Pagination cursor from response_metadata.next_cursor
}

func (*AuditQuery) SetCursor

func (q *AuditQuery) SetCursor(cursor string)

type AuditRetentionPolicy

AuditRetentionPolicy represents a retention policy in audit details

type AuditRetentionPolicy struct {
    Type         string `json:"type,omitempty"`          // Retention policy type
    DurationDays int    `json:"duration_days,omitempty"` // Duration in days
}

type AuditRole

AuditRole represents a role in audit log events

type AuditRole struct {
    ID   string `json:"id,omitempty"`   // Role ID
    Name string `json:"name,omitempty"` // Role name
    Type string `json:"type,omitempty"` // Role type
}

type AuditSchema

AuditSchema represents a schema definition for an entity type

type AuditSchema struct {
    Type       string      `json:"type,omitempty"`       // Entity type name
    Workspace  interface{} `json:"workspace,omitempty"`  // Workspace schema fields
    Enterprise interface{} `json:"enterprise,omitempty"` // Enterprise schema fields
}

type AuditSchemasResponse

AuditSchemasResponse represents the response from the audit/v1/schemas endpoint

type AuditSchemasResponse struct {
    Schemas []AuditSchema `json:"schemas,omitempty"` // Schema definitions
}

type AuditSlackList

AuditSlackList represents a Slack list in audit log events

type AuditSlackList struct {
    ID string `json:"id,omitempty"` // List ID
}

type AuditUser

AuditUser represents a user in audit log events

type AuditUser struct {
    ID    string `json:"id,omitempty"`    // User ID (e.g., W123AB456)
    Name  string `json:"name,omitempty"`  // User's display name
    Email string `json:"email,omitempty"` // User's email address
    Team  string `json:"team,omitempty"`  // Team/workspace ID
}

type AuditUsergroup

AuditUsergroup represents a user group in audit log events

type AuditUsergroup struct {
    ID   string `json:"id,omitempty"`   // User group ID
    Name string `json:"name,omitempty"` // User group name
}

type AuditWorkflow

AuditWorkflow represents a workflow in audit log events

type AuditWorkflow struct {
    ID     string `json:"id,omitempty"`     // Workflow ID
    Name   string `json:"name,omitempty"`   // Workflow name
    Domain string `json:"domain,omitempty"` // Workflow domain
}

type AuditWorkflowV2

AuditWorkflowV2 represents a workflow v2 in audit log events

type AuditWorkflowV2 struct {
    ID          string `json:"id,omitempty"`           // Workflow ID
    AppID       string `json:"app_id,omitempty"`       // Associated app ID
    DateUpdated int64  `json:"date_updated,omitempty"` // Last updated timestamp
    CallbackID  string `json:"callback_id,omitempty"`  // Callback ID
    Name        string `json:"name,omitempty"`         // Workflow name
    UpdatedBy   string `json:"updated_by,omitempty"`   // User who last updated
}

type Authorization

type Authorization struct {
    EnterpriseID        interface{} `json:"enterprise_id,omitempty"`         // ID of the enterprise (undefined, will revisit later)
    TeamID              string      `json:"team_id,omitempty"`               // ID of the team/workspace
    UserID              string      `json:"user_id,omitempty"`               // ID of the user or bot user in the workspace
    IsBot               bool        `json:"is_bot,omitempty"`                // Indicates whether this is a bot user
    IsEnterpriseInstall bool        `json:"is_enterprise_install,omitempty"` // Indicates whether this app was installed in an entire enterprise org
}

type Block

type Block struct {
    Type     string    `json:"type,omitempty"`     // Type of the block, here it's rich_text
    BlockID  string    `json:"block_id,omitempty"` // ID of the block
    Elements []Element `json:"elements,omitzero"`  // Elements in the block
}

type Channel

Channel represents the information about a channel in the Slack ‘users.conversations’ method.

type Channel struct {
    Created            int64         `json:"created"`                   // Channel creation timestamp.
    Creator            string        `json:"creator"`                   // User ID of the channel's creator.
    ID                 string        `json:"id"`                        // Channel ID.
    IsArchived         bool          `json:"is_archived"`               // Indicates if the channel is archived.
    IsChannel          bool          `json:"is_channel"`                // Indicates if the object is a channel.
    IsExtShared        bool          `json:"is_ext_shared"`             // Indicates if the channel is externally shared.
    IsGeneral          bool          `json:"is_general"`                // Indicates if the channel is a general channel.
    IsGroup            bool          `json:"is_group"`                  // Indicates if the object is a group.
    IsIM               bool          `json:"is_im"`                     // Indicates if the object is an instant message.
    IsMPIM             bool          `json:"is_mpim"`                   // Indicates if the object is a multi-party instant message.
    IsOpen             bool          `json:"is_open,omitempty"`         // Indicates if the channel is open. Only applicable for certain channel types.
    IsOrgShared        bool          `json:"is_org_shared"`             // Indicates if the channel is organizationally shared.
    IsPendingExtShared bool          `json:"is_pending_ext_shared"`     // Indicates if the channel is pending external sharing.
    IsPrivate          bool          `json:"is_private"`                // Indicates if the channel is private.
    IsShared           bool          `json:"is_shared"`                 // Indicates if the channel is shared.
    IsUserDeleted      bool          `json:"is_user_deleted,omitempty"` // Indicates if the user is deleted. Only applicable for certain channel types.
    Name               string        `json:"name"`                      // Channel name.
    NameNormalized     string        `json:"name_normalized"`           // Normalized channel name.
    PendingShared      []interface{} `json:"pending_shared"`            // List of pending shared channel IDs.
    Priority           float64       `json:"priority,omitempty"`        // Channel priority.
    PreviousNames      []string      `json:"previous_names"`            // List of previous names for the channel.
    Purpose            Purpose       `json:"purpose"`                   // Purpose information of the channel.
    Topic              Topic         `json:"topic"`                     // Topic information of the channel.
    Unlinked           int           `json:"unlinked"`                  // Unlinked count of the channel.
    User               string        `json:"user,omitempty"`            // User ID associated with the channel. Only applicable for certain channel types.
}

type ChatClient

ChatClient for chaining methods

type ChatClient struct {
    *Client
}

func (*ChatClient) DeleteMessage

func (c *ChatClient) DeleteMessage(channel, ts string) error

* # Delete a message from a channel

func (*ChatClient) GetPermalink

func (c *ChatClient) GetPermalink(channel, messageTS string) (string, error)

* # Get a permalink for a message

func (*ChatClient) PostEphemeral

func (c *ChatClient) PostEphemeral(channel, userID, text string) (*ChatResponse, error)

* # Post an ephemeral message (visible only to a specific user)

func (*ChatClient) PostMessage

func (c *ChatClient) PostMessage(message *SlackMessage) (*ChatResponse, error)

* # Post a message to a channel

func (*ChatClient) UpdateMessage

func (c *ChatClient) UpdateMessage(channel, ts, text string) (*ChatResponse, error)

* # Update a message in a channel

type ChatResponse

ChatResponse represents the response from chat methods

type ChatResponse struct {
    OK        bool   `json:"ok"`                   // Response status
    Channel   string `json:"channel,omitempty"`    // Channel ID where message was posted
    TS        string `json:"ts,omitempty"`         // Timestamp of the message
    MessageTS string `json:"message_ts,omitempty"` // Alias for ts in some responses
    Error     string `json:"error,omitempty"`      // Error message if not OK
    Warning   string `json:"warning,omitempty"`    // Warning message
}

type Client

### Slack Client Structs ---------------------------------------------------------------------

type Client struct {
    BaseURL       string           // BaseURL is the base URL for Slack API requests.
    BotID         string           // The ID of the bot in current workspace
    HTTP          *requests.Client // HTTP client used to make HTTP requests.
    Error         *Error           // Error is the error response from the last request made by the client.
    Log           *log.Logger      // Log is the logger used to log information about the client.
    Token         string           // Authentication token for the Slack API.
    SigningSecret string           // Signing secret for bots
    Cache         *cache.Cache     // Cache is the cache used to store responses from the Slack API.
    // contains filtered or unexported fields
}

func NewClient

func NewClient(verbosity int) *Client

- # Generate Slack Client

  • @param log *log.Logger
  • @return *Client
  • Example:

```go

startServer1 := flag.Bool("startServer1", false, "Start server 1")
flag.Parse()

s := slack.NewClient(log.DEBUG)

if *startServer1 {
	handlers := server.Handler{
		"/slack/events":           s.EventHandler,
		"/slack/command/userlist": s.CommandHandler,
	}
	go server.StartServer("127.0.0.1:8080", handlers)
}

```

func (*Client) Admin

func (c *Client) Admin() *AdminClient

Admin returns the admin sub-client for Enterprise Grid operations

func (*Client) Audit

func (c *Client) Audit() *AuditClient

Audit returns the audit sub-client for Audit Logs API operations https://docs.slack.dev/reference/audit-logs-api/

func (*Client) BuildURL

func (c *Client) BuildURL(endpoint string, identifiers ...interface{}) string

BuildURL builds a URL for a given resource and identifiers.

func (*Client) Chat

func (c *Client) Chat() *ChatClient

Chat returns the chat sub-client for messaging operations

func (*Client) CommandHandler

func (c *Client) CommandHandler(w http.ResponseWriter, r *http.Request)

func (*Client) EventHandler

func (c *Client) EventHandler(w http.ResponseWriter, r *http.Request)

func (*Client) GetBotID

func (c *Client) GetBotID() (string, error)

func (*Client) GetCache

func (c *Client) GetCache(key string, target any) bool

* GetCache retrieves a Slack API response from the cache

func (*Client) ResetRateLimiters

func (c *Client) ResetRateLimiters()

ResetRateLimiters clears all cached service clients, forcing fresh rate limiters Note: This does NOT affect the parent Client’s HTTP rate limiter

func (*Client) SCIM

func (c *Client) SCIM() *SCIMClient

SCIM returns the SCIM sub-client for organization-wide user management https://docs.slack.dev/reference/scim-api/

func (*Client) SendMessage

func (c *Client) SendMessage(e *Event, m *SlackMessage) error

func (*Client) SendReply

func (c *Client) SendReply(e *Event, m *SlackMessage) error

func (*Client) SetCache

func (c *Client) SetCache(key string, value any, duration time.Duration)

* SetCache stores a Slack API response in the cache

func (*Client) Users

func (c *Client) Users() *UsersClient

Users returns the users sub-client for user operations

func (*Client) VerifyRequest

func (c *Client) VerifyRequest(r *http.Request, body []byte) bool

type ConversationQuery

ConversationQuery for users.conversations https://api.slack.com/methods/users.conversations

type ConversationQuery struct {
    Cursor          string `url:"cursor,omitempty"`           // Paginate through collections by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata
    ExcludeArchived bool   `url:"exclude_archived,omitempty"` // Set to true to exclude archived channels from the list
    Limit           int    `url:"limit,omitempty"`            // The maximum number of items to return, up to 999 (recommended: no more than 200)
    TeamID          string `url:"team_id,omitempty"`          // Encoded team id to list conversations in, required if org token is used
    Types           string `url:"types,omitempty"`            // Mix and match channel types by providing a comma-separated list (e.g., "im,mpim,public_channel,private_channel")
    User            string `url:"user,omitempty"`             // Browse conversations by a specific user ID's membership
}

func (*ConversationQuery) SetCursor

func (q *ConversationQuery) SetCursor(cursor string)

type Element

type Element struct {
    Type     string         `json:"type,omitempty"`     // Type of the element, here it's rich_text_section
    Elements []InnerElement `json:"elements,omitempty"` // Inner elements in the element
}

type Error

Error represents the common error response from the Slack methods.

type Error struct {
    Ok    bool   `json:"ok,omitempty"`    // Indicates whether the request was successful.
    Error string `json:"error,omitempty"` // Describes the error that occurred.
}

type Event

https://api.slack.com/apis/connections/events-api#event-type-structure

type Event struct {
    ClientMsgID string  `json:"client_msg_id,omitempty"` // Client-specified ID for this message
    Type        string  `json:"type,omitempty"`          // Type of the event, here it's app_mention
    Text        string  `json:"text,omitempty"`          // Text in the message that mentions the app
    User        string  `json:"user,omitempty"`          // ID of the user that sent this message
    TS          string  `json:"ts,omitempty"`            // Timestamp when this message was sent
    Blocks      []Block `json:"blocks,omitempty"`        // Blocks in the message
    Team        string  `json:"team,omitempty"`          // ID of the team/workspace where this event occurred
    Channel     string  `json:"channel,omitempty"`       // ID of the channel where this event occurred
    EventTS     string  `json:"event_ts,omitempty"`      // Timestamp when this event happened
}

type EventCallback

https://api.slack.com/apis/connections/events-api#callback-field

type EventCallback struct {
    Token              string          `json:"token,omitempty"`                 // Verification token to verify that the incoming request is from Slack
    TeamID             string          `json:"team_id,omitempty"`               // ID of the team/workspace where the event occurred
    APIAppID           string          `json:"api_app_id,omitempty"`            // App ID of the app that has been installed in this workspace
    Type               string          `json:"type,omitempty"`                  // Type of the callback, it's always event_callback
    Event              Event           `json:"event,omitzero"`                  // Details of the event
    EventID            string          `json:"event_id,omitempty"`              // Globally unique ID for this event
    EventTime          int64           `json:"event_time,omitempty"`            // Time when the event happened
    Authorizations     []Authorization `json:"authorizations,omitempty"`        // Information about the authorizations for this workspace and event
    IsExtSharedChannel bool            `json:"is_ext_shared_channel,omitempty"` // Indicates whether the event is in a shared channel
    EventContext       string          `json:"event_context,omitempty"`         // Event context (undefined, will revisit later)
}

type InnerElement

type InnerElement struct {
    Type   string `json:"type,omitempty"`    // Type of the inner element, it can be user or text
    UserID string `json:"user_id,omitempty"` // ID of the user, this field is present when the type is user
    Text   string `json:"text,omitempty"`    // Text of the inner element, this field is present when the type is text
}

type Member

Member represents a member in the Slack users.list method response.

type Member struct {
    Color             string  `json:"color,omitempty"`               // Member's color code.
    Deleted           bool    `json:"deleted,omitempty"`             // Whether the member is deleted.
    Has2FA            bool    `json:"has_2fa,omitempty"`             // Whether the member has two-factor authentication enabled.
    ID                string  `json:"id"`                            // Member's unique identifier.
    IsAdmin           bool    `json:"is_admin,omitempty"`            // Whether the member is an administrator.
    IsAppUser         bool    `json:"is_app_user,omitempty"`         // Whether the member is an app user.
    IsBot             bool    `json:"is_bot,omitempty"`              // Whether the member is a bot.
    IsOwner           bool    `json:"is_owner,omitempty"`            // Whether the member is an owner.
    IsPrimaryOwner    bool    `json:"is_primary_owner,omitempty"`    // Whether the member is the primary owner.
    IsRestricted      bool    `json:"is_restricted,omitempty"`       // Whether the member is restricted.
    IsUltraRestricted bool    `json:"is_ultra_restricted,omitempty"` // Whether the member is ultra-restricted.
    Name              string  `json:"name"`                          // Member's username.
    Profile           Profile `json:"profile,omitzero"`              // Member's profile information.
    RealName          string  `json:"real_name,omitempty"`           // Member's real name.
    TeamID            string  `json:"team_id"`                       // Team identifier.
    TZ                string  `json:"tz,omitempty"`                  // Member's time zone.
    TzLabel           string  `json:"tz_label,omitempty"`            // Label for the time zone.
    TzOffset          int     `json:"tz_offset,omitempty"`           // Time zone offset in seconds.
    Updated           int64   `json:"updated,omitempty"`             // Timestamp for when the member was updated.
}

type Metadata

Metadata represents the response metadata in the Slack users.list method response.

type Metadata struct {
    NextCursor string `json:"next_cursor,omitempty"` // Next cursor for pagination.
}

type Profile

Profile represents a member’s profile in the Slack users.list method response.

type Profile struct {
    AvatarHash            string `json:"avatar_hash,omitempty"`             // Avatar hash.
    DisplayName           string `json:"display_name,omitempty"`            // Display name.
    DisplayNameNormalized string `json:"display_name_normalized,omitempty"` // Normalized display name.
    Email                 string `json:"email,omitempty"`                   // Email address.
    FirstName             string `json:"first_name,omitempty"`              // First name.
    Image1024             string `json:"image_1024,omitempty"`              // Image URL (1024x1024).
    Image192              string `json:"image_192,omitempty"`               // Image URL (192x192).
    Image24               string `json:"image_24,omitempty"`                // Image URL (24x24).
    Image32               string `json:"image_32,omitempty"`                // Image URL (32x32).
    Image48               string `json:"image_48,omitempty"`                // Image URL (48x48).
    Image512              string `json:"image_512,omitempty"`               // Image URL (512x512).
    Image72               string `json:"image_72,omitempty"`                // Image URL (72x72).
    ImageOriginal         string `json:"image_original,omitempty"`          // Original image URL.
    LastName              string `json:"last_name,omitempty"`               // Last name.
    Phone                 string `json:"phone,omitempty"`                   // Phone number.
    RealName              string `json:"real_name,omitempty"`               // Real name.
    RealNameNormalized    string `json:"real_name_normalized,omitempty"`    // Normalized real name.
    Skype                 string `json:"skype,omitempty"`                   // Skype ID.
    StatusEmoji           string `json:"status_emoji,omitempty"`            // Status emoji.
    StatusText            string `json:"status_text,omitempty"`             // Status text.
    Team                  string `json:"team,omitempty"`                    // Team ID.
    Title                 string `json:"title,omitempty"`                   // Title.
}

type Purpose

Purpose represents the purpose information of a channel in the Slack ‘users.conversations’ method.

type Purpose struct {
    Creator string `json:"creator"`  // User ID of the purpose's creator.
    LastSet int64  `json:"last_set"` // Timestamp of when the purpose was last set.
    Value   string `json:"value"`    // Purpose value or content.
}

type ResponseMetadata

ResponseMetadata represents the metadata related to a response in the Slack ‘users.conversations’ method.

type ResponseMetadata struct {
    NextCursor string `json:"next_cursor"` // Cursor for pagination.
}

type SCIMClient

SCIMClient for SCIM API operations (organization-wide user management)

type SCIMClient struct {
    *Client
    SCIMBaseURL string
}

func (*SCIMClient) BuildURL

func (c *SCIMClient) BuildURL(endpoint string, identifiers ...interface{}) string

BuildURL builds a URL for a given SCIM resource and identifiers.

func (*SCIMClient) FilterUsers

func (c *SCIMClient) FilterUsers(filter string) (*SCIMUserList, error)

* # Filter users with SCIM filter expressions

func (*SCIMClient) GetUser

func (c *SCIMClient) GetUser(userID string) (*SCIMUser, error)

* # Get a single user by ID

func (*SCIMClient) ListAllUsers

func (c *SCIMClient) ListAllUsers() (*SCIMUserList, error)

* # List all users in the organization with concurrent pagination

func (*SCIMClient) ListUsers

func (c *SCIMClient) ListUsers(query *SCIMQuery) (*SCIMUserList, error)

* # List users in the organization with pagination control

func (*SCIMClient) LookupByEmail

func (c *SCIMClient) LookupByEmail(email string) (*SCIMUser, error)

* # Look up a user by email address

type SCIMEmail

SCIMEmail represents an email address in SCIM

type SCIMEmail struct {
    Value   string `json:"value,omitempty"`   // Email address
    Type    string `json:"type,omitempty"`    // Type (e.g., "work", "home")
    Primary bool   `json:"primary,omitempty"` // Whether this is the primary email
}

type SCIMError

SCIMError represents an error response from the SCIM API

type SCIMError struct {
    Schemas []string `json:"schemas,omitempty"` // Error schema
    Detail  string   `json:"detail,omitempty"`  // Error detail message
    Status  int      `json:"status,omitempty"`  // HTTP status code
}

func (*SCIMError) Error

func (e *SCIMError) Error() string

Error implements the error interface for SCIMError

type SCIMGroupRef

SCIMGroupRef represents a group reference in SCIM user responses

type SCIMGroupRef struct {
    Value   string `json:"value,omitempty"`   // Group ID
    Display string `json:"display,omitempty"` // Group display name
}

type SCIMMeta

SCIMMeta represents SCIM resource metadata

type SCIMMeta struct {
    Created  string `json:"created,omitempty"`  // Creation timestamp
    Location string `json:"location,omitempty"` // Resource URL
}

type SCIMName

SCIMName represents the name components in SCIM

type SCIMName struct {
    GivenName       string `json:"givenName,omitempty"`       // First name
    FamilyName      string `json:"familyName,omitempty"`      // Last name
    HonorificPrefix string `json:"honorificPrefix,omitempty"` // Prefix (e.g., "Mr.", "Dr.")
}

type SCIMPaginatedList

SCIMPaginatedList is a generic structure representing a paginated response from SCIM API https://docs.slack.dev/reference/scim-api/

type SCIMPaginatedList[E any] struct {
    Schemas      []string `json:"schemas,omitempty"`
    TotalResults int      `json:"totalResults"`        // Total number of items in the organization
    ItemsPerPage int      `json:"itemsPerPage"`        // Number of results returned in this response
    StartIndex   int      `json:"startIndex"`          // 1-based index of first result
    Resources    *[]*E    `json:"Resources,omitempty"` // Array of resource items
}

func (SCIMPaginatedList[E]) Append

func (pl SCIMPaginatedList[E]) Append(elements *[]*E)

func (SCIMPaginatedList[E]) Elements

func (pl SCIMPaginatedList[E]) Elements() *[]*E

func (SCIMPaginatedList[E]) TotalCount

func (pl SCIMPaginatedList[E]) TotalCount() int

type SCIMPaginatedResponse

SCIMPaginatedResponse is an interface for SCIM API responses involving pagination Mirrors the PaginatedResponse pattern from SnipeIT for consistency

type SCIMPaginatedResponse[E any] interface {
    TotalCount() int
    Append(*[]*E)
    Elements() *[]*E
}

type SCIMPhoto

SCIMPhoto represents a profile photo in SCIM

type SCIMPhoto struct {
    Value string `json:"value,omitempty"` // URL to the photo
    Type  string `json:"type,omitempty"`  // Type (e.g., "photo")
}

type SCIMQuery

SCIMQuery for GET /scim/v1/Users https://docs.slack.dev/reference/scim-api/users

type SCIMQuery struct {
    Count      int    `url:"count,omitempty"`      // Number of results to return (max 1000)
    StartIndex int    `url:"startIndex,omitempty"` // 1-based index for pagination
    Filter     string `url:"filter,omitempty"`     // SCIM filter expression (e.g., "userName Eq \"john\"")
}

func (*SCIMQuery) Copy

func (q *SCIMQuery) Copy() SCIMQueryInterface

Implement SCIMQueryInterface for SCIMQuery

func (*SCIMQuery) GetCount

func (q *SCIMQuery) GetCount() int

func (*SCIMQuery) GetStartIndex

func (q *SCIMQuery) GetStartIndex() int

func (*SCIMQuery) SetCount

func (q *SCIMQuery) SetCount(count int)

func (*SCIMQuery) SetStartIndex

func (q *SCIMQuery) SetStartIndex(startIndex int)

type SCIMQueryInterface

SCIMQueryInterface defines methods for SCIM query parameters with pagination Uses startIndex (1-based) instead of offset (0-based)

type SCIMQueryInterface interface {
    Copy() SCIMQueryInterface
    GetCount() int
    SetCount(int)
    GetStartIndex() int
    SetStartIndex(int)
}

type SCIMSlackGuest

SCIMSlackGuest represents the Slack guest extension schema urn:scim:schemas:extension:slack:guest:1.0

type SCIMSlackGuest struct {
    Type       string `json:"type,omitempty"`       // Guest type: "multi" or "single"
    Expiration string `json:"expiration,omitempty"` // Guest expiration date (ISO 8601)
}

type SCIMUser

SCIMUser represents a user in the SCIM API https://docs.slack.dev/reference/scim-api/users

type SCIMUser struct {
    Schemas     []string        `json:"schemas,omitempty"`                                    // SCIM 2.0 schemas (e.g., "urn:ietf:params:scim:schemas:core:2.0:User")
    ID          string          `json:"id,omitempty"`                                         // Slack's unique user ID
    ExternalID  string          `json:"externalId,omitempty"`                                 // External identifier from identity provider
    UserName    string          `json:"userName,omitempty"`                                   // Unique username (typically email)
    Active      bool            `json:"active,omitempty"`                                     // Whether the user is active
    Name        SCIMName        `json:"name,omitempty"`                                       // User's name components
    DisplayName string          `json:"displayName,omitempty"`                                // Display name
    NickName    string          `json:"nickName,omitempty"`                                   // Nickname
    ProfileURL  string          `json:"profileUrl,omitempty"`                                 // URL to user's profile
    Title       string          `json:"title,omitempty"`                                      // Job title
    Timezone    string          `json:"timezone,omitempty"`                                   // User's timezone
    Emails      []SCIMEmail     `json:"emails,omitempty"`                                     // Email addresses
    Photos      []SCIMPhoto     `json:"photos,omitempty"`                                     // Profile photos
    Groups      []SCIMGroupRef  `json:"groups,omitempty"`                                     // Groups the user belongs to
    Meta        *SCIMMeta       `json:"meta,omitempty"`                                       // Resource metadata
    SlackGuest  *SCIMSlackGuest `json:"urn:scim:schemas:extension:slack:guest:1.0,omitempty"` // Slack guest extension
}

func (*SCIMUser) PrimaryEmail

func (u *SCIMUser) PrimaryEmail() string

PrimaryEmail returns the primary email address for the user Falls back to the first email if no primary is set, or UserName if no emails

type SCIMUserList

SCIMUserList wraps SCIMPaginatedList for SCIM user responses

type SCIMUserList struct {
    // contains filtered or unexported fields
}

func (*SCIMUserList) Map

func (r *SCIMUserList) Map() map[string]*SCIMUser

Map returns a map of SCIM users keyed by primary email for easy lookup

type SessionReset

SessionReset for admin.users.session.reset and admin.users.session.resetBulk https://api.slack.com/methods/admin.users.session.reset

type SessionReset struct {
    UserID     string   `json:"user_id,omitempty"`     // Single user (for reset)
    UserIDs    []string `json:"user_ids,omitempty"`    // Multiple users (for resetBulk)
    MobileOnly bool     `json:"mobile_only,omitempty"` // Only reset mobile sessions
    WebOnly    bool     `json:"web_only,omitempty"`    // Only reset web sessions
}

type SessionResetOption

SessionResetOption is a functional option for session reset

type SessionResetOption func(*SessionReset)

func WithMobileOnly

func WithMobileOnly() SessionResetOption

Functional options for SessionReset

func WithWebOnly

func WithWebOnly() SessionResetOption

type SlackAPIError

SlackAPIError represents an error response from the Slack API Implements the error interface for use in error handling

type SlackAPIError struct {
    OK               bool             `json:"ok"`                          // Always false for errors
    ErrorCode        string           `json:"error,omitempty"`             // Error code (e.g., "not_allowed_token_type")
    Warning          string           `json:"warning,omitempty"`           // Warning message if any
    ResponseMetadata ResponseMetadata `json:"response_metadata,omitempty"` // Additional error details
    Needed           string           `json:"needed,omitempty"`            // Required scope/permission
    Provided         string           `json:"provided,omitempty"`          // Provided scope/permission
}

func IsSlackError

func IsSlackError(err error) (*SlackAPIError, bool)

IsSlackError checks if the error is a SlackAPIError and returns it

func (*SlackAPIError) Error

func (e *SlackAPIError) Error() string

Error implements the error interface for SlackAPIError References the ErrorDetails map for human-readable error descriptions

type SlackAPIResponse

SlackAPIResponse is a generic interface for Slack API responses involving pagination

type SlackAPIResponse[T any] interface {
    Append(T) T
    NextCursor() string
}

type SlackChallenge

### Slack Event Structs ---------------------------------------------------------------------

type SlackChallenge struct {
    Token     string `json:"token,omitempty"`     // Verification token to verify that the incoming request is from Slack
    Challenge string `json:"challenge,omitempty"` // Challenge string used to verify the URL
    Type      string `json:"type,omitempty"`      // Type of the callback, it's always url_verification
}

type SlackMessage

### Slack Message Structs --------------------------------------------------------------------- https://api.slack.com/methods/chat.postMessage#args

type SlackMessage struct {
    AsUser         bool   `json:"as_user,omitempty"`         // Optional. (Legacy) Post the message as the authed user instead of as a bot.
    Attachments    string `json:"attachments,omitempty"`     // Optional. A JSON-based array of structured attachments, presented as a URL-encoded string.
    Blocks         string `json:"blocks,omitempty"`          // Optional. A JSON-based array of structured blocks, presented as a URL-encoded string.
    Channel        string `json:"channel"`                   // Required. Channel, private group, or IM channel to send the message to. Can be an encoded ID, or a name.
    IconEmoji      string `json:"icon_emoji,omitempty"`      // Optional. Emoji to use as the icon for this message. Overrides icon_url.
    IconURL        string `json:"icon_url,omitempty"`        // Optional. URL to an image to use as the icon for this message.
    LinkNames      bool   `json:"link_names,omitempty"`      // Optional. Find and link user groups.
    Metadata       string `json:"metadata,omitempty"`        // Optional. JSON object with event_type and event_payload fields. Metadata posted to Slack is accessible to members of that workspace.
    Markdown       bool   `json:"mrkdwn,omitempty"`          // Optional. Disable or enable Slack markup parsing.
    Parse          string `json:"parse,omitempty"`           // Optional. Change how messages are treated.
    ReplyBroadcast bool   `json:"reply_broadcast,omitempty"` // Optional. Indicates whether reply should be visible to everyone in the channel or conversation.
    Text           string `json:"text,omitempty"`            // Optional. The formatted text of the message to be published. Used as fallback text if blocks are included.
    ThreadTS       string `json:"thread_ts,omitempty"`       // Optional. Provide another message's ts value to make this message a reply.
    Token          string `json:"token"`                     // Required. Authentication token bearing required scopes.
    UnfurlLinks    bool   `json:"unfurl_links,omitempty"`    // Optional. Enable unfurling of primarily text-based content.
    UnfurlMedia    bool   `json:"unfurl_media,omitempty"`    // Optional. Disable or enable unfurling of media content.
    Username       string `json:"username,omitempty"`        // Optional. Set your bot's user name.
}

type SlackOK

SlackOK is a simple ok/error response used by many Slack methods

type SlackOK struct {
    OK    bool   `json:"ok"`
    Error string `json:"error,omitempty"`
}

type SlackQuery

SlackQuery is an interface for Slack API queries involving pagination

type SlackQuery interface {
    // SetCursor updates the query's cursor for pagination.
    SetCursor(string)
}

type SlackTokenPayload

type SlackTokenPayload struct {
    T string // Token for authentication
}

type SlashCommand

### Slack Command Structs ---------------------------------------------------------------------

type SlashCommand struct {
    Token       string `url:"token,omitempty"`
    TeamID      string `url:"team_id,omitempty"`
    ChannelID   string `url:"channel_id,omitempty"`
    UserName    string `url:"user_name,omitempty"`
    Command     string `url:"command,omitempty"`
    Text        string `url:"text,omitempty"`
    ResponseURL string `url:"response_url"`
}

type Topic

Topic represents the topic information of a channel in the Slack ‘users.conversations’ method.

type Topic struct {
    Creator string `json:"creator"`  // User ID of the topic's creator.
    LastSet int64  `json:"last_set"` // Timestamp of when the topic was last set.
    Value   string `json:"value"`    // Topic value or content.
}

type UserChannels

### Slack Channel Structs --------------------------------------------------------------------- UserChannels represents the response from the Slack ‘users.conversations’ method. https://api.slack.com/methods/users.conversations

type UserChannels struct {
    Channels         []Channel        `json:"channels"`          // List of channel information.
    OK               bool             `json:"ok"`                // Indicates the success status.
    ResponseMetadata ResponseMetadata `json:"response_metadata"` // Metadata related to the response, including pagination information.
}

func (UserChannels) Append

func (uc UserChannels) Append(other UserChannels) UserChannels

Implement SlackAPIResponse interface for UserChannels

func (UserChannels) NextCursor

func (uc UserChannels) NextCursor() string

type UserQuery

UserQuery for users.list and users.info https://api.slack.com/methods/users.list

type UserQuery struct {
    Cursor        string `url:"cursor,omitempty"`         // Paginate through collections by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata
    IncludeLocale bool   `url:"include_locale,omitempty"` // Set this to true to receive the locale for users
    Limit         int    `url:"limit,omitempty"`          // The maximum number of items to return, up to 999 (recommended: no more than 200)
    TeamID        string `url:"team_id,omitempty"`        // Encoded team id to list users in, required if org token is used
}

func (*UserQuery) SetCursor

func (q *UserQuery) SetCursor(cursor string)

type UserResponse

UserResponse represents the response from methods that return a single user https://api.slack.com/methods/users.info https://api.slack.com/methods/users.lookupByEmail

type UserResponse struct {
    OK    bool   `json:"ok"`              // Response status
    User  Member `json:"user,omitzero"`   // User object
    Error string `json:"error,omitempty"` // Error message if not OK
}

type Users

### Slack User Structs --------------------------------------------------------------------- UsersListResponse represents the common successful response from the Slack users.list method. https://api.slack.com/methods/users.list

type Users struct {
    CacheTS          int64    `json:"cache_ts,omitempty"`         // Cache timestamp.
    Members          []Member `json:"members,omitempty"`          // List of members.
    OK               bool     `json:"ok"`                         // Response status.
    ResponseMetadata Metadata `json:"response_metadata,omitzero"` // Metadata for the response.
}

func (Users) Append

func (u Users) Append(other Users) Users

Implement SlackAPIResponse interface for Users

func (*Users) Map

func (u *Users) Map() map[string]*Member

Map returns a map of users keyed by email for easy lookup

func (Users) NextCursor

func (u Users) NextCursor() string

type UsersClient

UsersClient for chaining methods

type UsersClient struct {
    *Client
}

func (*UsersClient) GetUser

func (c *UsersClient) GetUser(userID string) (*Member, error)

* # Get information about a user

func (*UsersClient) GetUserChannels

func (c *UsersClient) GetUserChannels(userID string) (*UserChannels, error)

* # Get channels for a user

func (*UsersClient) ListAllUsers

func (c *UsersClient) ListAllUsers() (*Users, error)

* # List all users in a Slack workspace

func (*UsersClient) ListUserConversations

func (c *UsersClient) ListUserConversations(query *ConversationQuery) (*UserChannels, error)

* # List all conversations for a user with custom options

func (*UsersClient) LookupByEmail

func (c *UsersClient) LookupByEmail(email string) (*Member, error)

* # Lookup user by email

Generated by gomarkdoc