You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add Team API endpoints
Added Team API endpoints for Domains, Messages, Projects, Routes, and core authentication strategies.
* wip
* refactor: update ping response handling to return trimmed string instead of integer
Adjusted `ping` methods in `EmailEndpoint` and `ApiClient` to return a trimmed string response. Updated tests accordingly to validate the new behavior.
* docs: add upgrade guide for migrating from v1 to v2
Added `UPGRADE.md` with detailed instructions for upgrading the PHP SDK from v1 to v2. Updated `README.md` to reference the new upgrade guide.
* fix
Sending API tokens are project-specific and authenticate with the `x-lettermint-token` header. API tokens are team-scoped and authenticate with `Authorization: Bearer ...`. Keep these tokens separate and never reuse an API token for sending-only workloads.
40
+
32
41
### Sending Emails
33
42
34
43
The SDK provides a fluent interface for composing and sending emails:
@@ -63,6 +72,36 @@ $lettermint->email
63
72
->send();
64
73
```
65
74
75
+
You can also send with an array payload:
76
+
77
+
```php
78
+
$response = $email->send([
79
+
'from' => 'sender@example.com',
80
+
'to' => ['recipient@example.com'],
81
+
'subject' => 'Hello from Lettermint!',
82
+
'text' => 'Hello! This is a test email.',
83
+
]);
84
+
```
85
+
86
+
### Batch Sending
87
+
88
+
```php
89
+
$response = $email->sendBatch([
90
+
[
91
+
'from' => 'sender@example.com',
92
+
'to' => ['recipient@example.com'],
93
+
'subject' => 'First email',
94
+
'text' => 'Hello!',
95
+
],
96
+
[
97
+
'from' => 'sender@example.com',
98
+
'to' => ['another@example.com'],
99
+
'subject' => 'Second email',
100
+
'text' => 'Hello again!',
101
+
],
102
+
]);
103
+
```
104
+
66
105
#### Inline Attachments
67
106
68
107
You can embed images and other content in your HTML emails using content IDs:
@@ -96,6 +135,48 @@ same request with the same idempotency key, the API will return the same respons
96
135
97
136
For more information, refer to the [documentation](https://docs.lettermint.co/platform/emails/idempotency).
98
137
138
+
### API Client
139
+
140
+
Use the API client for team-scoped resources such as projects, domains, routes, suppressions, stats, messages, and webhooks:
Version 2 changes the PHP SDK response model for the sending API. The latest released v1 SDK only exposed email sending, so this guide focuses on migrating existing sending integrations.
6
+
7
+
### 1. Update Composer
8
+
9
+
```bash
10
+
composer require lettermint/lettermint-php:^2.0
11
+
```
12
+
13
+
### 2. Prefer the new email client entry point
14
+
15
+
The v1 constructor-based style still maps to the email endpoint, but v2 introduces a clearer sending entry point:
`ping()` now returns the raw API ping response as a string.
120
+
121
+
Before:
122
+
123
+
```php
124
+
if ($lettermint->email->ping() === 200) {
125
+
// Sending API reachable
126
+
}
127
+
```
128
+
129
+
After:
130
+
131
+
```php
132
+
if ($email->ping() === 'pong') {
133
+
// Sending API reachable
134
+
}
135
+
```
136
+
137
+
### 5. Search and replace checklist
138
+
139
+
Search your codebase for:
140
+
141
+
```text
142
+
new Lettermint\Lettermint(
143
+
->email
144
+
['message_id']
145
+
['status']
146
+
sendBatch(
147
+
ping() === 200
148
+
```
149
+
150
+
Then update response handling to use typed properties or `toArray()`.
151
+
152
+
### Notes
153
+
154
+
The main migration risk is code that assumes SDK responses are arrays. Most of that code can be migrated by either using property access or appending `->toArray()` at the SDK boundary.
155
+
156
+
Version 2 also adds a new full API client via `Lettermint::api($apiToken)`, but this is new functionality rather than a migration requirement from v1.
0 commit comments