---
url: https://talkjs.com/docs/Data_APIs/Swift/Message_Content/
title: "Message content | Swift | TalkJS Documentation"
---

For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

# Message content

Structure text, attachments, and location shares in a message.

Every message has "content" which specifies the information in the message. This could be some formatted text, a file attachment, or a shared location.

See the [conceptual documentation](https://talkjs.com/docs/Concepts/Message_Content/) for message content to learn more about how TalkJS represents message content.

## protocol ContentBlock

The content of a message is structured as a list of content blocks.

No properties or methods are currently defined.

## struct TextBlock

A block of formatted text in a message’s content.

### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

### Properties

**children**: EntityTree

### constructor

TextBlock(children:)

#### Parameters

**children**: EntityTree

### \==

func _textBlock_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock)

**rhs _(unnamed)_**: [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock)

#### Returns

Bool

Full documentation of each TextNode variant

### struct Markup

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders its children with a specific style.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Markup__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Markup____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**children**: EntityTree

**type**: String

The kind of formatting to apply when rendering the children

-   type: "bold" is used when users type \*text\* and is rendered with HTML <strong>
-   type: "italic" is used when users type \_text\_ and is rendered with HTML <em>
-   type: "strikethrough" is used when users type ~text~ and is rendered with HTML <s>

### constructor

Markup(type:children:) throws

#### Parameters

**type**: String

**children**: EntityTree

### \==

func _markup_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [Markup](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Markup)

**rhs _(unnamed)_**: [Markup](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Markup)

#### Returns

Bool

### struct BulletList

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that adds indentation for a bullet-point list around its children (HTML `<ul>`).

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletList__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletList____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**children**: EntityTree

### constructor

BulletList(children:)

#### Parameters

**children**: EntityTree

### \==

func _bulletList_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [BulletList](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletList)

**rhs _(unnamed)_**: [BulletList](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletList)

#### Returns

Bool

### struct BulletPoint

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders its children with a bullet-point (HTML `<li>`).

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletPoint__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletPoint____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**children**: \[EntityTreeNode\]

### constructor

BulletPoint(children:)

#### Parameters

**children**: \[EntityTreeNode\]

### \==

func _bulletPoint_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [BulletPoint](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletPoint)

**rhs _(unnamed)_**: [BulletPoint](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#BulletPoint)

#### Returns

Bool

### struct Link

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders its children as a clickable link (HTML `<a>`).

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Link__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Link____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**children**: EntityTree

Inherited from `Clickable.children`.

**url**: String

The URL to open when the node is clicked.

### constructor

Link(url:children:)

#### Parameters

**url**: String

**children**: EntityTree

### \==

func _link_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [Link](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Link)

**rhs _(unnamed)_**: [Link](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Link)

#### Returns

Bool

### struct AutoLink

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders `text` as a link (HTML `<a>`).

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#AutoLink__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**text**: String

The text to display in the link.

**url**: String

The URL to open when a user clicks this node.

### constructor

AutoLink(url:text:)

#### Parameters

**url**: String

**text**: String

### struct ActionLink

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders its children as a clickable action link which triggers a custom action.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionLink__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionLink____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**action**: String

The name of the custom action to invoke when the link is clicked.

**children**: EntityTree

Inherited from `Clickable.children`.

**params**: CustomData

The parameters to pass to the custom action when the link is clicked.

### constructor

ActionLink(action:params:children:)

#### Parameters

**action**: String

**params**: CustomData

**children**: EntityTree

### \==

func _actionLink_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [ActionLink](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionLink)

**rhs _(unnamed)_**: [ActionLink](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionLink)

#### Returns

Bool

### struct ActionButton

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders its children as a clickable action button which triggers a custom action.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionButton__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionButton____" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">==</a></td><td><p>Inherited from <code class="px-[4px] py-[1.6px] rounded-[4px] bg-gray-200/75 text-gray-700">Equatable.==(_:_:)</code>.</p></td></tr></tbody></table>

#### Properties

**action**: String

The name of the custom action to invoke when the button is clicked.

**children**: EntityTree

Inherited from `Clickable.children`.

**params**: CustomData

The parameters to pass to the custom action when the button is clicked.

### constructor

ActionButton(action:params:children:)

#### Parameters

**action**: String

**params**: CustomData

**children**: EntityTree

### \==

func _actionButton_.\==(\_:\_:) -> Bool

Inherited from `Equatable.==(_:_:)`.

#### Parameters

**lhs _(unnamed)_**: [ActionButton](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionButton)

**rhs _(unnamed)_**: [ActionButton](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ActionButton)

#### Returns

Bool

### struct CodeSpan

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that renders `text` in an inline code span (HTML `<code>`).

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#CodeSpan__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**text**: String

Inherited from `Leaf.text`.

### constructor

CodeSpan(text:)

#### Parameters

**text**: String

### struct CustomEmoji

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that is used for custom emoji.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#CustomEmoji__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**text**: String

The name (including colons at the start and end) of the custom emoji to show.

### constructor

CustomEmoji(text:)

#### Parameters

**text**: String

### struct Mention

A node in a [TextBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#TextBlock) that is used when a user is mentioned.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#Mention__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**id**: String

The ID of the user who is mentioned.

**text**: String

The name of the user who is mentioned.

### constructor

Mention(id:text:)

#### Parameters

**id**: String

**text**: String

## protocol FileBlock

No properties or methods are currently defined.

Full documentation of each FileBlock variant

### struct GenericFileBlock

The most basic FileBlock variant, used whenever there is no additional metadata for a file.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#GenericFileBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**filename**: String

The name of the file, including file extension

**fileToken**: String

An encoded identifier for this file. Use in [SendFileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock) to send this file in another message.

**size**: Int64

The size of the file in bytes

**url**: String

The URL where you can fetch the file

### constructor

GenericFileBlock(url:size:filename:fileToken:)

#### Parameters

**url**: String

**size**: Int64

**filename**: String

**fileToken**: String

### struct VideoBlock

A FileBlock variant for a video attachment, with additional video-specific metadata.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#VideoBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**duration _(optional)_**: Double?

The duration of the video in seconds, if known.

**filename**: String

The name of the video file, including file extension.

**fileToken**: String

An encoded identifier for this file. Use in [SendFileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock) to send this video in another message.

**height _(optional)_**: Int?

The height of the video in pixels, if known.

**size**: Int64

The size of the file in bytes.

**url**: String

The URL where you can fetch the file.

**width _(optional)_**: Int?

The width of the video in pixels, if known.

### constructor

VideoBlock(url:size:filename:fileToken:width:height:duration:)

#### Parameters

**url**: String

**size**: Int64

**filename**: String

**fileToken**: String

**width _(optional)_**: Int?

**height _(optional)_**: Int?

**duration _(optional)_**: Double?

### struct ImageBlock

A FileBlock variant for an image attachment, with additional image-specific metadata.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ImageBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**filename**: String

The name of the image file, including file extension.

**fileToken**: String

An encoded identifier for this file. Use in [SendFileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock) to send this image in another message.

**height _(optional)_**: Int?

The height of the image in pixels, if known.

**size**: Int64

The size of the file in bytes.

**url**: String

The URL where you can fetch the file.

**width _(optional)_**: Int?

The width of the image in pixels, if known.

### constructor

ImageBlock(url:size:filename:fileToken:width:height:)

#### Parameters

**url**: String

**size**: Int64

**filename**: String

**fileToken**: String

**width _(optional)_**: Int?

**height _(optional)_**: Int?

### struct AudioBlock

A FileBlock variant for an audio attachment, with additional audio-specific metadata.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#AudioBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**duration _(optional)_**: Double?

The duration of the audio in seconds, if known

**filename**: String

The name of the audio file, including file extension

**fileToken**: String

An encoded identifier for this file. Use in [SendFileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock) to send this file in another message.

**size**: Int64

The size of the file in bytes

**url**: String

The URL where you can fetch the file

### constructor

AudioBlock(url:size:filename:fileToken:duration:)

#### Parameters

**url**: String

**size**: Int64

**filename**: String

**fileToken**: String

**duration _(optional)_**: Double?

### struct VoiceBlock

A FileBlock variant for a voice recording attachment, with additional voice-recording-specific metadata.

#### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#VoiceBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

#### Properties

**duration _(optional)_**: Double?

The duration of the voice recording in seconds, if known

**filename**: String

The name of the file, including file extension

**fileToken**: String

An encoded identifier for this file. Use in [SendFileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock) to send this voice recording in another message.

**size**: Int64

The size of the file in bytes

**url**: String

The URL where you can fetch the file

### constructor

VoiceBlock(url:size:filename:fileToken:duration:)

#### Parameters

**url**: String

**size**: Int64

**filename**: String

**fileToken**: String

**duration _(optional)_**: Double?

## struct LocationBlock

A block showing a location in the world, typically because a user shared their location in the chat.

### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#LocationBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

### Properties

**latitude**: Double

The north-south coordinate of the location.

Usually listed first in a pair of coordinates.

Must be a number between -90 and 90

**longitude**: Double

The east-west coordinate of the location.

Usually listed second in a pair of coordinates.

Must be a number between -180 and 180

### constructor

LocationBlock(latitude:longitude:)

#### Parameters

**latitude**: Double

**longitude**: Double

## protocol SendContentBlock

The version of [ContentBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#ContentBlock) that is used when sending or editing messages.

No properties or methods are currently defined.

## struct SendFileBlock

The version of [FileBlock](https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#FileBlock) that is used when sending or editing messages.

### Method Overview

<table class="my-0"><tbody><tr class="flex flex-col flex-no-wrap sm:table-row"><td><a href="https://talkjs.com/docs/Data_APIs/Swift/Message_Content/#SendFileBlock__constructor" class="no-underline font-mono text-blue-500 hover:text-blue-600 font-medium">constructor</a></td><td></td></tr></tbody></table>

### Properties

**fileToken**: String

The encoded identifier for the file, obtained by uploading a file with `Session/sendFile`, or taken from another message.

### constructor

SendFileBlock(fileToken:)

#### Parameters

**fileToken**: String
