Laravel: Publiq service class

Wrap the Publiq calls in an injectable service class, keeping the integration in one place.

Create app/Services/Publiq.php and inject it via the Laravel container:

<?php
namespace App\Services;

use Illuminate\Support\Facades\Http;

class Publiq
{
    public function send(array $payload): array
    {
        return Http::withToken(env('PUBLIQ_API_KEY'))
            ->post('https://api.publiq.digital/v1/emails', $payload)
            ->throw()
            ->json();
    }
}

Best practices

  • Always call Publiq from the server — the API key goes in the Authorization header, never on the client.
  • On 429/5xx, retry with exponential backoff (respect Retry-After).
  • Prefer templateKey over inline HTML to keep content versioned.
  • Handle errors via the response error.code field — see Errors.
  • Send from a verified domain — see Domains.

See also

Laravel: Publiq service class — Publiq Docs