> For the complete documentation index, see [llms.txt](https://docs.ccfolia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ccfolia.com/developer-api/message-logs-json.md).

# Export Message Logs JSON

v1.37.0

ルームチャットの右上メニュー内にある「JSON出力」から、メッセージデータをJSON形式で出力できます。

出力されるファイルは以下のような内容になります。

```json
{
  "messages": [
    {
      "name": "character A",
      "color": "#888888",
      "text": "1d100",
      "type": "text",
      "extend": {
        "roll": {
          "result": "(1D100) ＞ 80",
          "dices": [
            {
              "value": 80,
              "kind": "normal",
              "faces": 100
            }
          ],
          "secret": false,
          "success": false,
          "failure": false,
          "critical": false,
          "fumble": false
        }
      },
      "edited": false,
      "channel": "main",
      "channelName": "main",
      "createdAt": 1767193200,
      "updatedAt": 1767193200,
      "iconImage": "XXXXXX",
    }
  ],
  "images": {
	  "XXXXXX": "data:image/png;base64,6LWk5LiA6Imy"
  }
}
```

このようなJSONファイルが `{ルーム名}_log.json` として出力されます。

ただし、CCFOLIA PROユーザーが10万件以上のメッセージデータを出力する場合には、10万件ごとに分割されたJSONファイルがzip圧縮された状態で出力されます。

### Data Format

出力されたJSONファイルは以下の型定義 `Log` の形式をとります。

```json
type Log = {
  messages: MessageData[];
  images: { [id: string]: string }; // [!]
};

type MessageData = {
  name: string;
  iconImage: string | null; // [!]
  color: string;
  text: string;
  type: "text" | "note" | "system";
  extend: {
    roll?: {
      result: string;
      dices: { kind: string; value: number; faces: number }[];
      secret: boolean;
      success: boolean;
      failure: boolean;
      critical: boolean;
      fumble: boolean;
    };
  };
  edited: boolean;
  channel: string;
  channelName: string;
  createdAt: number; // numeric timestamp
  updatedAt: number; // numeric timestamp
};
```

\[!] `iconImage` には、キャラクター画像そのものではなく `images` の keyとなるIDが格納されます。

キャラクター画像は `images` にData URL化され、まとめられます。使用されているキャラクター画像のサイズによってはリサイズされます。

#### Message Type

`MessageData` の `type` についての詳細は以下の通りです。

* `text` : 通常のチャット送信メッセージ
* `note` : シナリオテキストから送信されたメッセージ
* `system` : その他、ステータス変更時などのシステムメッセージ
