1. Add your API key to config
Store the key in .env and expose it through config/services.php.
// config/services.php
'sendwich' => [
'key' => env('SENDWICH_API_KEY'),
],
POST /api/v1/message.
Store the key in .env and expose it through config/services.php.
// config/services.php
'sendwich' => [
'key' => env('SENDWICH_API_KEY'),
],
use Illuminate\Support\Facades\Http;
$response = Http::withToken(config('services.sendwich.key'))
->asJson()
->post('https://sendwich.dev/api/v1/message', [
'from' => 'Acme ',
'to' => ['customer@example.com'],
'subject' => 'Welcome to Acme',
'html' => 'Your account is ready.
',
'text' => 'Your account is ready.',
]);
if (! $response->successful()) {
report(new \RuntimeException('Sendwich send failed: '.$response->body()));
}
from address.