# PHP

Use the Kirora HTTP API from PHP while the official client is planned.

The official PHP client is planned and has no announced release date. Until it is available, use the HTTP API with the example below. The Composer package name will be confirmed when the client is released.

## What it will cover

The PHP client will follow the [SDK conformance](/docs/api/sdk-conformance) checklist and copy the shape of the [Node.js reference library](/docs/sdks/node): one namespace per API tag and one method per `operationId` (`$client->contacts->identify()`, `$client->events->track()`), a single exception carrying the API's `code`, bounded retries with jitter on 429 and 5xx, an injectable PSR-18 HTTP client, auto-paginating iterators, caller-supplied idempotency keys, and a constant-time webhook verifier.

## Use the HTTP API today

Call the API directly with your key as a bearer token. [`trackEvent`](/docs/api/reference/trackEvent) requires an `Idempotency-Key`; derive it from your own order or event id so a retry is recorded once. To track an event with PHP's cURL functions:

```php
<?php

$ch = curl_init('https://api.kirora.io/v1/events/track');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('KIRORA_API_KEY'),
        'Idempotency-Key: order-1042-completed',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'externalId' => 'cust_1042',
        'eventName' => 'Order Completed',
        'properties' => ['orderId' => '1042', 'total' => 42.5, 'currency' => 'USD'],
    ]),
]);

$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

echo $status, ' ', $body, PHP_EOL;
```

See [Errors](/docs/api/errors) and [Idempotency](/docs/api/idempotency) before adding retries.