# Mattermost Message Scraper (`jungle_synthesizer/mattermost-message-scraper`) Actor

Export messages from any Mattermost workspace — self-hosted or cloud. Provide your instance URL and a personal access token to scrape channels and posts. Supports team/channel filtering, date ranges, and direct message channels.

- **URL**: https://apify.com/jungle\_synthesizer/mattermost-message-scraper.md
- **Developed by:** [BowTiedRaccoon](https://apify.com/jungle_synthesizer) (community)
- **Categories:** Social media, Business
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Mattermost Message Scraper

Export messages from any Mattermost workspace — self-hosted or cloud. Provide your instance URL and a personal access token to scrape teams, channels, and posts. Supports filtering by team name, channel name, date range, and direct messages.

### What it does

The actor connects to the Mattermost REST API v4 to:

1. Fetch all teams accessible to the authenticated user
2. For each team, fetch all accessible channels
3. For each channel, paginate through posts and save them to the dataset

Each output record contains the full context of a message: which team and channel it came from, who posted it, when it was posted, the message content, reactions, and file attachment IDs.

### Who is it for

- **Enterprise and government teams** using self-hosted Mattermost for compliance archival and audit trails
- **Migration projects** moving from Mattermost to another platform (Slack, Discord, Teams)
- **Knowledge base export** — converting channel history to searchable documents or AI training data
- **Analytics and reporting** on team communication patterns

### Getting started

#### Step 1: Generate a personal access token

1. Log in to your Mattermost instance
2. Go to **Account Settings** → **Security** → **Personal Access Tokens**
3. Click **Create Token**, give it a description, and copy the token

> **Note:** Some Mattermost instances require an administrator to enable personal access tokens. Contact your Mattermost admin if the option is not visible in Account Settings.

#### Step 2: Run the actor

Set the following inputs:

| Input | Description |
|-------|-------------|
| **Instance URL** | Base URL of your Mattermost server (e.g. `https://mattermost.yourcompany.com`) |
| **Personal Access Token** | The token generated in Step 1 |
| **Team Names** | Optional list of team slugs to scrape (leave empty for all teams) |
| **Channel Names** | Optional list of channel names to scrape within the selected teams |
| **Max Items** | Maximum number of posts to return |
| **Since Date** | Only fetch posts on or after this date (ISO 8601) |
| **Until Date** | Only fetch posts on or before this date (ISO 8601) |
| **Include Direct Messages** | Set to `true` to also scrape D and G (group) channels |

#### Example input

```json
{
  "instanceUrl": "https://mattermost.yourcompany.com",
  "accessToken": "your-personal-access-token",
  "teamNames": ["engineering", "product"],
  "channelNames": ["general", "random"],
  "sinceDate": "2024-01-01",
  "maxItems": 1000
}
````

### Output

Each dataset record represents a single Mattermost post:

| Field | Type | Description |
|-------|------|-------------|
| `instance_url` | string | Base URL of the Mattermost instance |
| `team_id` | string | Team UUID |
| `team_name` | string | Team URL slug |
| `team_display_name` | string | Team display name |
| `channel_id` | string | Channel UUID |
| `channel_name` | string | Channel URL slug |
| `channel_display_name` | string | Channel display name |
| `channel_type` | string | `O`=public, `P`=private, `D`=direct, `G`=group |
| `channel_header` | string | Channel header text |
| `channel_purpose` | string | Channel purpose text |
| `post_id` | string | Post UUID |
| `post_root_id` | string | Parent post UUID (empty for root posts, set for thread replies) |
| `post_create_at` | integer | Creation timestamp in milliseconds since Unix epoch |
| `post_update_at` | integer | Last update timestamp in ms |
| `post_edit_at` | integer | Last edit timestamp in ms (0 if never edited) |
| `post_user_id` | string | Author's user UUID |
| `post_user_username` | string | Author's username |
| `post_message` | string | Post body text (Markdown) |
| `post_type` | string | Empty for regular posts; `system_*` for system messages |
| `post_hashtags` | string | Space-separated hashtags |
| `post_reactions` | string | JSON array of emoji reactions `[{emoji_name, user_id, create_at}]` |
| `post_file_ids` | string | JSON array of file attachment IDs |
| `post_props` | string | JSON object with post metadata (attachments, overrides, etc.) |

#### Example record

```json
{
  "instance_url": "https://community.mattermost.com",
  "team_id": "rcgiyftm7jyrxnma1osd8zswby",
  "team_name": "core",
  "team_display_name": "Contributors",
  "channel_id": "zw43c5ttrjyu9dg7jnudwuz6bw",
  "channel_name": "town-square",
  "channel_display_name": "Town Square",
  "channel_type": "O",
  "channel_header": "Welcome to Mattermost",
  "channel_purpose": "The default channel for the team",
  "post_id": "3yd1q7gcrinbdmdq5qmnggd4xy",
  "post_root_id": "",
  "post_create_at": 1748063442000,
  "post_update_at": 1748063442000,
  "post_edit_at": 0,
  "post_user_id": "nkb43bj3h3ga8p4m3n5rwhmtia",
  "post_user_username": "john.doe",
  "post_message": "Hello everyone!",
  "post_type": "",
  "post_hashtags": "",
  "post_reactions": "[]",
  "post_file_ids": "[]",
  "post_props": "{}"
}
```

### Filtering tips

- Use **Team Names** and **Channel Names** filters to narrow the scope and speed up the run. Both accept a partial list — channels in non-matching teams are automatically excluded.
- Use **Since Date** / **Until Date** to limit to a specific time window (e.g. last quarter for compliance reports).
- Set **Include Direct Messages** to `true` only when you need DM history. Note: your token must have access to the DM channels.

### Rate limits and performance

Mattermost's default API rate limit is generous for authenticated users (typically 200+ requests per second on self-hosted). The actor pages channels at 200 posts per request and resolves usernames with a local cache to minimize API calls.

For very large workspaces (millions of posts), set **Max Items** to limit the run, then resume by setting **Since Date** to the date of the last run.

### Self-hosted vs. cloud instances

The actor works identically with both self-hosted Mattermost and Mattermost cloud — just set `instanceUrl` to your instance's base URL.

For the public Mattermost community server, use `https://community.mattermost.com`.

# Actor input Schema

## `sp_intended_usage` (type: `string`):

Please describe how you plan to use the data extracted by this crawler.

## `sp_improvement_suggestions` (type: `string`):

Provide any feedback or suggestions for improvements.

## `sp_contact` (type: `string`):

Provide your email address so we can get in touch with you.

## `instanceUrl` (type: `string`):

Base URL of your Mattermost instance (e.g. https://mattermost.example.com). Use https://community.mattermost.com for the public Mattermost community server.

## `accessToken` (type: `string`):

Mattermost personal access token. Generate one in Account Settings → Security → Personal Access Tokens.

## `teamNames` (type: `array`):

List of team names (URL-slug form) to scrape. Leave empty to scrape all accessible teams.

## `channelNames` (type: `array`):

List of channel names to scrape within the selected teams. Leave empty to scrape all accessible channels.

## `includeDirectMessages` (type: `boolean`):

Include direct message (D) and group message (G) channels.

## `sinceDate` (type: `string`):

Fetch posts created on or after this date (ISO 8601, e.g. 2024-01-01).

## `untilDate` (type: `string`):

Fetch posts created on or before this date (ISO 8601, e.g. 2024-12-31).

## `maxItems` (type: `integer`):

Maximum number of post records to return across all channels.

## Actor input object example

```json
{
  "sp_intended_usage": "Describe your intended use...",
  "sp_improvement_suggestions": "Share your suggestions here...",
  "sp_contact": "Share your email here...",
  "instanceUrl": "https://community.mattermost.com",
  "includeDirectMessages": false,
  "maxItems": 10
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sp_intended_usage": "Describe your intended use...",
    "sp_improvement_suggestions": "Share your suggestions here...",
    "sp_contact": "Share your email here...",
    "instanceUrl": "https://community.mattermost.com",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("jungle_synthesizer/mattermost-message-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sp_intended_usage": "Describe your intended use...",
    "sp_improvement_suggestions": "Share your suggestions here...",
    "sp_contact": "Share your email here...",
    "instanceUrl": "https://community.mattermost.com",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("jungle_synthesizer/mattermost-message-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sp_intended_usage": "Describe your intended use...",
  "sp_improvement_suggestions": "Share your suggestions here...",
  "sp_contact": "Share your email here...",
  "instanceUrl": "https://community.mattermost.com",
  "maxItems": 10
}' |
apify call jungle_synthesizer/mattermost-message-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=jungle_synthesizer/mattermost-message-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Mattermost Message Scraper",
        "description": "Export messages from any Mattermost workspace — self-hosted or cloud. Provide your instance URL and a personal access token to scrape channels and posts. Supports team/channel filtering, date ranges, and direct message channels.",
        "version": "0.1",
        "x-build-id": "FKXuyAuIAf4bn12ql"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/jungle_synthesizer~mattermost-message-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-jungle_synthesizer-mattermost-message-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/jungle_synthesizer~mattermost-message-scraper/runs": {
            "post": {
                "operationId": "runs-sync-jungle_synthesizer-mattermost-message-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/jungle_synthesizer~mattermost-message-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-jungle_synthesizer-mattermost-message-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "instanceUrl",
                    "accessToken",
                    "maxItems"
                ],
                "properties": {
                    "sp_intended_usage": {
                        "title": "What is the intended usage of this data?",
                        "minLength": 1,
                        "type": "string",
                        "description": "Please describe how you plan to use the data extracted by this crawler."
                    },
                    "sp_improvement_suggestions": {
                        "title": "How can we improve this crawler for you?",
                        "minLength": 1,
                        "type": "string",
                        "description": "Provide any feedback or suggestions for improvements."
                    },
                    "sp_contact": {
                        "title": "Contact Email",
                        "minLength": 1,
                        "type": "string",
                        "description": "Provide your email address so we can get in touch with you."
                    },
                    "instanceUrl": {
                        "title": "Instance URL",
                        "type": "string",
                        "description": "Base URL of your Mattermost instance (e.g. https://mattermost.example.com). Use https://community.mattermost.com for the public Mattermost community server."
                    },
                    "accessToken": {
                        "title": "Personal Access Token",
                        "type": "string",
                        "description": "Mattermost personal access token. Generate one in Account Settings → Security → Personal Access Tokens."
                    },
                    "teamNames": {
                        "title": "Team Names",
                        "type": "array",
                        "description": "List of team names (URL-slug form) to scrape. Leave empty to scrape all accessible teams.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "channelNames": {
                        "title": "Channel Names",
                        "type": "array",
                        "description": "List of channel names to scrape within the selected teams. Leave empty to scrape all accessible channels.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeDirectMessages": {
                        "title": "Include Direct Messages",
                        "type": "boolean",
                        "description": "Include direct message (D) and group message (G) channels.",
                        "default": false
                    },
                    "sinceDate": {
                        "title": "Since Date",
                        "type": "string",
                        "description": "Fetch posts created on or after this date (ISO 8601, e.g. 2024-01-01)."
                    },
                    "untilDate": {
                        "title": "Until Date",
                        "type": "string",
                        "description": "Fetch posts created on or before this date (ISO 8601, e.g. 2024-12-31)."
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "type": "integer",
                        "description": "Maximum number of post records to return across all channels.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
