The Message History endpoint allows you to export all thread messages and their responses as a JSONL (JSON Lines) file.
This endpoint requires a service account token with the analytics scope. See the Authorization guide for details on obtaining a service account token.
start_date is not provided, returns all messages on and before the end_date (UTC 23:59:59)end_date is not provided, returns all messages on and after the start_date (UTC 00:00:00)The endpoint returns a streamed JSONL file with each line having the following structure:
If an error occurs during the streaming process, the final line in the file will have the following structure:
The messages provided by this endpoint will be on a 1 day delay, meaning it will not be able to fetch message history for messages made on the same day.
The JSONL format requires one JSON object per line. Each line must be valid JSON, but the file as a whole is not a JSON array.
There is no hard limit on the date range, but larger date ranges will take longer to process and return larger files. Consider breaking up very large date ranges into smaller chunks.