Is there an API to get a list of gmail filters and updates?

Google Apps has the Google Apps Email Settings API , which allows you to create a new mail filter through an API call .

Is there a (possibly undocumented) way to get a list of current filters and update them?

+6
source share
3 answers

A filter object has been added to the API, which allows you to process filters, including search, create and delete.

https://developers.google.com/gmail/api/guides/filter_settings

In particular:

Listing filters

GET https://www.googleapis.com/gmail/v1/users/userId/settings/filters 

Returns a list of JSON filter objects

Getting a specific filter

 GET https://www.googleapis.com/gmail/v1/users/userId/settings/filters/id 

Returns a single JSON filter object

Delete a specific filter

 DELETE https://www.googleapis.com/gmail/v1/users/userId/settings/filters/id 

Create Filter

 POST https://www.googleapis.com/gmail/v1/users/userId/settings/filters 

With a JSON encoded filter in the request body.

As long as REST URLs have v1 in the address, they are linked from the current documentation. Also note that the GMail API is currently migrating, and the deprecated API will no longer function as July 2016 . Keep this in mind as the API may change.

+3
source

No. There is no API for extracting filters, only create new ones (as you found).

However, users can export all of their filters from the user interface and re-import them into another account manually:

Using filters

0
source

I have not tried, but according to the Google Admin SDK docs, it looks like you can: https://developers.google.com/admin-sdk/email-settings/#retrieving_labels

-2
source

All Articles