All available operations for listing and editing messages


Looking for the message data format?

Check out the how-to guide for examples of the Cord message data format

List all messages in a thread #

This endpoint returns information about all messages in a thread.

HTTP Request #

HTTP:
GET https://api.cord.com/v1/threads/<ID>/messages
cURL:
curl "https://api.cord.com/v1/threads/<threadID>/messages" \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord thread get-messages <THREAD_ID>
GET https://api.cord.com/v1/threads/<ID>/messages
Copy

Request Body #

This REST endpoint has no request body.


Query Parameters #

This endpoint can take the following options:


sortDirection
optional
"ascending" | "descending"
Return messages in ascending or descending order of creation timestamp. 'descending' is the default.

Response #

The response is a JSON Array of objects with the following fields:


id
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.


authorID
string
The ID for the user that sent the message.


groupID
string
The ID for the group this message belongs to.


threadID
string
The ID for the thread this message is part of.


content
MessageContent
The content of the message.

This is an array of items. Each item can be one of the following:

  • MessageAssigneeNode

    This is an object with the following fields:

    Show property details

  • MessageBulletNode

    This is an object with the following fields:

    Show property details

  • MessageCodeNode

    This is an object with the following fields:

    Show property details

  • MessageLinkNode

    This is an object with the following fields:

    Show property details

  • MessageMentionNode

    This is an object with the following fields:

    Show property details

  • MessageNumberBulletNode

    This is an object with the following fields:

    Show property details

  • MessageParagraphNode

    This is an object with the following fields:

    Show property details

  • MessageQuoteNode

    This is an object with the following fields:

    Show property details

  • MessageTextNode

    This is an object with the following fields:

    Show property details

  • MessageTodoNode

    This is an object with the following fields:

    Show property details

  • MessageMarkdownNode

    This is an object with the following fields:

    Show property details



plaintext
string
A plaintext version of the structured message content.


url
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.


createdTimestamp
Date
The timestamp when this message was created. The default value is the current time.


deletedTimestamp
Date | null
The timestamp when this message was deleted, if it was. If unset, the message is not deleted.


updatedTimestamp
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.


iconURL
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.


translationKey
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.


type
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.


metadata
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.


extraClassnames
string | null
A optional space separated list of classnames to add to the message.


attachments
MessageAttachment[]
The items attached to this message.

This is an array of items. Each item can be one of the following:

  • MessageFileAttachment

    This is an object with the following fields:

    Show property details

  • MessageAnnotationAttachment

    This is an object with the following fields:

    Show property details

  • MessageScreenshotAttachment

    This is an object with the following fields:

    Show property details

  • MessageLinkPreviewAttachment

    This is an object with the following fields:

    Show property details



reactions
Reaction[]
The reactions to this message.

This is an array of objects, each of which has the following fields:

Show property details



seenBy
string[]
A list of IDs of the users that have seen the message.


skipLinkPreviews
boolean
If set, Cord won't analyze links in the message to generate previews.

List all messages #

This endpoint returns information about all messages in the project. Most of the times, fetching messages for a specific thread should be preferred.

HTTP Request #

HTTP:
GET https://api.cord.com/v1/messages
cURL:
curl "https://api.cord.com/v1/messages" \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message ls
GET https://api.cord.com/v1/messages
Copy

Request Body #

This REST endpoint has no request body.


Query Parameters #

This endpoint can take the following options:


limit
optional
number
Number of messages to return. Defaults to 1000.


token
optional
string
Pagination token. This is returned in the pagination object of a previous response.


filter
optional
ServerListMessageFilter
Messages will be matched against the filters specified. This is a partial match, which means any keys other than the ones you specify are ignored when checking for a match. Please note that because this is a query parameter in a REST API, this JSON object must be URI encoded before being sent.

This is an object with the following fields:

Show property details


Response #

The response is an object with the following fields:


messages
CoreMessageData[]
Page containing messages.

This is an array of objects, each of which has the following fields:

Show property details



pagination
PaginationDetails
Data related to cursor-based pagination.

This is an object with the following fields:

Show property details


Get a message #

This endpoint returns information about a single message.

HTTP Request #

HTTP:
GET https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
cURL:
curl "https://api.cord.com/v1/threads/<threadID>/messages/<messageID>" \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message get <ID>
GET https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
Copy

Request Body #

This REST endpoint has no request body.

Response #

The response is an object with the following fields:


id
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.


authorID
string
The ID for the user that sent the message.


groupID
string
The ID for the group this message belongs to.


threadID
string
The ID for the thread this message is part of.


content
MessageContent
The content of the message.

This is an array of items. Each item can be one of the following:

  • MessageAssigneeNode

    This is an object with the following fields:

    Show property details

  • MessageBulletNode

    This is an object with the following fields:

    Show property details

  • MessageCodeNode

    This is an object with the following fields:

    Show property details

  • MessageLinkNode

    This is an object with the following fields:

    Show property details

  • MessageMentionNode

    This is an object with the following fields:

    Show property details

  • MessageNumberBulletNode

    This is an object with the following fields:

    Show property details

  • MessageParagraphNode

    This is an object with the following fields:

    Show property details

  • MessageQuoteNode

    This is an object with the following fields:

    Show property details

  • MessageTextNode

    This is an object with the following fields:

    Show property details

  • MessageTodoNode

    This is an object with the following fields:

    Show property details

  • MessageMarkdownNode

    This is an object with the following fields:

    Show property details



plaintext
string
A plaintext version of the structured message content.


url
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.


createdTimestamp
Date
The timestamp when this message was created. The default value is the current time.


deletedTimestamp
Date | null
The timestamp when this message was deleted, if it was. If unset, the message is not deleted.


updatedTimestamp
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.


iconURL
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.


translationKey
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.


type
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.


metadata
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.


extraClassnames
string | null
A optional space separated list of classnames to add to the message.


attachments
MessageAttachment[]
The items attached to this message.

This is an array of items. Each item can be one of the following:

  • MessageFileAttachment

    This is an object with the following fields:

    Show property details

  • MessageAnnotationAttachment

    This is an object with the following fields:

    Show property details

  • MessageScreenshotAttachment

    This is an object with the following fields:

    Show property details

  • MessageLinkPreviewAttachment

    This is an object with the following fields:

    Show property details



reactions
Reaction[]
The reactions to this message.

This is an array of objects, each of which has the following fields:

Show property details



seenBy
string[]
A list of IDs of the users that have seen the message.


skipLinkPreviews
boolean
If set, Cord won't analyze links in the message to generate previews.

Create a message #

This endpoint adds a new message to a thread.

HTTP Request #

HTTP:
POST https://api.cord.com/v1/threads/<ID>/messages
cURL:
curl "https://api.cord.com/v1/threads/<threadID>/messages" \
  -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'\
  -H 'Content-Type: application/json' 
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message create [ID]
POST https://api.cord.com/v1/threads/<ID>/messages
Copy

Request Body #


addReactions
optional
ServerAddReactions[]
The reactions you want to add to this message. The default timestamp is the current time. Trying to create a reaction that already exists for a user does nothing. Doing the same as before with a timestamp will update the reaction with the new timestamp. The reaction users need to be an active member of the group that the message and thread belong to.

This is an array of objects, each of which has the following fields:

Show property details



addAttachments
optional
CreateFileAttachment[]
A list of attachments to add to the message. The same file cannot be attached to the same message multiple times.

This is an array of objects, each of which has the following fields:

Show property details



authorID
required
string
The ID for the user that sent the message.


content
required
MessageContent
The content of the message.

This is an array of items. Each item can be one of the following:

  • MessageAssigneeNode

    This is an object with the following fields:

    Show property details

  • MessageBulletNode

    This is an object with the following fields:

    Show property details

  • MessageCodeNode

    This is an object with the following fields:

    Show property details

  • MessageLinkNode

    This is an object with the following fields:

    Show property details

  • MessageMentionNode

    This is an object with the following fields:

    Show property details

  • MessageNumberBulletNode

    This is an object with the following fields:

    Show property details

  • MessageParagraphNode

    This is an object with the following fields:

    Show property details

  • MessageQuoteNode

    This is an object with the following fields:

    Show property details

  • MessageTextNode

    This is an object with the following fields:

    Show property details

  • MessageTodoNode

    This is an object with the following fields:

    Show property details

  • MessageMarkdownNode

    This is an object with the following fields:

    Show property details



type
optional
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.


id
optional
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.


createdTimestamp
optional
Date
The timestamp when this message was created. The default value is the current time.


iconURL
optional
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.


metadata
optional
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.


url
optional
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.


deletedTimestamp
optional
Date | null
The timestamp when this message was deleted, if it was. If unset, the message is not deleted.


updatedTimestamp
optional
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.


translationKey
optional
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.


extraClassnames
optional
string | null
A optional space separated list of classnames to add to the message.


skipLinkPreviews
optional
boolean
If set, Cord won't analyze links in the message to generate previews.


createThread
optional
Omit<ServerCreateThread, "id">
The parameters for creating a thread if the supplied thread doesn't exist yet. If the thread doesn't exist but createThread isn't provided, the call will generate an error. This value is ignored if the thread already exists.

This is an object with the following fields:

Show property details

Example Request #

cURL:
curl "https://api.cord.com/v1/threads/xyz456/messages" \
  -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  --json '{
    "id": "abc123",
    "authorID": "user123",
    "content": [{
      "type": "p",
      "children": [
        {
          "type": "mention",
          "user": { "id": "user456" },
          "children": [{"text": "@Zoidberg"}]
        },
        {
          "text": " Can you take a look at this?"
        }
      ]
    }]
  }'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message create abc123 --thread-id=xyz456 --author-id=user123 
--content='[{
  "type": "p",
  "children": [
    {
      "type": "mention",
      "user": { "id": "user456" },
      "children": [{ "text": "@Fry" }]
    },
    {
      "text": "Can you take a look at this?"
    }
  ]}]'
curl "https://api.cord.com/v1/threads/xyz456/messages" \
  -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  --json '{
    "id": "abc123",
    "authorID": "user123",
    "content": [{
      "type": "p",
      "children": [
        {
          "type": "mention",
          "user": { "id": "user456" },
          "children": [{"text": "@Zoidberg"}]
        },
        {
          "text": " Can you take a look at this?"
        }
      ]
    }]
  }'
Copy

Response #

If successful, the response will be:

JSON:
{
  "success": true,
  "message": "Message created.",
  "messageID": "abc123"
}
{
  "success": true,
  "message": "Message created.",
  "messageID": "abc123"
}
Copy

Update a message #

Use this endpoint to update an existing message.

HTTP Request #

HTTP:
PUT https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
cURL:
curl "https://api.cord.com/v1/threads/<threadID>/messages/<messageID>" \
  -X PUT \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'\
  -H 'Content-Type: application/json' 
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message update <ID>
PUT https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
Copy

Request Body #

Listed below are the fields of the request body to be added as part of the HTTP PUT request.


removeReactions
optional
ServerRemoveReactions[]
The reactions you want to remove from this message. Removing a reaction that does not exist will have no effect and will not return an error. An error is returned if a reaction is both added and deleted in the same request.


removeAttachments
optional
RemoveAttachment[]
The attachments you want to remove from this message. Removing an attachment that doesn't exist has no effect and won't return an error. Attempting to add and remove the same attachment in one request is an error.

This is an array of items. Each item can be one of the following:

  • RemoveLinkPreviewAttachment

    This is an object with the following fields:

    Show property details

  • RemoveFileAttachment

    This is an object with the following fields:

    Show property details



type
optional
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.


id
optional
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.


createdTimestamp
optional
Date
The timestamp when this message was created. The default value is the current time.


iconURL
optional
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.


metadata
optional
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.


url
optional
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.


authorID
optional
string
The ID for the user that sent the message.


content
optional
MessageContent
The content of the message.

This is an array of items. Each item can be one of the following:

  • MessageAssigneeNode

    This is an object with the following fields:

    Show property details

  • MessageBulletNode

    This is an object with the following fields:

    Show property details

  • MessageCodeNode

    This is an object with the following fields:

    Show property details

  • MessageLinkNode

    This is an object with the following fields:

    Show property details

  • MessageMentionNode

    This is an object with the following fields:

    Show property details

  • MessageNumberBulletNode

    This is an object with the following fields:

    Show property details

  • MessageParagraphNode

    This is an object with the following fields:

    Show property details

  • MessageQuoteNode

    This is an object with the following fields:

    Show property details

  • MessageTextNode

    This is an object with the following fields:

    Show property details

  • MessageTodoNode

    This is an object with the following fields:

    Show property details

  • MessageMarkdownNode

    This is an object with the following fields:

    Show property details



updatedTimestamp
optional
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.


translationKey
optional
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.


extraClassnames
optional
string | null
A optional space separated list of classnames to add to the message.


skipLinkPreviews
optional
boolean
If set, Cord won't analyze links in the message to generate previews.


addReactions
optional
ServerAddReactions[]
The reactions you want to add to this message. The default timestamp is the current time. Trying to create a reaction that already exists for a user does nothing. Doing the same as before with a timestamp will update the reaction with the new timestamp. The reaction users need to be an active member of the group that the message and thread belong to.

This is an array of objects, each of which has the following fields:

Show property details



addAttachments
optional
CreateFileAttachment[]
A list of attachments to add to the message. The same file cannot be attached to the same message multiple times.

This is an array of objects, each of which has the following fields:

Show property details



deleted
optional
boolean
Whether we want to mark this message as deleted. Setting this to true without providing a value for deletedTimestamp is equivalent to setting deletedTimestamp to current time and setting this to false is equivalent to setting deletedTimestamp to null.


deletedTimestamp
optional
Date | null
The timestamp when this message was deleted, if it was. If set to null, the message is not deleted. Deleting a message this way will only soft delete it, replacing the content of the message with a record of the deletion on the frontend. If you'd like to permanently delete it instead, use the delete message endpoint.

Response #

If successful, the response will be:

JSON:
{
  "success": true,
  "message": "✅ You successfully updated message abc123"
}
{
  "success": true,
  "message": "✅ You successfully updated message abc123"
}
Copy

Delete a message #

This endpoint deletes a message.

HTTP Request #

HTTP:
DELETE https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
cURL:
curl "https://api.cord.com/v1/threads/<threadID>/messages/<messageID>" \
  -X DELETE \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord message delete <ID>
DELETE https://api.cord.com/v1/threads/<threadID>/messages/<messageID>
Copy

Request Body #

This REST endpoint has no request body.

Response #

If successful, the response will be:

JSON:
{
  "success": true,
  "message": "💀 You successfully deleted message abc123"
}
{
  "success": true,
  "message": "💀 You successfully deleted message abc123"
}
Copy

Not finding the answer you need? Ask our Developer Community

Ask Cordy