{
  "openapi": "3.0.1",
  "info": {
    "title": "Gmail Intelligence – Read-Only Gmail API Export & Search",
    "description": "Read your own Gmail READ-ONLY via the official Gmail API with your own Google Cloud OAuth client (gmail.readonly): Gmail search, labels, export JSON/CSV, attachments, stats, duplicates, threads, phishing signs, AI summary with your key. Free demo.",
    "version": "0.1",
    "x-build-id": "6AOjXctBMFHvzCV2V"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/badr_xba~gmail-intelligence/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-badr_xba-gmail-intelligence",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/badr_xba~gmail-intelligence/runs": {
      "post": {
        "operationId": "runs-sync-badr_xba-gmail-intelligence",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/badr_xba~gmail-intelligence/run-sync": {
      "post": {
        "operationId": "run-sync-badr_xba-gmail-intelligence",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "source": {
            "title": "Source",
            "enum": [
              "auto",
              "demo",
              "gmail"
            ],
            "type": "string",
            "description": "auto = demo when the three Google fields are empty, your Gmail when one of them is filled in. demo = fictional sample mailbox (no Google account needed, nothing charged).",
            "default": "auto"
          },
          "clientId": {
            "title": "OAuth client ID",
            "type": "string",
            "description": "The client ID of YOUR OWN OAuth client (type 'Web application') in YOUR Google Cloud project, ending with .apps.googleusercontent.com. Not secret, but only you should use it. See the README: 5 setup steps."
          },
          "clientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "The client secret of the same OAuth client (Google Cloud Console > Google Auth Platform > Clients). Stored encrypted by Apify as a secret input; never logged or written to the results."
          },
          "refreshToken": {
            "title": "Refresh token (scope gmail.readonly)",
            "type": "string",
            "description": "Created by you in the Google OAuth Playground with 'Use your own OAuth credentials' and ONLY the scope https://www.googleapis.com/auth/gmail.readonly (it usually starts with 1//). Stored encrypted as a secret input; never logged. Revoke it at myaccount.google.com/permissions when you no longer need it."
          },
          "gmailQuery": {
            "title": "Gmail search",
            "type": "string",
            "description": "Optional. The same search syntax as the Gmail search box, run by Gmail itself, for example: from:billing@example.com has:attachment newer_than:30d, or subject:(invoice OR receipt) -label:paid. Leave empty to read everything (newest first)."
          },
          "labels": {
            "title": "Labels",
            "type": "array",
            "description": "Optional. Labels to read, by name or ID: INBOX, SENT, SPAM, TRASH, STARRED, IMPORTANT, your own labels (for example Clients/Acme). Several labels = e-mails from any of them. Empty = all mail except Spam and Trash. A label that does not exist is reported in FAILED_INPUTS with the list of your labels.",
            "items": {
              "type": "string"
            }
          },
          "includeSpamTrash": {
            "title": "Include Spam and Trash",
            "type": "boolean",
            "description": "Also read e-mails in Spam and Trash (always on when you choose the SPAM or TRASH label).",
            "default": false
          },
          "dateFrom": {
            "title": "From date",
            "pattern": "^$|^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only e-mails received on or after this day (YYYY-MM-DD, UTC)."
          },
          "dateTo": {
            "title": "To date",
            "pattern": "^$|^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only e-mails received on or before this day (YYYY-MM-DD, UTC)."
          },
          "unreadOnly": {
            "title": "Unread e-mails only",
            "type": "boolean",
            "description": "Only e-mails not yet read. They stay unread: this Actor never marks anything as read.",
            "default": false
          },
          "hasAttachments": {
            "title": "With attachments only",
            "type": "boolean",
            "description": "Only e-mails that have at least one attached file.",
            "default": false
          },
          "maxMessages": {
            "title": "Maximum e-mails",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Maximum number of e-mails read in this run (newest first).",
            "default": 50
          },
          "maxMessageMb": {
            "title": "Maximum e-mail size (MB)",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Bigger e-mails are kept with their headers only (bodyTruncated: true).",
            "default": 25
          },
          "requestTimeoutSecs": {
            "title": "Google request timeout (seconds)",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "How long to wait for one Google answer before retrying (busy or failing requests are retried up to 3 times).",
            "default": 30
          },
          "services": {
            "title": "Analyses",
            "type": "array",
            "description": "Free analyses added to the results: stats = mailbox report; duplicates = same e-mail found twice; threads = conversations; phishing = warning signs (indicators, never a verdict); classify = category by rules; attachments = one row per attachment (metadata).",
            "items": {
              "type": "string",
              "enum": [
                "stats",
                "duplicates",
                "threads",
                "phishing",
                "classify",
                "attachments"
              ],
              "enumTitles": [
                "Mailbox report",
                "Duplicates",
                "Conversations",
                "Phishing indicators",
                "Category (rules)",
                "Attachment rows"
              ]
            },
            "default": [
              "stats",
              "duplicates",
              "threads",
              "phishing",
              "classify"
            ]
          },
          "includeBody": {
            "title": "Include the e-mail text",
            "type": "boolean",
            "description": "Add the plain text of each e-mail (bodyText). Turn off to keep only headers, snippet and analyses.",
            "default": true
          },
          "bodyMaxChars": {
            "title": "Maximum text length",
            "minimum": 0,
            "maximum": 200000,
            "type": "integer",
            "description": "Longer texts are cut (bodyTruncated: true).",
            "default": 20000
          },
          "includeHtml": {
            "title": "Include the HTML version",
            "type": "boolean",
            "description": "Add the raw HTML (bodyHtml). It is never rendered or executed by the Actor.",
            "default": false
          },
          "includeHeaders": {
            "title": "Include useful headers",
            "type": "boolean",
            "description": "Add a short list of headers (Reply-To, Return-Path, Authentication-Results, List-Unsubscribe, priority...).",
            "default": true
          },
          "exportCsv": {
            "title": "Also save a CSV file",
            "type": "boolean",
            "description": "Save the e-mail list as EMAILS_CSV in the key-value store (one line per e-mail, spreadsheet-safe).",
            "default": true
          },
          "downloadAttachments": {
            "title": "Save attachment files",
            "type": "boolean",
            "description": "Save attached files to the run's key-value store (never opened or executed). Risky types (.exe, .js, .html, macros...) are never saved: metadata only.",
            "default": false
          },
          "maxAttachmentMb": {
            "title": "Maximum size per file (MB)",
            "minimum": 1,
            "maximum": 25,
            "type": "integer",
            "description": "Bigger files are listed but not saved (tooLarge).",
            "default": 10
          },
          "maxTotalAttachmentsMb": {
            "title": "Maximum total of saved files (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "When reached, other files are listed but not saved (runCapReached).",
            "default": 100
          },
          "aiProvider": {
            "title": "AI summary and category (your own key)",
            "enum": [
              "none",
              "openai",
              "anthropic",
              "gemini"
            ],
            "type": "string",
            "description": "Optional. Uses YOUR OpenAI, Anthropic or Gemini key: the AI cost is billed by your provider. E-mail text is sent as untrusted data; the AI has no tools and can only return a summary and a category.",
            "default": "none"
          },
          "aiApiKey": {
            "title": "AI API key",
            "type": "string",
            "description": "Your own API key for the chosen AI provider. Stored as a secret input; never logged or written to the results."
          },
          "aiModel": {
            "title": "AI model (optional)",
            "type": "string",
            "description": "Leave empty for a low-cost default model of the chosen provider."
          },
          "aiLanguage": {
            "title": "Summary language",
            "type": "string",
            "description": "Language of the AI summaries, for example English or French.",
            "default": "English"
          },
          "maxAiEmails": {
            "title": "Maximum e-mails sent to the AI",
            "minimum": 0,
            "maximum": 1000,
            "type": "integer",
            "description": "Cost guard for your AI account.",
            "default": 25
          },
          "redactBeforeAi": {
            "title": "Mask addresses and phone numbers before the AI",
            "type": "boolean",
            "description": "E-mail addresses and phone numbers in the text are replaced by [redacted] before sending to your AI provider.",
            "default": true
          },
          "failRunOnError": {
            "title": "Mark the run as FAILED when Gmail cannot be read",
            "type": "boolean",
            "description": "Off (default): the run ends SUCCEEDED with a clear message and FAILED_INPUTS (expired token, API not enabled...). On: those problems end the run as FAILED (useful for scheduled monitoring).",
            "default": false
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}