PHP Quickstart
Call the Engium REST API from PHP using cURL or the Guzzle HTTP client — works with Laravel, Symfony, and plain PHP 8+.
info
Prerequisites
- •PHP 8.0+
- •cURL extension enabled (default on most hosts)
- •API key and Tenant ID from Settings → Developer
info
Laravel tip
In Laravel, store ENGIUM_API_KEY and ENGIUM_TENANT_ID in .env and access via env(). Use Http::withHeaders([...]) from the Laravel HTTP facade for a fluent interface.
Implementation
engium.php
<?php
$API_KEY = getenv('ENGIUM_API_KEY');
$TENANT = getenv('ENGIUM_TENANT_ID');
$BASE = 'https://api.engium.app/api/v1';
function engium_post(string $path, array $body, string $apiKey, string $tenant): array {
$ch = curl_init("$BASE/$path");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($body),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $apiKey",
"X-Tenant-ID: $tenant",
'Content-Type: application/json',
],
CURLOPT_TIMEOUT => 30,
]);
$resp = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code >= 400) throw new RuntimeException("Engium error: HTTP $code");
return json_decode($resp, true);
}
$session = engium_post('conversations/send', [
'recipient' => '+15550102999',
'channel' => 'whatsapp',
'message' => ['text' => 'Hello from PHP! 🐘'],
], $API_KEY, $TENANT);
echo "Session ID: {$session['id']}\n";
echo "Status : {$session['status']}\n";Request Parameters
| Parameter | Type | Requirement |
|---|---|---|
Authorization | Header · string | Required |
X-Tenant-ID | Header · UUID | Required |
AuthorizationRequiredBearer {api_key}. Generate from Settings → Developer → API Keys.
Type:Header · string
X-Tenant-IDRequiredYour Tenant UUID. All API data is scoped to this tenant.
Type:Header · UUID
Was this helpful?