REST API for searching emails and deleting them

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
ssudheerk99
Posts: 1
Joined: Thu Feb 03, 2022 5:11 am

REST API for searching emails and deleting them

Post by ssudheerk99 »

I am working on an automation, to be able to search emails in an mailbox and then delte it using the REST API, but when I a going through the API document I am not able to find the rest. api to search and delete
can somebody help me with this please
User avatar
jeastman
Zimbra Employee
Zimbra Employee
Posts: 87
Joined: Tue Mar 29, 2016 1:36 pm

Re: REST API for searching emails and deleting them

Post by jeastman »

The Zimbra REST API is documented here: https://github.com/Zimbra/zm-mailbox/bl ... s/rest.txt

Search is available (see doc), but I do not believe there is any support for delete actions through that interface. You will need to use SOAP API (or some other interface) to delete items.
John Eastman
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

Re: REST API for searching emails and deleting them

Post by shawns »

Is there a way to return some email messages (like 10 or 100) OR some mail ids from Inbox using Zimbra API (for example: https://servername/home/username/inbox? ... =is:unread)? Thanks!
mitesh.savani
Zimbra Employee
Zimbra Employee
Posts: 13
Joined: Wed Oct 19, 2022 6:05 am

Re: REST API for searching emails and deleting them

Post by mitesh.savani »

By passing query parameter to the Rest API, you may obtain message information in JSON format and you can get message id from that message information.


Code: Select all

https://servername/home/username?fmt=json&query=QUERY_STRING

QUERY_STRING be like in:<FOLDERNAME> AND after:<MM/DD/YYY> AND before:<MM/DD/YYYY>


API request: 
https://servername/home/username?fmt=json&query=in:<FOLDERNAME> AND after:<MM/DD/YYY> AND before:<MM/DD/YYYY>

Example: (below request provides Inbox folder's messages which received on 3-May-2023.)
https://servername/home/username?fmt=json&query=in:inbox AND after:5/2/2023 AND before:5/4/2023

You can refer this https://wiki.zimbra.com/wiki/Zimbra_Web ... earch_Tips to prepare QUERY_STRING.
Post Reply