> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.signalcore.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.signalcore.ai/_mcp/server.

# Payload de webhook de Gmail

> Estructura del payload de webhook para eventos de correo de Gmail

Los webhooks de Gmail se envían para correos electrónicos entrantes y salientes.

## Payload de ejemplo

```json
{
  "event": {
    "id": "evt_gmail_abc123",
    "channel": "gmail",
    "timestamp": 1706640000.0,
    "data": {
      "timestamp": 1706640000.0,
      "direction": "inbound",
      "platform": "gmail",
      "email_id": "email_xyz789",
      "message_id": "<CADmL4p5xyz@mail.gmail.com>",
      "subject": "Question about your services",
      "body": "<html><body><p>Hi, I'm interested in learning more about...</p></body></html>",
      "body_plain": "Hi, I'm interested in learning more about...",
      "is_from_account": false,
      "account_id": "acc_123",
      "from_attendee": {
        "display_name": "John Doe",
        "identifier": "john@example.com",
        "identifier_type": "EMAIL_ADDRESS"
      },
      "to_attendees": [
        {
          "display_name": "Your Business",
          "identifier": "hello@yourbusiness.com",
          "identifier_type": "EMAIL_ADDRESS"
        }
      ],
      "cc_attendees": [],
      "bcc_attendees": [],
      "reply_to_attendees": [],
      "email_event_type": "mail_received",
      "date": 1706640000.0,
      "read_date": null,
      "folders": ["INBOX"],
      "has_attachments": true,
      "attachments": [
        {
          "id": "att_001",
          "name": "proposal.pdf",
          "size": 102400,
          "mimetype": "application/pdf",
          "url": "https://..."
        }
      ],
      "in_reply_to": null,
      "is_complete": true,
      "tracking_id": "track_abc",
      "origin": "external",
      "usage_data": {
        "prompt_tokens": 300,
        "completion_tokens": 150,
        "model": "gpt-4"
      },
      "tools_called": ["check_availability"],
      "analysis_result": {
        "sentiment": "positive",
        "intent": "inquiry"
      }
    }
  },
  "lead_id": "lead_123",
  "lead_contact": {
    "number": "",
    "email": "john@example.com",
    "name": "John Doe"
  },
  "business_id": "biz_456",
  "lead_created": true
}
```

## Referencia de campos

### Campos principales

| Campo              | Tipo    | Requerido | Descripción                                  |
| ------------------ | ------- | --------- | -------------------------------------------- |
| `timestamp`        | float   | Sí        | Marca de tiempo Unix epoch                   |
| `direction`        | string  | Sí        | `inbound` o `outbound`                       |
| `platform`         | string  | Sí        | Siempre `gmail`                              |
| `email_id`         | string  | Sí        | ID de correo interno                         |
| `message_id`       | string  | Sí        | Encabezado RFC822 Message-ID                 |
| `subject`          | string  | Sí        | Línea de asunto del correo                   |
| `body`             | string  | Sí        | Cuerpo del correo en HTML                    |
| `is_from_account`  | boolean | Sí        | True si fue enviado por la cuenta conectada  |
| `account_id`       | string  | Sí        | ID de cuenta de Gmail conectada              |
| `email_event_type` | string  | Sí        | Tipo de evento                               |
| `date`             | float   | Sí        | Marca de tiempo de confirmación del servidor |

### Valores de email_event_type

| Valor           | Descripción     |
| --------------- | --------------- |
| `mail_received` | Correo entrante |
| `mail_sent`     | Correo saliente |

### Objeto from_attendee

| Campo             | Tipo   | Descripción                             |
| ----------------- | ------ | --------------------------------------- |
| `display_name`    | string | Nombre visible del remitente (opcional) |
| `identifier`      | string | Dirección de correo                     |
| `identifier_type` | string | Siempre `EMAIL_ADDRESS`                 |

### Array to_attendees

Array de objetos destinatarios con la misma estructura que `from_attendee`.

### Campos opcionales

| Campo                | Tipo    | Descripción                             |
| -------------------- | ------- | --------------------------------------- |
| `body_plain`         | string  | Versión en texto plano del cuerpo       |
| `cc_attendees`       | array   | Destinatarios CC                        |
| `bcc_attendees`      | array   | Destinatarios BCC                       |
| `reply_to_attendees` | array   | Direcciones Reply-To                    |
| `read_date`          | float   | Cuándo se leyó el correo                |
| `folders`            | array   | Carpetas del correo (INBOX, SENT, etc.) |
| `role`               | string  | Rol de la carpeta                       |
| `has_attachments`    | boolean | Si tiene adjuntos                       |
| `attachments`        | array   | Adjuntos del correo                     |
| `in_reply_to`        | object  | Referencia al correo padre              |
| `is_complete`        | boolean | Si está completamente cargado           |
| `tracking_id`        | string  | ID de seguimiento interno               |
| `origin`             | string  | `unipile` o `external`                  |
| `usage_data`         | object  | Uso de tokens LLM                       |
| `tools_called`       | array   | Nombres de herramientas ejecutadas      |
| `analysis_result`    | object  | Resultado del análisis de IA            |
| `appointments`       | array   | Citas extraídas                         |
| `execution_context`  | object  | Contexto del activador de origen        |

### Array de attachments

| Campo      | Tipo    | Descripción        |
| ---------- | ------- | ------------------ |
| `id`       | string  | ID del adjunto     |
| `name`     | string  | Nombre del archivo |
| `size`     | integer | Tamaño en bytes    |
| `mimetype` | string  | Tipo MIME          |
| `url`      | string  | URL de descarga    |

### Objeto in_reply_to

| Campo        | Tipo   | Descripción                 |
| ------------ | ------ | --------------------------- |
| `message_id` | string | RFC822 Message-ID del padre |
| `id`         | string | ID interno del padre        |

### Valores de origin

| Valor      | Descripción                   |
| ---------- | ----------------------------- |
| `external` | Correo de remitente externo   |
| `unipile`  | Correo enviado vía SignalCore |