stream_chat

package module
v8.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: BSD-3-Clause Imports: 25 Imported by: 1 module, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

[!CAUTION]

⚠️ This is a legacy SDK. It is deprecated.

🚫 Do not start new projects with stream-chat-go.

✅ Use getstream-go instead. It covers Chat, Video, Moderation and Feeds in one SDK.

🔁 Already using stream-chat-go? Follow the migration guide to move your code.

Legacy Go SDK for Stream Chat

build godoc

Legacy Go API client for Stream Chat, a service for building chat applications.
Explore the docs »

Report Bug · Request Feature

📝 About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access chat API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).

⚙️ Installation

go get github.com/GetStream/stream-chat-go/v8

✨ Getting started

package main

import (
	"os"

	stream "github.com/GetStream/stream-chat-go/v8"
)

var APIKey = os.Getenv("STREAM_KEY")
var APISecret = os.Getenv("STREAM_SECRET")
var userID = "" // your server user id

func main() {
	// Initialize client
	client, err := stream.NewClient(APIKey, APISecret)
	
	// Or with a specific timeout
	client, err := stream.NewClient(APIKey, APISecret, WithTimeout(3 * time.Second))

	// Or using only environmental variables: (required) STREAM_KEY, (required) STREAM_SECRET,
	// (optional) STREAM_CHAT_TIMEOUT
	client, err := stream.NewClientFromEnvVars()

	// handle error

	// Define a context
	ctx := context.Background()

	// use client methods

	// create channel with users
	users := []string{"id1", "id2", "id3"}
	userID := "id1"
	channel, err := client.CreateChannelWithMembers(ctx, "messaging", "channel-id", userID, users...)

	// use channel methods
	msg, err := channel.SendMessage(ctx, &stream.Message{Text: "hello"}, userID)
}

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Head over to CONTRIBUTING.md for some development tips.

🧑‍💻 We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.

Documentation

Index

Examples

Constants

View Source
const (
	WebhookHook    HookType = "webhook"
	SQSHook        HookType = "sqs"
	SNSHook        HookType = "sns"
	PendingMessage HookType = "pending_message"

	CallbackModeNone  CallbackMode = "CALLBACK_MODE_NONE"
	CallbackModeREST  CallbackMode = "CALLBACK_MODE_REST"
	CallbackModeTwirp CallbackMode = "CALLBACK_MODE_TWIRP"

	ProductAll        Product = "all"
	ProductChat       Product = "chat"
	ProductVideo      Product = "video"
	ProductModeration Product = "moderation"
	ProductFeeds      Product = "feeds"
)
View Source
const (
	AutoModDisabled modType = "disabled"
	AutoModSimple   modType = "simple"
	AutoModAI       modType = "AI"

	ModBehaviourFlag  modBehaviour = "flag"
	ModBehaviourBlock modBehaviour = "block"

	MessageRetentionForever = "infinite"
)
View Source
const (
	PushProviderAPNS     = PushProviderType("apn")
	PushProviderFirebase = PushProviderType("firebase")
	PushProviderXiaomi   = PushProviderType("xiaomi")
	PushProviderHuawei   = PushProviderType("huawei")
)
View Source
const (
	HeaderRateLimit     = "X-Ratelimit-Limit"
	HeaderRateRemaining = "X-Ratelimit-Remaining"
	HeaderRateReset     = "X-Ratelimit-Reset"
)
View Source
const (
	// DefaultBaseURL is the default base URL for the stream chat api.
	// It works like CDN style and connects you to the closest production server.
	// By default, there is no real reason to change it. Use it only if you know what you are doing.
	DefaultBaseURL = "https://chat.stream-io-api.com"
)

Variables

View Source
var DefaultChannelConfig = ChannelConfig{
	Automod:           AutoModDisabled,
	ModBehavior:       ModBehaviourFlag,
	MaxMessageLength:  defaultMessageLength,
	MessageRetention:  MessageRetentionForever,
	PushNotifications: true,
}

DefaultChannelConfig is the default channel configuration.

View Source
var ErrInvalidWebhook = errors.New("invalid webhook")

ErrInvalidWebhook is the sentinel wrapped by every malformed-webhook / verification error from this package so callers can use errors.Is with a single check.

View Source
var MaxWebhookPayloadBytes int64 = 10 << 20

MaxWebhookPayloadBytes caps the decompressed size of a gzip webhook body. GunzipPayload runs before the signature check, so without a cap an unsigned gzip bomb could exhaust memory. Raise it if your events are larger.

Functions

func AddMembersWithHideHistory

func AddMembersWithHideHistory() func(*addMembersOptions)

func AddMembersWithHideHistoryBefore

func AddMembersWithHideHistoryBefore(before time.Time) func(*addMembersOptions)

func AddMembersWithMessage

func AddMembersWithMessage(message *Message) func(*addMembersOptions)

func AddMembersWithRolesAssignment

func AddMembersWithRolesAssignment(assignements []*RoleAssignment) func(*addMembersOptions)

func BanWithBanFromFutureChannels added in v8.2.0

func BanWithBanFromFutureChannels() func(*banOptions)

BanWithBanFromFutureChannels when set to true, the user will be automatically banned from all future channels created by the user who issued the ban. Note: This option requires BanWithChannel to also be set.

func BanWithChannel added in v8.2.0

func BanWithChannel(channelType, channelID string) func(*banOptions)

BanWithChannel sets the channel context for the ban operation. This is required when using BanWithBanFromFutureChannels at the client level.

func BanWithDeleteReactions added in v8.5.0

func BanWithDeleteReactions() func(*banOptions)

BanWithDeleteReactions when set to true, all reactions by the banned user on other users' messages will be deleted.

func BanWithExpiration

func BanWithExpiration(expiration int) func(*banOptions)

BanWithExpiration set when the ban will expire. Should be in minutes. eg. to ban during one hour: BanWithExpiration(60).

func BanWithReason

func BanWithReason(reason string) func(*banOptions)

func DeactivateUserWithCreatedBy

func DeactivateUserWithCreatedBy(userID string) func(*deactivateUserOptions)

func DeactivateUserWithMarkChannelsDeleted

func DeactivateUserWithMarkChannelsDeleted() func(*deactivateUserOptions)

func DeactivateUserWithMarkMessagesDeleted

func DeactivateUserWithMarkMessagesDeleted() func(*deactivateUserOptions)

func DecodeSnsPayload added in v8.6.0

func DecodeSnsPayload(notificationBody string) ([]byte, error)

DecodeSnsPayload reverses an SNS HTTP notification envelope: when the input is a JSON envelope ({"Type":"Notification","Message":"..."}), the inner Message field is extracted and run through the SQS pipeline (base64-decode, then gzip-if-magic). When the input is not a JSON envelope it is treated as the already-extracted Message string, so existing call sites that pre-unwrap continue to work.

func DecodeSqsPayload added in v8.6.0

func DecodeSqsPayload(body string) ([]byte, error)

DecodeSqsPayload reverses the SQS firehose envelope: the message Body is base64-decoded and, when the result begins with the gzip magic, it is gzip-decompressed. The same call works whether or not Stream is currently compressing payloads.

func DeleteUserWithDeleteConversations

func DeleteUserWithDeleteConversations() func(*deleteUserOptions)

func DeleteUserWithHardDelete

func DeleteUserWithHardDelete() func(*deleteUserOptions)

func DeleteUserWithMarkMessagesDeleted

func DeleteUserWithMarkMessagesDeleted() func(*deleteUserOptions)

func GunzipPayload added in v8.6.0

func GunzipPayload(body []byte) ([]byte, error)

GunzipPayload returns body unchanged unless the first two bytes are the gzip magic (1f 8b, per RFC 1952), in which case the gzip stream is inflated and the decompressed bytes are returned.

Magic-byte detection lets the same handler stay correct when middleware auto-decompresses the request before your code sees it.

Returns an error wrapping ErrInvalidWebhook when the gzip stream is malformed or decompresses to more than MaxWebhookPayloadBytes.

func KeepChannelHidden

func KeepChannelHidden(r *messageRequest)

func MarkReadThread

func MarkReadThread(id string) func(*markReadOption)

func MarkReadUntilMessage

func MarkReadUntilMessage(id string) func(*markReadOption)

func MarkUnreadFromMessage

func MarkUnreadFromMessage(id string) func(*markUnreadOption)

Specify ID of the message from where the channel is marked unread.

func MarkUnreadFromTimestamp

func MarkUnreadFromTimestamp(timestamp time.Time) func(*markUnreadOption)

func MarkUnreadThread

func MarkUnreadThread(id string) func(*markUnreadOption)

func MessagePending

func MessagePending(r *messageRequest)

MessagePending sets a flag that marks this message as pending. Deprecated: Use WithPending(true) instead.

func MessageSkipEnrichURL

func MessageSkipEnrichURL(r *messageRequest)

MessageSkipEnrichURL is a flag that disables enrichment of the URLs in the message.

func MessageSkipPush

func MessageSkipPush(r *messageRequest)

MessageSkipPush is a flag that be given to SendMessage if you don't want to generate any push notifications.

func MuteWithExpiration

func MuteWithExpiration(expiration int) func(*muteOptions)

func ReactivateUserWithCreatedBy

func ReactivateUserWithCreatedBy(userID string) func(*reactivateUserOptions)

func ReactivateUserWithName

func ReactivateUserWithName(name string) func(*reactivateUserOptions)

func ReactivateUserWithRestoreChannels

func ReactivateUserWithRestoreChannels() func(*reactivateUserOptions)

func ReactivateUserWithRestoreMessages

func ReactivateUserWithRestoreMessages() func(*reactivateUserOptions)

func TruncateWithHardDelete

func TruncateWithHardDelete() func(*truncateOptions)

func TruncateWithMessage

func TruncateWithMessage(message *Message) func(*truncateOptions)

func TruncateWithSkipPush

func TruncateWithSkipPush() func(*truncateOptions)

func TruncateWithTruncatedAt

func TruncateWithTruncatedAt(truncatedAt *time.Time) func(*truncateOptions)

func TruncateWithUser

func TruncateWithUser(user *User) func(*truncateOptions)

func TruncateWithUserID

func TruncateWithUserID(userID string) func(*truncateOptions)

func UnbanWithCreatedBy added in v8.2.0

func UnbanWithCreatedBy(userID string) func(*unbanOptions)

UnbanWithCreatedBy sets the user ID who originally created the ban. This is required when using UnbanWithRemoveFutureChannelsBan.

func UnbanWithRemoveFutureChannelsBan added in v8.2.0

func UnbanWithRemoveFutureChannelsBan() func(*unbanOptions)

UnbanWithRemoveFutureChannelsBan when set to true, also removes the future channel ban, so the user will no longer be auto-banned in new channels. Note: This option requires UnbanWithCreatedBy to also be set.

func VerifySignature added in v8.6.0

func VerifySignature(body []byte, signature, secret string) error

VerifySignature compares the hex-encoded HMAC-SHA256 of body (using secret as the key) to signature with a constant-time comparison. It returns nil on match. On mismatch it returns an error wrapping ErrInvalidWebhook (message contains "signature mismatch"). The digest is always over uncompressed JSON bytes.

func Version

func Version() string

Version returns the version of the library.

func WithTimeout

func WithTimeout(t time.Duration) func(c *Client)

Types

type APNConfig

type APNConfig struct {
	Enabled              bool   `json:"enabled"`
	Development          bool   `json:"development"`
	AuthType             string `json:"auth_type,omitempty"`
	AuthKey              string `json:"auth_key,omitempty"`
	NotificationTemplate string `json:"notification_template"`
	Host                 string `json:"host,omitempty"`
	BundleID             string `json:"bundle_id,omitempty"`
	TeamID               string `json:"team_id,omitempty"`
	KeyID                string `json:"key_id,omitempty"`
}

type ActiveLiveLocationsResponse

type ActiveLiveLocationsResponse struct {
	ActiveLiveLocations []*SharedLocation `json:"active_live_locations"`
	Response
}

type AddMembersOptions

type AddMembersOptions func(*addMembersOptions)

type AppResponse

type AppResponse struct {
	App *AppSettings `json:"app"`
	Response
}

type AppSettings

type AppSettings struct {
	Name                     string                    `json:"name"`
	OrganizationName         string                    `json:"organization"`
	Suspended                bool                      `json:"suspended"`
	SuspendedExplanation     string                    `json:"suspended_explanation"`
	ConfigNameMap            map[string]*ChannelConfig `json:"channel_configs"`
	RevokeTokensIssuedBefore *time.Time                `json:"revoke_tokens_issued_before"`

	DisableAuth        *bool `json:"disable_auth_checks,omitempty"`
	DisablePermissions *bool `json:"disable_permissions_checks,omitempty"`

	PushNotifications                     PushNotificationFields `json:"push_notifications"`
	PushConfig                            *PushConfigRequest     `json:"push_config,omitempty"`
	APNConfig                             *APNConfig             `json:"apn_config,omitempty"`
	FirebaseConfig                        *FirebaseConfigRequest `json:"firebase_config,omitempty"`
	XiaomiConfig                          *XiaomiConfigRequest   `json:"xiaomi_config,omitempty"`
	HuaweiConfig                          *HuaweiConfigRequest   `json:"huawei_config,omitempty"`
	WebhookURL                            *string                `json:"webhook_url,omitempty"`
	WebhookEvents                         []string               `json:"webhook_events,omitempty"`
	SqsURL                                *string                `json:"sqs_url,omitempty"`
	SqsKey                                *string                `json:"sqs_key,omitempty"`
	SqsSecret                             *string                `json:"sqs_secret,omitempty"`
	SnsTopicArn                           *string                `json:"sns_topic_arn,omitempty"`
	SnsKey                                *string                `json:"sns_key,omitempty"`
	SnsSecret                             *string                `json:"sns_secret,omitempty"`
	BeforeMessageSendHookURL              *string                `json:"before_message_send_hook_url,omitempty"`
	BeforeMessageSendHookAttemptTimeoutMs *int                   `json:"before_message_send_hook_attempt_timeout_ms,omitempty"`
	CustomActionHandlerURL                *string                `json:"custom_action_handler_url,omitempty"`

	FileUploadConfig       *FileUploadConfig `json:"file_upload_config,omitempty"`
	ImageUploadConfig      *FileUploadConfig `json:"image_upload_config,omitempty"`
	ImageModerationLabels  []string          `json:"image_moderation_labels,omitempty"`
	ImageModerationEnabled *bool             `json:"image_moderation_enabled,omitempty"`

	PermissionVersion      *string             `json:"permission_version,omitempty"`
	MigratePermissionsToV2 *bool               `json:"migrate_permissions_to_v2,omitempty"`
	Policies               map[string][]Policy `json:"policies"`
	Grants                 map[string][]string `json:"grants,omitempty"`

	MultiTenantEnabled        *bool                         `json:"multi_tenant_enabled,omitempty"`
	AsyncURLEnrichEnabled     *bool                         `json:"async_url_enrich_enabled,omitempty"`
	AutoTranslationEnabled    *bool                         `json:"auto_translation_enabled,omitempty"`
	RemindersInterval         int                           `json:"reminders_interval,omitempty"`
	UserSearchDisallowedRoles []string                      `json:"user_search_disallowed_roles,omitempty"`
	EnforceUniqueUsernames    *string                       `json:"enforce_unique_usernames,omitempty"`
	ChannelHideMembersOnly    *bool                         `json:"channel_hide_members_only,omitempty"`
	AsyncModerationConfig     *AsyncModerationConfiguration `json:"async_moderation_config,omitempty"`
	EventHooks                []EventHook                   `json:"event_hooks,omitempty"`
	SharedLocationsEnabled    *bool                         `json:"shared_locations_enabled,omitempty"`
	UserResponseTimeEnabled   *bool                         `json:"user_response_time_enabled,omitempty"`
}

func NewAppSettings

func NewAppSettings() *AppSettings

func (*AppSettings) SetAPNConfig

func (a *AppSettings) SetAPNConfig(c APNConfig) *AppSettings

func (*AppSettings) SetAsyncModerationConfig

func (a *AppSettings) SetAsyncModerationConfig(c AsyncModerationConfiguration) *AppSettings

func (*AppSettings) SetBeforeMessageSendHookAttemptTimeoutMs added in v8.6.0

func (a *AppSettings) SetBeforeMessageSendHookAttemptTimeoutMs(ms int) *AppSettings

func (*AppSettings) SetDisableAuth

func (a *AppSettings) SetDisableAuth(b bool) *AppSettings

func (*AppSettings) SetDisablePermissions

func (a *AppSettings) SetDisablePermissions(b bool) *AppSettings

func (*AppSettings) SetEventHooks

func (a *AppSettings) SetEventHooks(eventHooks []EventHook) *AppSettings

func (*AppSettings) SetFirebaseConfig

func (a *AppSettings) SetFirebaseConfig(c FirebaseConfigRequest) *AppSettings

func (*AppSettings) SetGrants

func (a *AppSettings) SetGrants(g map[string][]string) *AppSettings

func (*AppSettings) SetMultiTenant

func (a *AppSettings) SetMultiTenant(b bool) *AppSettings

func (*AppSettings) SetSharedLocationsEnabled

func (a *AppSettings) SetSharedLocationsEnabled(b bool) *AppSettings

func (*AppSettings) SetUserResponseTimeEnabled

func (a *AppSettings) SetUserResponseTimeEnabled(b bool) *AppSettings

func (*AppSettings) SetWebhookURL

func (a *AppSettings) SetWebhookURL(s string) *AppSettings

type AsyncModerationCallback

type AsyncModerationCallback struct {
	Mode      string `json:"mode"`
	ServerURL string `json:"server_url"`
}

type AsyncModerationConfiguration

type AsyncModerationConfiguration struct {
	Callback *AsyncModerationCallback `json:"callback,omitempty"`
	Timeout  int                      `json:"timeout_ms,omitempty"`
}

type AsyncTaskResponse

type AsyncTaskResponse struct {
	TaskID string `json:"task_id"`
	Response
}

type Attachment

type Attachment struct {
	Type string `json:"type,omitempty"` // text, image, audio, video

	AuthorName string `json:"author_name,omitempty"`
	Title      string `json:"title,omitempty"`
	TitleLink  string `json:"title_link,omitempty"`
	Text       string `json:"text,omitempty"`

	ImageURL    string `json:"image_url,omitempty"`
	ThumbURL    string `json:"thumb_url,omitempty"`
	AssetURL    string `json:"asset_url,omitempty"`
	OGScrapeURL string `json:"og_scrape_url,omitempty"`
	MimeType    string `json:"mime_type,omitempty"`

	ExtraData map[string]interface{} `json:"-"`
}

func (Attachment) MarshalJSON

func (a Attachment) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Attachment) UnmarshalJSON

func (a *Attachment) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Ban

type Ban struct {
	Channel   *Channel   `json:"channel,omitempty"`
	User      *User      `json:"user"`
	Expires   *time.Time `json:"expires,omitempty"`
	Reason    string     `json:"reason,omitempty"`
	Shadow    bool       `json:"shadow,omitempty"`
	BannedBy  *User      `json:"banned_by,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

type BanOption

type BanOption func(*banOptions)

type BlockUsersResponse

type BlockUsersResponse struct {
	Response
	BlockedByUserID string    `json:"blocked_by_user_id"`
	BlockedUserID   string    `json:"blocked_user_id"`
	CreatedAt       time.Time `json:"created_at"`
}

type BlockedUserResponse

type BlockedUserResponse struct {
	BlockedByUser   UsersResponse `json:"user"`
	BlockedByUserID string        `json:"user_id"`

	BlockedUser   UsersResponse `json:"blocked_user"`
	BlockedUserID string        `json:"blocked_user_id"`
	CreatedAt     time.Time     `json:"created_at"`
}

type Blocklist

type Blocklist struct {
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	BlocklistBase
}

type BlocklistBase

type BlocklistBase struct {
	Name  string   `json:"name"`
	Words []string `json:"words"`
}

type BlocklistCreateRequest

type BlocklistCreateRequest struct {
	BlocklistBase
}

type Callback

type Callback struct {
	Mode CallbackMode `json:"mode"`
}

type CallbackMode

type CallbackMode string

type Channel

type Channel struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	CID  string `json:"cid"` // full id in format channel_type:channel_ID
	Team string `json:"team"`

	Config ChannelConfig `json:"config"`

	CreatedBy *User `json:"created_by"`
	Disabled  bool  `json:"disabled"`
	Frozen    bool  `json:"frozen"`

	MemberCount int              `json:"member_count"`
	Members     []*ChannelMember `json:"members"`

	MessageCount    *int           `json:"message_count"`
	Messages        []*Message     `json:"messages"`
	PinnedMessages  []*Message     `json:"pinned_messages"`
	PendingMessages []*Message     `json:"pending_messages"`
	Read            []*ChannelRead `json:"read"`

	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	LastMessageAt time.Time `json:"last_message_at"`

	TruncatedBy *User      `json:"truncated_by"`
	TruncatedAt *time.Time `json:"truncated_at"`

	ExtraData map[string]interface{} `json:"-"`

	WatcherCount int     `json:"watcher_count"`
	Watchers     []*User `json:"watchers"`

	PushPreferences *ChannelPushPreferences `json:"push_preferences"`
	Hidden          bool                    `json:"hidden"`
	// contains filtered or unexported fields
}

func (*Channel) AcceptInvite

func (ch *Channel) AcceptInvite(ctx context.Context, userID string, message *Message) (*Response, error)

AcceptInvite accepts an invite to the channel.

func (*Channel) AddChannelMembers

func (ch *Channel) AddChannelMembers(ctx context.Context, members []*ChannelMember, options ...AddMembersOptions) (*Response, error)

AddChannelMembers adds members with given []*ChannelMember to the channel.

func (*Channel) AddFilterTags

func (ch *Channel) AddFilterTags(ctx context.Context, tags []string, message *Message) (*Response, error)

AddFilterTags adds filter tags to the channel.

func (*Channel) AddMembers

func (ch *Channel) AddMembers(ctx context.Context, userIDs []string, options ...AddMembersOptions) (*Response, error)

AddMembers adds members with given user IDs to the channel. If you want to add members with ChannelMember objects, use AddChannelMembers instead.

func (*Channel) AddModerators

func (ch *Channel) AddModerators(ctx context.Context, userIDs ...string) (*Response, error)

AddModerators adds moderators with given IDs to the channel.

Example

See https://getstream.io/chat/docs/channel_members/ for more details.

channel := &Channel{}
newModerators := []string{"bob", "sue"}
ctx := context.Background()

_, _ = channel.AddModerators(ctx, "thierry", "josh")
_, _ = channel.AddModerators(ctx, newModerators...)
_, _ = channel.DemoteModerators(ctx, newModerators...)

func (*Channel) AddModeratorsWithMessage

func (ch *Channel) AddModeratorsWithMessage(ctx context.Context, userIDs []string, msg *Message) (*Response, error)

AddModerators adds moderators with given IDs to the channel and produce system message.

func (*Channel) Archive

func (ch *Channel) Archive(ctx context.Context, userID string) (*ChannelMemberResponse, error)

Archive archives the channel for the user.

func (*Channel) AssignRole

func (ch *Channel) AssignRole(ctx context.Context, assignments []*RoleAssignment, msg *Message) (*Response, error)

AssignRoles assigns roles to members with given IDs.

func (*Channel) BanUser

func (ch *Channel) BanUser(ctx context.Context, targetID, bannedBy string, options ...BanOption) (*Response, error)

BanUser bans targetID on the channel ch.

func (*Channel) CreateDraft

func (ch *Channel) CreateDraft(ctx context.Context, userID string, message *messageRequestMessage) (*CreateDraftResponse, error)

CreateDraft creates or updates a draft message in a channel.

func (*Channel) Delete

func (ch *Channel) Delete(ctx context.Context, options ...DeleteOption) (*Response, error)

Delete removes the channel. Messages are permanently removed.

func (*Channel) DeleteDraft

func (ch *Channel) DeleteDraft(ctx context.Context, userID string, parentID *string) (*Response, error)

DeleteDraft deletes a draft message from a channel.

func (*Channel) DeleteFile

func (ch *Channel) DeleteFile(ctx context.Context, location string) (*Response, error)

DeleteFile removes uploaded file.

func (*Channel) DeleteImage

func (ch *Channel) DeleteImage(ctx context.Context, location string) (*Response, error)

DeleteImage removes uploaded image.

func (*Channel) DeleteReaction

func (ch *Channel) DeleteReaction(ctx context.Context, messageID, reactionType, userID string) (*ReactionResponse, error)

DeleteReaction removes a reaction from message with given ID. Deprecated: DeleteReaction is deprecated, use client.DeleteReaction instead.

func (*Channel) DemoteModerators

func (ch *Channel) DemoteModerators(ctx context.Context, userIDs ...string) (*Response, error)

DemoteModerators moderators with given IDs from the channel.

func (*Channel) DemoteModeratorsWithMessage

func (ch *Channel) DemoteModeratorsWithMessage(ctx context.Context, userIDs []string, msg *Message) (*Response, error)

DemoteModerators moderators with given IDs from the channel and produce system message.

func (*Channel) GetDraft

func (ch *Channel) GetDraft(ctx context.Context, parentID *string, userID string) (*GetDraftResponse, error)

GetDraft retrieves a draft message from a channel.

func (*Channel) GetMessages

func (ch *Channel) GetMessages(ctx context.Context, messageIDs []string) (*GetMessagesResponse, error)

GetMessages returns messages for multiple message ids.

func (*Channel) GetReplies

func (ch *Channel) GetReplies(ctx context.Context, parentID string, options map[string][]string) (*RepliesResponse, error)

GetReplies returns list of the message replies for a parent message. options: Pagination params, ie {limit:10, idlte: 10}

func (*Channel) Hide

func (ch *Channel) Hide(ctx context.Context, userID string) (*Response, error)

Hide makes channel hidden for userID.

func (*Channel) HideWithHistoryClear

func (ch *Channel) HideWithHistoryClear(ctx context.Context, userID string) (*Response, error)

HideWithHistoryClear clear marks channel as hidden and remove all messages for user.

func (*Channel) InviteMembers

func (ch *Channel) InviteMembers(ctx context.Context, userIDs ...string) (*Response, error)

InviteMembers invites users with given IDs to the channel.

func (*Channel) InviteMembersWithMessage

func (ch *Channel) InviteMembersWithMessage(ctx context.Context, userIDs []string, msg *Message) (*Response, error)

InviteMembers invites users with given IDs to the channel and produce system message.

func (*Channel) MarkRead

func (ch *Channel) MarkRead(ctx context.Context, userID string, options ...MarkReadOption) (*Response, error)

MarkRead sends the mark read event for user with given ID, only works if the `read_events` setting is enabled.

func (*Channel) MarkUnread

func (ch *Channel) MarkUnread(ctx context.Context, userID string, options ...MarkUnreadOption) (*Response, error)

MarkUnread message or thread (not both) for specified user.

func (Channel) MarshalJSON

func (ch Channel) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Channel) Mute

func (ch *Channel) Mute(ctx context.Context, userID string, expiration *time.Duration) (*ChannelMuteResponse, error)

Mute mutes the channel. The user will stop receiving messages from the channel.

func (*Channel) PartialUpdate

func (ch *Channel) PartialUpdate(ctx context.Context, update PartialUpdate) (*Response, error)

PartialUpdate set and unset specific fields when it is necessary to retain additional custom data fields on the object. AKA a patch style update.

func (*Channel) PartialUpdateMember

func (ch *Channel) PartialUpdateMember(ctx context.Context, userID string, update PartialUpdate) (*ChannelMemberResponse, error)

PartialUpdateMember set and unset specific fields when it is necessary to retain additional custom data fields on the object. AKA a patch style update.

func (*Channel) Pin

func (ch *Channel) Pin(ctx context.Context, userID string) (*ChannelMemberResponse, error)

Pin pins the channel for the user.

func (*Channel) Query

func (ch *Channel) Query(ctx context.Context, q *QueryRequest) (*QueryResponse, error)

Query makes request to channel api and updates channel internal state.

Example
ctx := context.Background()
channel := &Channel{}
msg, _ := channel.SendMessage(ctx, &Message{Text: "test message", Pinned: true}, channel.CreatedBy.ID)

q := &QueryRequest{
	Messages: &MessagePaginationParamsRequest{PaginationParamsRequest: PaginationParamsRequest{Limit: 1, IDLT: msg.Message.ID}},
	Members:  &PaginationParamsRequest{Limit: 1, Offset: 0},
	Watchers: &PaginationParamsRequest{Limit: 1, Offset: 0},
}
_, _ = channel.Query(ctx, q)

func (*Channel) QueryMembers

func (ch *Channel) QueryMembers(ctx context.Context, q *QueryOption, sorters ...*SortOption) (*QueryMembersResponse, error)

QueryMembers queries members of a channel.

func (*Channel) RefreshState

func (ch *Channel) RefreshState(ctx context.Context) (*QueryResponse, error)

RefreshState makes request to channel api and updates channel internal state.

func (*Channel) RejectInvite

func (ch *Channel) RejectInvite(ctx context.Context, userID string, message *Message) (*Response, error)

RejectInvite rejects an invite to the channel.

func (*Channel) RemoveFilterTags

func (ch *Channel) RemoveFilterTags(ctx context.Context, tags []string, message *Message) (*Response, error)

RemoveFilterTags removes filter tags from the channel and refreshes channel state.

func (*Channel) RemoveMembers

func (ch *Channel) RemoveMembers(ctx context.Context, userIDs []string, message *Message) (*Response, error)

RemoveMembers deletes members with given IDs from the channel.

func (*Channel) SendAction

func (ch *Channel) SendAction(ctx context.Context, msgID string, formData map[string]string) (*MessageResponse, error)

SendAction for a message.

func (*Channel) SendEvent

func (ch *Channel) SendEvent(ctx context.Context, event *Event, userID string) (*Response, error)

SendEvent sends an event on this channel.

func (*Channel) SendFile

func (ch *Channel) SendFile(ctx context.Context, request SendFileRequest) (*SendFileResponse, error)

SendFile sends file to the channel. Returns file url or error.

func (*Channel) SendImage

func (ch *Channel) SendImage(ctx context.Context, request SendFileRequest) (*SendFileResponse, error)

SendFile sends image to the channel. Returns file url or error.

func (*Channel) SendMessage

func (ch *Channel) SendMessage(ctx context.Context, message *Message, userID string, options ...SendMessageOption) (*MessageResponse, error)

SendMessage sends a message to the channel. Returns full message details from server.

func (*Channel) SendReaction

func (ch *Channel) SendReaction(ctx context.Context, reaction *Reaction, messageID, userID string) (*ReactionResponse, error)

SendReaction sends a reaction to message with given ID. Deprecated: SendReaction is deprecated, use client.SendReaction instead.

func (*Channel) ShadowBan

func (ch *Channel) ShadowBan(ctx context.Context, targetID, bannedByID string, options ...BanOption) (*Response, error)

ShadowBan shadow bans targetID on the channel ch.

func (*Channel) Show

func (ch *Channel) Show(ctx context.Context, userID string) (*Response, error)

Show makes channel visible for userID.

func (*Channel) Truncate

func (ch *Channel) Truncate(ctx context.Context, options ...TruncateOption) (*Response, error)

Truncate removes all messages from the channel. You can pass in options such as hard_delete, skip_push or a custom message.

func (*Channel) UnBanUser

func (ch *Channel) UnBanUser(ctx context.Context, targetID string, options ...UnbanOption) (*Response, error)

UnBanUser removes the ban for targetID from the channel ch.

func (*Channel) Unarchive

func (ch *Channel) Unarchive(ctx context.Context, userID string) (*ChannelMemberResponse, error)

Unarchive unarchives the channel for the user.

func (*Channel) UnmarshalJSON

func (ch *Channel) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Channel) Unmute

func (ch *Channel) Unmute(ctx context.Context, userID string) (*Response, error)

Unmute removes a mute from a channel so the user will receive messages again.

func (*Channel) Unpin

func (ch *Channel) Unpin(ctx context.Context, userID string) (*ChannelMemberResponse, error)

Unpin unpins the channel for the user.

func (*Channel) Update

func (ch *Channel) Update(ctx context.Context, properties map[string]interface{}, message *Message) (*Response, error)

Update edits the channel's custom properties.

properties: the object to update the custom properties of this channel with message: optional update message

Example
client := &Client{}
ctx := context.Background()

data := map[string]interface{}{
	"image":      "https://path/to/image",
	"created_by": "elon",
	"roles":      map[string]string{"elon": "admin", "gwynne": "moderator"},
}

spacexChannel := client.Channel("team", "spacex")
if _, err := spacexChannel.Update(ctx, data, nil); err != nil {
	log.Fatalf("Error: %v", err)
}

type ChannelBatchMemberRequest added in v8.1.0

type ChannelBatchMemberRequest struct {
	UserID      string `json:"user_id"`
	ChannelRole string `json:"channel_role,omitempty"`
}

ChannelBatchMemberRequest represents a member in batch operations.

type ChannelBatchOperation added in v8.1.0

type ChannelBatchOperation string

ChannelBatchOperation represents the type of batch update operation.

const (
	BatchUpdateOperationAddMembers       ChannelBatchOperation = "addMembers"
	BatchUpdateOperationRemoveMembers    ChannelBatchOperation = "removeMembers"
	BatchUpdateOperationInviteMembers    ChannelBatchOperation = "inviteMembers"
	BatchUpdateOperationAssignRoles      ChannelBatchOperation = "assignRoles"
	BatchUpdateOperationAddModerators    ChannelBatchOperation = "addModerators"
	BatchUpdateOperationDemoteModerators ChannelBatchOperation = "demoteModerators"
	BatchUpdateOperationHide             ChannelBatchOperation = "hide"
	BatchUpdateOperationShow             ChannelBatchOperation = "show"
	BatchUpdateOperationArchive          ChannelBatchOperation = "archive"
	BatchUpdateOperationUnarchive        ChannelBatchOperation = "unarchive"
	BatchUpdateOperationUpdateData       ChannelBatchOperation = "updateData"
)

type ChannelBatchUpdater added in v8.1.0

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

ChannelBatchUpdater provides convenience methods for batch channel operations.

func (*ChannelBatchUpdater) AddMembers added in v8.1.0

AddMembers adds members to channels matching the filter.

func (*ChannelBatchUpdater) AddModerators added in v8.1.0

AddModerators adds moderators to channels matching the filter.

func (*ChannelBatchUpdater) Archive added in v8.1.0

Archive archives channels matching the filter for the specified members.

func (*ChannelBatchUpdater) AssignRoles added in v8.1.0

AssignRoles assigns roles to members in channels matching the filter.

func (*ChannelBatchUpdater) DemoteModerators added in v8.1.0

DemoteModerators removes moderator role from members in channels matching the filter.

func (*ChannelBatchUpdater) Hide added in v8.1.0

Hide hides channels matching the filter for the specified members.

func (*ChannelBatchUpdater) InviteMembers added in v8.1.0

InviteMembers invites members to channels matching the filter.

func (*ChannelBatchUpdater) RemoveMembers added in v8.1.0

RemoveMembers removes members from channels matching the filter.

func (*ChannelBatchUpdater) Show added in v8.1.0

Show shows channels matching the filter for the specified members.

func (*ChannelBatchUpdater) Unarchive added in v8.1.0

Unarchive unarchives channels matching the filter for the specified members.

func (*ChannelBatchUpdater) UpdateData added in v8.1.0

UpdateData updates data on channels matching the filter.

type ChannelConfig

type ChannelConfig struct {
	Name string `json:"name"`

	// features
	// show typing indicators or not (probably auto disable if more than X users in a channel)
	TypingEvents bool `json:"typing_events"`
	// store who has read the message, or at least when they last viewed the chat
	ReadEvents bool `json:"read_events"`
	// connect events can get very noisy for larger chat groups
	ConnectEvents bool `json:"connect_events"`
	// make messages searchable
	Search    bool `json:"search"`
	Reactions bool `json:"reactions"`
	Reminders bool `json:"reminders"`
	Replies   bool `json:"replies"`
	Mutes     bool `json:"mutes"`
	// enable/disable push notifications
	PushNotifications bool `json:"push_notifications"`
	Uploads           bool `json:"uploads"`
	URLEnrichment     bool `json:"url_enrichment"`
	CustomEvents      bool `json:"custom_events"`
	CountMessages     bool `json:"count_messages"`

	// number of days to keep messages, must be MessageRetentionForever or numeric string
	MessageRetention    string `json:"message_retention"`
	MaxMessageLength    int    `json:"max_message_length"`
	MarkMessagesPending bool   `json:"mark_messages_pending"`

	Automod     modType      `json:"automod"` // disabled, simple or AI
	ModBehavior modBehaviour `json:"automod_behavior"`

	BlockList         string       `json:"blocklist"`
	BlockListBehavior modBehaviour `json:"blocklist_behavior"`
	AutomodThresholds *Thresholds  `json:"automod_thresholds"`

	// Dynamic Partitioning
	PartitionSize int             `json:"partition_size,omitempty"`
	PartitionTTL  *DurationString `json:"partition_ttl,omitempty"`

	SkipLastMsgUpdateForSystemMsgs bool `json:"skip_last_msg_update_for_system_msgs,omitempty"`

	// UserMessageReminders is a flag to enable user message reminders.
	UserMessageReminders bool `json:"user_message_reminders,omitempty"`
}

ChannelConfig is the configuration for a channel.

type ChannelDataUpdate added in v8.1.0

type ChannelDataUpdate struct {
	Frozen                  *bool                  `json:"frozen,omitempty"`
	Disabled                *bool                  `json:"disabled,omitempty"`
	Custom                  map[string]interface{} `json:"custom,omitempty"`
	Team                    string                 `json:"team,omitempty"`
	ConfigOverrides         map[string]interface{} `json:"config_overrides,omitempty"`
	AutoTranslationEnabled  *bool                  `json:"auto_translation_enabled,omitempty"`
	AutoTranslationLanguage string                 `json:"auto_translation_language,omitempty"`
}

ChannelDataUpdate represents data that can be updated on channels in batch.

type ChannelMember

type ChannelMember struct {
	UserID      string `json:"user_id,omitempty"`
	User        *User  `json:"user,omitempty"`
	IsModerator bool   `json:"is_moderator,omitempty"`

	Invited            bool       `json:"invited,omitempty"`
	InviteAcceptedAt   *time.Time `json:"invite_accepted_at,omitempty"`
	InviteRejectedAt   *time.Time `json:"invite_rejected_at,omitempty"`
	Status             string     `json:"status,omitempty"`
	Role               string     `json:"role,omitempty"`
	ChannelRole        string     `json:"channel_role"`
	Banned             bool       `json:"banned"`
	BanExpires         *time.Time `json:"ban_expires,omitempty"`
	ShadowBanned       bool       `json:"shadow_banned"`
	ArchivedAt         *time.Time `json:"archived_at,omitempty"`
	PinnedAt           *time.Time `json:"pinned_at,omitempty"`
	NotificationsMuted bool       `json:"notifications_muted"`

	ExtraData map[string]interface{} `json:"-"`

	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

func (ChannelMember) MarshalJSON

func (m ChannelMember) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ChannelMember) UnmarshalJSON

func (m *ChannelMember) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ChannelMemberResponse

type ChannelMemberResponse struct {
	ChannelMember ChannelMember `json:"channel_member"`
	Response
}

type ChannelMute

type ChannelMute struct {
	User      User       `json:"user"`
	Channel   Channel    `json:"channel"`
	Expires   *time.Time `json:"expires"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

ChannelMute represents a channel mute.

type ChannelMuteResponse

type ChannelMuteResponse struct {
	ChannelMute ChannelMute `json:"channel_mute"`
	Response
}

type ChannelPushPreferences

type ChannelPushPreferences struct {
	ChatLevel     string     `json:"chat_level"`
	CallLevel     string     `json:"call_level"`
	DisabledUntil *time.Time `json:"disabled_until"`
}

type ChannelRead

type ChannelRead struct {
	User                   *User      `json:"user"`
	LastRead               time.Time  `json:"last_read"`
	UnreadMessages         int        `json:"unread_messages"`
	LastDeliveredAt        *time.Time `json:"last_delivered_at,omitempty"`
	LastDeliveredMessageID *string    `json:"last_delivered_message_id,omitempty"`
}

type ChannelRequest

type ChannelRequest struct {
	CreatedBy               *User                  `json:"created_by,omitempty"`
	Team                    string                 `json:"team,omitempty"`
	AutoTranslationEnabled  bool                   `json:"auto_translation_enabled,omitempty"`
	AutoTranslationLanguage string                 `json:"auto_translation_language,omitempty"`
	Frozen                  *bool                  `json:"frozen,omitempty"`
	Disabled                *bool                  `json:"disabled,omitempty"`
	ChannelMembers          []*ChannelMember       `json:"members,omitempty"`
	Members                 []string               `json:"-"`
	Invites                 []string               `json:"invites,omitempty"`
	ExtraData               map[string]interface{} `json:"-"`
	FilterTags              []string               `json:"filter_tags,omitempty"`
}

func (ChannelRequest) MarshalJSON

func (c ChannelRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ChannelRequest) UnmarshalJSON

func (c *ChannelRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ChannelType

type ChannelType struct {
	ChannelConfig

	Commands []*Command `json:"commands"`
	// Deprecated: Use Permissions V2 API instead,
	// that can be found in permission_client.go.
	// See https://getstream.io/chat/docs/go-golang/migrating_from_legacy/?language=go
	Permissions []*ChannelTypePermission `json:"permissions"`
	Grants      map[string][]string      `json:"grants"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func NewChannelType

func NewChannelType(name string) *ChannelType

NewChannelType returns initialized ChannelType with default values.

type ChannelTypePermission

type ChannelTypePermission struct {
	Name   string `json:"name"`   // required
	Action string `json:"action"` // one of: Deny Allow

	Resources []string `json:"resources"` // required
	Roles     []string `json:"roles"`
	Owner     bool     `json:"owner"`
	Priority  int      `json:"priority"` // required
}

type ChannelTypeResponse

type ChannelTypeResponse struct {
	*ChannelType

	Commands []string `json:"commands"`

	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`

	Response
}

type ChannelTypesResponse

type ChannelTypesResponse struct {
	ChannelTypes map[string]*ChannelType `json:"channel_types"`
	Response
}

type ChannelsBatchFilters added in v8.1.0

type ChannelsBatchFilters struct {
	CIDs  interface{} `json:"cids,omitempty"`
	Types interface{} `json:"types,omitempty"`
}

ChannelsBatchFilters represents filters for batch channel updates.

type ChannelsBatchOptions added in v8.1.0

type ChannelsBatchOptions struct {
	Operation ChannelBatchOperation `json:"operation"`
	Filter    ChannelsBatchFilters  `json:"filter"`
	Members   interface{}           `json:"members,omitempty"`
	Data      *ChannelDataUpdate    `json:"data,omitempty"`
}

ChannelsBatchOptions represents options for batch channel updates.

type CheckPushRequest

type CheckPushRequest struct {
	MessageID            string `json:"message_id,omitempty"`
	ApnTemplate          string `json:"apn_template,omitempty"`
	FirebaseTemplate     string `json:"firebase_template,omitempty"`
	FirebaseDataTemplate string `json:"firebase_data_template,omitempty"`
	SkipDevices          *bool  `json:"skip_devices,omitempty"`
	PushProviderName     string `json:"push_provider_name,omitempty"`
	PushProviderType     string `json:"push_provider_type,omitempty"`
	UserID               string `json:"user_id,omitempty"`
	User                 *User  `json:"user,omitempty"`
}

type CheckPushResponse

type CheckPushResponse struct {
	DeviceErrors             map[string]DeviceError `json:"device_errors"`
	GeneralErrors            []string               `json:"general_errors"`
	SkipDevices              *bool                  `json:"skip_devices"`
	RenderedApnTemplate      string                 `json:"rendered_apn_template"`
	RenderedFirebaseTemplate string                 `json:"rendered_firebase_template"`
	RenderedMessage          map[string]string      `json:"rendered_message"`
	Response
}

type CheckSNSRequest

type CheckSNSRequest struct {
	SnsTopicARN string `json:"sns_topic_arn"`
	SnsKey      string `json:"sns_key"`
	SnsSecret   string `json:"sns_secret"`
}

type CheckSNSResponse

type CheckSNSResponse struct {
	Status string                 `json:"status"`
	Error  string                 `json:"error"`
	Data   map[string]interface{} `json:"data"`
	Response
}

type CheckSQSRequest

type CheckSQSRequest struct {
	SqsURL    string `json:"sqs_url"`
	SqsKey    string `json:"sqs_key"`
	SqsSecret string `json:"sqs_secret"`
}

type CheckSQSResponse

type CheckSQSResponse struct {
	Status string                 `json:"status"`
	Error  string                 `json:"error"`
	Data   map[string]interface{} `json:"data"`
	Response
}

type Client

type Client struct {
	BaseURL string
	HTTP    *http.Client `json:"-"`
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey, apiSecret string, options ...ClientOption) (*Client, error)

NewClient creates new stream chat api client.

func NewClientFromEnvVars

func NewClientFromEnvVars() (*Client, error)

NewClientFromEnvVars creates a new Client where the API key is retrieved from STREAM_KEY and the secret from STREAM_SECRET environmental variables.

func (*Client) AddDevice

func (c *Client) AddDevice(ctx context.Context, device *Device) (*Response, error)

AddDevice adds new device.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, _ = client.AddDevice(ctx, &Device{
	ID:           "2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207",
	UserID:       "elon",
	PushProvider: PushProviderAPNS,
})

func (*Client) BanUser

func (c *Client) BanUser(ctx context.Context, targetID, bannedBy string, options ...BanOption) (*Response, error)

BanUser bans targetID.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

// ban a user for 60 minutes from all channel
_, _ = client.BanUser(ctx, "eviluser", "modUser", BanWithExpiration(60), BanWithReason("Banned for one hour"))

// ban a user from the livestream:fortnite channel
channel := client.Channel("livestream", "fortnite")
_, _ = channel.BanUser(ctx, "eviluser", "modUser", BanWithReason("Profanity is not allowed here"))

// remove ban from channel
channel = client.Channel("livestream", "fortnite")
_, _ = channel.UnBanUser(ctx, "eviluser")

// remove global ban
_, _ = client.UnBanUser(ctx, "eviluser")

func (*Client) BlockUser

func (c *Client) BlockUser(ctx context.Context, targetID, userID string) (*BlockUsersResponse, error)

BlockUser blocks targetID.

func (*Client) Channel

func (c *Client) Channel(channelType, channelID string) *Channel

Channel returns a Channel object for future API calls.

func (*Client) ChannelBatchUpdater added in v8.1.0

func (c *Client) ChannelBatchUpdater() *ChannelBatchUpdater

ChannelBatchUpdater returns a ChannelBatchUpdater instance for batch channel operations.

func (*Client) CheckPush

func (c *Client) CheckPush(ctx context.Context, req *CheckPushRequest) (*CheckPushResponse, error)

CheckPush initiates a push test.

func (*Client) CheckSns

func (c *Client) CheckSns(ctx context.Context, req *CheckSNSRequest) (*CheckSNSResponse, error)

func (*Client) CheckSqs

func (c *Client) CheckSqs(ctx context.Context, req *CheckSQSRequest) (*CheckSQSResponse, error)

CheckSqs checks whether the AWS credentials are valid for the SQS queue access.

func (*Client) CommitMessage

func (c *Client) CommitMessage(ctx context.Context, msgID string) (*Response, error)

func (*Client) CreateBlocklist

func (c *Client) CreateBlocklist(ctx context.Context, blocklist *BlocklistCreateRequest) (*Response, error)

CreateBlocklist creates a blocklist.

func (*Client) CreateChannel

func (c *Client) CreateChannel(ctx context.Context, chanType, chanID, userID string, data *ChannelRequest, opts ...CreateChannelOptionFunc) (*CreateChannelResponse, error)

CreateChannel creates new channel of given type and id or returns already created one.

func (*Client) CreateChannelType

func (c *Client) CreateChannelType(ctx context.Context, chType *ChannelType) (*ChannelTypeResponse, error)

CreateChannelType adds new channel type.

Example

See https://getstream.io/chat/docs/channel_features/ for more details.

client := &Client{}
ctx := context.Background()

newChannelType := &ChannelType{
	// Copy the default settings.
	ChannelConfig: DefaultChannelConfig,
}

newChannelType.Name = "public"
newChannelType.Mutes = false
newChannelType.Reactions = false
newChannelType.Permissions = append(newChannelType.Permissions,
	&ChannelTypePermission{
		Name:      "Allow reads for all",
		Priority:  999,
		Resources: []string{"ReadChannel", "CreateMessage"},
		Action:    "Allow",
	},
	&ChannelTypePermission{
		Name:      "Deny all",
		Priority:  1,
		Resources: []string{"*"},
		Action:    "Deny",
	},
)

_, _ = client.CreateChannelType(ctx, newChannelType)

func (*Client) CreateChannelWithMembers

func (c *Client) CreateChannelWithMembers(ctx context.Context, chanType, chanID, userID string, memberIDs ...string) (*CreateChannelResponse, error)

CreateChannelWithMembers creates new channel of given type and id or returns already created one.

func (*Client) CreateCommand

func (c *Client) CreateCommand(ctx context.Context, cmd *Command) (*CommandResponse, error)

CreateCommand registers a new custom command.

Example

See https://getstream.io/chat/docs/custom_commands/ for more details.

client := &Client{}
ctx := context.Background()

newCommand := &Command{
	Name:        "my-command",
	Description: "my command",
	Args:        "[@username]",
	Set:         "custom_cmd_set",
}

_, _ = client.CreateCommand(ctx, newCommand)

func (*Client) CreateGuestUser

func (c *Client) CreateGuestUser(ctx context.Context, user *User) (*GuestUserResponse, error)

CreateGuestUser creates a new guest user.

func (*Client) CreateImport

func (c *Client) CreateImport(ctx context.Context, filePath string, mode ImportMode, opts ...CreateImportOption) (*CreateImportResponse, error)

CreateImport creates a new import task. Note: Do not use this. It is present for internal usage only. This function can, and will, break and/or be removed at any point in time.

func (*Client) CreateImportURL

func (c *Client) CreateImportURL(ctx context.Context, filename string) (*CreateImportURLResponse, error)

CreateImportURL creates a new import URL. Note: Do not use this. It is present for internal usage only. This function can, and will, break and/or be removed at any point in time.

func (*Client) CreateReminder

func (c *Client) CreateReminder(ctx context.Context, messageID, userID string, remindAt *time.Time) (*ReminderResponse, error)

CreateReminder creates a reminder for a message. messageID: The ID of the message to create a reminder for userID: The ID of the user creating the reminder remindAt: When to remind the user (optional)

func (*Client) CreateToken

func (c *Client) CreateToken(userID string, expire time.Time, issuedAt ...time.Time) (string, error)

CreateToken creates a new token for user with optional expire time. Zero time is assumed to be no expire.

func (*Client) DeactivateUser

func (c *Client) DeactivateUser(ctx context.Context, targetID string, options ...DeactivateUserOptions) (*Response, error)

DeactivateUser deactivates the user with the given target user ID.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, _ = client.DeactivateUser(ctx, "userID")

func (*Client) DeactivateUsers

func (c *Client) DeactivateUsers(ctx context.Context, targetIDs []string, options ...DeactivateUserOptions) (*AsyncTaskResponse, error)

DeactivateUsers deactivates the users with the given target user IDs. It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be checked with client.GetTask method.

func (*Client) DeleteBlocklist

func (c *Client) DeleteBlocklist(ctx context.Context, name string) (*Response, error)

DeleteBlocklist deletes a blocklist.

func (*Client) DeleteChannelType

func (c *Client) DeleteChannelType(ctx context.Context, name string) (*Response, error)

DeleteChannelType deletes channel type.

Example
client := &Client{}
ctx := context.Background()

_, _ = client.DeleteChannelType(ctx, "public")

func (*Client) DeleteChannels

func (c *Client) DeleteChannels(ctx context.Context, cids []string, hardDelete bool, options ...DeleteOption) (*AsyncTaskResponse, error)

DeleteChannels deletes channels asynchronously. Channels and messages will be hard deleted if hardDelete is true. It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be check with client.GetTask method.

func (*Client) DeleteCommand

func (c *Client) DeleteCommand(ctx context.Context, cmdName string) (*Response, error)

DeleteCommand deletes a custom command referenced by cmdName.

Example
client := &Client{}
ctx := context.Background()

_, _ = client.DeleteCommand(ctx, "my-command")

func (*Client) DeleteDevice

func (c *Client) DeleteDevice(ctx context.Context, userID, deviceID string) (*Response, error)

DeleteDevice deletes a device from the user.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

deviceID := "2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207"
userID := "elon"
_, _ = client.DeleteDevice(ctx, userID, deviceID)

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, msgID string) (*Response, error)

DeleteMessage soft deletes the message with given msgID.

func (*Client) DeleteMessageWithOptions

func (c *Client) DeleteMessageWithOptions(ctx context.Context, msgID string, options ...DeleteMessageOption) (*Response, error)

DeleteMessageWithOptions deletes the message with given msgID using the provided options.

func (*Client) DeletePushProvider

func (c *Client) DeletePushProvider(ctx context.Context, providerType, name string) (*Response, error)

DeletePushProvider deletes a push provider.

func (*Client) DeleteReaction

func (c *Client) DeleteReaction(ctx context.Context, messageID, reactionType, userID string) (*ReactionResponse, error)

DeleteReaction removes a reaction from message with given ID.

func (*Client) DeleteReminder

func (c *Client) DeleteReminder(ctx context.Context, messageID, userID string) (*Response, error)

DeleteReminder deletes a reminder for a message. messageID: The ID of the message with the reminder userID: The ID of the user who owns the reminder

func (*Client) DeleteScheduledMessage added in v8.7.0

func (c *Client) DeleteScheduledMessage(ctx context.Context, scheduledMessageID string) (*ScheduledMessageResponse, error)

DeleteScheduledMessage cancels a scheduled message so it is never sent, or removes a failed one.

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, targetID string, options ...DeleteUserOption) (*Response, error)

DeleteUser deletes the user with the given target user ID.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, _ = client.DeleteUser(ctx, "userID")
Example (Hard)
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, _ = client.DeleteUser(ctx, "userID",
	DeleteUserWithHardDelete(),
	DeleteUserWithMarkMessagesDeleted(),
)

func (*Client) DeleteUsers

func (c *Client) DeleteUsers(ctx context.Context, userIDs []string, options DeleteUserOptions) (*AsyncTaskResponse, error)

DeleteUsers deletes users asynchronously. User will be deleted either "hard" or "soft" Conversations (1to1 channels) will be deleted if either "hard" or "soft" Messages will be deleted if either "hard" or "soft" NewChannelOwnerID any channels owned by the hard-deleted user will be transferred to this user ID It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be check with client.GetTask method.

func (*Client) ExportChannels

func (c *Client) ExportChannels(ctx context.Context, channels []*ExportableChannel, options *ExportChannelOptions) (*AsyncTaskResponse, error)

ExportChannels requests an asynchronous export of the provided channels. It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be check with client.GetTask method.

func (*Client) ExportUser

func (c *Client) ExportUser(ctx context.Context, targetID string) (*ExportUserResponse, error)

ExportUser exports the user with the given target user ID.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

user, _ := client.ExportUser(ctx, "userID")
log.Printf("%#v", user)

func (*Client) ExportUsers

func (c *Client) ExportUsers(ctx context.Context, userIDs []string) (*AsyncTaskResponse, error)

ExportUsers requests an asynchronous export of the provided user IDs. It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be check with client.GetTask method.

func (*Client) FlagMessage

func (c *Client) FlagMessage(ctx context.Context, msgID, userID string) (*Response, error)

FlagMessage flags the message with given msgID.

func (*Client) FlagUser

func (c *Client) FlagUser(ctx context.Context, targetID, flaggedBy string) (*Response, error)

FlagUser flags the user with the given targetID.

func (*Client) GetAppSettings

func (c *Client) GetAppSettings(ctx context.Context) (*AppResponse, error)

GetAppSettings returns app settings.

func (*Client) GetBlockedUser

func (c *Client) GetBlockedUser(ctx context.Context, blockedBy string) (*GetBlockedUsersResponse, error)

GetBlockedUser returns blocked user

func (*Client) GetBlocklist

func (c *Client) GetBlocklist(ctx context.Context, name string) (*GetBlocklistResponse, error)

GetBlocklist gets a blocklist.

func (*Client) GetChannelType

func (c *Client) GetChannelType(ctx context.Context, chanType string) (*GetChannelTypeResponse, error)

GetChannelType returns information about channel type.

Example
client := &Client{}
ctx := context.Background()
_, _ = client.GetChannelType(ctx, "public")

func (*Client) GetCommand

func (c *Client) GetCommand(ctx context.Context, cmdName string) (*GetCommandResponse, error)

GetCommand retrieves a custom command referenced by cmdName.

Example
client := &Client{}
ctx := context.Background()
_, _ = client.GetCommand(ctx, "my-command")

func (*Client) GetDevices

func (c *Client) GetDevices(ctx context.Context, userID string) (*DevicesResponse, error)

GetDevices retrieves the list of devices for user.

func (*Client) GetExportChannelsTask

func (c *Client) GetExportChannelsTask(ctx context.Context, taskID string) (*TaskResponse, error)

GetExportChannelsTask returns current state of the export task.

func (*Client) GetImport

func (c *Client) GetImport(ctx context.Context, id string) (*GetImportResponse, error)

GetImport returns an import task. Note: Do not use this. It is present for internal usage only. This function can, and will, break and/or be removed at any point in time.

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, msgID string) (*MessageResponse, error)

GetMessage returns message by ID.

func (*Client) GetRateLimits

func (c *Client) GetRateLimits(ctx context.Context, options ...GetRateLimitsOption) (GetRateLimitsResponse, error)

GetRateLimits returns the current rate limit quotas and usage. If no options are passed, all the limits for all platforms are returned.

func (*Client) GetReactions

func (c *Client) GetReactions(ctx context.Context, messageID string, options map[string][]string) (*ReactionsResponse, error)

GetReactions returns list of the reactions for message with given ID. options: Pagination params, ie {"limit":{"10"}, "idlte": {"10"}}

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id string) (*TaskResponse, error)

GetTask returns the status of a task that has been ran asynchronously.

func (*Client) GetUserActiveLocations

func (c *Client) GetUserActiveLocations(ctx context.Context, userID string) (*ActiveLiveLocationsResponse, error)

GetUserActiveLocations returns all active live locations for a user

func (*Client) HardDeleteMessage

func (c *Client) HardDeleteMessage(ctx context.Context, msgID string) (*Response, error)

HardDeleteMessage deletes the message with given msgID. This is permanent.

func (*Client) ListBlocklists

func (c *Client) ListBlocklists(ctx context.Context) (*ListBlocklistsResponse, error)

ListBlocklists lists all blocklists.

func (*Client) ListChannelTypes

func (c *Client) ListChannelTypes(ctx context.Context) (*ChannelTypesResponse, error)

ListChannelTypes returns all channel types.

Example
client := &Client{}
ctx := context.Background()
_, _ = client.ListChannelTypes(ctx)

func (*Client) ListCommands

func (c *Client) ListCommands(ctx context.Context) (*CommandsResponse, error)

ListCommands returns a list of custom commands.

Example
client := &Client{}
ctx := context.Background()
_, _ = client.ListCommands(ctx)

func (*Client) ListImports

func (c *Client) ListImports(ctx context.Context, opts *ListImportsOptions) (*ListImportsResponse, error)

ListImports returns all import tasks. Note: Do not use this. It is present for internal usage only. This function can, and will, break and/or be removed at any point in time.

func (*Client) ListPushProviders

func (c *Client) ListPushProviders(ctx context.Context) (*PushProviderListResponse, error)

ListPushProviders returns the list of push providers.

func (*Client) MarkAllRead

func (c *Client) MarkAllRead(ctx context.Context, userID string) (*Response, error)

MarkAllRead marks all messages as read for userID.

func (*Client) MarkDelivered

func (c *Client) MarkDelivered(ctx context.Context, options *MarkDeliveredOptions) (*Response, error)

MarkDelivered sends the mark delivered event for this user, only works if the `delivery_receipts` setting is enabled. Note: Unlike the JavaScript SDK, this method doesn't automatically check delivery receipts settings as the Go SDK doesn't maintain user state. You should check this manually if needed.

func (*Client) MarkDeliveredSimple

func (c *Client) MarkDeliveredSimple(ctx context.Context, userID, messageID, channelCID string) (*Response, error)

MarkDeliveredSimple is a convenience method to mark a message as delivered for a specific user.

func (*Client) MuteUser

func (c *Client) MuteUser(ctx context.Context, targetID, mutedBy string, options ...MuteOption) (*Response, error)

MuteUser mutes targetID.

func (*Client) MuteUsers

func (c *Client) MuteUsers(ctx context.Context, targetIDs []string, mutedBy string, options ...MuteOption) (*Response, error)

MuteUsers mutes all users in targetIDs.

func (*Client) ParseSns added in v8.6.0

func (c *Client) ParseSns(body string) (*Event, error)

ParseSns is the client-bound form of the package-level ParseSns helper. SNS deliveries from Stream are not HMAC-signed (AWS signs the notification envelope), so this is a pure decode-and-parse call.

func (*Client) ParseSqs added in v8.6.0

func (c *Client) ParseSqs(body string) (*Event, error)

ParseSqs is the client-bound form of the package-level ParseSqs helper. SQS deliveries from Stream are not HMAC-signed (the queue itself is the authentication layer via IAM), so this is a pure decode-and-parse call.

func (*Client) PartialUpdateMessage

func (c *Client) PartialUpdateMessage(ctx context.Context, messageID string, updates *MessagePartialUpdateRequest) (*MessageResponse, error)

PartialUpdateMessage partially updates message with given msgID.

func (*Client) PartialUpdateUser

func (c *Client) PartialUpdateUser(ctx context.Context, update PartialUserUpdate) (*User, error)

PartialUpdateUser makes partial update for single user.

func (*Client) PartialUpdateUsers

func (c *Client) PartialUpdateUsers(ctx context.Context, updates []PartialUserUpdate) (*UsersResponse, error)

PartialUpdateUsers makes partial update for users.

func (*Client) Permissions

func (c *Client) Permissions() *PermissionClient

Permissions returns a client for handling app permissions.

func (*Client) PinMessage

func (c *Client) PinMessage(ctx context.Context, msgID, pinnedByID string, expiration *time.Time) (*MessageResponse, error)

PinMessage pins the message with given msgID.

func (*Client) QueryBannedUsers

func (c *Client) QueryBannedUsers(ctx context.Context, q *QueryBannedUsersOptions, sorters ...*SortOption) (*QueryBannedUsersResponse, error)

QueryBannedUsers filters and returns a list of banned users. Banned users can be retrieved in different ways: 1) Using the dedicated query bans endpoint 2) User Search: you can add the banned:true condition to your search. Please note that this will only return users that were banned at the app-level and not the ones that were banned only on channels.

func (*Client) QueryChannels

func (c *Client) QueryChannels(ctx context.Context, q *QueryOption, sort ...*SortOption) (*QueryChannelsResponse, error)

QueryChannels returns list of channels with members and messages, that match QueryOption. If any number of SortOption are set, result will be sorted by field and direction in oder of sort options.

func (*Client) QueryDrafts

func (c *Client) QueryDrafts(ctx context.Context, options *QueryDraftsOptions) (*QueryDraftsResponse, error)

QueryDrafts retrieves all drafts for the current user.

func (*Client) QueryFlagReports

QueryFlagReports returns list of flag reports that match the filter.

func (*Client) QueryFutureChannelBans added in v8.2.0

func (c *Client) QueryFutureChannelBans(ctx context.Context, opts *QueryFutureChannelBansOptions) (*QueryFutureChannelBansResponse, error)

QueryFutureChannelBans queries future channel bans. Future channel bans are automatically applied when a user creates a new channel or adds a member to an existing channel.

func (*Client) QueryMessageFlags

func (c *Client) QueryMessageFlags(ctx context.Context, q *QueryOption) (*QueryMessageFlagsResponse, error)

QueryMessageFlags returns list of message flags that match QueryOption.

func (*Client) QueryMessageHistory

func (c *Client) QueryMessageHistory(ctx context.Context, request QueryMessageHistoryRequest) (*QueryMessageHistoryResponse, error)

func (*Client) QueryReminders

func (c *Client) QueryReminders(ctx context.Context, userID string, filterConditions map[string]interface{}, sort []*SortOption, options map[string]interface{}) (*QueryRemindersResponse, error)

QueryReminders queries reminders based on filter conditions. userID: The ID of the user whose reminders to query filterConditions: Conditions to filter reminders sort: Sort parameters (default: [{field: "remind_at", direction: 1}]) options: Additional query options like limit, offset

func (*Client) QueryScheduledMessages added in v8.7.0

func (c *Client) QueryScheduledMessages(ctx context.Context, options *QueryScheduledMessagesOptions) (*QueryScheduledMessagesResponse, error)

QueryScheduledMessages lists the scheduled and failed messages of one user across channels.

func (*Client) QueryTeamUsageStats added in v8.2.2

func (c *Client) QueryTeamUsageStats(ctx context.Context, req *QueryTeamUsageStatsRequest) (*QueryTeamUsageStatsResponse, error)

QueryTeamUsageStats queries team-level usage statistics from the warehouse database.

Returns usage metrics grouped by team with cursor-based pagination.

Date Range Options (mutually exclusive):

  • Use 'Month' parameter (YYYY-MM format) for monthly aggregated values
  • Use 'StartDate'/'EndDate' parameters (YYYY-MM-DD format) for daily breakdown
  • If neither provided, defaults to current month (monthly mode)

This endpoint is server-side only.

func (*Client) QueryThreads

func (c *Client) QueryThreads(ctx context.Context, query *QueryThreadsRequest) (*QueryThreadsResponse, error)

func (*Client) QueryUsers

func (c *Client) QueryUsers(ctx context.Context, q *QueryUsersOptions, sorters ...*SortOption) (*QueryUsersResponse, error)

QueryUsers returns list of users that match QueryUsersOptions. If any number of SortOption are set, result will be sorted by field and direction in the order of sort options.

func (*Client) ReactivateUser

func (c *Client) ReactivateUser(ctx context.Context, targetID string, options ...ReactivateUserOptions) (*Response, error)

ReactivateUser reactivates a deactivated user with the given target user ID.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, _ = client.ReactivateUser(ctx, "userID")

func (*Client) ReactivateUsers

func (c *Client) ReactivateUsers(ctx context.Context, targetIDs []string, options ...ReactivateUserOptions) (*AsyncTaskResponse, error)

ReactivateUsers reactivates deactivated users with the given target user IDs. It returns an AsyncTaskResponse object which contains the task ID, the status of the task can be checked with client.GetTask method.

func (*Client) RestoreUsers

func (c *Client) RestoreUsers(ctx context.Context, userIDs []string) (*Response, error)

func (*Client) ReviewFlagReport

func (c *Client) ReviewFlagReport(ctx context.Context, reportID string, req *ReviewFlagReportRequest) (*ReviewFlagReportResponse, error)

ReviewFlagReports sends a review of the flag report ID.

func (*Client) RevokeTokens

func (c *Client) RevokeTokens(ctx context.Context, before *time.Time) (*Response, error)

RevokeTokens revokes all tokens for an application issued before given time.

func (*Client) RevokeUserToken

func (c *Client) RevokeUserToken(ctx context.Context, userID string, before *time.Time) (*Response, error)

RevokeUserToken revoke token for a user issued before given time.

func (*Client) RevokeUsersTokens

func (c *Client) RevokeUsersTokens(ctx context.Context, userIDs []string, before *time.Time) (*Response, error)

RevokeUsersTokens revoke tokens for users issued before given time.

func (*Client) Search

func (c *Client) Search(ctx context.Context, request SearchRequest) (*SearchResponse, error)

Search returns messages matching for given keyword.

func (*Client) SearchWithFullResponse

func (c *Client) SearchWithFullResponse(ctx context.Context, request SearchRequest) (*SearchFullResponse, error)

SearchWithFullResponse performs a search and returns the full results.

func (*Client) SendReaction

func (c *Client) SendReaction(ctx context.Context, reaction *Reaction, messageID, userID string) (*ReactionResponse, error)

SendReaction sends a reaction to message with given ID.

Example
client := &Client{}
msgID := "123"
userID := "bob-1"
ctx := context.Background()

reaction := &Reaction{
	Type:      "love",
	ExtraData: map[string]interface{}{"my_custom_field": 123},
}
_, err := client.SendReaction(ctx, reaction, msgID, userID)
if err != nil {
	log.Fatalf("Found Error: %v", err)
}

func (*Client) SendScheduledMessageNow added in v8.7.0

func (c *Client) SendScheduledMessageNow(ctx context.Context, scheduledMessageID string) (*ScheduledMessageResponse, error)

SendScheduledMessageNow moves the send time of a scheduled message to now and queues the send.

func (*Client) SendUserCustomEvent

func (c *Client) SendUserCustomEvent(ctx context.Context, targetUserID string, event *UserCustomEvent) (*Response, error)

SendUserCustomEvent sends a custom event to all connected clients for the target user id.

func (*Client) SetClient

func (c *Client) SetClient(client *http.Client)

SetClient sets a new underlying HTTP client.

func (*Client) ShadowBan

func (c *Client) ShadowBan(ctx context.Context, targetID, bannedByID string, options ...BanOption) (*Response, error)

ShadowBan shadow bans targetID.

func (*Client) TranslateMessage

func (c *Client) TranslateMessage(ctx context.Context, msgID, language string) (*TranslationResponse, error)

TranslateMessage translates the message with given msgID to the given language.

func (*Client) UnBanUser

func (c *Client) UnBanUser(ctx context.Context, targetID string, options ...UnbanOption) (*Response, error)

UnBanUser removes the ban for targetID.

func (*Client) UnPinMessage

func (c *Client) UnPinMessage(ctx context.Context, msgID, userID string) (*MessageResponse, error)

UnPinMessage unpins the message with given msgID.

func (*Client) UnblockUser

func (c *Client) UnblockUser(ctx context.Context, targetID, userID string) (*UnblockUsersResponse, error)

UnblockUser Unblocks targetID.

func (*Client) UnmuteUser

func (c *Client) UnmuteUser(ctx context.Context, targetID, unmutedBy string) (*Response, error)

UnmuteUser unmute targetID.

func (*Client) UnmuteUsers

func (c *Client) UnmuteUsers(ctx context.Context, targetIDs []string, unmutedBy string) (*Response, error)

UnmuteUsers unmute all users in targetIDs.

func (*Client) UnreadCounts

func (c *Client) UnreadCounts(ctx context.Context, userID string) (*UnreadCountsResponse, error)

func (*Client) UnreadCountsBatch

func (c *Client) UnreadCountsBatch(ctx context.Context, userIDs []string) (*UnreadCountsBatchResponse, error)

func (*Client) UpdateAppSettings

func (c *Client) UpdateAppSettings(ctx context.Context, settings *AppSettings) (*Response, error)

UpdateAppSettings makes request to update app settings Example of usage:

settings := NewAppSettings().SetDisableAuth(true)
err := client.UpdateAppSettings(settings)
Example (Disable_auth)

See https://getstream.io/chat/docs/app_settings_auth/ for more details.

client, err := NewClient("XXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
if err != nil {
	log.Fatalf("Err: %v", err)
}
ctx := context.Background()

// disable auth checks, allows dev token usage
settings := NewAppSettings().SetDisableAuth(true)
_, err = client.UpdateAppSettings(ctx, settings)
if err != nil {
	log.Fatalf("Err: %v", err)
}

// re-enable auth checks
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetDisableAuth(false))
if err != nil {
	log.Fatalf("Err: %v", err)
}
Example (Disable_permission)
client, err := NewClient("XXXX", "XXXX")
if err != nil {
	log.Fatalf("Err: %v", err)
}
ctx := context.Background()

// disable permission checkse
settings := NewAppSettings().SetDisablePermissions(true)
_, err = client.UpdateAppSettings(ctx, settings)
if err != nil {
	log.Fatalf("Err: %v", err)
}

// re-enable permission checks
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetDisablePermissions(false))
if err != nil {
	log.Fatalf("Err: %v", err)
}

func (*Client) UpdateBlocklist

func (c *Client) UpdateBlocklist(ctx context.Context, name string, words []string) (*Response, error)

UpdateBlocklist updates a blocklist.

func (*Client) UpdateChannelType

func (c *Client) UpdateChannelType(ctx context.Context, name string, options map[string]interface{}) (*Response, error)

UpdateChannelType updates channel type.

Example
client := &Client{}
ctx := context.Background()

_, _ = client.UpdateChannelType(ctx, "public", map[string]interface{}{
	"permissions": []map[string]interface{}{
		{
			"name":      "Allow reads for all",
			"priority":  999,
			"resources": []string{"ReadChannel", "CreateMessage"},
			"role":      "*",
			"action":    "Allow",
		},
		{
			"name":      "Deny all",
			"priority":  1,
			"resources": []string{"*"},
			"role":      "*",
			"action":    "Deny",
		},
	},
	"replies":  false,
	"commands": []string{"all"},
})
Example (Bool)
client := &Client{}
ctx := context.Background()

_, _ = client.UpdateChannelType(ctx, "public", map[string]interface{}{
	"typing_events":  false,
	"read_events":    true,
	"connect_events": true,
	"search":         false,
	"reactions":      true,
	"replies":        false,
	"mutes":          true,
})
Example (Other)
client := &Client{}
ctx := context.Background()

_, _ = client.UpdateChannelType(ctx,
	"public",
	map[string]interface{}{
		"automod":            "disabled",
		"message_retention":  "7",
		"max_message_length": 140,
		"commands":           []interface{}{"ban", "unban"},
	},
)
Example (Permissions)
client := &Client{}
ctx := context.Background()

_, _ = client.UpdateChannelType(ctx,
	"public",
	map[string]interface{}{
		"permissions": []map[string]interface{}{
			{
				"name":      "Allow reads for all",
				"priority":  999,
				"resources": []string{"ReadChannel", "CreateMessage"},
				"role":      "*",
				"action":    "Allow",
			},
			{
				"name":      "Deny all",
				"priority":  1,
				"resources": []string{"*"},
				"action":    "Deny",
			},
		},
	},
)

func (*Client) UpdateChannelsBatch added in v8.1.0

func (c *Client) UpdateChannelsBatch(ctx context.Context, options *ChannelsBatchOptions) (*AsyncTaskResponse, error)

UpdateChannelsBatch updates channels in batch based on the provided options.

func (*Client) UpdateCommand

func (c *Client) UpdateCommand(ctx context.Context, cmdName string, update *Command) (*CommandResponse, error)

UpdateCommand updates a custom command referenced by cmdName.

Example
client := &Client{}
ctx := context.Background()

update := Command{Description: "updated description"}
_, _ = client.UpdateCommand(ctx, "my-command", &update)

func (*Client) UpdateMessage

func (c *Client) UpdateMessage(ctx context.Context, msg *Message, msgID string) (*MessageResponse, error)

UpdateMessage updates message with given msgID.

func (*Client) UpdateReminder

func (c *Client) UpdateReminder(ctx context.Context, messageID, userID string, remindAt *time.Time) (*ReminderResponse, error)

UpdateReminder updates a reminder for a message. messageID: The ID of the message with the reminder userID: The ID of the user who owns the reminder remindAt: When to remind the user (optional)

func (*Client) UpdateScheduledMessage added in v8.7.0

func (c *Client) UpdateScheduledMessage(ctx context.Context, scheduledMessageID string, message *Message, scheduledAt *time.Time) (*ScheduledMessageResponse, error)

UpdateScheduledMessage replaces the message and/or the send time of a scheduled message. At least one of message and scheduledAt must be set. message, when set, replaces the scheduled message as a whole; its ID and user are ignored, the sender stays the user who scheduled it.

func (*Client) UpdateUserActiveLocation

func (c *Client) UpdateUserActiveLocation(ctx context.Context, userID string, location *SharedLocation) (*SharedLocationResponse, error)

UpdateUserActiveLocation updates a location

func (*Client) UpsertPushProvider

func (c *Client) UpsertPushProvider(ctx context.Context, provider *PushProvider) (*Response, error)

UpsertPushProvider inserts or updates a push provider.

func (*Client) UpsertUser

func (c *Client) UpsertUser(ctx context.Context, user *User) (*UpsertUserResponse, error)

UpsertUser is a single user version of UpsertUsers for convenience.

Example
client, _ := NewClient("XXXX", "XXXX")
ctx := context.Background()

_, err := client.UpsertUser(ctx, &User{
	ID:   "tommaso",
	Name: "Tommaso",
	Role: "Admin",
})
if err != nil {
	log.Fatalf("Err: %v", err)
}

func (*Client) UpsertUsers

func (c *Client) UpsertUsers(ctx context.Context, users ...*User) (*UsersResponse, error)

UpsertUsers creates the given users. If a user doesn't exist, it will be created. Otherwise, custom data will be extended or updated. Missing data is never removed.

func (*Client) VerifyAndParseWebhook added in v8.6.0

func (c *Client) VerifyAndParseWebhook(body []byte, signature string) (*Event, error)

VerifyAndParseWebhook is the client-bound form of the package-level helper; it pulls the API secret from the receiver so call sites only supply the request body and signature.

func (*Client) VerifyWebhook

func (c *Client) VerifyWebhook(body, signature []byte) (valid bool)

VerifyWebhook validates if hmac signature is correct for message body. The comparison is constant-time.

type ClientOption

type ClientOption func(c *Client)

type Command

type Command struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Args        string `json:"args"`
	Set         string `json:"set"`
}

Command represents a custom command.

type CommandResponse

type CommandResponse struct {
	Command *Command `json:"command"`
	Response
}

CommandResponse represents an API response containing one Command.

type CommandsResponse

type CommandsResponse struct {
	Commands []*Command
}

CommandsResponse represents an API response containing a list of Command.

type CreateChannelOptionFunc

type CreateChannelOptionFunc func(*CreateChannelOptions)

func HideForCreator

func HideForCreator(hideForCreator bool) CreateChannelOptionFunc

type CreateChannelOptions

type CreateChannelOptions struct {
	HideForCreator bool
}

type CreateChannelResponse

type CreateChannelResponse struct {
	Channel *Channel
	*Response
}

type CreateDraftResponse

type CreateDraftResponse struct {
	Draft Draft `json:"draft"`
	Response
}

CreateDraftResponse is the response from CreateDraft.

type CreateImportOption added in v8.3.0

type CreateImportOption func(*createImportRequest)

func WithMergeCustom added in v8.3.0

func WithMergeCustom(mergeCustom bool) CreateImportOption

WithMergeCustom sets whether custom data should be merged during import.

type CreateImportResponse

type CreateImportResponse struct {
	ImportTask *ImportTask `json:"import_task"`
	Response
}

type CreateImportURLResponse

type CreateImportURLResponse struct {
	Path      string `json:"path"`
	UploadURL string `json:"upload_url"`
	Response
}

type DailyValue added in v8.2.2

type DailyValue struct {
	// Date in YYYY-MM-DD format.
	Date string `json:"date"`
	// Value is the metric value for this date.
	Value int64 `json:"value"`
}

DailyValue represents a metric value for a specific date.

type DeactivateUserOptions

type DeactivateUserOptions func(*deactivateUserOptions)

type DeleteMessageOption

type DeleteMessageOption func(*DeleteMessageOptions)

DeleteMessageOption is a function type for configuring delete message options.

func DeleteMessageWithDeleteForMe

func DeleteMessageWithDeleteForMe(userID string) DeleteMessageOption

DeleteMessageWithDeleteForMe sets the delete_for_me option.

func DeleteMessageWithHard

func DeleteMessageWithHard() DeleteMessageOption

DeleteMessageWithHard sets the hard delete option.

type DeleteMessageOptions

type DeleteMessageOptions struct {
	Hard        bool   `json:"hard,omitempty"`
	DeleteForMe bool   `json:"delete_for_me,omitempty"`
	UserID      string `json:"user_id,omitempty"`
}

DeleteMessageOptions contains options for deleting a message.

type DeleteOption added in v8.6.0

type DeleteOption func(*deleteOptions)

func DeleteWithSkipTruncate added in v8.6.0

func DeleteWithSkipTruncate() DeleteOption

DeleteWithSkipTruncate keeps the messages of a soft deleted channel, so a channel recreated with the same ID comes back with its history. It is rejected together with a hard delete, and only distinct channels are eligible.

type DeleteType

type DeleteType string
const (
	HardDelete DeleteType = "hard"
	SoftDelete DeleteType = "soft"
)

type DeleteUserOption

type DeleteUserOption func(*deleteUserOptions)

type DeleteUserOptions

type DeleteUserOptions struct {
	User              DeleteType `json:"user"`
	Messages          DeleteType `json:"messages,omitempty"`
	Conversations     DeleteType `json:"conversations,omitempty"`
	NewChannelOwnerID string     `json:"new_channel_owner_id,omitempty"`
}

type DeliveredMessageConfirmation

type DeliveredMessageConfirmation struct {
	ChannelCID string `json:"cid"`
	MessageID  string `json:"id"`
}

type DeliveryReceipts

type DeliveryReceipts struct {
	Enabled bool `json:"enabled"`
}

type Device

type Device struct {
	ID               string           `json:"id"`                 // The device ID.
	UserID           string           `json:"user_id"`            // The user ID for this device.
	PushProvider     PushProviderType `json:"push_provider"`      // The push provider for this device. One of constants PushProvider*
	PushProviderName string           `json:"push_provider_name"` // The push provider name for this device.
}

type DeviceError

type DeviceError struct {
	Provider     string `json:"provider"`
	ProviderName string `json:"provider_name"`
	ErrorMessage string `json:"error_message"`
}

type DevicesResponse

type DevicesResponse struct {
	Devices []*Device `json:"devices"`
	Response
}

type Draft

type Draft struct {
	ChannelCID    string        `json:"channel_cid"`
	CreatedAt     time.Time     `json:"created_at"`
	Message       *DraftMessage `json:"message"`
	Channel       *Channel      `json:"channel,omitempty"`
	ParentID      string        `json:"parent_id,omitempty"`
	ParentMessage *Message      `json:"parent_message,omitempty"`
	QuotedMessage *Message      `json:"quoted_message,omitempty"`
}

Draft represents a draft message and its associated channel and optionally parent and quoted message.

type DraftMessage

type DraftMessage struct {
	ID              string                 `json:"id"`
	Text            string                 `json:"text"`
	HTML            *string                `json:"html,omitempty"`
	MML             *string                `json:"mml,omitempty"`
	ParentID        *string                `json:"parent_id,omitempty"`
	ShowInChannel   *bool                  `json:"show_in_channel,omitempty"`
	Attachments     []Attachment           `json:"attachments,omitempty"`
	MentionedUsers  []User                 `json:"mentioned_users,omitempty"`
	Custom          map[string]interface{} `json:"custom,omitempty"`
	QuotedMessageID *string                `json:"quoted_message_id,omitempty"`
	Type            string                 `json:"type,omitempty"`
	Silent          *bool                  `json:"silent,omitempty"`
	PollID          string                 `json:"poll_id,omitempty"`
}

DraftMessage represents a draft message.

type DurationString

type DurationString time.Duration

DurationString is a duration that's encoded to as a string in JSON.

func NewDurationString

func NewDurationString(d time.Duration) *DurationString

NewDurationString creates a pointer to a DurationString.

func (DurationString) MarshalJSON

func (d DurationString) MarshalJSON() ([]byte, error)

MarshalJSON encodes the duration as a string such as "2h30m".

func (DurationString) String

func (d DurationString) String() string

String returns the duration as a string such as "2h30m".

func (*DurationString) UnmarshalJSON

func (d *DurationString) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes a duration from a string formatted as [time.Duration.String()](https://golang.org/pkg/time/#Duration.String)

type Error

type Error struct {
	Code            int               `json:"code"`
	Message         string            `json:"message"`
	ExceptionFields map[string]string `json:"exception_fields,omitempty"`
	StatusCode      int               `json:"StatusCode"`
	Duration        string            `json:"duration"`
	MoreInfo        string            `json:"more_info"`

	RateLimit *RateLimitInfo `json:"-"`
}

func (Error) Error

func (e Error) Error() string

type Event

type Event struct {
	CID          string           `json:"cid,omitempty"` // Channel ID
	Type         EventType        `json:"type"`          // Event type, one of Event* constants
	Message      *Message         `json:"message,omitempty"`
	Reaction     *Reaction        `json:"reaction,omitempty"`
	Channel      *Channel         `json:"channel,omitempty"`
	Member       *ChannelMember   `json:"member,omitempty"`
	Members      []*ChannelMember `json:"members,omitempty"`
	User         *User            `json:"user,omitempty"`
	UserID       string           `json:"user_id,omitempty"`
	OwnUser      *User            `json:"me,omitempty"`
	WatcherCount int              `json:"watcher_count,omitempty"`
	DeletedForMe bool             `json:"deleted_for_me,omitempty"`

	// ScheduledMessage is set on scheduled_message.* events. On
	// scheduled_message.sent, the ID of the sent message is in ExtraData["message_id"].
	ScheduledMessage *ScheduledMessage `json:"scheduled_message,omitempty"`

	ExtraData map[string]interface{} `json:"-"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

Event is received from a webhook, or sent with the SendEvent function.

func ParseEvent added in v8.6.0

func ParseEvent(payload []byte) (*Event, error)

ParseEvent decodes the JSON-encoded webhook payload into a typed Event. Unknown event types still parse successfully because Event.Type is a string alias.

func ParseSns added in v8.6.0

func ParseSns(message string) (*Event, error)

ParseSns decodes an SNS-delivered payload (unwraps SNS envelope when present), then parses the inner JSON Event. No HMAC verification.

func ParseSqs added in v8.6.0

func ParseSqs(messageBody string) (*Event, error)

ParseSqs decodes the SQS message Body and returns the parsed Event. Stream does not attach an HMAC to SQS deliveries; use VerifyAndParseWebhook for HTTP.

func VerifyAndParseWebhook added in v8.6.0

func VerifyAndParseWebhook(body []byte, signature, secret string) (*Event, error)

VerifyAndParseWebhook decompresses body when gzipped, verifies the HMAC signature against secret, and returns the parsed Event.

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) error

type EventHook

type EventHook struct {
	ID          string   `json:"id"`
	HookType    HookType `json:"hook_type"`
	Enabled     bool     `json:"enabled"`
	EventTypes  []string `json:"event_types"`
	Product     Product  `json:"product,omitempty"`
	WebhookURL  string   `json:"webhook_url,omitempty"`
	SQSQueueURL string   `json:"sqs_queue_url,omitempty"`
	SQSRegion   string   `json:"sqs_region,omitempty"`
	SQSAuthType string   `json:"sqs_auth_type,omitempty"`
	SQSKey      string   `json:"sqs_key,omitempty"`
	SQSSecret   string   `json:"sqs_secret,omitempty"`
	SQSRoleARN  string   `json:"sqs_role_arn,omitempty"`
	SNSTopicARN string   `json:"sns_topic_arn,omitempty"`
	SNSRegion   string   `json:"sns_region,omitempty"`
	SNSAuthType string   `json:"sns_auth_type,omitempty"`
	SNSKey      string   `json:"sns_key,omitempty"`
	SNSSecret   string   `json:"sns_secret,omitempty"`
	SNSRoleARN  string   `json:"sns_role_arn,omitempty"`

	// pending message config
	TimeoutMs int       `json:"timeout_ms,omitempty"`
	Callback  *Callback `json:"callback,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type EventType

type EventType string

EventType marks which of the various sub-types of a webhook event you are receiving or sending.

const (
	// EventMessageNew is fired when a new message is added.
	EventMessageNew EventType = "message.new"
	// EventMessageUpdated is fired when a message is updated.
	EventMessageUpdated EventType = "message.updated"
	// EventMessageDeleted is fired when a message is deleted.
	EventMessageDeleted EventType = "message.deleted"
	// EventMessageRead is fired when a user calls mark as read.
	EventMessageRead EventType = "message.read"

	// EventReactionNew is fired when a message reaction is added.
	EventReactionNew EventType = "reaction.new"
	// EventReactionDeleted is fired when a message reaction deleted.
	EventReactionDeleted EventType = "reaction.deleted"

	// EventMemberAdded is fired when a member is added to a channel.
	EventMemberAdded EventType = "member.added"
	// EventMemberUpdated is fired when a member is updated.
	EventMemberUpdated EventType = "member.updated"
	// EventMemberRemoved is fired when a member is removed from a channel.
	EventMemberRemoved EventType = "member.removed"

	// EventChannelCreated is fired when a channel is created.
	EventChannelCreated EventType = "channel.created"
	// EventChannelUpdated is fired when a channel is updated.
	EventChannelUpdated EventType = "channel.updated"
	// EventChannelDeleted is fired when a channel is deleted.
	EventChannelDeleted EventType = "channel.deleted"
	// EventChannelTruncated is fired when a channel is truncated.
	EventChannelTruncated EventType = "channel.truncated"

	// EventHealthCheck is fired when a user is updated.
	EventHealthCheck EventType = "health.check"

	// EventNotificationNewMessage and family are fired when a notification is
	// created, marked read, invited to a channel, and so on.
	EventNotificationNewMessage         EventType = "notification.message_new"
	EventNotificationMarkRead           EventType = "notification.mark_read"
	EventNotificationInvited            EventType = "notification.invited"
	EventNotificationInviteAccepted     EventType = "notification.invite_accepted"
	EventNotificationAddedToChannel     EventType = "notification.added_to_channel"
	EventNotificationRemovedFromChannel EventType = "notification.removed_from_channel"
	EventNotificationMutesUpdated       EventType = "notification.mutes_updated"

	// EventTypingStart and EventTypingStop are fired when a user starts or stops typing.
	EventTypingStart EventType = "typing.start"
	EventTypingStop  EventType = "typing.stop"

	// EventUserMuted is fired when a user is muted.
	EventUserMuted EventType = "user.muted"
	// EventUserUnmuted is fired when a user is unmuted.
	EventUserUnmuted         EventType = "user.unmuted"
	EventUserPresenceChanged EventType = "user.presence.changed"
	EventUserWatchingStart   EventType = "user.watching.start"
	EventUserWatchingStop    EventType = "user.watching.stop"
	EventUserUpdated         EventType = "user.updated"

	EventUserUnreadMessageReminder EventType = "user.unread_message_reminder"

	// Scheduled message events. Only failed and sent are delivered to webhooks;
	// created, updated and deleted go to the scheduling user's connections only.
	EventScheduledMessageCreated EventType = "scheduled_message.created"
	EventScheduledMessageUpdated EventType = "scheduled_message.updated"
	EventScheduledMessageDeleted EventType = "scheduled_message.deleted"
	EventScheduledMessageSent    EventType = "scheduled_message.sent"
	EventScheduledMessageFailed  EventType = "scheduled_message.failed"
)

type ExportChannelOptions

type ExportChannelOptions struct {
	ClearDeletedMessageText  *bool  `json:"clear_deleted_message_text,omitempty"`
	IncludeTruncatedMessages *bool  `json:"include_truncated_messages,omitempty"`
	ExportUsers              *bool  `json:"export_users,omitempty"`
	Version                  string `json:"version,omitempty"`
}

type ExportUserResponse

type ExportUserResponse struct {
	User      *User       `json:"user"`
	Messages  []*Message  `json:"messages"`
	Reactions []*Reaction `json:"reactions"`
	Response
}

type ExportableChannel

type ExportableChannel struct {
	Type          string     `json:"type"`
	ID            string     `json:"id"`
	MessagesSince *time.Time `json:"messages_since,omitempty"`
	MessagesUntil *time.Time `json:"messages_until,omitempty"`
}

type ExtendedFlagReport

type ExtendedFlagReport struct {
	FlagReport
	ReviewResult  string                 `json:"review_result"`
	ReviewDetails map[string]interface{} `json:"review_details"`
	ReviewedAt    time.Time              `json:"reviewed_at"`
	ReviewedBy    User                   `json:"reviewed_by"`
}

type FileUploadConfig

type FileUploadConfig struct {
	AllowedFileExtensions []string `json:"allowed_file_extensions,omitempty"`
	BlockedFileExtensions []string `json:"blocked_file_extensions,omitempty"`
	AllowedMimeTypes      []string `json:"allowed_mime_types,omitempty"`
	BlockedMimeTypes      []string `json:"blocked_mime_types,omitempty"`
	SizeLimit             *int     `json:"size_limit,omitempty"`
}

type FirebaseConfig

type FirebaseConfig struct {
	Enabled              bool   `json:"enabled"`
	NotificationTemplate string `json:"notification_template"`
	DataTemplate         string `json:"data_template"`
}

type FirebaseConfigRequest

type FirebaseConfigRequest struct {
	ServerKey            string  `json:"server_key"`
	NotificationTemplate string  `json:"notification_template,omitempty"`
	DataTemplate         string  `json:"data_template,omitempty"`
	APNTemplate          *string `json:"apn_template,omitempty"`
	CredentialsJSON      string  `json:"credentials_json,omitempty"`
}

type FlagReport

type FlagReport struct {
	ID            string    `json:"id"`
	Message       *Message  `json:"message"`
	FlagsCount    int       `json:"flags_count"`
	MessageUserID string    `json:"message_user_id"`
	ChannelCid    string    `json:"channel_cid"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type FutureChannelBan added in v8.2.0

type FutureChannelBan struct {
	User      *User      `json:"user,omitempty"`
	Expires   *time.Time `json:"expires,omitempty"`
	Reason    string     `json:"reason,omitempty"`
	Shadow    bool       `json:"shadow,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

FutureChannelBan represents a future channel ban entry.

type GetBlockedUsersResponse

type GetBlockedUsersResponse struct {
	Response
	BlockedUsers []*BlockedUserResponse `json:"blocks"`
}

type GetBlocklistResponse

type GetBlocklistResponse struct {
	Blocklist *Blocklist `json:"blocklist"`
	Response
}

type GetChannelTypeResponse

type GetChannelTypeResponse struct {
	*ChannelType
	Response
}

type GetCommandResponse

type GetCommandResponse struct {
	*Command
	Response
}

type GetDraftResponse

type GetDraftResponse struct {
	Draft Draft `json:"draft"`
	Response
}

GetDraftResponse is the response from GetDraft.

type GetImportResponse

type GetImportResponse struct {
	ImportTask *ImportTask `json:"import_task"`
	Response
}

type GetMessagesResponse

type GetMessagesResponse struct {
	Messages []*Message `json:"messages"`
	Response
}

type GetPermissionResponse

type GetPermissionResponse struct {
	Permission *Permission `json:"permission"`
	Response
}

type GetRateLimitsOption

type GetRateLimitsOption func(p *getRateLimitsParams)

GetRateLimitsOption configures the Client.GetRateLimits call.

func WithAndroid

func WithAndroid() GetRateLimitsOption

WithAndroid restricts the returned limits to Android clients only.

func WithEndpoints

func WithEndpoints(endpoints ...string) GetRateLimitsOption

WithEndpoints restricts the returned limits info to the specified endpoints.

func WithIOS

func WithIOS() GetRateLimitsOption

WithIOS restricts the returned limits to iOS clients only.

func WithServerSide

func WithServerSide() GetRateLimitsOption

WithServerSide restricts the returned limits to server-side clients only.

func WithWeb

func WithWeb() GetRateLimitsOption

WithWeb restricts the returned limits to web clients only.

type GetRateLimitsResponse

type GetRateLimitsResponse struct {
	ServerSide RateLimitsMap `json:"server_side,omitempty"`
	Android    RateLimitsMap `json:"android,omitempty"`
	IOS        RateLimitsMap `json:"ios,omitempty"`
	Web        RateLimitsMap `json:"web,omitempty"`
}

GetRateLimitsResponse is the response of the Client.GetRateLimits call. It includes, if present, the rate limits for the supported platforms, namely server-side, Android, iOS, and web.

type GuestUserResponse

type GuestUserResponse struct {
	User        *User  `json:"user"`
	AccessToken string `json:"access_token"`
	Response
}

type HookType

type HookType string

type HuaweiConfig

type HuaweiConfig struct {
	Enabled bool `json:"enabled"`
}

type HuaweiConfigRequest

type HuaweiConfigRequest struct {
	ID     string `json:"id"`
	Secret string `json:"secret"`
}

type ImportMode

type ImportMode string
const (
	InsertMode ImportMode = "insert"
	UpsertMode ImportMode = "upsert"
)

type ImportTask

type ImportTask struct {
	CreatedAt time.Time            `json:"created_at"`
	Path      string               `json:"path"`
	Mode      ImportMode           `json:"mode"`
	History   []*ImportTaskHistory `json:"history"`
	ID        string               `json:"id"`
	State     string               `json:"state"`
	UpdatedAt time.Time            `json:"updated_at"`
	Result    interface{}          `json:"result"`
	Size      *int                 `json:"size"`
}

type ImportTaskHistory

type ImportTaskHistory struct {
	CreatedAt time.Time `json:"created_at"`
	NextState string    `json:"next_state"`
	PrevState string    `json:"prev_state"`
}

type LabelThresholds

type LabelThresholds struct {
	Flag  float32 `json:"flag"`
	Block float32 `json:"block"`
}

type ListBlocklistsResponse

type ListBlocklistsResponse struct {
	Blocklists []*Blocklist `json:"blocklists"`
	Response
}

type ListImportsOptions

type ListImportsOptions struct {
	Limit  int
	Offset int
}

type ListImportsResponse

type ListImportsResponse struct {
	ImportTasks []*ImportTask `json:"import_tasks"`
	Response
}

type ListPermissionsResponse

type ListPermissionsResponse struct {
	Permissions []*Permission `json:"permissions"`
	Response
}

type MarkDeliveredOptions

type MarkDeliveredOptions struct {
	LatestDeliveredMessages []DeliveredMessageConfirmation `json:"latest_delivered_messages"`
	User                    *User                          `json:"user,omitempty"`
	UserID                  string                         `json:"user_id,omitempty"`
}

MarkDeliveredOptions represents the options for marking messages as delivered.

type MarkReadOption

type MarkReadOption func(*markReadOption)

type MarkUnreadOption

type MarkUnreadOption func(option *markUnreadOption)

type Message

type Message struct {
	ID  string `json:"id"`
	CID string `json:"cid"`

	Text string `json:"text"`
	HTML string `json:"html"`

	Type   MessageType `json:"type,omitempty"` // one of MessageType* constants
	Silent bool        `json:"silent,omitempty"`

	User            *User          `json:"user"`
	UserID          string         `json:"user_id"`
	Attachments     []*Attachment  `json:"attachments"`
	LatestReactions []*Reaction    `json:"latest_reactions"` // last reactions
	OwnReactions    []*Reaction    `json:"own_reactions"`
	ReactionCounts  map[string]int `json:"reaction_counts"`
	ReactionScores  map[string]int `json:"reaction_scores"`

	ParentID           string  `json:"parent_id,omitempty"`       // id of parent message if it's reply
	ShowInChannel      bool    `json:"show_in_channel,omitempty"` // show reply message also in channel
	ThreadParticipants []*User `json:"thread_participants,omitempty"`

	ReplyCount           int      `json:"reply_count,omitempty"`
	QuotedMessageID      string   `json:"quoted_message_id,omitempty"`
	MentionedUsers       []*User  `json:"mentioned_users"`
	RestrictedVisibility []string `json:"restricted_visibility,omitempty"`

	Command string `json:"command,omitempty"`

	Shadowed   bool       `json:"shadowed,omitempty"`
	Pinned     bool       `json:"pinned,omitempty"`
	PinnedAt   *time.Time `json:"pinned_at,omitempty"`
	PinnedBy   *User      `json:"pinned_by,omitempty"`
	PinExpires *time.Time `json:"pin_expires,omitempty"`

	ImageModerationLabels map[string][]string `json:"image_labels,omitempty"`

	MML  string            `json:"mml,omitempty"`
	I18n map[string]string `json:"i18n,omitempty"`

	CreatedAt    *time.Time `json:"created_at,omitempty"`
	UpdatedAt    *time.Time `json:"updated_at,omitempty"`
	DeletedAt    *time.Time `json:"deleted_at,omitempty"`
	DeletedForMe bool       `json:"deleted_for_me,omitempty"`

	ExtraData map[string]interface{} `json:"-"`

	SharedLocation *SharedLocation `json:"shared_location,omitempty"`
	Member         *ChannelMember  `json:"member,omitempty"`
}

func (Message) MarshalJSON

func (m Message) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type MessageFlag

type MessageFlag struct {
	CreatedByAutomod bool `json:"created_by_automod"`
	ModerationResult *struct {
		MessageID            string `json:"message_id"`
		Action               string `json:"action"`
		ModeratedBy          string `json:"moderated_by"`
		BlockedWord          string `json:"blocked_word"`
		BlocklistName        string `json:"blocklist_name"`
		ModerationThresholds *struct {
			Explicit *struct {
				Flag  float32 `json:"flag"`
				Block float32 `json:"block"`
			} `json:"explicit"`
			Spam *struct {
				Flag  float32 `json:"flag"`
				Block float32 `json:"block"`
			} `json:"spam"`
			Toxic *struct {
				Flag  float32 `json:"flag"`
				Block float32 `json:"block"`
			} `json:"toxic"`
		} `json:"moderation_thresholds"`
		AIModerationResponse *struct {
			Toxic    float32 `json:"toxic"`
			Explicit float32 `json:"explicit"`
			Spam     float32 `json:"spam"`
		} `json:"ai_moderation_response"`
		UserKarma    float64   `json:"user_karma"`
		UserBadKarma bool      `json:"user_bad_karma"`
		CreatedAt    time.Time `json:"created_at"`
		UpdatedAt    time.Time `json:"updated_at"`
	} `json:"moderation_result"`
	User    *User    `json:"user"`
	Message *Message `json:"message"`

	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	ReviewedAt time.Time `json:"reviewed_at"`
	ReviewedBy *User     `json:"reviewed_by"`
	ApprovedAt time.Time `json:"approved_at"`
	RejectedAt time.Time `json:"rejected_at"`
}

type MessageHistoryEntry

type MessageHistoryEntry struct {
	MessageID          string    `json:"message_id"`
	MessageUpdatedByID string    `json:"message_updated_by_id"`
	MessageUpdatedAt   time.Time `json:"message_updated_at"`

	Text        string                 `json:"text"`
	Attachments []*Attachment          `json:"attachments"`
	ExtraData   map[string]interface{} `json:"-"`
}

func (MessageHistoryEntry) MarshalJSON

func (m MessageHistoryEntry) MarshalJSON() ([]byte, error)

func (*MessageHistoryEntry) UnmarshalJSON

func (m *MessageHistoryEntry) UnmarshalJSON(data []byte) error

type MessagePaginationParamsRequest

type MessagePaginationParamsRequest struct {
	PaginationParamsRequest
	CreatedAtAfterEq  *time.Time `json:"created_at_after_or_equal,omitempty"`
	CreatedAtAfter    *time.Time `json:"created_at_after,omitempty"`
	CreatedAtBeforeEq *time.Time `json:"created_at_before_or_equal,omitempty"`
	CreatedAtBefore   *time.Time `json:"created_at_before,omitempty"`
	IDAround          string     `json:"id_around,omitempty"`
	CreatedAtAround   *time.Time `json:"created_at_around,omitempty"`
}

type MessagePartialUpdateRequest

type MessagePartialUpdateRequest struct {
	PartialUpdate
	UserID        string `json:"user_id"`
	SkipEnrichURL bool   `json:"skip_enrich_url"`
}

type MessageResponse

type MessageResponse struct {
	Message                *Message          `json:"message"`
	PendingMessageMetadata map[string]string `json:"pending_message_metadata,omitempty"`
	// ScheduledMessage is set only when the message was sent WithScheduledAt.
	// Message then holds the content as it will be sent; it is not in the channel yet.
	ScheduledMessage *ScheduledMessage `json:"scheduled_message,omitempty"`
	Response
}

type MessageType

type MessageType string
const (
	MessageTypeRegular   MessageType = "regular"
	MessageTypeError     MessageType = "error"
	MessageTypeReply     MessageType = "reply"
	MessageTypeSystem    MessageType = "system"
	MessageTypeEphemeral MessageType = "ephemeral"
)

type MetricStats added in v8.2.2

type MetricStats struct {
	// Daily contains per-day values (only present in daily mode).
	Daily []DailyValue `json:"daily,omitempty"`
	// Total is the aggregated total value.
	Total int64 `json:"total"`
}

MetricStats represents statistics for a single metric with optional daily breakdown.

type Mute

type Mute struct {
	User      User       `json:"user"`
	Target    User       `json:"target"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Expires   *time.Time `json:"expires"`
}

Mute represents a user mute.

type MuteOption

type MuteOption func(*muteOptions)

type PagerRequest

type PagerRequest struct {
	Limit *int    `json:"limit" validate:"omitempty,gte=0,lte=100"`
	Next  *string `json:"next"`
	Prev  *string `json:"prev"`
}

type PagerResponse

type PagerResponse struct {
	Next *string `json:"next,omitempty"`
	Prev *string `json:"prev,omitempty"`
}

type PaginationParamsRequest

type PaginationParamsRequest struct {
	Limit  int    `json:"limit,omitempty"`
	Offset int    `json:"offset,omitempty"`
	IDGTE  string `json:"id_gte,omitempty"`
	IDGT   string `json:"id_gt,omitempty"`
	IDLTE  string `json:"id_lte,omitempty"`
	IDLT   string `json:"id_lt,omitempty"`
}

type ParsedPredefinedFilterResponse added in v8.2.0

type ParsedPredefinedFilterResponse struct {
	Name   string                 `json:"name"`
	Filter map[string]interface{} `json:"filter"`
	Sort   []*SortOption          `json:"sort,omitempty"`
}

ParsedPredefinedFilterResponse contains the interpolated filter and sort from a predefined filter. This is returned in the QueryChannels response when using a predefined filter.

type PartialUpdate

type PartialUpdate struct {
	Set   map[string]interface{} `json:"set"`
	Unset []string               `json:"unset"`
}

type PartialUserUpdate

type PartialUserUpdate struct {
	ID    string                 `json:"id"`              // User ID, required
	Set   map[string]interface{} `json:"set,omitempty"`   // map of field.name => value; optional
	Unset []string               `json:"unset,omitempty"` // list of field names to unset
}

PartialUserUpdate request; Set and Unset fields can be set at same time, but should not be same field, for example you cannot set 'field.path.name' and unset 'field.path' at the same time. Field path should not contain spaces or dots (dot is path separator).

type Permission

type Permission struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Action      string                 `json:"action"`
	Owner       bool                   `json:"owner"`
	SameTeam    bool                   `json:"same_team"`
	Condition   map[string]interface{} `json:"condition"`
	Custom      bool                   `json:"custom"`
	Level       string                 `json:"level"`
}

type PermissionClient

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

func (*PermissionClient) CreatePermission

func (p *PermissionClient) CreatePermission(ctx context.Context, perm *Permission) (*Response, error)

CreatePermission creates a new permission.

func (*PermissionClient) CreateRole

func (p *PermissionClient) CreateRole(ctx context.Context, name string) (*Response, error)

CreateRole creates a new role.

func (*PermissionClient) DeletePermission

func (p *PermissionClient) DeletePermission(ctx context.Context, id string) (*Response, error)

DeletePermission deletes a permission by id.

func (*PermissionClient) DeleteRole

func (p *PermissionClient) DeleteRole(ctx context.Context, name string) (*Response, error)

DeleteRole deletes an existing role by name.

func (*PermissionClient) GetPermission

func (p *PermissionClient) GetPermission(ctx context.Context, id string) (*GetPermissionResponse, error)

GetPermission returns a permission by id.

func (*PermissionClient) ListPermissions

func (p *PermissionClient) ListPermissions(ctx context.Context) (*ListPermissionsResponse, error)

ListPermissions returns all permissions of an app.

func (*PermissionClient) ListRoles

func (p *PermissionClient) ListRoles(ctx context.Context) (*RolesResponse, error)

ListRole returns all roles.

func (*PermissionClient) UpdatePermission

func (p *PermissionClient) UpdatePermission(ctx context.Context, id string, perm *Permission) (*Response, error)

UpdatePermission updates an existing permission by id. Only custom permissions can be updated.

type Policy

type Policy struct {
	Name      string    `json:"name"`
	Resources []string  `json:"resources"`
	Roles     []string  `json:"roles"`
	Action    int       `json:"action"` // allow: 1, deny: 0
	Owner     bool      `json:"owner"`
	Priority  int       `json:"priority"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type PrivacySettings

type PrivacySettings struct {
	TypingIndicators *TypingIndicators `json:"typing_indicators,omitempty"`
	ReadReceipts     *ReadReceipts     `json:"read_receipts,omitempty"`
	DeliveryReceipts *DeliveryReceipts `json:"delivery_receipts,omitempty"`
}

type Product

type Product string

type PushConfigRequest

type PushConfigRequest struct {
	Version     string `json:"version,omitempty"`
	OfflineOnly bool   `json:"offline_only,omitempty"`
}

type PushNotificationFields

type PushNotificationFields struct {
	Version        string         `json:"version"`
	OfflineOnly    bool           `json:"offline_only"`
	APNConfig      APNConfig      `json:"apn"`
	FirebaseConfig FirebaseConfig `json:"firebase"`
	HuaweiConfig   HuaweiConfig   `json:"huawei"`
	XiaomiConfig   XiaomiConfig   `json:"xiaomi"`
	Providers      []PushProvider `json:"providers,omitempty"`
}

type PushProvider

type PushProvider struct {
	Type           PushProviderType `json:"type"`
	Name           string           `json:"name"`
	Description    string           `json:"description,omitempty"`
	DisabledAt     *time.Time       `json:"disabled_at,omitempty"`
	DisabledReason string           `json:"disabled_reason,omitempty"`

	APNAuthKey string `json:"apn_auth_key,omitempty"`
	APNKeyID   string `json:"apn_key_id,omitempty"`
	APNTeamID  string `json:"apn_team_id,omitempty"`
	APNTopic   string `json:"apn_topic,omitempty"`

	FirebaseCredentials          string  `json:"firebase_credentials,omitempty"`
	FirebaseNotificationTemplate *string `json:"firebase_notification_template,omitempty"`
	FirebaseAPNTemplate          *string `json:"firebase_apn_template,omitempty"`

	HuaweiAppID     string `json:"huawei_app_id,omitempty"`
	HuaweiAppSecret string `json:"huawei_app_secret,omitempty"`

	XiaomiPackageName string `json:"xiaomi_package_name,omitempty"`
	XiaomiAppSecret   string `json:"xiaomi_app_secret,omitempty"`
}

type PushProviderListResponse

type PushProviderListResponse struct {
	Response
	PushProviders []PushProvider `json:"push_providers"`
}

type PushProviderType

type PushProviderType = string

type QueryBannedUsersOptions

type QueryBannedUsersOptions struct {
	*QueryOption
}

type QueryBannedUsersResponse

type QueryBannedUsersResponse struct {
	Bans []*Ban `json:"bans"`
	Response
}

type QueryChannelsResponse

type QueryChannelsResponse struct {
	Channels         []*Channel
	PredefinedFilter *ParsedPredefinedFilterResponse
	Response
}

type QueryDraftsOptions

type QueryDraftsOptions struct {
	UserID string `json:"user_id"`

	// Filter is the filter to be used to query the drafts based on 'channel_cid', 'parent_id' or 'created_at'..
	Filter map[string]any `json:"filter,omitempty"`

	// Sort is the sort to be used to query the drafts. Can sort by 'created_at'.
	Sort []*SortOption `json:"sort,omitempty"`

	// Limit the number of drafts returned.
	Limit int `json:"limit,omitempty"`
	// Pagination parameter. Pass the 'next' value from a previous response to continue from that point.
	Next string `json:"next,omitempty"`
	// Pagination parameter. Pass the 'prev' value from a previous response to continue from that point.
	Prev string `json:"prev,omitempty"`
}

QueryDraftsOptions represents the options for the QueryDrafts request.

type QueryDraftsResponse

type QueryDraftsResponse struct {
	Drafts []Draft `json:"drafts"`
	// Next is to be used as the 'next' parameter to get the next page.
	Next *string `json:"next,omitempty"`
	// Prev is to be used as the 'prev' parameter to get the previous page.
	Prev *string `json:"prev,omitempty"`
	Response
}

QueryDraftsResponse is the response from QueryDrafts.

type QueryFlagReportsRequest

type QueryFlagReportsRequest struct {
	FilterConditions map[string]interface{} `json:"filter_conditions,omitempty"`
	Limit            int                    `json:"limit,omitempty"`
	Offset           int                    `json:"offset,omitempty"`
}

type QueryFlagReportsResponse

type QueryFlagReportsResponse struct {
	Response
	FlagReports []*FlagReport `json:"flag_reports"`
}

type QueryFutureChannelBansOptions added in v8.2.0

type QueryFutureChannelBansOptions struct {
	UserID             string `json:"user_id,omitempty"`
	TargetUserID       string `json:"target_user_id,omitempty"`
	ExcludeExpiredBans bool   `json:"exclude_expired_bans,omitempty"`
	Limit              int    `json:"limit,omitempty"`
	Offset             int    `json:"offset,omitempty"`
}

QueryFutureChannelBansOptions contains options for querying future channel bans.

type QueryFutureChannelBansResponse added in v8.2.0

type QueryFutureChannelBansResponse struct {
	Bans []*FutureChannelBan `json:"bans"`
	Response
}

QueryFutureChannelBansResponse is the response from QueryFutureChannelBans.

type QueryMembersResponse

type QueryMembersResponse struct {
	Members []*ChannelMember `json:"members"`

	Response
}

type QueryMessageFlagsResponse

type QueryMessageFlagsResponse struct {
	Flags []*MessageFlag `json:"flags"`
	Response
}

type QueryMessageHistoryRequest

type QueryMessageHistoryRequest struct {
	Filter map[string]any `json:"filter"`
	Sort   []*SortOption  `json:"sort,omitempty"`

	Limit int    `json:"limit,omitempty"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
}

type QueryMessageHistoryResponse

type QueryMessageHistoryResponse struct {
	MessageHistory []*MessageHistoryEntry `json:"message_history"`

	Next *string `json:"next,omitempty"`
	Prev *string `json:"prev,omitempty"`
	Response
}

type QueryOption

type QueryOption struct {
	// https://getstream.io/chat/docs/#query_syntax
	Filter map[string]interface{} `json:"filter_conditions,omitempty"`
	Sort   []*SortOption          `json:"sort,omitempty"`

	UserID       string `json:"user_id,omitempty"`
	Limit        int    `json:"limit,omitempty"`  // pagination option: limit number of results
	Offset       int    `json:"offset,omitempty"` // pagination option: offset to return items from
	MessageLimit *int   `json:"message_limit,omitempty"`
	MemberLimit  *int   `json:"member_limit,omitempty"`
}

type QueryRemindersResponse

type QueryRemindersResponse struct {
	Reminders []*Reminder `json:"reminders"`
	Response
}

type QueryRequest

type QueryRequest struct {
	Data           *ChannelRequest                 `json:"data,omitempty"`
	Watch          bool                            `json:"watch,omitempty"`
	State          bool                            `json:"state,omitempty"`
	Presence       bool                            `json:"presence,omitempty"`
	Messages       *MessagePaginationParamsRequest `json:"messages,omitempty"`
	Members        *PaginationParamsRequest        `json:"members,omitempty"`
	Watchers       *PaginationParamsRequest        `json:"watchers,omitempty"`
	HideForCreator bool                            `json:"hide_for_creator,omitempty"`
}

type QueryResponse

type QueryResponse struct {
	Channel        *Channel         `json:"channel,omitempty"`
	Messages       []*Message       `json:"messages,omitempty"`
	PinnedMessages []*Message       `json:"pinned_messages,omitempty"`
	Members        []*ChannelMember `json:"members,omitempty"`
	Read           []*ChannelRead   `json:"read,omitempty"`

	Response
}

type QueryScheduledMessagesOptions added in v8.7.0

type QueryScheduledMessagesOptions struct {
	// UserID is the user whose scheduled messages are listed. Required.
	UserID string `json:"user_id"`

	Filter *ScheduledMessagesFilter `json:"filter,omitempty"`

	// Sort supports only scheduled_at ascending.
	Sort []*SortOption `json:"sort,omitempty"`

	// Limit is the page size, 1 to 100. Defaults to 20.
	Limit int `json:"limit,omitempty"`
	// Next is the 'next' value of a previous response, to continue from that point.
	Next string `json:"next,omitempty"`
}

QueryScheduledMessagesOptions represents the options for the QueryScheduledMessages request.

type QueryScheduledMessagesResponse added in v8.7.0

type QueryScheduledMessagesResponse struct {
	// ScheduledMessages lists pending messages first, then failed ones, each by scheduled_at.
	ScheduledMessages []*ScheduledMessage `json:"scheduled_messages"`
	// Next is to be used as the 'next' option to get the next page. Empty on the last page.
	Next string `json:"next,omitempty"`
	Response
}

QueryScheduledMessagesResponse is one page of scheduled messages.

type QueryTeamUsageStatsRequest added in v8.2.2

type QueryTeamUsageStatsRequest struct {
	// Month in YYYY-MM format (e.g., '2026-01'). Mutually exclusive with StartDate/EndDate.
	// Returns aggregated monthly values.
	Month string `json:"month,omitempty"`
	// StartDate in YYYY-MM-DD format. Used with EndDate for custom date range.
	// Returns daily breakdown.
	StartDate string `json:"start_date,omitempty"`
	// EndDate in YYYY-MM-DD format. Used with StartDate for custom date range.
	// Returns daily breakdown.
	EndDate string `json:"end_date,omitempty"`
	// Limit is the maximum number of teams to return per page (default: 30, max: 30).
	Limit *int `json:"limit,omitempty"`
	// Next is the cursor for pagination to fetch next page of teams.
	Next string `json:"next,omitempty"`
}

QueryTeamUsageStatsRequest contains the parameters for querying team usage stats.

type QueryTeamUsageStatsResponse added in v8.2.2

type QueryTeamUsageStatsResponse struct {
	// Teams contains the array of team usage statistics.
	Teams []TeamUsageStats `json:"teams"`
	// Next is the cursor for pagination to fetch next page.
	Next string `json:"next,omitempty"`
	Response
}

QueryTeamUsageStatsResponse is the response from QueryTeamUsageStats.

type QueryThreadsRequest

type QueryThreadsRequest struct {
	User   *User  `json:"user,omitempty"`
	UserID string `json:"user_id,omitempty"`

	Filter map[string]any        `json:"filter,omitempty"`
	Sort   *SortParamRequestList `json:"sort,omitempty"`
	Watch  *bool                 `json:"watch,omitempty"`
	PagerRequest
}

type QueryThreadsResponse

type QueryThreadsResponse struct {
	Threads []ThreadResponse `json:"threads"`
	Response
	PagerResponse
}

type QueryUsersOptions

type QueryUsersOptions struct {
	QueryOption

	IncludeDeactivatedUsers bool `json:"include_deactivated_users"`
}

type QueryUsersResponse

type QueryUsersResponse struct {
	Users []*User `json:"users"`
	Response
}

type RateLimitInfo

type RateLimitInfo struct {
	// Limit is the maximum number of API calls for a single time window (1 minute).
	Limit int64 `json:"limit"`
	// Remaining is the number of API calls remaining in the current time window (1 minute).
	Remaining int64 `json:"remaining"`
	// Reset is the Unix timestamp of the expiration of the current rate limit time window.
	Reset int64 `json:"reset"`
}

RateLimitInfo represents the quota and usage for a single endpoint.

func NewRateLimitFromHeaders

func NewRateLimitFromHeaders(headers http.Header) *RateLimitInfo

func (RateLimitInfo) ResetTime

func (i RateLimitInfo) ResetTime() time.Time

ResetTime is a simple helper to get the time.Time representation of the Reset field of the given limit window.

type RateLimitsMap

type RateLimitsMap map[string]RateLimitInfo

RateLimitsMap holds the rate limit information, where the keys are the names of the endpoints and the values are the related RateLimitInfo containing the quota, usage, and reset data.

type Reaction

type Reaction struct {
	MessageID string `json:"message_id"`
	UserID    string `json:"user_id"`
	Type      string `json:"type"`

	// any other fields the user wants to attach a reaction
	ExtraData map[string]interface{} `json:"-"`
}

func (Reaction) MarshalJSON

func (s Reaction) MarshalJSON() ([]byte, error)

func (*Reaction) UnmarshalJSON

func (s *Reaction) UnmarshalJSON(data []byte) error

type ReactionResponse

type ReactionResponse struct {
	Message  *Message  `json:"message"`
	Reaction *Reaction `json:"reaction"`
	Response
}

type ReactionsResponse

type ReactionsResponse struct {
	Reactions []*Reaction `json:"reactions"`
	Response
}

type ReactivateUserOptions

type ReactivateUserOptions func(*reactivateUserOptions)

type ReadReceipts

type ReadReceipts struct {
	Enabled bool `json:"enabled"`
}

type Reminder

type Reminder struct {
	ChannelID string     `json:"channel_id"`
	MessageID string     `json:"message_id"`
	Message   *Message   `json:"message,omitempty"`
	UserID    string     `json:"user_id"`
	User      *User      `json:"user,omitempty"`
	RemindAt  *time.Time `json:"remind_at,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Reminder) UnmarshalJSON

func (s *Reminder) UnmarshalJSON(data []byte) error

type ReminderRequest

type ReminderRequest struct {
	UserID    string     `json:"user_id"`
	MessageID string     `json:"message_id"`
	RemindAt  *time.Time `json:"remind_at,omitempty"`
}

type ReminderResponse

type ReminderResponse struct {
	Reminder *Reminder `json:"reminder"`
	Response
}

type RepliesResponse

type RepliesResponse struct {
	Messages []*Message `json:"messages"`
	Response
}

type Response

type Response struct {
	RateLimitInfo *RateLimitInfo `json:"ratelimit"`
}

Response is the base response returned to client. It contains rate limit information. All specific response returned to the client should embed this type.

type RestoreUserRequest

type RestoreUserRequest struct {
	UserIDs []string `json:"user_ids"`
}

type ReviewFlagReportRequest

type ReviewFlagReportRequest struct {
	ReviewResult  string                 `json:"review_result,omitempty"`
	UserID        string                 `json:"user_id,omitempty"`
	ReviewDetails map[string]interface{} `json:"review_details,omitempty"`
}

type ReviewFlagReportResponse

type ReviewFlagReportResponse struct {
	Response
	FlagReport *ExtendedFlagReport `json:"flag_report"`
}

type Role

type Role struct {
	Name      string    `json:"name"`
	Custom    bool      `json:"custom"`
	Scopes    []string  `json:"scoped"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type RoleAssignment

type RoleAssignment struct {
	// UserID is the ID of the user to assign the role to.
	UserID string `json:"user_id"`

	// ChannelRole is the role to assign to the user.
	ChannelRole string `json:"channel_role"`
}

type RolesResponse

type RolesResponse struct {
	Roles []*Role `json:"roles"`
	Response
}

type ScheduledMessage added in v8.7.0

type ScheduledMessage struct {
	ID            string                        `json:"id"`
	CID           string                        `json:"cid"`
	User          *User                         `json:"user"`
	Message       *ScheduledMessageContent      `json:"message"`
	ScheduledAt   time.Time                     `json:"scheduled_at"`
	Status        ScheduledMessageStatus        `json:"status"`
	FailureReason ScheduledMessageFailureReason `json:"failure_reason,omitempty"`
	Channel       *ScheduledMessageChannel      `json:"channel,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ScheduledMessage is a message stored to be sent later.

type ScheduledMessageChannel added in v8.7.0

type ScheduledMessageChannel struct {
	CID   string `json:"cid"`
	Type  string `json:"type"`
	ID    string `json:"id"`
	Name  string `json:"name,omitempty"`
	Image string `json:"image,omitempty"`
}

ScheduledMessageChannel identifies the channel of a scheduled message. It is only set in QueryScheduledMessages results.

type ScheduledMessageContent added in v8.7.0

type ScheduledMessageContent struct {
	Text                 string          `json:"text"`
	MML                  string          `json:"mml,omitempty"`
	HTML                 string          `json:"html,omitempty"`
	Type                 MessageType     `json:"type,omitempty"`
	Attachments          []*Attachment   `json:"attachments,omitempty"`
	ParentID             string          `json:"parent_id,omitempty"`
	ShowInChannel        bool            `json:"show_in_channel,omitempty"`
	QuotedMessageID      string          `json:"quoted_message_id,omitempty"`
	MentionedUsers       []string        `json:"mentioned_users,omitempty"` // IDs of the mentioned users
	MentionedRoles       []string        `json:"mentioned_roles,omitempty"`
	MentionedGroupIDs    []string        `json:"mentioned_group_ids,omitempty"`
	MentionedChannel     bool            `json:"mentioned_channel,omitempty"`
	MentionedHere        bool            `json:"mentioned_here,omitempty"`
	RestrictedVisibility []string        `json:"restricted_visibility,omitempty"`
	Silent               bool            `json:"silent,omitempty"`
	Pinned               bool            `json:"pinned,omitempty"`
	PinExpires           *time.Time      `json:"pin_expires,omitempty"`
	PollID               string          `json:"poll_id,omitempty"`
	SharedLocation       *SharedLocation `json:"shared_location,omitempty"`

	// ExtraData holds the custom fields of the message. As on Message, they are
	// top-level keys of the message object.
	ExtraData map[string]interface{} `json:"-"`
}

ScheduledMessageContent is the message a scheduled message will send. It has no ID: the ID of the sent message is only known once it is sent (see the scheduled_message.sent event).

func (ScheduledMessageContent) MarshalJSON added in v8.7.0

func (m ScheduledMessageContent) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ScheduledMessageContent) UnmarshalJSON added in v8.7.0

func (m *ScheduledMessageContent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ScheduledMessageFailureReason added in v8.7.0

type ScheduledMessageFailureReason string

ScheduledMessageFailureReason says why a scheduled message failed to send.

const (
	ScheduledMessageFailureBanned              ScheduledMessageFailureReason = "banned"
	ScheduledMessageFailureNoPermission        ScheduledMessageFailureReason = "no_permission"
	ScheduledMessageFailureChannelFrozen       ScheduledMessageFailureReason = "channel_frozen"
	ScheduledMessageFailureChannelDeleted      ScheduledMessageFailureReason = "channel_deleted"
	ScheduledMessageFailureUserDeleted         ScheduledMessageFailureReason = "user_deleted"
	ScheduledMessageFailureModerationBlocked   ScheduledMessageFailureReason = "moderation_blocked"
	ScheduledMessageFailureHookRejected        ScheduledMessageFailureReason = "hook_rejected"
	ScheduledMessageFailureExpired             ScheduledMessageFailureReason = "expired"
	ScheduledMessageFailureInternalError       ScheduledMessageFailureReason = "internal_error"
	ScheduledMessageFailureInvalidMessage      ScheduledMessageFailureReason = "invalid_message"
	ScheduledMessageFailurePendingNotSupported ScheduledMessageFailureReason = "pending_not_supported"
)

type ScheduledMessageResponse added in v8.7.0

type ScheduledMessageResponse struct {
	ScheduledMessage *ScheduledMessage `json:"scheduled_message"`
	Response
}

ScheduledMessageResponse is the response of the scheduled message endpoints.

type ScheduledMessageStatus added in v8.7.0

type ScheduledMessageStatus string

ScheduledMessageStatus is the status of a scheduled message.

const (
	// ScheduledMessageStatusScheduled means the message waits for its send time.
	ScheduledMessageStatusScheduled ScheduledMessageStatus = "scheduled"
	// ScheduledMessageStatusSending means the message is being sent. It can no
	// longer be updated or deleted.
	ScheduledMessageStatusSending ScheduledMessageStatus = "sending"
	// ScheduledMessageStatusFailed means the message could not be sent. See
	// ScheduledMessage.FailureReason. A failed message can only be deleted.
	ScheduledMessageStatusFailed ScheduledMessageStatus = "failed"
	// ScheduledMessageStatusCanceled is reported when a scheduled message is deleted.
	ScheduledMessageStatusCanceled ScheduledMessageStatus = "canceled"
	// ScheduledMessageStatusSent is reported only by the scheduled_message.sent event.
	ScheduledMessageStatusSent ScheduledMessageStatus = "sent"
)

type ScheduledMessagesFilter added in v8.7.0

type ScheduledMessagesFilter struct {
	// CID returns only the scheduled messages of this channel.
	CID string `json:"cid,omitempty"`
	// Status returns only these statuses: scheduled, sending and/or failed.
	Status []ScheduledMessageStatus `json:"status,omitempty"`
}

ScheduledMessagesFilter narrows QueryScheduledMessages. Empty fields mean no restriction.

type SearchFullResponse

type SearchFullResponse struct {
	Results  []SearchMessageResponse `json:"results"`
	Next     string                  `json:"next,omitempty"`
	Previous string                  `json:"previous,omitempty"`
	Response
}

type SearchMessageResponse

type SearchMessageResponse struct {
	Message *Message `json:"message"`
}

type SearchRequest

type SearchRequest struct {
	// Required
	Query          string                 `json:"query"`
	Filters        map[string]interface{} `json:"filter_conditions"`
	MessageFilters map[string]interface{} `json:"message_filter_conditions"`

	// Pagination, optional
	Limit  int    `json:"limit,omitempty"`
	Offset int    `json:"offset,omitempty"`
	Next   string `json:"next,omitempty"`

	// Sort, optional
	Sort []SortOption `json:"sort,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	Messages []*Message
	Response
}

type SendFileRequest

type SendFileRequest struct {
	Reader io.Reader `json:"-"`
	// name of the file would be stored
	FileName string
	// User object; required
	User *User
}

type SendFileResponse

type SendFileResponse struct {
	File string `json:"file"`
	Response
}

type SendMessageOption

type SendMessageOption func(*messageRequest)

SendMessageOption is an option that modifies behavior of send message request.

func MessagePendingMessageMetadata

func MessagePendingMessageMetadata(metadata map[string]string) SendMessageOption

MessagePendingMessageMetadata saves metadata to the pending message.

func WithForceModeration

func WithForceModeration(forceModeration bool) SendMessageOption

WithForceModeration returns an option that sets the ForceModeration flag to the specified value.

func WithPending

func WithPending(pending bool) SendMessageOption

WithPending returns an option that sets the Pending flag to the specified value.

func WithScheduledAt added in v8.7.0

func WithScheduledAt(scheduledAt time.Time) SendMessageOption

WithScheduledAt schedules the message to be sent at the given time instead of sending it now. The response then carries ScheduledMessage, and Message holds the content as it will be sent; its ID is the scheduled message ID, not the ID of the sent message.

The send time must be at least one minute and at most the app's maximum lead time (120 days by default) from now. Scheduled messages must be enabled for the app.

type SharedLocation

type SharedLocation struct {
	MessageID  string `json:"message_id"`
	ChannelCID string `json:"channel_cid"`
	UserID     string `json:"user_id"`

	Latitude          *float64   `json:"latitude,omitempty"`
	Longitude         *float64   `json:"longitude,omitempty"`
	CreatedByDeviceID string     `json:"created_by_device_id"`
	EndAt             *time.Time `json:"end_at,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SharedLocationResponse

type SharedLocationResponse struct {
	SharedLocation

	Message *MessageResponse `json:"message,omitempty"`
	Channel *Channel         `json:"channel,omitempty"`
}

type SortOption

type SortOption struct {
	Field     string `json:"field"`     // field name to sort by,from json tags(in camel case), for example created_at
	Direction int    `json:"direction"` // [-1, 1]
}

type SortParamRequest

type SortParamRequest struct {
	// Name of field to sort by
	Field string `json:"field"`

	// Direction is the sorting direction, 1 for Ascending, -1 for Descending, default is 1
	Direction int `json:"direction"`
}

type SortParamRequestList

type SortParamRequestList []*SortParamRequest

type TaskResponse

type TaskResponse struct {
	TaskID    string     `json:"task_id"`
	Status    TaskStatus `json:"status"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`

	Result map[string]interface{} `json:"result,omitempty"`
	Response
}

type TaskStatus

type TaskStatus string
const (
	TaskStatusWaiting   TaskStatus = "waiting"
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusRunning   TaskStatus = "running"
	TaskStatusCompleted TaskStatus = "completed"
	TaskStatusFailed    TaskStatus = "failed"
)

type TeamUsageStats added in v8.2.2

type TeamUsageStats struct {
	// Team identifier (empty string for users not assigned to any team).
	Team string `json:"team"`

	// UsersDaily is the daily active users.
	UsersDaily MetricStats `json:"users_daily"`
	// MessagesDaily is the daily messages sent.
	MessagesDaily MetricStats `json:"messages_daily"`
	// TranslationsDaily is the daily translations.
	TranslationsDaily MetricStats `json:"translations_daily"`
	// ImageModerationsDaily is the daily image moderations.
	ImageModerationsDaily MetricStats `json:"image_moderations_daily"`

	// ConcurrentUsers is the peak concurrent users.
	ConcurrentUsers MetricStats `json:"concurrent_users"`
	// ConcurrentConnections is the peak concurrent connections.
	ConcurrentConnections MetricStats `json:"concurrent_connections"`

	// UsersTotal is the total users.
	UsersTotal MetricStats `json:"users_total"`
	// UsersLast24Hours is users active in last 24 hours.
	UsersLast24Hours MetricStats `json:"users_last_24_hours"`
	// UsersLast30Days is MAU - users active in last 30 days.
	UsersLast30Days MetricStats `json:"users_last_30_days"`
	// UsersMonthToDate is users active this month.
	UsersMonthToDate MetricStats `json:"users_month_to_date"`
	// UsersEngagedLast30Days is engaged MAU.
	UsersEngagedLast30Days MetricStats `json:"users_engaged_last_30_days"`
	// UsersEngagedMonthToDate is engaged users this month.
	UsersEngagedMonthToDate MetricStats `json:"users_engaged_month_to_date"`

	// MessagesTotal is total messages.
	MessagesTotal MetricStats `json:"messages_total"`
	// MessagesLast24Hours is messages in last 24 hours.
	MessagesLast24Hours MetricStats `json:"messages_last_24_hours"`
	// MessagesLast30Days is messages in last 30 days.
	MessagesLast30Days MetricStats `json:"messages_last_30_days"`
	// MessagesMonthToDate is messages this month.
	MessagesMonthToDate MetricStats `json:"messages_month_to_date"`
}

TeamUsageStats represents team-level usage statistics for multi-tenant apps.

type Thread

type Thread struct {
	AppPK int `json:"app_pk"`

	ChannelCID string   `json:"channel_cid"`
	Channel    *Channel `json:"channel,omitempty"`

	ParentMessageID string   `json:"parent_message_id"`
	ParentMessage   *Message `json:"parent_message,omitempty"`

	CreatedByUserID string `json:"created_by_user_id"`
	CreatedBy       *User  `json:"created_by,omitempty"`

	ReplyCount             int                `json:"reply_count,omitempty"`
	ParticipantCount       int                `json:"participant_count,omitempty"`
	ActiveParticipantCount int                `json:"active_participant_count,omitempty"`
	Participants           ThreadParticipants `json:"thread_participants,omitempty"`

	LastMessageAt time.Time  `json:"last_message_at,omitempty"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	DeletedAt     *time.Time `json:"deleted_at,omitempty"`

	Title  string         `json:"title"`
	Custom map[string]any `json:"custom"`
}

type ThreadParticipant

type ThreadParticipant struct {
	AppPK int `json:"app_pk"`

	ChannelCID string `json:"channel_cid"`

	LastThreadMessageAt *time.Time `json:"last_thread_message_at"`
	ThreadID            string     `json:"thread_id,omitempty"`

	UserID string `json:"user_id,omitempty"`
	User   *User  `json:"user,omitempty"`

	CreatedAt    time.Time  `json:"created_at"`
	LeftThreadAt *time.Time `json:"left_thread_at,omitempty"`
	LastReadAt   time.Time  `json:"last_read_at"`

	Custom map[string]interface{} `json:"custom"`
}

type ThreadParticipants

type ThreadParticipants []*ThreadParticipant

type ThreadResponse

type ThreadResponse struct {
	ChannelCID             string             `json:"channel_cid"`
	Channel                *Channel           `json:"channel,omitempty"`
	ParentMessageID        string             `json:"parent_message_id"`
	ParentMessage          *MessageResponse   `json:"parent_message,omitempty"`
	CreatedByUserID        string             `json:"created_by_user_id"`
	CreatedBy              *UsersResponse     `json:"created_by,omitempty"`
	ReplyCount             int                `json:"reply_count,omitempty"`
	ParticipantCount       int                `json:"participant_count,omitempty"`
	ActiveParticipantCount int                `json:"active_participant_count,omitempty"`
	Participants           ThreadParticipants `json:"thread_participants,omitempty"`
	LastMessageAt          *time.Time         `json:"last_message_at,omitempty"`
	CreatedAt              *time.Time         `json:"created_at"`
	UpdatedAt              *time.Time         `json:"updated_at"`
	DeletedAt              *time.Time         `json:"deleted_at,omitempty"`
	Title                  string             `json:"title"`
	Custom                 map[string]any     `json:"custom"`

	LatestReplies []MessageResponse `json:"latest_replies,omitempty"`
	Read          ChannelRead       `json:"read,omitempty"`
	Draft         Draft
}

type Thresholds

type Thresholds struct {
	Explicit *LabelThresholds `json:"explicit"`
	Spam     *LabelThresholds `json:"spam"`
	Toxic    *LabelThresholds `json:"toxic"`
}

type TranslationResponse

type TranslationResponse struct {
	Message *Message `json:"message"`
	Response
}

type TruncateOption

type TruncateOption func(*truncateOptions)

type TruncateResponse

type TruncateResponse struct {
	Response
	Channel *Channel `json:"channel"`
	Message *Message `json:"message"`
}

type TypingIndicators

type TypingIndicators struct {
	Enabled bool `json:"enabled"`
}

type UnbanOption added in v8.2.0

type UnbanOption func(*unbanOptions)

type UnblockUsersResponse

type UnblockUsersResponse struct {
	Response
}

type UnreadCountsBatchResponse

type UnreadCountsBatchResponse struct {
	CountsByUser map[string]*UnreadCountsResponse `json:"counts_by_user"`
	Response
}

type UnreadCountsChannel

type UnreadCountsChannel struct {
	ChannelID   string    `json:"channel_id"`
	UnreadCount int       `json:"unread_count"`
	LastRead    time.Time `json:"last_read"`
}

type UnreadCountsChannelType

type UnreadCountsChannelType struct {
	ChannelType  string `json:"channel_type"`
	ChannelCount int    `json:"channel_count"`
	UnreadCount  int    `json:"unread_count"`
}

type UnreadCountsResponse

type UnreadCountsResponse struct {
	TotalUnreadCount        int                       `json:"total_unread_count"`
	TotalUnreadThreadsCount int                       `json:"total_unread_threads_count"`
	Channels                []UnreadCountsChannel     `json:"channels"`
	ChannelType             []UnreadCountsChannelType `json:"channel_type"`
	Threads                 []UnreadCountsThread      `json:"threads"`
	Response
}

type UnreadCountsThread

type UnreadCountsThread struct {
	UnreadCount       int       `json:"unread_count"`
	LastRead          time.Time `json:"last_read"`
	LastReadMessageID string    `json:"last_read_message_id"`
	ParentMessageID   string    `json:"parent_message_id"`
}

type UpsertUserResponse

type UpsertUserResponse struct {
	User *User
	Response
}

type User

type User struct {
	ID        string            `json:"id"`
	Name      string            `json:"name,omitempty"`
	Image     string            `json:"image,omitempty"`
	Role      string            `json:"role,omitempty"`
	Teams     []string          `json:"teams,omitempty"`
	TeamsRole map[string]string `json:"teams_role,omitempty"`
	Language  string            `json:"language,omitempty"`

	Online          bool             `json:"online,omitempty"`
	Invisible       bool             `json:"invisible,omitempty"`
	PrivacySettings *PrivacySettings `json:"privacy_settings,omitempty"`

	CreatedAt  *time.Time `json:"created_at,omitempty"`
	UpdatedAt  *time.Time `json:"updated_at,omitempty"`
	LastActive *time.Time `json:"last_active,omitempty"`

	Mutes                    []*Mute                `json:"mutes,omitempty"`
	BlockedUserIDs           []string               `json:"blocked_user_ids,omitempty"`
	ChannelMutes             []*ChannelMute         `json:"channel_mutes,omitempty"`
	ExtraData                map[string]interface{} `json:"-"`
	RevokeTokensIssuedBefore *time.Time             `json:"revoke_tokens_issued_before,omitempty"`
	AvgResponseTime          *int                   `json:"avg_response_time,omitempty"`
}

func (User) MarshalJSON

func (u User) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*User) UnmarshalJSON

func (u *User) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type UserCustomEvent

type UserCustomEvent struct {
	// Type should be a custom type. Using a built-in event is not supported here.
	Type string `json:"type"`

	ExtraData map[string]interface{} `json:"-"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

UserCustomEvent is a custom event sent to a particular user.

func (UserCustomEvent) MarshalJSON

func (e UserCustomEvent) MarshalJSON() ([]byte, error)

func (*UserCustomEvent) UnmarshalJSON

func (e *UserCustomEvent) UnmarshalJSON(data []byte) error

type UsersResponse

type UsersResponse struct {
	Users map[string]*User `json:"users"`
	Response
}

type XiaomiConfig

type XiaomiConfig struct {
	Enabled bool `json:"enabled"`
}

type XiaomiConfigRequest

type XiaomiConfigRequest struct {
	PackageName string `json:"package_name"`
	Secret      string `json:"secret"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL