# Fetch Email Document Attachments

> Perform Fetch Email Document Attachments through GMail.

Source: [https://genhealth.ai/docs/workflows/integrations/gmail/gmail_fetch_pdf_attachments](https://genhealth.ai/docs/workflows/integrations/gmail/gmail_fetch_pdf_attachments)

Integration: [GMail](https://genhealth.ai/docs/workflows/integrations/gmail.md)

- Handler: `gmail_fetch_pdf_attachments`

## Use in a workflow

Copy this discovered node config, fill params from the input contract, and validate the complete graph. Integration results are available as {{node_id.default.field}}. Check business success before dependent writes; completion alone does not prove business success.

```json

{
  "_group": "GMail",
  "params": {
    "source": "gmail_inbox",
    "document_type": "Other",
    "document_status": "complete",
    "content_hash_mode": "raw_bytes",
    "include_drive_links": false,
    "max_drive_pdf_bytes": 104857600,
    "max_pdf_attachments": 10,
    "capture_body_document": false,
    "deduplicate_by_content": false,
    "include_attached_images": false,
    "reuse_existing_document": false,
    "show_documents_in_inbox": false,
    "max_pdf_attachment_bytes": 26214400,
    "enforce_attachment_limits": true,
    "preserve_existing_stored_pdf": false
  },
  "handler": "gmail_fetch_pdf_attachments"
}

```

[Action contracts](https://genhealth.ai/docs/workflows/action-contracts.md) · [Run recovery](https://genhealth.ai/docs/workflows/operations.md)

## Inputs

- `message_id` — Message Id (expression, required)
  Required literal value or workflow expression.
- `document_type` — Document Type (select)
  Optional selected identifier or value.
  Default: `"Other"`
  Options: Prescription ("Prescription"), Demographics ("Demographics"), Insurance ("Insurance"), Qualifying Test ("Qualifying Test"), Physician Notes ("Physician Notes"), Other ("Other")
- `source` — Source (text)
  Optional text value.
  Default: `"gmail_inbox"`
- `show_documents_in_inbox` — Show Documents In Inbox (boolean)
  Optional true-or-false value.
  Default: `false`
- `deduplicate_by_content` — Deduplicate By Content (boolean)
  Optional true-or-false value.
  Default: `false`
- `content_hash_mode` — Content Hash Mode (select)
  Optional selected identifier or value.
  Default: `"raw_bytes"`
  Options: Raw Bytes (SHA-256) ("raw_bytes"), Content (re-encoding robust) ("content")
- `preserve_existing_stored_pdf` — Preserve Existing Stored Pdf (boolean)
  Optional true-or-false value.
  Default: `false`
- `document_status` — Document Status (select)
  Optional selected identifier or value.
  Default: `"complete"`
  Options: Complete ("complete"), Processing ("processing"), Review ("review")
- `workflow_id_override` — Workflow Id Override (text)
  Optional text value.
- `reuse_existing_document` — Reuse Existing Document (boolean)
  Optional true-or-false value.
  Default: `false`
- `include_attached_images` — Include Attached Images (boolean)
  Optional true-or-false value.
  Default: `false`
- `body_field_label` — Body Field Label (text)
  Optional text value.
- `body_field_labels` — Body Field Labels (json)
  Optional JSON value.
- `capture_body_document` — Capture Body Document (boolean)
  Optional true-or-false value.
  Default: `false`
- `document_metadata` — Document Metadata (json)
  Optional JSON value.
- `forwarded_original_timezone` — Forwarded Original Timezone (text)
  Optional text value.
- `max_pdf_attachments` — Max Pdf Attachments (number)
  Optional numeric value.
  Default: `10`
- `max_pdf_attachment_bytes` — Max Pdf Attachment Bytes (number)
  Optional numeric value.
  Default: `26214400`
- `enforce_attachment_limits` — Enforce Attachment Limits (boolean)
  Optional true-or-false value.
  Default: `true`
- `include_drive_links` — Include Drive Links (boolean)
  Optional true-or-false value.
  Default: `false`
- `max_drive_pdf_bytes` — Max Drive Pdf Bytes (number)
  Optional numeric value.
  Default: `104857600`

## Outputs

- `success` — Success
- `message_id` — Message Id
- `document_ids` — Document Ids
- `new_document_ids` — New Document Ids
- `existing_document_ids` — Existing Document Ids
- `duplicate_count` — Duplicate Count
- `all_attachments_existing` — All Attachments Existing
- `attachments` — Attachments
- `attachment_results` — Attachment Results
- `attachment_count` — Attachment Count
- `failed_count` — Failed Count
- `unsupported_attachments` — Unsupported Attachments
- `unsupported_count` — Unsupported Count
- `max_pdf_attachments` — Max Pdf Attachments
- `max_pdf_attachment_bytes` — Max Pdf Attachment Bytes
- `email_body_field` — Email Body Field
- `email_body_fields` — Email Body Fields
- `email_body_field_statuses` — Email Body Field Statuses
- `count` — Count
- `body_document_count` — Body Document Count
- `skipped` — Skipped
- `skip_reason` — Skip Reason
- `error` — Error
- `error_message` — Error Message
- `error_code` — Error Code
- `forwarded_original_sent_at` — Forwarded Original Sent At
- `forwarded_original_status` — Forwarded Original Status

Output schema completeness: `best_effort_declared`

## Safety

- External effect: `write`
- Confirmation recommended: no
- Retry safe: no
- Dry run supported: no

## Schemas

These schemas are first-pass authoring guidance. Runtime validation remains authoritative.

### Input schema

```json
{
  "type": "object",
  "required": [
    "message_id"
  ],
  "properties": {
    "source": {
      "type": "string",
      "default": "gmail_inbox",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "message_id": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "document_type": {
      "enum": [
        "Prescription",
        "Demographics",
        "Insurance",
        "Qualifying Test",
        "Physician Notes",
        "Other"
      ],
      "type": "string",
      "default": "Other",
      "description": "Optional selected identifier or value.",
      "x-workflow-field-type": "select"
    },
    "document_status": {
      "enum": [
        "complete",
        "processing",
        "review"
      ],
      "type": "string",
      "default": "complete",
      "description": "Optional selected identifier or value.",
      "x-workflow-field-type": "select"
    },
    "body_field_label": {
      "type": "string",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "body_field_labels": {
      "description": "Optional JSON value.",
      "x-workflow-field-type": "json"
    },
    "content_hash_mode": {
      "enum": [
        "raw_bytes",
        "content"
      ],
      "type": "string",
      "default": "raw_bytes",
      "description": "Optional selected identifier or value.",
      "x-workflow-field-type": "select"
    },
    "document_metadata": {
      "description": "Optional JSON value.",
      "x-workflow-field-type": "json"
    },
    "include_drive_links": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "max_drive_pdf_bytes": {
      "type": "number",
      "default": 104857600,
      "description": "Optional numeric value.",
      "x-workflow-field-type": "number"
    },
    "max_pdf_attachments": {
      "type": "number",
      "default": 10,
      "description": "Optional numeric value.",
      "x-workflow-field-type": "number"
    },
    "workflow_id_override": {
      "type": "string",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "capture_body_document": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "deduplicate_by_content": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "include_attached_images": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "reuse_existing_document": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "show_documents_in_inbox": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "max_pdf_attachment_bytes": {
      "type": "number",
      "default": 26214400,
      "description": "Optional numeric value.",
      "x-workflow-field-type": "number"
    },
    "enforce_attachment_limits": {
      "type": "boolean",
      "default": true,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "forwarded_original_timezone": {
      "type": "string",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "preserve_existing_stored_pdf": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    }
  },
  "additionalProperties": false
}
```

### Output schema

```json
{
  "type": "object",
  "properties": {
    "count": {},
    "error": {},
    "skipped": {},
    "success": {},
    "error_code": {},
    "message_id": {},
    "attachments": {},
    "skip_reason": {},
    "document_ids": {},
    "failed_count": {},
    "error_message": {},
    "duplicate_count": {},
    "attachment_count": {},
    "email_body_field": {},
    "new_document_ids": {},
    "email_body_fields": {},
    "unsupported_count": {},
    "attachment_results": {},
    "body_document_count": {},
    "max_pdf_attachments": {},
    "existing_document_ids": {},
    "unsupported_attachments": {},
    "all_attachments_existing": {},
    "max_pdf_attachment_bytes": {},
    "email_body_field_statuses": {},
    "forwarded_original_status": {},
    "forwarded_original_sent_at": {}
  },
  "additionalProperties": true
}
```
