How do I save message records for 7 days

Hello, I want to save the chat records in the database for a period of time; Users can query; Is there a plug-in that can do that?
Please help me. Thank you

You can try Monitoring Service plugin. Although lately it had a few issues. Specifically messages in group chat are often not in correct order.

Thank you very much; So how do users query historical messages is there an open REST API interface?

Monitoring service supports XEP-0136 and XEP-0313 for archive management. Clients should use these protocols to query and retrieve history. I believe it uses IQ stanzas, regular jabber packets. Not REST API.