Gomuks RPC API

Envelope

All RPC messages (requests, responses and events) use the same envelope format:

  • command (string): the command/event name.
  • request_id (integer): incrementing (or decrementing) message ID. Responses will always contain the same ID. Requests without an ID will never be replied to. For events, the backend will start at -1 and go backwards.
  • data (any): payload for the command/event, type depends on the command.

Responses

For every request with request_id set, the backend replies exactly once with the same request_id and one of:

  • command: "response" with data containing the command-specific return value.
  • command: "error" with data being the error message string.

Cancellation

Requests can be canceled by sending a cancel request with the target request_id inside data, plus an optional reason string. Cancellation is best-effort: some operations may not stop immediately and there is no guarantee of rollbacks.

Websocket

The main method of connecting is using the websocket. The websocket is at _gomuks/websocket and requires standard cookie authentication.

However, the RPC API is intentionally just JSON, so it can be sent over other transports as well. In particular, when bundling the backend with the frontend, it is recommended to use a direct in-process channel rather than the websocket. If writing a frontend in a language other than Go, the C FFI bindings may be useful.

Compression

If the compress query param is set to 1, the websocket will use a connection-wide deflate compression similar to how Discord's gateway works. Only messages sent by the backend are compressed; client messages are not.

Enabling compression will also enable batched messages in a single frame, i.e. multiple JSON objects may be concatenated together using a newline (\n) as the separator if the backend detects that the connection isn't keeping up. There is currently no option to turn off batching when compression is enabled.

Compression is recommended for lower bandwidth networks like mobile data. It can save up to 70% of bandwidth. The primary downside is that standard developer tools will no longer understand the websocket messages.

Event buffering

The backend will buffer events that the client hasn't acknowledged yet to allow faster resuming in case the websocket is interrupted. To use session resumption, the client has to handle the run_id command and store the run_id field inside the data. When reconnecting, the client should include the run ID as well as the most recent negative request ID it received in the run_id and last_received_event query params respectively.

The event buffer is entirely in-memory, which means resumption will fail if the backend has been restarted. For non-resumed inits, the first sync_complete event will have the clear_state flag set to true. For successful resumes, the client will only get missed events rather than the full initial sync.

The init_complete event is always sent once the client is caught up regardless of whether the resume succeeded or not.

Keepalive pings and event acknowledgement

Clients MUST send periodic pings to keep the connection alive. The backend will kill connections that don't send any data for over 60 seconds. Clients SHOULD implement similar timeouts and reconnect if they don't receive any data from the backend. The recommended ping interval is 15 seconds.

Unlike normal requests, pings are exclusive to the websocket layer and will result in "command": "pong" instead of "command": "response".

In addition to keeping the connection open, pings are used to acknowledge received events so that the backend can remove them from its in-memory cache. Clients should include the most recent negative request ID they received in the last_received_id field inside the data of the ping.

Example

Request:

{
  "command": "ping",
  "request_id": 123,
  "data": {
    "last_received_id": -456
  }
}

Response:

{
  "command": "pong",
  "request_id": 123
}

Commands

Requests that frontends can send to the backend.

get_state #

get_state returns the current client state (login/verification/session info). Note that state is also emitted as client_state events, so you usually don't need to request it manually.

Response
ClientState(9 fields)
  • is_initialized bool
  • is_logged_in bool
  • is_verified bool
  • verification_state VerificationState
    VerificationState(4 fields)
    • is_verified bool
    • state_checked bool
    • has_cross_signing bool
    • has_ssss bool
  • user_id id.UserID(string) optional
  • device_id id.DeviceID(string) optional
  • homeserver_url string optional
  • displayname string optional
  • avatar_url id.ContentURIString(string) optional

cancel #

cancel an in-flight request. Returns true if the given request ID was found, false otherwise.

Request
CancelRequestParams(2 fields)
  • request_id int64
  • reason string optional
Response
bool

send_message #

send_message sends a Matrix message into a room. This is a higher-level helper around sending m.room.message (and related) content. This will always perform an asynchronous send, which means the returned event won't have an ID yet. Listen for the send_complete event to get the final result.

Request
SendMessageParams(7 fields)
Response
database.Event(23 fields)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

send_event #

send_event sends an arbitrary event into a room. This should be used for non-message events like reactions. Note that state events must use set_state instead.

Request
SendEventParams(5 fields)
Response
database.Event(23 fields)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

resend_event #

resend_event retries sending a previously failed outgoing event.

Request
ResendEventParams(1 field)
  • transaction_id string
Response
database.Event(23 fields)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

set_membership #

set_membership is used for membership actions like inviting, kicking, banning or unbanning a user. This should not be used for the user's own membership. Use join_room, leave_room or knock_room instead.

Request
SetMembershipParams(5 fields)
  • action string
  • room_id id.RoomID(string)
  • user_id id.UserID(string)
  • reason string optional
  • msc4293_redact_events bool optional

    If true, the ban event will set a flag to suggest that clients hide all the user's messages.

set_account_data #

set_account_data sets global or per-room account data.

Request
SetAccountDataParams(3 fields)
  • room_id id.RoomID(string) optional

    If set, the request will set room account data rather than global.

  • type string
  • content json.RawMessage(arbitrary JSON)

set_typing #

set_typing starts or stops sending typing notifications in a room.

Request
SetTypingParams(2 fields)

set_profile_field #

set_profile_field sets a field in the current user's Matrix profile.

Request
SetProfileFieldParams(2 fields)

get_mutual_rooms #

get_mutual_rooms returns the list of rooms shared between the current user and another user from the homeserver.

Request
GetMutualRoomsParams(2 fields)
  • user_id id.UserID(string)
  • next_batch string optional
Response
mautrix.RespMutualRooms(3 fields)
  • joined []id.RoomID(string)
  • next_batch string optional
  • count int optional

track_user_devices #

track_user_devices start tracking a user’s e2ee device list if it's not already tracked, then returns encryption info (same result as get_profile_encryption_info).

Request
GetProfileParams(1 field)
Response
ProfileEncryptionInfo(6 fields)

get_profile_encryption_info #

get_profile_encryption_info returns the device list and trust state information for a user.

Request
GetProfileParams(1 field)
Response
ProfileEncryptionInfo(6 fields)

get_event #

get_event returns a single event in a room. This uses the database if possible, but will fetch from the homeserver if the event isn't found locally.

Request
GetEventParams(3 fields)
Response
database.Event(23 fields)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

get_event_context #

get_event_context returns context around an event (before/after timeline slices) from the homeserver. This is used for jumping to a specific point on the timeline. Note that there is currently no safe way to merge back into the main timeline, so jumping has to be implemented as a separate view.

Request
GetEventContextParams(3 fields)
Response
EventContextResponse(5 fields)
  • end string
  • start string
  • before []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • after []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • database.Event(23 fields)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional

paginate_manual #

paginate_manual returns a page of messages from the homeserver using a pagination token. This is used to paginate after jumping to a specific event using get_event_context and for normal pagination in the thread view.

Request
PaginateManualParams(5 fields)
  • room_id id.RoomID(string)
  • thread_root id.EventID(string) optional

    Root event ID for thread pagination. Omit for non-thread pagination.

  • since string optional

    next_batch token from previous request or the start/end fields of get_event_context. Can be empty for starting thread pagination.

  • direction mautrix.Direction(string, 1 character)
  • limit int
Response
ManualPaginationResponse(2 fields)
  • events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • next_batch string optional

search_local #

search_local searches for messages in the local database.

Request
SearchParams(10 fields)
  • search_term string

    The search term to search for. This is passed directly to an SQLite fts5 MATCH query.

  • raw_like string optional

    An extra search term to match against the raw content JSON.

  • limit int

    Maximum number of results to return.

  • room_ids []id.RoomID(string) optional

    Rooms in which to search. If empty, all rooms will be searched.

  • senders []id.UserID(string) optional

    Users whose messages to search. If empty, messages from all users will be searched.

  • min_timestamp jsontime.UnixMilli(int64) optional
  • max_timestamp jsontime.UnixMilli(int64) optional
  • include_redacted bool optional

    Whether to also search redacted events.

  • sort_by_time bool optional

    Whether to sort results by timestamp instead of relevance.

  • next_batch string optional

    The next batch value from a previous response. All other parameters must remain exactly the same.

Response
ManualPaginationResponse(2 fields)
  • events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • next_batch string optional

search_server #

search_server searches for messages on the homeserver.

Request
SearchServerParams(6 fields)
  • search_term string

    The search term to search for. The syntax is up to the homeserver.

  • limit int

    Maximum number of results to return.

  • room_ids []id.RoomID(string) optional

    Rooms in which to search. If empty, all rooms will be searched.

  • senders []id.UserID(string) optional

    Users whose messages to search. If empty, messages from all users will be searched.

  • sort_by_time bool optional

    Whether to sort results by timestamp instead of relevance.

  • next_batch string optional

    The next batch value from a previous response. All other parameters must remain exactly the same.

Response
ManualPaginationResponse(2 fields)
  • events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • next_batch string optional

get_mentions #

get_mentions returns recent events that mention the current user. This will not call the homeserver. The result is sorted by timestamp in descending order. Sorting by timestamp means the sender could have faked it, but there's no other cross-room event ordering in Matrix.

Request
GetMentionsParams(4 fields)
  • max_timestamp jsontime.UnixMilli(int64)

    The maximum event timestamp to return. For the first query, this should be set to the current timestamp.

  • The unread type to filter for. Usually you want [database.UnreadTypeHighlight].

  • limit int

    Maximum number of events to return.

  • room_id id.RoomID(string) optional

    Optional room ID to filter mentions to a specific room.

Response
[]database.Event(23 fields per item)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

get_related_events #

get_related_events returns events related to a given event from the database (e.g. reactions, edits, replies depending on relation type). This will not call the homeserver.

Request
GetRelatedEventsParams(3 fields)
Response
[]database.Event(23 fields per item)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

get_sticky_events #

get_sticky_events returns active sticky events in the given room. This will not call the homeserver.

Request
GetStickyEventsParams(1 field)
Response
[]database.Event(23 fields per item)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

get_room_state #

get_room_state returns full room state, optionally after fetching it from the homeserver.

Request
GetRoomStateParams(4 fields)
  • room_id id.RoomID(string)
  • refetch bool optional

    Force refetch the entire state from the homeserver.

  • fetch_members bool optional

    Fetch membership events from homeserver. The client should always set this when opening a room if has_member_list is false in the room metadata.

  • include_members bool optional

    Whether to include the member list in the response. This can be used with fetch_members to tell the backend to fetch the list in the background rather than waiting for it.

Response
[]database.Event(23 fields per item)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

get_specific_room_state #

get_specific_room_state returns the requested individual state events. The events are only fetched from the database, this will not call the homeserver.

Request
GetSpecificRoomStateParams(1 field)
Response
[]database.Event(23 fields per item)
  • rowid database.EventRowID(int64)
  • timeline_rowid database.TimelineRowID(int64)

    The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

  • room_id id.RoomID(string)
  • event_id id.EventID(string)
  • sender id.UserID(string)
  • type string
  • state_key string optional
  • timestamp jsontime.UnixMilli(int64)
  • content json.RawMessage(arbitrary JSON)
  • decrypted json.RawMessage(arbitrary JSON) optional
  • decrypted_type string optional
  • unsigned json.RawMessage(arbitrary JSON) optional
  • local_content database.LocalContent optional
    database.LocalContent(8 fields)
    • sanitized_html string optional

      Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

    • html_version int optional

      A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

    • was_plaintext bool optional

      Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

    • big_emoji bool optional

      Whether the event contains emoji only and should be rendered with a big font size.

    • has_math bool optional

      Whether the event contains LaTeX math.

    • edit_source string optional

      The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

    • reply_fallback_removed bool optional

      Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

    • push_rule_id string optional

      The push rule ID that caused this event to notify or highlight.

  • transaction_id string optional
  • redacted_by id.EventID(string) optional
  • relates_to id.EventID(string) optional
  • relation_type event.RelationType(string) optional
  • decryption_error string optional
  • send_error string optional
  • reactions map[string]int optional
  • last_edit_rowid database.EventRowID(int64) optional
  • unread_type database.UnreadType(int) optional
  • sticky_duration_ms jsontime.Milliseconds(int64) optional

paginate #

paginate returns older messages in the timeline. This will return locally cached timelines if available and fetch more from the homeserver if needed.

Request
PaginateParams(4 fields)
  • room_id id.RoomID(string)
  • max_timeline_id database.TimelineRowID(int64) optional

    The oldest known timeline row ID. All returned messages will have a lower ID than this (hence max ID). This should be omitted or set to zero when resetting.

  • limit int

    Maximum number of messages to return.

  • reset bool optional

    If true, the backend will throw away any locally cached timeline state and reload it from the server.

Response
PaginationResponse(5 fields)
  • events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • receipts map[id.EventID(string)][]database.Receipt
    map[id.EventID(string)][]database.Receipt(6 fields per value item)
  • related_events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • has_more bool
  • from_server bool

get_room_summary #

get_room_summary returns the basic metadata of a room from the homeserver, such as name, topic, avatar and member count. This should be used for previewing rooms before joining. For joined rooms, metadata is automatically pushed in the sync payloads.

Request
GetRoomSummaryParams(2 fields)
  • room_id_or_alias string
  • via []string optional

    Via servers to attempt to join through. This is required when using a room ID to join a server that the homeserver isn't participating in.

Response
mautrix.RespRoomSummary(17 fields)

get_space_hierarchy #

get_space_hierarchy returns a space hierarchy, which may include rooms the user isn't in yet. This should only be used for rendering the space index page. For the room list, space edge information is automatically pushed in syncs.

Request
GetHierarchyParams(5 fields)
  • room_id id.RoomID(string)
  • from string optional
  • limit int
  • max_depth int optional
  • suggested_only bool optional
Response
mautrix.RespHierarchy(2 fields)
  • next_batch string optional
  • []mautrix.ChildRoomsChunk(14 fields per item)
    • room_id id.RoomID(string)
    • avatar_url id.ContentURIString(string) optional
    • canonical_alias id.RoomAlias(string) optional
    • guest_can_join bool
    • join_rule event.JoinRule(string) optional
    • name string optional
    • num_joined_members int
    • room_type event.RoomType(string)
    • topic string optional
    • world_readable bool
    • room_version id.RoomVersion(string) optional
    • encryption id.Algorithm(string) optional
    • allowed_room_ids []id.RoomID(string) optional
    • children_state []event.Event
      []event.Event(12 fields per item)
      • state_key string optional

        The state key for the event. Only present on State Events.

      • sender id.UserID(string) optional

        The user ID of the sender of the event

      • type event.Type(string)

        The event type

      • origin_server_ts int64 optional

        The unix timestamp when this message was sent by the origin server

      • event_id id.EventID(string) optional

        The unique ID of this event

      • room_id id.RoomID(string) optional

        The room the event was sent to. May be nil (e.g. for presence)

      • content event.Content(arbitrary JSON object)

        The JSON content of the event.

      • redacts id.EventID(string) optional

        The event ID that was redacted if a m.room.redaction event

      • unsigned event.Unsigned optional

        Unsigned content set by own homeserver.

      • msc4354_sticky event.Sticky optional
        event.Sticky(1 field)
      • to_user_id id.UserID(string) optional

        The user ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

      • to_device_id id.DeviceID(string) optional

        The device ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

join_room #

join_room joins the given room ID or alias.

Request
JoinRoomParams(4 fields)
  • room_id_or_alias string
  • via []string optional

    Via servers to attempt to join through. This is required when using a room ID to join a server that the homeserver isn't participating in.

  • reason string optional
  • from_invite bool optional

    FromInvite indicates whether this join was initiated from accepting an invite. RoomIDOrAlias must be a room ID when using this flag.

Response
mautrix.RespJoinRoom(1 field)

knock_room #

knock_room knocks on the given room ID or alias.

Request
JoinRoomParams(4 fields)
  • room_id_or_alias string
  • via []string optional

    Via servers to attempt to join through. This is required when using a room ID to join a server that the homeserver isn't participating in.

  • reason string optional
  • from_invite bool optional

    FromInvite indicates whether this join was initiated from accepting an invite. RoomIDOrAlias must be a room ID when using this flag.

Response
mautrix.RespKnockRoom(1 field)

create_room #

create_room creates a new room.

Request
mautrix.ReqCreateRoom(19 fields)
  • visibility string optional
  • room_alias_name string optional
  • name string optional
  • topic string optional
  • invite []id.UserID(string) optional
  • invite_3pid []mautrix.ReqInvite3PID optional
    []mautrix.ReqInvite3PID(3 fields per item)
    • id_server string
    • medium string
    • address string
  • creation_content map[string]any optional
  • initial_state []event.Event optional
    []event.Event(12 fields per item)
    • state_key string optional

      The state key for the event. Only present on State Events.

    • sender id.UserID(string) optional

      The user ID of the sender of the event

    • type event.Type(string)

      The event type

    • origin_server_ts int64 optional

      The unix timestamp when this message was sent by the origin server

    • event_id id.EventID(string) optional

      The unique ID of this event

    • room_id id.RoomID(string) optional

      The room the event was sent to. May be nil (e.g. for presence)

    • content event.Content(arbitrary JSON object)

      The JSON content of the event.

    • redacts id.EventID(string) optional

      The event ID that was redacted if a m.room.redaction event

    • unsigned event.Unsigned optional

      Unsigned content set by own homeserver.

    • msc4354_sticky event.Sticky optional
      event.Sticky(1 field)
    • to_user_id id.UserID(string) optional

      The user ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

    • to_device_id id.DeviceID(string) optional

      The device ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

  • preset string optional
  • is_direct bool optional
  • room_version id.RoomVersion(string) optional
  • power_level_content_override event.PowerLevelsEventContent optional
    event.PowerLevelsEventContent(10 fields)
    • users map[id.UserID(string)]int optional
    • users_default int optional
    • events map[string]int optional
    • events_default int optional
    • notifications event.NotificationPowerLevels optional
      event.NotificationPowerLevels(1 field)
      • room int optional
    • state_default int optional
    • invite int optional
    • kick int optional
    • ban int optional
    • redact int optional
  • fi.mau.room_id id.RoomID(string) optional
  • fi.mau.origin_server_ts int64 optional
  • com.beeper.initial_members []id.UserID(string) optional
  • com.beeper.auto_join_invites bool optional
  • com.beeper.local_room_id id.RoomID(string) optional
  • com.beeper.bridge_name string optional
  • com.beeper.bridge_account_id string optional
Response
mautrix.RespCreateRoom(1 field)

mute_room #

mute_room mutes or unmutes a room by manipulating push rules. It returns the previous mute state.

Request
MuteRoomParams(2 fields)
Response
bool

update_push_rule #

update_push_rule is used to create, edit, delete, enable or disable push rules.

Request
UpdatePushRuleParams(4 fields)

ensure_group_session_shared #

ensure_group_session_shared ensures that the Megolm session for a room has been shared to all recipient devices. Calling this is not required, but it should be called when the user first starts typing to make sending faster.

Request
EnsureGroupSessionSharedParams(1 field)

request_openid_token #

request_openid_token returns an OpenID token from the homeserver. OpenID tokens are used to authenticate with various external services. Widgets also need this method.

To log into css.gomuks.app, use the response data to form the following URL and open it in a browser: https://css.gomuks.app/login?token=${access_token}&server_name=${matrix_server_name}

Response
mautrix.RespOpenIDToken(4 fields)
  • access_token string
  • expires_in int
  • matrix_server_name string
  • token_type string

    Always "Bearer"

logout #

logout logs out the current session. Note that this may break the process until it's restarted.

login #

login logs into a homeserver using a username and password. After a successful login, the client_state event will be dispatched. The frontend should use the event rather than the response to this method to update its state.

Request
LoginParams(3 fields)
  • homeserver_url string
  • username string
  • password string

login_custom #

login_custom sends a custom login request. Like the login request, this will also dispatch a client_state event after a successful login.

Request
LoginCustomParams(2 fields)

verify #

verify verifies the session using a recovery key or recovery phrase. Like the login request, this will also dispatch a client_state event after successfully verifying.

Request
VerifyParams(1 field)
  • recovery_key string

generate_recovery_key #

generate_recovery_key generates a new recovery key, optionally from a given recovery phrase. This will not actually use the generated key for anything, reset_encryption has to be called separately.

Request
GenerateRecoveryKeyParams(1 field)
  • passphrase string
Response
RecoveryKeyResponse(2 fields)

register_push #

register_push stores a gomuks-specific pusher in the database. This will not register a pusher on the homeserver. Push notifications will not work without the gomuks backend being online.

Request
database.PushRegistration(5 fields)
  • device_id string

    An arbitrary (but stable) device identifier. Only one push registration can be active per device ID.

  • type database.PushType(string)

    The type of pusher.

  • data json.RawMessage(arbitrary JSON)

    The type-specific data.

    For FCM, this is the FCM token as a string. For web push, this is the subscription info as a JSON object (endpoint string and keys object with p256dh and auth strings).

  • An optional gomuks-specific encryption configuration. Mostly relevant for FCM (and APNs in the future), as web push has built-in encryption.

    database.EncryptionKey(1 field)
    • key base64 string optional

      32 random bytes used as the static AES-GCM key.

  • expiration jsontime.Unix(int64)

    Unix timestamp (seconds) when the registration should be considered stale. The frontend should re-register well before this time.

listen_to_device #

listen_to_device toggles including to-device messages in sync_complete events. Only relevant for widgets. Returns the previous value of the setting.

Request
bool
Response
bool

get_turn_servers #

get_turn_servers returns TURN server credentials from the homeserver.

Response
mautrix.RespTurnServer(4 fields)
  • username string
  • password string
  • ttl int
  • uris []string

get_media_config #

get_media_config returns the homeserver's media repository configuration (e.g. upload size limit)

Response
mautrix.RespMediaConfig(1 field)
  • m.upload.size int64 optional

calculate_room_id #

calculate_room_id calculates a room ID locally from a timestamp and creation content. This is only relevant when creating v12+ rooms with the fi.mau.origin_server_ts extension that allows the client to pre-calculate the room ID.

Request
CalculateRoomIDParams(2 fields)
Response
id.RoomID(string)

get_account_info #

get_account_info returns the homeserver URL and access token for the active login. This is only available in the C FFI. HTTP clients aren't allowed to read the client's access token.

Response
database.Account(6 fields)
  • user_id id.UserID(string) optional
  • device_id id.DeviceID(string) optional
  • access_token string optional
  • homeserver_url string optional
  • display_name string optional

    TODO save to database

  • avatar_url id.ContentURI(string) optional

upload_media #

upload_media uploads a file on the local disk to the server and returns the m.room.message to use in send_message. This is only available in the C FFI. HTTP clients must use the /upload API.

Request
UploadMediaParams(10 fields)
  • path string
  • filename string optional

    The file name for the upload. If empty, the base name of Path will be used.

  • encrypt bool optional

    Whether the upload should be encrypted.

  • voice_message bool optional

    Whether the upload is a voice message. If true, a waveform will be generated.

  • force_file bool optional

    Force sending as m.file instead of image/video/audio based on mime type?

  • encode_to string optional

    Mime type to re-encode media to. Options below only apply if this is set.

  • resize_width int optional

    Absolute width and height to resize to.

  • resize_height int optional
  • resize_percent int optional

    Percentage to resize by. Must be between 1 and 100.

  • quality int optional

    For jpeg and webp files, the quality to encode as. Defaults to 80.

export_keys #

export_keys exports megolm room keys and returns the exported file as a string. This is only available in the C FFI. HTTP clients must use the /keys/export API.

Request
ExportKeysParams(2 fields)
  • passphrase string
  • room_id id.RoomID(string) optional
Response
string

Events

Events that the backend will send to connected frontends.

sync_complete #

sync_complete is emitted after a /sync request has been fully processed and stored. This is also used for sending the room list to the client when first connecting.

Payload
SyncComplete(9 fields)
  • since string optional

    The since token sent to the server in the /sync request. This is only for debugging, the frontend doesn't need to care about it.

  • clear_state bool optional

    If true, the frontend should throw away all state it has before applying this sync. This is used on the first payload after connecting if resuming wasn't used or didn't succeed.

  • account_data map[event.Type(string)]database.AccountData

    New global account data events. Only changed events are listed here, but the entire content of each changed event should be replaced.

    map[event.Type(string)]database.AccountData(4 fields per value)
    • user_id id.UserID(string)

      The user ID who owns this account data (i.e. always the currently logged-in user).

    • room_id id.RoomID(string) optional

      If this is a room account data event, the room ID it is associated with. Omitted for global account data.

    • type string
    • content json.RawMessage(arbitrary JSON)
  • rooms map[id.RoomID(string)]SyncRoom

    List of rooms that the user is participating in that have new data available.

    map[id.RoomID(string)]SyncRoom(10 fields per value)
    • Metadata about the room. The frontend should replace the entire cached object rather than merging.

      database.Room(20 fields)
    • New timeline events to append to the existing list (except if reset is set, in which case this replaces the existing list).

      []database.TimelineRowTuple(2 fields per item)
    • reset bool

      If true, the frontend should discard the existing timeline cache for this room.

    • state map[event.Type(string)]map[string]database.EventRowID(int64)

      New state events. This nested map should be deeply merged into the existing state map.

    • account_data map[event.Type(string)]database.AccountData

      New room account data events. Like global account data, only changes are listed, but the entire content of changed events should be replaced.

      map[event.Type(string)]database.AccountData(4 fields per value)
      • user_id id.UserID(string)

        The user ID who owns this account data (i.e. always the currently logged-in user).

      • room_id id.RoomID(string) optional

        If this is a room account data event, the room ID it is associated with. Omitted for global account data.

      • type string
      • content json.RawMessage(arbitrary JSON)
    • events []database.Event

      Events that the frontend needs to handle this sync. This may include old events, as well as events the frontend already has. The timeline and state fields are the ones that decide where the events are actually used.

      []database.Event(23 fields per item)
      • rowid database.EventRowID(int64)
      • timeline_rowid database.TimelineRowID(int64)

        The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

      • room_id id.RoomID(string)
      • event_id id.EventID(string)
      • sender id.UserID(string)
      • type string
      • state_key string optional
      • timestamp jsontime.UnixMilli(int64)
      • content json.RawMessage(arbitrary JSON)
      • decrypted json.RawMessage(arbitrary JSON) optional
      • decrypted_type string optional
      • unsigned json.RawMessage(arbitrary JSON) optional
      • local_content database.LocalContent optional
        database.LocalContent(8 fields)
        • sanitized_html string optional

          Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

        • html_version int optional

          A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

        • was_plaintext bool optional

          Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

        • big_emoji bool optional

          Whether the event contains emoji only and should be rendered with a big font size.

        • has_math bool optional

          Whether the event contains LaTeX math.

        • edit_source string optional

          The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

        • reply_fallback_removed bool optional

          Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

        • push_rule_id string optional

          The push rule ID that caused this event to notify or highlight.

      • transaction_id string optional
      • redacted_by id.EventID(string) optional
      • relates_to id.EventID(string) optional
      • relation_type event.RelationType(string) optional
      • decryption_error string optional
      • send_error string optional
      • reactions map[string]int optional
      • last_edit_rowid database.EventRowID(int64) optional
      • unread_type database.UnreadType(int) optional
      • sticky_duration_ms jsontime.Milliseconds(int64) optional
    • receipts map[id.EventID(string)][]database.Receipt

      New read receipts. The frontend should only keep the latest receipt per user.

      map[id.EventID(string)][]database.Receipt(6 fields per value item)
    • sticky []database.EventRowID(int64) optional

      New MSC4354 sticky events that aren't included in timeline.

    • dismiss_notifications bool
    • notifications []SyncNotification
      []SyncNotification(3 fields per item)
  • left_rooms []id.RoomID(string)

    List of rooms that the user has left. The frontend should delete all state associated with these rooms.

  • invited_rooms []database.InvitedRoom

    List of new rooms that the user has been invited to.

    []database.InvitedRoom(3 fields per item)
    • room_id id.RoomID(string)

      The ID of the invited room.

    • created_at jsontime.UnixMilli(int64)

      Either the timestamp of the invite event, or the time when the invite was received.

    • invite_state []event.Event

      The (untrusted) room metadata state events for the room.

      []event.Event(12 fields per item)
      • state_key string optional

        The state key for the event. Only present on State Events.

      • sender id.UserID(string) optional

        The user ID of the sender of the event

      • type event.Type(string)

        The event type

      • origin_server_ts int64 optional

        The unix timestamp when this message was sent by the origin server

      • event_id id.EventID(string) optional

        The unique ID of this event

      • room_id id.RoomID(string) optional

        The room the event was sent to. May be nil (e.g. for presence)

      • content event.Content(arbitrary JSON object)

        The JSON content of the event.

      • redacts id.EventID(string) optional

        The event ID that was redacted if a m.room.redaction event

      • unsigned event.Unsigned optional

        Unsigned content set by own homeserver.

      • msc4354_sticky event.Sticky optional
        event.Sticky(1 field)
      • to_user_id id.UserID(string) optional

        The user ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

      • to_device_id id.DeviceID(string) optional

        The device ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.

  • space_edges map[id.RoomID(string)][]database.SpaceEdge

    List of spaces and their edges. When an edge in a space changes, all edges in that space are resent, so the frontend should replace the entire list for that space.

    map[id.RoomID(string)][]database.SpaceEdge(7 fields per value item)
    • space_id id.RoomID(string) optional

      The room ID of the space (the parent).

    • child_id id.RoomID(string)

      The room ID of the child room.

    • child_event_rowid database.EventRowID(int64) optional

      The event row ID of the m.space.child event. Always inside the parent room.

    • order string optional

      The order string contained in the child event used for sorting within the space.

    • suggested bool optional

      Whether the space suggests this child room.

    • parent_event_rowid database.EventRowID(int64) optional

      The event row ID of the m.space.parent event. Always inside the child room.

    • canonical bool optional

      Whether the room considers the space as canonical.

  • top_level_spaces []id.RoomID(string)

    List of room IDs that should be considered as top-level spaces. The frontend should replace the entire list if this field is set.

  • to_device []SyncToDevice optional

    New to-device events. This is only used for widgets and only emitted if opted in with the send_to_device command.

    []SyncToDevice(4 fields per item)

sync_status #

sync_status is emitted if the /sync loop starts or stops erroring.

Payload
SyncStatus(4 fields)

events_decrypted #

events_decrypted is emitted when one or more events were decrypted after initially failing to decrypt.

Payload
EventsDecrypted(3 fields)
  • room_id id.RoomID(string)
  • preview_event_rowid database.EventRowID(int64) optional
  • events []database.Event
    []database.Event(23 fields per item)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional

typing #

typing is emitted when new typing notifications are received in a room.

Payload
Typing(2 fields)

send_complete #

send_complete is emitted when a previously started message send has completed. Both successes and failures can be reported this way.

Payload
SendComplete(2 fields)
  • database.Event(23 fields)
    • rowid database.EventRowID(int64)
    • timeline_rowid database.TimelineRowID(int64)

      The timeline row ID is only filled when paginating messages. In normal syncs, timeline row IDs can be found in the separate timeline field rather than inside events.

    • room_id id.RoomID(string)
    • event_id id.EventID(string)
    • sender id.UserID(string)
    • type string
    • state_key string optional
    • timestamp jsontime.UnixMilli(int64)
    • content json.RawMessage(arbitrary JSON)
    • decrypted json.RawMessage(arbitrary JSON) optional
    • decrypted_type string optional
    • unsigned json.RawMessage(arbitrary JSON) optional
    • local_content database.LocalContent optional
      database.LocalContent(8 fields)
      • sanitized_html string optional

        Sanitized HTML that is safe to render directly. This is optimized for web browsers, non-web frontends may want to parse the original HTML from formatted_body locally.

      • html_version int optional

        A version identifier for the sanitized HTML. This is only used to reparse the source in case there are changes to the sanitizer. Not relevant for frontends.

      • was_plaintext bool optional

        Whether the event was plaintext, i.e. did not have a formatted_body field. sanitized_html may be present anyway in case body contained characters that need HTML escaping.

      • big_emoji bool optional

        Whether the event contains emoji only and should be rendered with a big font size.

      • has_math bool optional

        Whether the event contains LaTeX math.

      • edit_source string optional

        The message content that should be used as the initial composer state when editing this message. For messages sent from this gomuks instance, this will be the raw user input. For messages sent from other clients, this is parsed from the HTML and therefore may have slight changes to the original markdown (but the resulting HTML is the same anyway).

      • reply_fallback_removed bool optional

        Whether the reply fallback was removed from the body and formatted_body. There is no way to get it back, as the content isn't stored.

      • push_rule_id string optional

        The push rule ID that caused this event to notify or highlight.

    • transaction_id string optional
    • redacted_by id.EventID(string) optional
    • relates_to id.EventID(string) optional
    • relation_type event.RelationType(string) optional
    • decryption_error string optional
    • send_error string optional
    • reactions map[string]int optional
    • last_edit_rowid database.EventRowID(int64) optional
    • unread_type database.UnreadType(int) optional
    • sticky_duration_ms jsontime.Milliseconds(int64) optional
  • error error

client_state #

client_state is emitted when the client login state or global profile changes.

Payload
ClientState(9 fields)
  • is_initialized bool
  • is_logged_in bool
  • is_verified bool
  • verification_state VerificationState
    VerificationState(4 fields)
    • is_verified bool
    • state_checked bool
    • has_cross_signing bool
    • has_ssss bool
  • user_id id.UserID(string) optional
  • device_id id.DeviceID(string) optional
  • homeserver_url string optional
  • displayname string optional
  • avatar_url id.ContentURIString(string) optional

init_complete #

init_complete is emitted after all post-connect payloads have been dispatched.

Payload
InitComplete (empty object)

image_auth_token #

image_auth_token is emitted in websocket mode every 30 minutes, containing a short-lived token for image/media requests.

Payload

run_id #

run_id is emitted to identify the current backend process and some additional metadata.

Payload
RunData(3 fields)
  • run_id string

    RunID is a random string that changes whenever the backend is restarted. This is sent with the last received event ID when resuming connections, as resume data is only stored in memory.

  • etag string

    ETag is a hash of the frontend. If the ETag meta value in index.html doesn't match this, the web interface will reload itself to update. Non-web clients don't need to care about this.

  • vapid_key string

    VAPIDKey is the server key used for web push sent by the gomuks backend.