Skip to content

[CUST-5735] feat(messages): add send_raw_mime for raw MIME message send - #488

Merged
benjaminwhtan merged 2 commits into
mainfrom
CUST-5735-python-raw-mime-send
Sep 30, 2026
Merged

benjaminwhtan merged 2 commits into
mainfrom
CUST-5735-python-raw-mime-send

Conversation

@benjaminwhtan

Copy link
Copy Markdown
Contributor

Summary

The v3 API supports sending a raw RFC 822 MIME message (POST /v3/grants/{grant_id}/messages/send?type=mime), but the Python SDK had no way to call it. Customers who need exact control over the outgoing message, such as setting Importance: High / X-Priority: 1 on Microsoft grants, had to hand-roll HTTP requests. This adds messages.send_raw_mime().

client.messages.send_raw_mime(
    identifier=grant_id,
    request_body={"mime": mime_bytes},
)

Changes

  • Add Messages.send_raw_mime(identifier, request_body, overrides=None), returning Response[Message]. It follows the repo's request_body TypedDict convention and is named to pair with the existing read-side fields="raw_mime".
  • Add the SendRawMimeRequest model. mime accepts str or bytes. Bytes are sent exactly as given; strings are encoded as UTF-8.
  • Add _build_raw_mime_form_request, which sends the MIME as a message/rfc822 file part named mime. v3-send's constructMimeReader reads the file part first and streams it to disk. A plain form value only works through a fallback that logs an error, and Go's multipart parser holds plain values in memory with a size cap.
  • type=mime is set internally and isn't exposed as a query param, because it selects the endpoint rather than being an option.
  • Add unit tests for the resource method (str, bytes, overrides) and the form builder (file part, byte preservation).
  • Add the examples/raw_mime_send_demo example and README, and a CHANGELOG entry.

Testing

  • Full unit suite passes (491 tests, e2e excluded)
  • No new pylint warnings in touched files
  • Checked the outgoing request with only the network call mocked: ?type=mime, a multipart/form-data body with a single mime file part, and bytes unchanged
  • Live send from a Microsoft grant, using the example script against this branch (editable install). The send succeeded, and the received message in Outlook showed the high-importance flag, with Importance: High and X-Priority: 1 in the message source.

Related

  • CUST-5735 (Node and Ruby SDKs still to follow)

🤖 Generated with Claude Code

- add Messages.send_raw_mime() that posts to /v3/grants/{grant_id}/messages/send?type=mime
- add SendRawMimeRequest model with a mime field accepting str or bytes
- add _build_raw_mime_form_request helper that sends the MIME as a message/rfc822 file part
- add unit tests for the resource method and the form builder
- add raw_mime_send_demo example and README
- add changelog entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pengfeiye

pengfeiye commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

this is a new feature you might need to update the sdk referrence doc AI should be able to resolve the error on the PR

@benjaminwhtan
benjaminwhtan merged commit c0a9b43 into main Sep 30, 2026
7 checks passed
@benjaminwhtan benjaminwhtan mentioned this pull request Sep 30, 2026
2 of 4 tasks

This branch was successfully deployed

1 active deployment
sdk-reference — 7a616501 Deployed Sep 30, 2026 by benjaminwhtan via docs #588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants