Get started

PHP SDK

Connect Laravel, WordPress, or PHP backends to the QuickCallAI call pipeline.

Back to documentation
Get started8 min
1

Create the PHP client

The PHP SDK uses cURL and the same authenticated JSON contract as the dashboard backend.

PHP SDK
<?php

final class QuickCallAI
{
    public function __construct(
        private string $apiKey,
        private string $baseUrl = 'https://ai.quickcall.tech/api'
    ) {
        $this->baseUrl = rtrim($this->baseUrl, '/');
    }

    private function request(string $method, string $path, ?array $payload = null): array
    {
        $ch = curl_init($this->baseUrl . $path);
        curl_setopt_array($ch, [
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER => [
                'Authorization: Bearer ' . $this->apiKey,
                'Content-Type: application/json',
            ],
        ]);
        if ($payload !== null) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        }

        $body = curl_exec($ch);
        $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
        if ($body === false) {
            throw new RuntimeException(curl_error($ch));
        }
        curl_close($ch);

        $data = json_decode($body, true) ?: [];
        if ($status >= 400 || ($data['success'] ?? true) === false) {
            throw new RuntimeException($data['message'] ?? $data['error'] ?? $body);
        }
        return $data;
    }

    public function initiateCall(array $input): array
    {
        return $this->request('POST', '/calls/demo/initiate', [
            'phone_number' => $input['phone_number'],
            'customer_name' => $input['customer_name'] ?? 'Customer',
            'prompt' => $input['prompt'],
            'language' => $input['language'] ?? 'en-US',
            'voice_model' => $input['voice_model'] ?? 'aura-asteria-en',
            'provider' => $input['provider'] ?? 'twilio',
            'agent_id' => $input['agent_id'] ?? null,
        ]);
    }

    public function getCallStatus(string $callId): array
    {
        return $this->request('GET', '/calls/demo/' . rawurlencode($callId) . '/status');
    }

    public function endCall(string $callId): array
    {
        return $this->request('POST', '/calls/demo/' . rawurlencode($callId) . '/end');
    }
}