feat(inboxes): accept path attachments on drafts
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, soInboxDrafts.AttachmentParams(...)still works as a constructor.PathAttachmentParams(new):path,filename, plus an optionalcontent_typethat 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
pathrules instead of "apathreturns a 422". examples/inboxes.pyadds apathattachment to the draft.- Version: 2.50.1 → 2.51.0 (minor).
Verification
flake8,pytest(852 passed) andmypy(strict) all pass. mypy shows only the 5unused-ignoreerrors that are also on main.- New tests: create and update send
pathattachments with and withoutcontent_type. mypy checks that an attachment with no source, with both sources, or withcontentand nocontent_typestays a type error. - Live against api.resend.com through the SDK:
- create with
pathstoresinvoice.pdf(application/pdf, 80893 bytes) - update with
path+contentstores both - an
ftp://path raises a 422ResendError - a draft with a
pathattachment sends
- create with
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
pathrules instead of "apathreturns a 422". - Adds a
pathattachment to the draft example. - Bumps the version to 2.51.0.