Documentation Index
Fetch the complete documentation index at: https://mintlify.com/matrix-org/matrix-js-sdk/llms.txt
Use this file to discover all available pages before exploring further.
MatrixEvent is the core event model in matrix-js-sdk. Every event received from
the homeserver — whether a room message, state event, or ephemeral event — is wrapped
in a MatrixEvent instance.
Constructor
event parameter is the raw JSON event object from the homeserver. Applications
should not access matrixEvent.event directly; use the getter methods instead.
Key Properties
The raw (possibly encrypted) event object as received from the homeserver. Avoid
direct access; use getters such as
getType(), getContent(), and getSender().The
RoomMember who sent this event, or null (e.g. for presence events, or if
the member is not yet loaded). Only reliably set for events appearing in a timeline.The
RoomMember who is the target of this event — e.g. the invitee, the person
being banned. Only meaningful for m.room.member events.The sending status of a locally-created event.
null once the remote echo has been
received. See the EventStatus enum below.The most recent error associated with sending this event, if any.
An approximate local timestamp (milliseconds since epoch) for when this event was
received by the device, adjusted for the server-reported
age field.When
true (the default), getDirectionalContent() returns event.content.
When false (for backwards-looking state events), it returns prev_content.Methods
Identification
getId()
$143350589368169JsLZx:localhost. May be undefined for
unsent local echo events before they have been echoed back.
getType()
m.room.message). For encrypted events
that have been successfully decrypted, this returns the cleartext type.
getSender()
@alice:matrix.org).
getRoomId()
undefined for to-device events such as m.presence.
getStateKey()
state_key if this is a state event. Returns undefined for message
events.
isState()
true if this is a state event.
Content
getContent<T>()
getOriginalContent<T>()
getPrevContent()
getWireContent()
Timestamps
getTs()
origin_server_ts timestamp in milliseconds since epoch.
getDate()
Date object, or null if origin_server_ts is
not set.
Encryption
isEncrypted()
true if the wire type of this event is m.room.encrypted.
isDecryptionFailure()
true if this is an encrypted event that could not be decrypted. The SDK
may retry decryption automatically when new key material arrives.
decryptionFailureReason
DecryptionFailureCode enum.
Otherwise null.
isBeingDecrypted()
true if a decryption attempt is currently in progress.
Redaction
isRedacted()
true if this event has been redacted (either a local or server-confirmed
redaction).
makeRedacted(redactionEvent, room)
MatrixEventEvent.BeforeRedaction first.
Thread information
threadRootId
isThreadRoot
true if this event is the root event of a thread.
MatrixEventEvent Enum
Events emitted byMatrixEvent instances:
| Value | String | Description |
|---|---|---|
MatrixEventEvent.Decrypted | "Event.decrypted" | Decryption succeeded or failed. Handler: (event, err?) |
MatrixEventEvent.BeforeRedaction | "Event.beforeRedaction" | Fires just before the event is redacted. Handler: (event, redactionEvent) |
MatrixEventEvent.VisibilityChange | "Event.visibilityChange" | Message visibility changed (MSC3531). Handler: (event, visible) |
MatrixEventEvent.LocalEventIdReplaced | "Event.localEventIdReplaced" | A local echo event ID was replaced with the real ID. |
MatrixEventEvent.Status | "Event.status" | The send status changed. Handler: (event, status) |
MatrixEventEvent.Replaced | "Event.replaced" | The event was replaced by an edit. |
MatrixEventEvent.RelationsCreated | "Event.relationsCreated" | A new relations collection was created. |
MatrixEventEvent.SentinelUpdated | "Event.sentinelUpdated" | The sentinel member for this event was updated. |
EventStatus Enum
The send lifecycle of a locally-created event:| Value | String | Description |
|---|---|---|
EventStatus.ENCRYPTING | "encrypting" | The event is being encrypted before sending. |
EventStatus.QUEUED | "queued" | The event is queued, waiting to be sent. |
EventStatus.SENDING | "sending" | The /send request is in flight. |
EventStatus.SENT | "sent" | The server acknowledged the event; waiting for remote echo. |
EventStatus.NOT_SENT | "not_sent" | The send failed and will not be retried automatically. |
EventStatus.CANCELLED | "cancelled" | The send was cancelled before it could complete. |
status is set to
null.