Skip to main content
POST
/
messages
JavaScript
import Whop from '@whop/sdk';

const client = new Whop({
  apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});

const message = await client.messages.create({ channel_id: 'channel_id', content: 'content' });

console.log(message.id);
{
  "id": "<string>",
  "content": "Hey, are you available for a **quick call**?",
  "created_at": "2023-12-01T05:00:00.401Z",
  "updated_at": "2023-12-01T05:00:00.401Z",
  "poll": {
    "options": [
      {
        "id": "<string>",
        "text": "<string>"
      }
    ]
  },
  "replying_to_message_id": "<string>",
  "is_edited": true,
  "is_pinned": true,
  "message_type": "regular",
  "user": {
    "id": "user_xxxxxxxxxxxxx",
    "username": "johndoe42",
    "name": "John Doe"
  },
  "view_count": 42,
  "reaction_counts": [
    {
      "emoji": "<string>",
      "count": 42
    }
  ],
  "poll_votes": [
    {
      "option_id": "<string>",
      "count": 42
    }
  ]
}

Authorizations

Authorization
string
header
required

A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************

Body

application/json

Parameters for CreateMessage

channel_id
string
required

The unique identifier of the channel or experience to send the message in. For example, 'exp_xxxxx' or 'feed_xxxxx'.

content
string
required

The body of the message in Markdown format. For example, 'Hello world'.

attachments
FileInputWithId · object[] | null

A list of file attachments to include with the message, such as images or videos.

poll
object

A poll to attach to this message, allowing recipients to vote on options.

replying_to_message_id
string | null

The unique identifier of the message this is replying to, creating a threaded reply.

Response

A successful response

A message sent within an experience chat, direct message, or group chat.

id
string
required

Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.

content
string | null
required

The message content formatted as Markdown. Null if the message has no text content.

Example:

"Hey, are you available for a **quick call**?"

created_at
string<date-time>
required

The timestamp when this message was originally created.

Example:

"2023-12-01T05:00:00.401Z"

updated_at
string<date-time>
required

The timestamp when this message was last modified.

Example:

"2023-12-01T05:00:00.401Z"

poll
object
required

A poll attached to this message. Null if the message does not contain a poll.

replying_to_message_id
string | null
required

The unique identifier of the message this post is replying to. Null if this is not a reply.

is_edited
boolean
required

Whether the message content has been edited after it was originally sent.

is_pinned
boolean
required

Whether this message is pinned to the top of the channel for easy access.

message_type
enum<string>
required

The classification of this message: regular, system, or automated.

Available options:
regular,
system,
automated
user
object
required

The user who authored this message.

view_count
integer | null
required

The number of unique views this message has received. Null if view tracking is not enabled for this channel.

Example:

42

reaction_counts
object[]
required

Aggregated reaction counts on this message, filtered to a specific reaction type.

poll_votes
object[]
required

Aggregated reaction counts on this message, filtered to a specific reaction type.