feat(inboxes): accept path attachments on drafts

DI
2h ago
+96-27

resend.Inboxes.Drafts.create() and .update() now accept path attachments. This ports resend/resend-node#1172 (released in resend@6.36.0). Spec: resend/resend-openapi#141. The API change is live.

Changes

The attachments field of create/update is now typed as InboxDrafts.DraftAttachmentParams, a union of two TypedDicts, so mypy rejects invalid shapes:

  • AttachmentParams: content, filename, content_type (all required). This is the existing type, unchanged, so InboxDrafts.AttachmentParams(...) still works as a constructor.
  • PathAttachmentParams (new): path, filename, plus an optional content_type that defaults to the downloaded file's type.

The params are sent as-is, so no runtime change was needed. Fully backward compatible.

  • The create/update docstrings now describe the path rules instead of "a path returns a 422".
  • examples/inboxes.py adds a path attachment to the draft.
  • Version: 2.50.1 → 2.51.0 (minor).

Verification

  • flake8, pytest (852 passed) and mypy (strict) all pass. mypy shows only the 5 unused-ignore errors that are also on main.
  • New tests: create and update send path attachments with and without content_type. mypy checks that an attachment with no source, with both sources, or with content and no content_type stays a type error.
  • Live against api.resend.com through the SDK:
    • create with path stores invoice.pdf (application/pdf, 80893 bytes)
    • update with path + content stores both
    • an ftp:// path raises a 422 ResendError
    • a draft with a path attachment sends

Linear: DEV-2420


Summary by cubic

Adds support for path URL attachments to inbox drafts. InboxDrafts.AttachmentParams stays a TypedDict for inline content, and the new DraftAttachmentParams union accepts either inline base64 content or a URL downloaded when the request is made, so mypy rejects attachment dicts that mix or omit both sources. Params are sent as-is, so no runtime change was needed and existing code using AttachmentParams keeps working.

  • Updates the create/update docstrings to describe the path rules instead of "a path returns a 422".
  • Adds a path attachment to the draft example.
  • Bumps the version to 2.51.0.