Go API
Generated from the source and its doc comments (sdk/go/agentim/agentim.go).
go get github.com/wmkrfjnwvb-svg/agentim/sdk/go/agentimFunctions
Section titled “Functions”func New(baseURL, apiKey string) *ClientNew returns a client with 3 retries and a 30 second timeout.
CreateUserToken
Section titled “CreateUserToken”func CreateUserToken(kid, secret, userID string, expiresIn time.Duration) (string, error)CreateUserToken signs a client token for one of your users (docs/en/design/access.md §4.2): an HS256 JWT with the signing key from agentim signing-key create. Do this in your backend after your own login and give the token to your app; no call to AgentIM is made.
type Error structError is an error answered by the server (RFC 9457 problem details). Code is one of the protocol’s codes: forbidden, not_found, conflict, blocked…
Error.Error
Section titled “Error.Error”func (e *Error) Error() string { return fmt.Sprintf("%d %s: %s", e.Status, e.Code, e.Detail) }Error formats the HTTP status, the error code and the server’s explanation.
Client
Section titled “Client”type Client structClient calls the open API with one API key.
Client.Do
Section titled “Client.Do”func (c *Client) Do(ctx context.Context, method, path string, body any, out any) errorDo is the low-level call: POSTs get an Idempotency-Key reused across retries; GET, PUT and POST are retried on network errors, 429 and 503.
Client.DoRaw
Section titled “Client.DoRaw”func (c *Client) DoRaw(ctx context.Context, method, path string, data []byte, out any) errorDoRaw sends bytes as the body (application/octet-stream), e.g. a file.
Client.RevokeTokens
Section titled “Client.RevokeTokens”func (c *Client) RevokeTokens(ctx context.Context, userID string) (M, error)RevokeTokens logs a person out everywhere: client tokens issued until now are refused.
Client.IssueAgentKey
Section titled “Client.IssueAgentKey”func (c *Client) IssueAgentKey(ctx context.Context, agentID string, revokeOthers bool) (M, error)IssueAgentKey returns a new key for an agent; revokeOthers revokes every other key of it in the same write (rotation). The key is shown only here.
Client.RevokeAgentKeys
Section titled “Client.RevokeAgentKeys”func (c *Client) RevokeAgentKeys(ctx context.Context, agentID string) (M, error)RevokeAgentKeys revokes every key of an agent and disconnects it.
Client.RevokeAgentKey
Section titled “Client.RevokeAgentKey”func (c *Client) RevokeAgentKey(ctx context.Context, agentID, deviceID string) (M, error)RevokeAgentKey revokes one key of an agent (by its device id).
Client.ListAgents
Section titled “Client.ListAgents”func (c *Client) ListAgents(ctx context.Context, userID string) (M, error)ListAgents returns the agents a person owns, with their keys (never the secrets).
Client.StopAgent
Section titled “Client.StopAgent”func (c *Client) StopAgent(ctx context.Context, agentID, reason string) (M, error)StopAgent stops an agent at once (kill switch): it is disconnected and refused until ResumeAgent.
Client.ResumeAgent
Section titled “Client.ResumeAgent”func (c *Client) ResumeAgent(ctx context.Context, agentID string) (M, error)ResumeAgent resumes a stopped agent.
Client.TransferAgent
Section titled “Client.TransferAgent”func (c *Client) TransferAgent(ctx context.Context, agentID, owner string, rotateKeys bool) (M, error)TransferAgent gives a team agent to another person of its unit; rotateKeys revokes its keys in the same write.
Client.DestroyAgent
Section titled “Client.DestroyAgent”func (c *Client) DestroyAgent(ctx context.Context, agentID string) (M, error)DestroyAgent destroys an agent for good: keys revoked, memberships ended, checkpoints deleted.
Client.ExportAgent
Section titled “Client.ExportAgent”func (c *Client) ExportAgent(ctx context.Context, agentID string, withConversations bool) (M, error)ExportAgent exports an agent (settings, checkpoints, optionally its conversations) as a package signed by this deployment.
Client.ImportAgent
Section titled “Client.ImportAgent”func (c *Client) ImportAgent(ctx context.Context, pkg M, owner, name string, allowUnverified bool) (M, error)ImportAgent creates an agent from a package. allowUnverified accepts a package this deployment cannot verify (unsigned, or from another deployment).
Client.ListDevices
Section titled “Client.ListDevices”func (c *Client) ListDevices(ctx context.Context, userID string) (M, error)ListDevices returns a person’s devices (one per client token).
Client.LogoutDevice
Section titled “Client.LogoutDevice”func (c *Client) LogoutDevice(ctx context.Context, userID, deviceID string) (M, error)LogoutDevice revokes one device’s token and disconnects it.
Client.DeleteUser
Section titled “Client.DeleteUser”func (c *Client) DeleteUser(ctx context.Context, userID string) (M, error)DeleteUser deletes a person’s account; it returns the erasure’s progress.
Client.Erasure
Section titled “Client.Erasure”func (c *Client) Erasure(ctx context.Context, userID string) (M, error)Erasure returns the progress of an account deletion: running or done.
Client.ExportUser
Section titled “Client.ExportUser”func (c *Client) ExportUser(ctx context.Context, userID, after string) ([]M, error)ExportUser returns the person’s own data, one object per line (NDJSON); after continues from a line’s cursor.
Client.Reports
Section titled “Client.Reports”func (c *Client) Reports(ctx context.Context, state string, limit, offset int) (M, error)Reports returns the moderation queue by state, newest first, in pages.
Client.GetReport
Section titled “Client.GetReport”func (c *Client) GetReport(ctx context.Context, id string) (M, error)GetReport returns one report with its target and what was decided.
Client.ResolveReport
Section titled “Client.ResolveReport”func (c *Client) ResolveReport(ctx context.Context, id string, decision M) (M, error)ResolveReport takes action (none, remove_content, suspend_user, ban_user), reason and, for suspend_user, days.
Client.SilenceMember
Section titled “Client.SilenceMember”func (c *Client) SilenceMember(ctx context.Context, convID, userID string, seconds int, reason string) (M, error)SilenceMember stops a member from sending, editing or streaming in the conversation for seconds.
Client.UnsilenceMember
Section titled “Client.UnsilenceMember”func (c *Client) UnsilenceMember(ctx context.Context, convID, userID string) (M, error)UnsilenceMember lifts a silence early.
Client.UpsertUser
Section titled “Client.UpsertUser”func (c *Client) UpsertUser(ctx context.Context, id string, attrs M) (M, error)UpsertUser creates or updates a user with your own id: a person, or an agent with an owner (then the answer carries its first key).
Client.GetUser
Section titled “Client.GetUser”func (c *Client) GetUser(ctx context.Context, id string) (M, error)GetUser returns a user by your id.
Client.UpdateUser
Section titled “Client.UpdateUser”func (c *Client) UpdateUser(ctx context.Context, id string, attrs M) (M, error)UpdateUser changes a user’s display name, avatar or custom fields.
Client.DeactivateUser
Section titled “Client.DeactivateUser”func (c *Client) DeactivateUser(ctx context.Context, id string) (M, error)DeactivateUser logs a user out everywhere and refuses them until reactivated; their data stays.
Client.ReactivateUser
Section titled “Client.ReactivateUser”func (c *Client) ReactivateUser(ctx context.Context, id string) (M, error)ReactivateUser reactivates a deactivated user.
Client.BatchUsers
Section titled “Client.BatchUsers”func (c *Client) BatchUsers(ctx context.Context, users []M) (M, error)BatchUsers creates or updates up to 100 users in one call; one result per user.
Client.UserConversations
Section titled “Client.UserConversations”func (c *Client) UserConversations(ctx context.Context, id string) (M, error)UserConversations returns the conversations a user is in.
Client.CreateConversation
Section titled “Client.CreateConversation”func (c *Client) CreateConversation(ctx context.Context, conv M) (M, error)CreateConversation creates a conversation as a user or as the system (“as”: “system”, then name an “owner”).
Client.GetConversation
Section titled “Client.GetConversation”func (c *Client) GetConversation(ctx context.Context, id string) (M, error)GetConversation returns a conversation: kind, title, members, custom fields.
Client.UpdateConversation
Section titled “Client.UpdateConversation”func (c *Client) UpdateConversation(ctx context.Context, id string, change M) (M, error)UpdateConversation renames a conversation or replaces its custom fields.
Client.DissolveConversation
Section titled “Client.DissolveConversation”func (c *Client) DissolveConversation(ctx context.Context, id, as string) (M, error)DissolveConversation dissolves a conversation: everyone loses access and the content is deleted.
Client.AddMembers
Section titled “Client.AddMembers”func (c *Client) AddMembers(ctx context.Context, id, as string, users []string) (M, error)AddMembers adds users to a conversation; one result per user.
Client.RemoveMember
Section titled “Client.RemoveMember”func (c *Client) RemoveMember(ctx context.Context, id, user, as string) (M, error)RemoveMember removes a member.
Client.SetRole
Section titled “Client.SetRole”func (c *Client) SetRole(ctx context.Context, id, user, role, as string) (M, error)SetRole makes a member an admin or a member, or the owner (transfers ownership).
Client.UploadFile
Section titled “Client.UploadFile”func (c *Client) UploadFile(ctx context.Context, convID, as, name string, data []byte, mime string) (M, error)UploadFile uploads a whole file (at most 64 MiB) as user as: the server removes EXIF and GPS and makes a thumbnail. mime may be empty.
Client.SendFile
Section titled “Client.SendFile”func (c *Client) SendFile(ctx context.Context, convID, as, name string, data []byte, mime, caption string) (M, error)SendFile uploads a file and sends it as an image or file message.
Client.FileURL
Section titled “Client.FileURL”func (c *Client) FileURL(ctx context.Context, convID, fileID, as, variant string) (M, error)FileURL is a link (valid 5 minutes) to read a file; variant is “original”, “thumb” or empty, as may be empty (the system).
Client.SendMessage
Section titled “Client.SendMessage”func (c *Client) SendMessage(ctx context.Context, convID string, m M) (M, error)SendMessage sends a message as a member or as the system; with client_msg_id a retry returns the first result.
Client.SendToUser
Section titled “Client.SendToUser”func (c *Client) SendToUser(ctx context.Context, userID string, m M) (M, error)SendToUser sends to a user in their direct conversation, opened if needed.
Client.BatchSend
Section titled “Client.BatchSend”func (c *Client) BatchSend(ctx context.Context, m M) (M, error)BatchSend sends the same message to up to 100 users; one result per user.
Client.EditMessage
Section titled “Client.EditMessage”func (c *Client) EditMessage(ctx context.Context, id string, m M) (M, error)EditMessage edits a message as its sender (or the system).
Client.RecallMessage
Section titled “Client.RecallMessage”func (c *Client) RecallMessage(ctx context.Context, id, as string) (M, error)RecallMessage recalls a message for everyone.
Client.History
Section titled “Client.History”func (c *Client) History(ctx context.Context, convID string, afterSeq, limit int) (M, error)History returns a conversation’s events after a seq, in pages.
Client.MarkRead
Section titled “Client.MarkRead”func (c *Client) MarkRead(ctx context.Context, convID, as string, seq int) (M, error)MarkRead marks a conversation read up to seq for a user.
Client.ListThreads
Section titled “Client.ListThreads”func (c *Client) ListThreads(ctx context.Context, convID, as string) (M, error)ListThreads lists a conversation’s threads, latest reply first; with as, the ones that user follows.
Client.GetThread
Section titled “Client.GetThread”func (c *Client) GetThread(ctx context.Context, convID, threadID string, afterSeq int) (M, error)GetThread returns a thread’s root, summary and replies after a seq.
Client.AddReaction
Section titled “Client.AddReaction”func (c *Client) AddReaction(ctx context.Context, convID, msgID, key, as string) (M, error)AddReaction adds a member’s reaction; adding it again changes nothing.
Client.RemoveReaction
Section titled “Client.RemoveReaction”func (c *Client) RemoveReaction(ctx context.Context, convID, msgID, key, as string) (M, error)RemoveReaction removes a member’s reaction.
Client.ListReactions
Section titled “Client.ListReactions”func (c *Client) ListReactions(ctx context.Context, convID, msgID, key string) (M, error)ListReactions lists who reacted with a key, oldest first.
Client.ListPins
Section titled “Client.ListPins”func (c *Client) ListPins(ctx context.Context, convID string) (M, error)ListPins lists the pinned messages, latest pin first.
Client.PinMessage
Section titled “Client.PinMessage”func (c *Client) PinMessage(ctx context.Context, convID, msgID, as string) (M, error)PinMessage pins a message as a member; pinning it again changes nothing.
Client.UnpinMessage
Section titled “Client.UnpinMessage”func (c *Client) UnpinMessage(ctx context.Context, convID, msgID, as string) (M, error)UnpinMessage unpins a message as a member.
type M = map[string]anyM is a JSON object.