{
  "name": "gmail_filter_generator",
  "title": "Gmail filter generator",
  "description": "Builds Gmail filters. Returns a Gmail search string per filter, to preview matches in Gmail's search bar, and a mailFilters.xml file the user imports in Gmail under Settings, Filters and Blocked Addresses, Import filters. Each filter needs at least one condition and one action.",
  "page": "https://construct.computer/tools/gmail-filter-generator/",
  "endpoint": "https://construct.computer/api/tools/gmail-filter-generator",
  "usage": "GET https://construct.computer/api/tools/gmail-filter-generator?input=<URL-encoded JSON>, or POST the JSON as the request body.",
  "input_schema": {
    "type": "object",
    "properties": {
      "filters": {
        "minItems": 1,
        "maxItems": 20,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "description": "A name to tell filters apart. Gmail stores no names, so it is written as a comment in the XML.",
              "type": "string",
              "maxLength": 80
            },
            "from": {
              "description": "Sender addresses or @domain.com. Any one matches.",
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "to": {
              "description": "Recipient addresses. Any one matches.",
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "subject": {
              "description": "Words or phrases in the subject. Any one matches.",
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "has_words": {
              "description": "Words anywhere in the email. Gmail search operators allowed.",
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "does_not_have": {
              "description": "Words that keep an email out.",
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "has_attachment": {
              "type": "boolean"
            },
            "larger_than_mb": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 50
            },
            "smaller_than_mb": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 50
            },
            "label": {
              "description": "Label to apply, nested with a slash like Clients/Acme.",
              "type": "string",
              "maxLength": 200
            },
            "skip_inbox": {
              "type": "boolean"
            },
            "mark_read": {
              "type": "boolean"
            },
            "star": {
              "type": "boolean"
            },
            "never_spam": {
              "type": "boolean"
            },
            "importance": {
              "type": "string",
              "enum": [
                "always",
                "never"
              ]
            },
            "delete": {
              "type": "boolean"
            },
            "category": {
              "description": "personal is Primary, promo is Promotions, notification is Updates, group is Forums.",
              "type": "string",
              "enum": [
                "personal",
                "social",
                "promo",
                "notification",
                "group"
              ]
            },
            "forward_to": {
              "type": "string",
              "format": "email",
              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
            }
          },
          "additionalProperties": false
        }
      }
    },
    "required": [
      "filters"
    ],
    "additionalProperties": false
  },
  "example_input": {
    "filters": [
      {
        "name": "Receipts",
        "from": [
          "billing@stripe.com",
          "@paddle.com"
        ],
        "subject": [
          "receipt",
          "invoice"
        ],
        "label": "Receipts",
        "skip_inbox": true
      }
    ]
  },
  "example_request": "https://construct.computer/api/tools/gmail-filter-generator?input=%7B%22filters%22%3A%5B%7B%22name%22%3A%22Receipts%22%2C%22from%22%3A%5B%22billing%40stripe.com%22%2C%22%40paddle.com%22%5D%2C%22subject%22%3A%5B%22receipt%22%2C%22invoice%22%5D%2C%22label%22%3A%22Receipts%22%2C%22skip_inbox%22%3Atrue%7D%5D%7D"
}