> ## Documentation Index
> Fetch the complete documentation index at: https://learn.biq.li/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP SDK

> Reference for the server-only biqli/sdk Composer package.

`biqli/sdk` requires PHP 8.1 or newer and a secret workspace API key.

```bash theme={null}
composer require biqli/sdk
```

```php theme={null}
use Biqli\Sdk\Biqli;

$biqli = new Biqli($_ENV['BIQLI_API_KEY']);
```

## Constructor options

Pass options as the second constructor argument:

```php theme={null}
$biqli = new Biqli($_ENV['BIQLI_API_KEY'], [
    'timeoutMs' => 10000,
    'clientName' => 'acme-laravel',
    'clientVersion' => '1.0.0',
    'retry' => [
        'maxRetries' => 2,
        'baseDelayMs' => 250,
        'maxDelayMs' => 5000,
        'jitter' => true,
    ],
]);
```

| Option              | Default              | Description                                                |
| :------------------ | :------------------- | :--------------------------------------------------------- |
| `baseUrl`           | `https://biq.li/api` | API base URL                                               |
| `timeoutMs`         | `10000`              | Connect and request timeout per attempt, up to 120 seconds |
| `clientName`        | SDK name             | Diagnostic client header                                   |
| `clientVersion`     | SDK version          | Diagnostic version header                                  |
| `retry.maxRetries`  | `2`                  | Retries after the first attempt, up to 8                   |
| `retry.baseDelayMs` | `250`                | Initial retry delay                                        |
| `retry.maxDelayMs`  | `5000`               | Maximum retry delay, up to 60 seconds                      |
| `retry.jitter`      | `true`               | Randomize delays                                           |
| `httpClient`        | New Guzzle client    | Custom `ClientInterface` for testing or integration        |

## Methods

```php theme={null}
$lead = $biqli->track->lead($input, $options);
$sale = $biqli->track->sale($input, $options);
```

The optional request array accepts `idempotencyKey` and `requestId`.

Inputs match the [lead](/docs/api-reference/conversions/track-lead) and [sale](/docs/api-reference/conversions/track-sale) API schemas. Results are associative arrays matching the endpoint responses.

## Exceptions

```php theme={null}
use Biqli\Sdk\Exceptions\BiqliException;
```

`BiqliException` exposes:

* `$errorCode`
* `$status`
* `$requestId`
* `$details`
* `$retryable`
* `$attempts`

The SDK retries network errors and HTTP `408`, `425`, `429`, and `5xx`. It honors a valid `Retry-After` response up to 60 seconds.

For durable replay across processes, supply a lead `eventId` or a sale `paymentProcessor` plus `invoiceId`.

See [PHP and Laravel](/developers/server/php-laravel) for a complete implementation.
