Skip to main content

Bulk import data

Large quantities of data can be imported from a JSONL file into Mattermost at the command line using the bulk import feature. This feature is most suitable for migrating data from an existing system, or for pre-populating a new installation with data.

You can import the following data types:

  • Teams
  • Threaded discussions
  • Channels (public and private)
  • Users
  • Users' team memberships
  • Users' channel memberships
  • Users' notification preferences
  • Users' custom status
  • Posts (regular, non-reply posts)
  • Posts' replies
  • Posts' reactions
  • Posts' file attachments
  • Direct message and group message channels
  • Direct message and group message channels' read/unread status
  • Direct messages and group messages
  • Direct messages from a user to themselves
  • Permissions schemes
  • Custom emoji
  • Bot users

Importing additional types of posts is not yet supported.

About the bulk import command

The bulk import command is interruptible and idempotent

If the import is interrupted for any reason, it continues from where it left off the next time you run it. You can run the command repeatedly with the same data file, and the data is imported only once. Posts with matching timestamps to incoming posts will have their attachments replaced by the incoming data. Prior to v5.20 any updates to posts with matching timestamps were appended to older posts.

You can run the bulk import command on a live system

Although you don't need to shut down Mattermost to run the command, changes made by users of the system between runs can be overwritten if the corresponding fields exist in the data file.

Some data fields are optional

Not all fields are mandatory. If an optional field is missing from the object that is being imported, the field's current value in the database is not changed.

The bulk import command is not a synchronization tool

You cannot use the bulk import command to remove any objects or their fields from the Mattermost database. The command only creates or overwrites fields.

Bulk import data

Before running the bulk import command, you must first create a JSONL file that contains the data that you want to import in your Mattermost directory. The file can have any name, but in this example it's called data.jsonl. The format of the file is described in the data-format section.

Next, zip it by running the zip -r data.zip data.jsonl command.

Using mmctl local mode

From Mattermost v9.5, the mmctl bulk import process command in local mode supports processing an import file without uploading it to the server.

Run mmctl import process --bypass-upload <file>.zip --local to start your import and enable the Mattermost server to read from the file directly.

Not using mmctl local mode

If you're not running mmctl commands in local mode:

  1. Upload the ZIP file to the database by running the mmctl import upload command. For example: mmctl import upload data.zip. After uploading, two IDs are returned: the first line contains the upload session ID, and the second line contains the filename.
  2. Confirm that the file is uploaded and ready for use by running the mmctl import list available command.
  3. Import your uploaded file by running the mmctl import process command using the upload session ID (not the filename). For example: mmctl import process <upload_session_id>_data.zip where <upload_session_id> is the upload session ID returned from the upload command.

Data format

The input data file must be a valid JSONL file with the following objects, each on its own line in the file. The objects must occur in the file in the order listed.

Version
Mandatory. The Version object must be the first line in the file, and must occur only once. The version is the version of the bulk import tool, which is currently 1.

Scheme
Optional. If present, Scheme objects must occur after the Version object but before any Team objects.

Emoji
Optional. If present, Emoji objects must occur after the Version objects but before any Team objects.

Team
Optional. If present, Team objects must occur after any Scheme objects and before any Channel objects.

Channel
Optional. If present, Channel objects must occur after all Team objects and before any User objects.

User
Optional. If present, User objects must occur after the Team and Channel objects in the file and before any Post objects. Each User object defines the teams and channels that the user is a member of. If the corresponding teams and channels are not in the data file, then they must exist in the Mattermost database.

Post
Optional. If present, Post objects must occur after the last User object but before any DirectChannel objects. Each Post object defines the team, the channel, and the username of the user who posted the message. If the corresponding team, channel, or user are not in the data file, then they must exist in the Mattermost database.

DirectChannel
Optional. If present, DirectChannel objects must occur after all Post objects in the file and before any DirectPost objects.

DirectPost
Optional. If present, DirectPost objects must occur after all other objects in the file. Each DirectPost object defines the usernames of the channel members and the username of the user who posted the message. If the corresponding usernames are not in the data file, then they must exist in the Mattermost database.

With the exception of the Version object, each object has a field or a combination of fields that is used as the unique identifier of that object. The bulk import command uses the unique identifier to determine if the object being imported is a new object or an update to an existing object.

The identifiers for each object are listed in the following table:

Objects and their unique identifiers
ObjectUnique Identifier
VersionNot Applicable
Schemename
Rolename
Emojiname
Teamname
Channelname, team
Userusername
UserNotifyPropsusername
UserTeamMembershipteam, username
UserChannelMembershipteam, channel, username
Postchannel, message, create_at
Replypost, message, create_at
Reactionpost, emoji_name, create_at
Attachmentpath
DirectChannelmembers
DirectPostchannel_members, user, message, create_at

The following fragment is from a file that imports two teams, each with two channels, many users, and many posts.

{ "type": "version", ... }
{ "type": "team", "team": { "name": "TeamA", ...} }
{ "type": "team", "team": { "name": "TeamB", ...} }
{ "type": "channel", "channel": { "team": "TeamA", "name": "channel_a1", ...} }
{ "type": "channel", "channel": { "team": "TeamA", "name": "channel_a2", ...} }
{ "type": "channel", "channel": { "team": "TeamB", "name": "channel_b1", ...} }
{ "type": "channel", "channel": { "team": "TeamB", "name": "channel_b2", ...} }
{ "type": "user", "user": { "username": "user001", ...} }
{ "type": "user", "user": { "username": "user002", ...} }
{ "type": "user", "user": { "username": "user003", ...} }
{ "type": "user", ... }
{ "type": "user", ... }
{ "type": "user", ... }
.
.
.
{ "type": "post", { "team": "TeamA", "name": "channel_a1", "user": "user001", ...} }
{ "type": "post", { "team": "TeamA", "name": "channel_a1", "user": "user001", ...} }
{ "type": "post", { "team": "TeamA", "name": "channel_a1", "user": "user001", ...} }
.
.
.

Version object

The Version object must be the first object in the data file, and can appear only once. The version represents the version of the bulk import tool and currently is 1.

Example Version object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "version",
"version": 1
}

Fields of the Version object

Field nameTypeDescriptionValidatedMandatory
typestringMust be the string "version"YesYes
versionnumberMust be the number 1.YesYes

Scheme object

Scheme objects represent Permissions Schemes in the Mattermost permissions system. If present, Scheme objects must occur after the Version object and before any Team objects.

Example Scheme object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "scheme",
"scheme": {
"name": "custom_scheme_name",
"display_name": "Custom Scheme Name",
"description": "This is a custom override scheme.",
"scope": "team",
"default_team_admin_role": {
"name": "custom_scheme_team_admin_role",
"display_name": "Custom Scheme Team Admin Role",
"description": "This is the default team admin role for the custom scheme.",
"permissions": ["add_user_to_team", "manage_team_roles"],
},
"default_team_user_role": {
"name": "custom_scheme_team_user_role",
"display_name": "Custom Scheme Team User Role",
"description": "This is the default team user role for the custom scheme.",
"permissions": ["create_public_channel", "create_private_channel"],
},
"default_channel_admin_role": {
"name": "custom_scheme_channel_admin_role",
"display_name": "Custom Scheme Channel Admin Role",
"description": "This is the default channel admin role for the custom scheme.",
"permissions": ["manage_private_channel_members", "manage_channel_roles"],
},
"default_channel_user_role": {
"name": "custom_scheme_channel_user_role",
"display_name": "Custom Scheme Channel User Role",
"description": "This is the default channel user role for the custom scheme.",
"permissions": ["manage_public_channel_members", "manage_public_channel_properties"],
},
}
}

Fields of the Scheme object

Field nameTypeDescriptionValidatedMandatory
namestringThe scheme name. Must start with and contain only lowercase letters ([a-z0-9]) or _, and must be between 2-64 characters in length.YesYes
display_namestringThe display name for the scheme.YesYes
scopestringThe scope for the scheme. Must be either "team" or "channel".YesYes
descriptionstringThe description of the scheme.YesNo
default_team_admin_roleRole objectThe default role applied to team admins in teams using this scheme. This field is mandatory if the scheme scope is set to "team", otherwise must not be present.YesNo
default_team_user_roleRole objectThe default role applied to Team Users in teams using this scheme. This field is mandatory if the scheme scope is set to "team", otherwise must not be present.YesNo
default_channel_admin_roleRole objectThe default role applied to channel admins in channels using this scheme. This field is mandatory for both "team" and "channel" scope schemes.YesYes
default_channel_user_roleRole objectThe default role applied to Channel Users in channels using this scheme. This field is mandatory for both "team" and "channel" scope schemes.YesYes

Fields of the Role object

This object is a member of the Scheme object.

Field nameTypeDescriptionValidatedMandatory
namestringThe scheme name.YesYes
display_namestringThe display name for the scheme.YesYes
descriptionstringThe description of the scheme.YesNo
permissionsarrayThe permissions the role should grant. This is an array of strings where the strings are the names of individual permissions in the Mattermost permissions system.YesNo

Emoji object

Emoji objects represent custom Emoji. If present, Emoji objects must occur after the Version object and before any Team objects.

Example Emoji object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "emoji",
"emoji": {
"name": "custom-emoji-troll",
"image": "bulkdata/emoji/trollolol.png"
}
}

Fields of the Emoji object

Field nameTypeDescriptionValidatedMandatory
namestringThe emoji name.YesYes
imagestringThe path (either absolute or relative to the current working directory) to the image file for this emoji.NoYes

Team object

If present, Team objects must occur after the Version object and before any Channel objects.

Example Team object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "team",
"team": {
"name": "team-name",
"display_name": "Team Display Name",
"type": "O",
"description": "The Team Description",
"allow_open_invite": true
}
}

Fields of the Team object

[1] Not validated, but an error occurs if no such scheme exists when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
namestringThe team name.YesYes
display_namestringThe display name for the team.YesYes
typestringThe type of team. Can have one the following values:
O for an open team
I for an invite-only team.
YesYes
descriptionstringThe team description.YesNo
allow_open_inviteboolWhether to allow open invitations. Must have one of the following values:
true
false
YesNo
schemestringThe name of the Scheme that should be applied to this team.No [1]No

Channel object

If present, Channel objects must occur after all Team objects and before any User objects.

Example Channel object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "channel",
"channel": {
"team": "team-name",
"name": "channel-name",
"display_name": "Channel Name",
"type": "O",
"header": "The Channel Header",
"purpose": "The Channel Purpose",
}
}

Fields of the Channel object

[1] Not validated, but an error occurs if no such team/scheme exists when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
teamstringThe name of the team this channel belongs to.No [1]Yes
namestringThe name of the channel. Must start with and contain only lowercase letters ([a-z0-9]) or - or _.YesYes
display_namestringThe display name for the channel.Yesyes
typestringThe type of channel. Can have one the following values:
O for a public channel.
P for a private channel.
YesYes
headerstringThe channel header.YesNo
purposestringThe channel purpose.YesNo
schemestringThe name of the Scheme that should be applied to this team.No [1]No

User object

If present, User objects must occur after the Team and Channel objects in the file and before any Post objects.

Example User object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "user",
"user": {
"profile_image": "profile-picture.png",
"username": "username",
"email": "email@example.com",
"auth_service": "",
"password": "passw0rd",
"nickname": "bobuser",
"first_name": "Bob",
"last_name": "User",
"position": "Senior Developer",
"roles": "system_user",
"locale": "pt_BR",
"teams": [
{
"name": "team-name",
"theme": "{
\"awayIndicator\":\"#DBBD4E\",
\"buttonBg\":\"#23A1FF\",
\"buttonColor\":\"#FFFFFF\",
\"centerChannelBg\":\"#ffffff\",
\"centerChannelColor\":\"#333333\",
\"codeTheme\":\"github\",
\"linkColor\":\"#2389d7\",
\"mentionBg\":\"#2389d7\",
\"mentionColor\":\"#ffffff\",
\"mentionHighlightBg\":\"#fff2bb\",
\"mentionHighlightLink\":\"#2f81b7\",
\"newMessageSeparator\":\"#FF8800\",
\"onlineIndicator\":\"#7DBE00\",
\"sidebarBg\":\"#fafafa\",
\"sidebarHeaderBg\":\"#3481B9\",
\"sidebarHeaderTextColor\":\"#ffffff\",
\"sidebarText\":\"#333333\",
\"sidebarTextActiveBorder\":\"#378FD2\",
\"sidebarTextActiveColor\":\"#111111\",
\"sidebarTextHoverBg\":\"#e6f2fa\",
\"sidebarUnreadText\":\"#333333\",
}",
"roles": "team_user team_admin",
"channels": [
{
"name": "channel-name",
"roles": "channel_user",
"notify_props": {
"desktop": "default",
"mark_unread": "all"
}
}
]
}
]
}
}

Fields of the User object

Field nameTypeDescriptionValidatedMandatory
profile_imagestringThe user’s profile image. This must be an existing file path.YesNo
usernamestringThe user’s username. This is the unique identifier for the user.YesYes
emailstringThe user’s email address.YesYes
auth_servicestringThe authentication service to use for this user account. If not provided, it defaults to password-based authentication. Must be one of the following values:
"" or not provided - password authentication.
"gitlab" - GitLab authentication.
"ldap" - LDAP authentication (Enterprise and Professional)
"saml" - Generic SAML based authentication (Enterprise)
"google" - Google OAuth authentication (Enterprise)
"office365" - Microsoft Entra ID OAuth Authentication (Enterprise)
NoNo
auth_datastringThe authentication data if auth_service is used. The value depends on the auth_service that is specified.
The data comes from the following fields for the respective auth_services:
"" or not provided - must be omitted.
"gitlab" - The value of the Id attribute provided in the GitLab auth data.
"ldap" - The value of the LDAP attribute specified as the "ID Attribute" in the Mattermost LDAP configuration.
"saml" - The value of the SAML Email address attribute.
"google" - The value of the OAuth Id attribute.
"office365" - The value of the OAuth Id attribute.
NoNo
passwordstringA password for the user. Can be present only when password-based authentication is used. When password-based authentication is used and the password is not present, the bulk import command generates a password.YesNo
nicknamestringThe user’s nickname.YesNo
first_namestringThe user’s first name.YesNo
last_namestringThe user’s last name.YesNo
positionstringThe user’s position.YesNo
rolesstringThe user’s roles. Must be one of the following values:
"system_user"
"system_admin system_user"
YesNo
localestringThe user’s locale. This must be a valid locale for which Mattermost has been localised.NoNo
delete_atint64Timestamp for when the user was deactivated.NoNo
teamsarrayThe teams which the user will be made a member of. Must be an array of UserTeamMembership objects.YesNo
themestringThe user’s theme. Formatted as a Mattermost theme string.NoNo
military_timestringHow times should be displayed to this user. Must be one of the following values:
"true" - Use 24 hour clock.
"false" - Use 12 hour clock.
NoNo
collapse_previewsstringWhether to collapse or expand link previews by default. Must be one of the following values:
"true" - Collapsed by default.
"false" - Expanded by default.
NoNo
message_displaystringWhich style to use for displayed messages. Must be one of the following values:
"clean" - Use the standard style.
"compact" - Use the compact style.
NoNo
channel_display_modestringHow to display channel messages. Must be one of the following values:
"full" - Use the full width of the screen.
"centered" - Use a fixed width, centered block.
NoNo
tutorial_stepstringWhere to start the user tutorial. Must be one of the following values:
"1", "2" or "3" - Start from the specified tutorial step.
"999" - Skip the user tutorial.
NoNo
use_markdown_previewboolEnable preview of message markdown formatting. Can have one the following values:
"True"
"False"
YesYes
use_formattingboolEnable post formatting for links, emoji, text styles and line breaks. Can have one the following values:
"True"
"False"
YesYes
show_unread_sectionboolEnable showing unread messages at top of channel sidebar. Can have one the following values:
"True"
"False"
YesYes
email_intervalstringSpecify an email batching interval during bulk import. Can have one of the following values:
"immediately" - Emails are sent immediately.
"fifteen" - Emails are batched and sent every 15 minutes.
"hour" - Emails are batched and sent every hour.
YesYes
notify_propsUserNotifyProps objectThe user’s notify preferences, as defined by the UserNotifyProps object.YesNo

Fields of the UserNotifyProps object

This object is a member of the User object.

[1] Not validated, but an error occurs if no such team exists when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
desktopstringPreference for sending desktop notifications. Must be one of the following values:
"all" - For all activity.
"mention" - Only for mentions.
"none" - Never.
YesNo
desktop_soundstringPreference for whether desktop notification sound is played. Must be one of the following values:
"true" - Sound is played.
"false" - Sound is not played.
YesNo
emailstringPreference for email notifications. Must be one of the following values:
"true" - Email notifications are sent based on the email_interval setting
"false" - Email notifications are not sent.
NoNo
mobilestringPreference for sending mobile push notifications. Must be one of the following values:
"all" - For all activity.
"mention" - Only for mentions.
"none" - Never.
YesNo
mobile_push_statusstringPreference for when push notifications are triggered. Must be one of the following values:
"online" - When online, away or offline.
"away" - When away or offline.
"offline" - When offline.
YesNo
channelstringWhether @all, @channel and @here trigger mentions. Must be one of the following values:
"true" - Mentions are triggered.
"false" - Mentions are not triggered.
YesNo
commentsstringPreference for reply mention notifications. Must be one of the following values:
"any" - Trigger notifications on messages in reply threads that the user starts or participates in.
"root" - Trigger notifications on messages in threads that the user starts.
"never" - Do not trigger notifications on messages in reply threads unless the user is mentioned.
YesNo
mention_keysstringPreference for custom non-case sensitive words that trigger mentions. Words must be separated by commas.NoNo

Fields of the UserTeamMembership object

This object is a member of the User object.

[1] Not validated, but an error occurs if no such team exists when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
namestringThe name of the team this user should be a member of.No [1]Yes
themestringThe user’s theme for the specified team. Formatted as a Mattermost theme string.YesNo
rolesstringThe roles the user should have within this team. Must be one of the following values:
"team_user"
"team_admin team_user"
YesNo
channelsarrayThe channels within this team that the user should be made a member of. Must be an array of UserChannelMembership objects.YesNo

Fields of the UserChannelMembership object

This object is a member of the TeamMembership object.

[1] Not validated, but an error occurs if the parent channel does not exist when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
namestringThe name of the channel in the parent team that this user should be a member of.No [1]Yes
rolesstringThe roles the user should have within this channel. Must be one of the following values:
"channel_user"
"channel_user channel_admin"
YesNo
notify_propsobjectThe notify preferences for this user in this channel. Must be a ChannelNotifyProps objectYesNo
favoritebooleanWhether to favorite the channel. Must be one of the following values:
"true" - Yes.
"false" - No.
NoNo

Fields of the ChannelNotifyProps object

This object is a member of the ChannelMembership object.

Field nameTypeDescriptionValidatedMandatory
desktopstringPreference for sending desktop notifications. Must be one of the following values:
"default" - Global default.
"all" - For all activity.
"mention" - Only for mentions.
"none" - Never.
YesNo
mobilestringPreference for sending mobile notifications. Must be one of the following values:
"default" - Global default.
"all" - For all activity.
"mention" - Only for mentions.
"none" - Never.
YesNo
mark_unreadstringPreference for marking channel as unread. Must be one of the following values:
"all" - For all unread messages.
"mention" - Only for mentions.
YesNo

Post object

If present, Post objects must occur after the last User object in the file, but before any DirectChannel objects.

Example Post object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "post",
"post": {
"team": "team-name",
"channel": "channel-name",
"user": "username",
"message": "The post message",
"props": {
"attachments": [{
"pretext": "This is the attachment pretext.",
"text": "This is the attachment text."
}]
},
"create_at": 140012340013,
"flagged_by": [
"username1",
"username2",
"username3"
],
"replies": [{
"user": "username4",
"message": "The reply message",
"create_at": 140012352049,
"attachments": [{
"path": "/some/valid/file/path/1"
}],
}, {
"user": "username5",
"message": "Other reply message",
"create_at": 140012353057,
}],
"reactions": [{
"user": "username6",
"emoji_name": "+1",
"create_at": 140012356032,
}, {
"user": "username7",
"emoji_name": "heart",
"create_at": 140012359034,
}],
"attachments": [{
"path": "/some/valid/file/path/1"
}, {
"path": "/some/valid/file/path/2"
}]
}
}

Fields of the Post object

[1] Not validated, but an error occurs if the team does not exist when running in apply mode.
[2] Not validated, but an error occurs if the channel does not exist in the corresponding team when running in apply mode.
[3] Not validated, but an error occurs if the user does not exist when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
teamstringThe name of the team that this post is in.No [1]Yes
channelstringThe name of the channel that this post is in.No [2]Yes
userstringThe username of the user for this post.No [3]Yes
messagestringThe message that the post contains.YesYes
propsobjectThe props for a post. Contains additional formatting information used by integrations and bot posts. For a more detailed explanation see the message attachments documentation.YesYes
create_atintThe timestamp for the post, in milliseconds since the Unix epoch.YesYes
flagged_byarrayMust contain a list of members who have flagged the post.NoNo
repliesarrayThe posts in reply to this post. Must be an array of Reply objects.YesNo
reactionsarrayThe emoji reactions to this post. Must be an array of Reaction objects.YesNo
attachmentsarrayFile attachments associated with this post. Must be an array of Attachment objects.YesNo

Fields of the Reply object

This object is a member of the Post/DirectPost object.

Field nameTypeDescriptionValidatedMandatory
userstringThe username of the user for this reply.No [3]Yes
messagestringThe message that the reply contains.YesYes
create_atintThe timestamp for the reply, in milliseconds since the Unix epoch.YesYes
flagged_byarrayMust contain a list of members who have flagged the post.NoNo
reactionsarrayThe emoji reactions to this post. Must be an array of Reaction objects.YesNo
attachmentsarrayThe file attachments to this post. Must be an array of Attachment objects.YesNo

Fields of the Reaction object

This object is a member of the Post/DirectPost object.

Field nameTypeDescriptionValidatedMandatory
userstringThe username of the user for this reply.No [3]Yes
emoji_namestringThe emoji of the reaction.YesYes
create_atintThe timestamp for the reply, in milliseconds since the Unix epoch.YesYes

Fields of the Attachment object

This object is a member of the Post/DirectPost object.

[1] Not validated, but an error occurs if the file path is not found or accessible when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
pathstringThe path to the file to be attached to the post.No [1]Yes

DirectChannel object

A direct channel can have from two to eight users as members of the channel. If there are only two members, Mattermost treats it as a Direct Message channel. If there are three or more members, Mattermost treats it as a Group Message channel.

Example DirectChannel object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "direct_channel",
"direct_channel": {
"members": [
"username1",
"username2",
"username3"
],
"header": "The Channel Header",
"favorited_by": [
"username1",
"username2",
"username3"
]
}
}

Fields of the DirectChannel object

[1] Not validated, but an error occurs if one or more of the users don't exist when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
membersarrayMust contain a list of members, with a minimum of two usernames and a maximum of eight usernames.No [1]Yes
headerstringThe channel header.YesNo
favorited_byarrayMust contain a list of members who have favorited the channel.NoNo

DirectPost object

DirectPost objects must occur after all other objects in the file.

Example DirectPost object

For clarity, the object is shown using regular JSON formatting, but in the data file it cannot be spread across several lines. It must be all on one line.

{
"type": "direct_post",
"direct_post": {
"channel_members": [
"username1",
"username2",
"username3",
],
"user": "username2",
"message": "Hello Group Channel",
"create_at": 140012340013,
"flagged_by": [
"username1",
"username2",
"username3"
],
"replies": [{
"user": "username4",
"message": "The reply message",
"create_at": 140012352049,
}, {
"user": "username5",
"message": "Other reply message",
"create_at": 140012353057,
}],
"reactions": [{
"user": "username6",
"emoji_name": "+1",
"create_at": 140012356032,
}, {
"user": "username7",
"emoji_name": "heart",
"create_at": 140012359034,
}]
}
}

Fields of the DirectPost object

[1] Not validated, but an error occurs if no channels contain an identical list when running in apply mode.
[2] Not validated, but an error occurs if the user does not exist when running in apply mode.
Field nameTypeDescriptionValidatedMandatory
channel_membersarrayMust contain a list of members, with a minimum of two usernames and a maximum of eight usernames.No [1]Yes
userstringThe username of the user for this post.No [2]Yes
messagestringThe message that the post contains.YesYes
create_atintThe timestamp for the post, in milliseconds since the Unix epoch.YesYes
flagged_byarrayMust contain a list of members who have flagged the post.NoNo
repliesarrayThe posts in reply to this direct post. Must be an array of Reply objects.YesNo
reactionsarrayThe emoji reactions to this direct post. Must be an array of Reaction objects.YesNo
attachmentsarrayThe attachments to this direct post. Must be an array of Attachment objects.YesNo

Common issues

Run the bulk import command as the mattermost user. Running it as root or any other user will cause issues with file permissions on imported attachments.

Ensure that file attachments are enabled, that you have enough free space in your file storage system to support the incoming attachments, and that your maximum file size is appropriate.

Make sure you have enough free space for logs on the Mattermost server as well as free space on the database server for both the database itself and transaction logs.

Disable anti-virus or any other plugins that might interfere with attachment uploading. They could potentially block uploading of attachments and cause the import to fail if configured incorrectly. If you need anti-virus scanning, scan the attachment folder before the import.

Troubleshooting

Running the bulk import tool hangs and doesn't complete

If you have Bleve search indexing enabled, temporarily disable it in System Console > Experimental > Bleve and run the command again.

Bleve does not support multiple processes opening and manipulating the same index. Therefore, if the Mattermost server is running, an attempt to run the bulk import tool will lock when trying to open the indeces.