Allow omitting Subject and From for hosted-template sends (#117)#126
Merged
Conversation
EmailMessage.Subject and From were non-nullable and always serialized, so a hosted-template send could not omit them to fall back to the template's defaults (sending subject: null risks a validation error). The send API makes subject/from optional when template.id is present. Make both nullable with JsonIgnore(WhenWritingNull) so they are omitted when unset. Normal sends are unaffected (a missing subject was already a server-side error and still is). From is included alongside Subject because a template send needs both omittable.
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Makes Subject and From nullable with JsonIgnore(WhenWritingNull) for hosted-template sends. Small, isolated change with tests.
Re-trigger cubic
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #117.
Problem
EmailMessage.SubjectandEmailMessage.Fromare non-nullable and lackJsonIgnore, so they are always serialized. When sending a hosted template, the API allows omittingsubject/fromto use the template's defaults (server validation only requires them whentemplate.idis absent). Today the SDK can't cleanly omit them — sendingsubject: nullrisks a validation error.Fix
Make
SubjectandFromnullable with[JsonIgnore(Condition = WhenWritingNull)], so they're omitted from the payload when unset.Scope note: #117 names only
Subject, butFromhas the identical problem and a template send needs both omittable, so this includesFromtoo. Happy to split it out if you'd prefer the PR mirror the issue exactly.No regression for normal sends: a missing subject was already rejected server-side and still is — this only changes
nullfrom"subject": nullto omitted.Verification
Build + full suite on .NET 8: 117/117 pass (2 new serialization tests: omitted-when-null, present-when-set).
Summary by cubic
Allows omitting Subject and From when sending a hosted template. This matches the API and uses template defaults instead of sending null values.
Written for commit b962801. Summary will update on new commits.