Skip to content

Document simple to/subject/body fields for Gmail send API #51

@c9r

Description

@c9r

Problem

When using gmail/gmail.users.messages.send, the type definitions show:

  • payload?: MessagePart with nested headers and body.data
  • raw?: string described as "RFC 2822 formatted and base64url encoded"

This led me down a rabbit hole of constructing proper MIME messages with CRLF line endings, base64url encoding, etc. — none of which worked.

Solution

Turns out the Toolcog bridge accepts simple top-level fields:

{
  "to": "recipient@example.com",
  "subject": "Hello",
  "body": "Message content"
}

This is much better UX, but it's not documented in the types.

Suggestion

Add these fields to the TypeScript interface or operation description:

interface GmailUsersMessagesSendRequestBody {
  // Simple send (Toolcog extension)
  to?: string;
  cc?: string;
  bcc?: string;
  subject?: string;
  body?: string;
  
  // Standard Gmail API fields
  raw?: string;
  payload?: MessagePart;
  // ...
}

Or add a one-liner to the description: "For simple sends, use to, subject, and body fields directly."

Context

Discovered during a demo where I spent ~15 minutes trying various RFC 2822 encoding approaches before stumbling on the simple pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationdx

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions