Messages

Messages are core communication entities within Lux channels, similar to Discord messages. They facilitate text-based interactions between users across the platform. This page details the various message endpoints you can leverage to manage communications programmatically. We'll explore how to query, create, update, and delete messages within the Lux environment.

The message model

The message model encompasses all essential information about a Lux message, including its content, author information, and related metadata. Messages serve as the primary communication method in Lux channels, enabling users to interact with each other and with applications built on the Lux platform.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the message.

  • Name
    type
    Type
    ChannelType
    Description

    The type of channel the message belongs to.

  • Name
    content
    Type
    string
    Description

    The text content of the message.

  • Name
    nonce
    Type
    string
    Description

    The nonce of the message to check it it was properly received.

  • Name
    channel_id
    Type
    string
    Description

    The ID of the channel this message was sent in.

  • Name
    author
    Type
    object
    Description

    The user object who sent this message.

  • Name
    message_reference
    Type
    object
    Description

    Reference to message object, if this is a reply.

  • Name
    flags
    Type
    number
    Description

    Bitfield of message flags.

  • Name
    created_at
    Type
    timestamp
    Description

    Timestamp of when the message was created.

  • Name
    edited_at
    Type
    timestamp | null
    Description

    Timestamp of when the message was last edited, if applicable.


GET/v1/channels/:channel_id/messages/:message_id

Get a message

This endpoint allows you to retrieve a message by providing its channel ID and message ID. Refer to the properties list at the top of this page to see which properties are included with message objects.

Request

GET
/v1/channels/1344387816333352652/messages/1344387816333352999
curl https://api.lux.gg/v1/channels/1344387816333352652/messages/1344387816333352999 \
  -H "Authorization: {token}"

Response

{
  "id": "1344387816333352999",
  "type": 0,
  "content": "Hello, world!",
  "channel_id": "1344387816333352652",
  "author": {
    "id": "1344387816333399999",
    "username": "JohnDoe",
    "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
    "created_at": "2025-01-15T12:30:45.123456Z",
    "updated_at": "2025-02-20T08:15:30.987654Z",
    "verified": true,
    "public_flags": 0
  },
  "flags": 0,
  "created_at": "2025-02-26T19:17:12.848375Z",
  "edited_at": null
}

GET/v1/channels/:channel_id/messages

List messages

This endpoint allows you to retrieve multiple messages from a channel. The response is paginated and sorted by message creation time in descending order (newest first).

Query parameters

  • Name
    limit
    Type
    integer
    Description

    Maximum number of messages to return (1-100). Default: 50.

  • Name
    before
    Type
    string
    Description

    Get messages before this message ID.

  • Name
    after
    Type
    string
    Description

    Get messages after this message ID.

Request

GET
/v1/channels/1344387816333352652/messages?limit=10
curl https://api.lux.gg/v1/channels/1344387816333352652/messages?limit=10 \
  -H "Authorization: {token}"

Response

[
  {
    "id": "1344389816333352001",
    "type": 0,
    "content": "This is a newer message",
    "channel_id": "1344387816333352652",
    "author": {
      "id": "1344387816333399999",
      "username": "JohnDoe",
      "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
      "created_at": "2025-01-15T12:30:45.123456Z",
      "updated_at": "2025-02-20T08:15:30.987654Z",
      "verified": true,
      "public_flags": 0
    },
    "flags": 0,
    "created_at": "2025-02-26T19:25:12.848375Z",
    "edited_at": null
  },
  {
    "id": "1344387816333352999",
    "type": 0,
    "content": "Hello, world!",
    "channel_id": "1344387816333352652",
    "author": {
      "id": "1344387816333399999",
      "username": "JohnDoe",
      "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
      "created_at": "2025-01-15T12:30:45.123456Z",
      "updated_at": "2025-02-20T08:15:30.987654Z",
      "verified": true,
      "public_flags": 0
    },
    "flags": 0,
    "created_at": "2025-02-26T19:17:12.848375Z",
    "edited_at": null
  }
]

POST/v1/channels/:channel_id/messages

Create a message

This endpoint allows you to create a new message in a channel.

Required attributes

  • Name
    content
    Type
    string
    Description

    The text content of your message.

Optional attributes

  • Name
    message_reference
    Type
    object
    Description

    Reference to another message, if this is a reply.

    • Name
      message_id
      Type
      string
      Description

      The ID of the message being replied to.

Request

POST
/v1/channels/1344387816333352652/messages
curl https://api.lux.gg/v1/channels/1344387816333352652/messages \
  -H "Authorization: {token}" \
  -d content="This is a new message!" \
  -d message_reference[message_id]="1344387816333352999"

Response

{
  "id": "1344390816333352002",
  "type": 0,
  "content": "This is a new message!",
  "channel_id": "1344387816333352652",
  "author": {
    "id": "1344387816333399999",
    "username": "JohnDoe",
    "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
    "created_at": "2025-01-15T12:30:45.123456Z",
    "updated_at": "2025-02-20T08:15:30.987654Z",
    "verified": true,
    "public_flags": 0
  },
  "message_reference": {
    "id": "1344387816333352999",
    "type": 0,
    "content": "Hello, world!",
    "channel_id": "1344387816333352652",
    "author": {
      "id": "1344387816333399999",
      "username": "JohnDoe",
      "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
      "created_at": "2025-01-15T12:30:45.123456Z",
      "updated_at": "2025-02-20T08:15:30.987654Z",
      "verified": true,
      "public_flags": 0
    },
    "flags": 0,
    "created_at": "2025-02-26T19:17:12.848375Z",
    "edited_at": null
  },
  "flags": 0,
  "created_at": "2025-02-26T19:30:45.123456Z",
  "edited_at": null
}

PATCH/v1/channels/:channel_id/messages/:message_id

Edit a message

This endpoint allows you to edit an existing message. You can only edit messages that were created by the same user making the request.

Required attributes

  • Name
    content
    Type
    string
    Description

    The new text content of your message.

Request

PATCH
/v1/channels/1344387816333352652/messages/1344390816333352002
curl -X PATCH https://api.lux.gg/v1/channels/1344387816333352652/messages/1344390816333352002 \
  -H "Authorization: {token}" \
  -d content="This is an edited message!"

Response

{
  "id": "1344390816333352002",
  "type": 0,
  "content": "This is an edited message!",
  "channel_id": "1344387816333352652",
  "author": {
    "id": "1344387816333399999",
    "username": "JohnDoe",
    "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
    "created_at": "2025-01-15T12:30:45.123456Z",
    "updated_at": "2025-02-20T08:15:30.987654Z",
    "verified": true,
    "public_flags": 0
  },
  "message_reference": {
    "id": "1344387816333352999",
    "type": 0,
    "content": "Hello, world!",
    "channel_id": "1344387816333352652",
    "author": {
      "id": "1344387816333399999",
      "username": "JohnDoe",
      "avatar": "https://assets.lux.gg/avatars/1344387816333399999.png",
      "created_at": "2025-01-15T12:30:45.123456Z",
      "updated_at": "2025-02-20T08:15:30.987654Z",
      "verified": true,
      "public_flags": 0
    },
    "flags": 0,
    "created_at": "2025-02-26T19:17:12.848375Z",
    "edited_at": null
  },
  "flags": 0,
  "created_at": "2025-02-26T19:30:45.123456Z",
  "edited_at": "2025-02-26T19:35:12.654321Z"
}

DELETE/v1/channels/:channel_id/messages/:message_id

Delete a message

This endpoint allows you to delete an existing message. You can only delete messages that were created by the same user making the request, or if you have appropriate permissions in the channel.

Request

DELETE
/v1/channels/1344387816333352652/messages/1344390816333352002
curl -X DELETE https://api.lux.gg/v1/channels/1344387816333352652/messages/1344390816333352002 \
  -H "Authorization: {token}"

Response

{
  "success": true
}

Was this page helpful?