diff --git a/src/BrevoEmailMessage.php b/src/BrevoEmailMessage.php index 7c0aba0..1264c78 100644 --- a/src/BrevoEmailMessage.php +++ b/src/BrevoEmailMessage.php @@ -16,7 +16,7 @@ final class BrevoEmailMessage public array $cc = []; - public int $templateId; + public ?int $templateId = null; public ?string $subject = null; @@ -161,10 +161,13 @@ public function toArray(): array $data = [ 'sender' => $this->from, 'to' => $this->to, - 'templateId' => $this->templateId, 'params' => $this->params, ]; + if (filled($this->templateId)) { + $data['templateId'] = $this->templateId; + } + if (filled($this->subject)) { $data['subject'] = $this->subject; }