Hi. I have a good amount of experience with python and I think I can supply this code for you. My qualifications include a B.S. in Computer Science, relevant work experience, and a commitment to excellence.
You said that you needed this to be a restful API but also stated that when the api is called the results should be stored in a MongoDB datastore.
To clarify, a restful API is a part of a web application usually. This means that a web request (through browser or some other client) will come in, the application will do its job, and typically send a response back to the client.
Questions:
Is this meant to be a web application?
Should the api endpoint that does the searching return any results back to the requester or just store the data in mongo?
Should the application search only messages for the term or messages, subjects, and recipients?
Please provide more details on what data you want to store in mongo.