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

# Use the PHP SDK

> Install the Leadping PHP SDK, supply a Kiota request adapter, and call typed API routes.

* Package: `leadpingai/sdk`
* Repository: [`leadpingai/leadping-php`](https://github.com/leadpingai/leadping-php)

## Install

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

## Create the client

```php theme={null}
<?php

use Http\Promise\FulfilledPromise;
use Http\Promise\Promise;
use Leadping\OpenApiClient\LeadpingOpenApiClient;
use Microsoft\Kiota\Abstractions\Authentication\AuthenticationProvider;
use Microsoft\Kiota\Abstractions\RequestInformation;
use Microsoft\Kiota\Http\GuzzleRequestAdapter;

final class LeadpingAuthenticationProvider implements AuthenticationProvider
{
    public function __construct(private readonly string $credential) {}

    public function authenticateRequest(
        RequestInformation $request,
        array $additionalAuthenticationContext = []
    ): Promise {
        $request->getHeaders()->tryAdd('Authorization', 'Bearer ' . $this->credential);
        return new FulfilledPromise($request);
    }
}

$credential = getenv('LEADPING_API_KEY');
if ($credential === false || $credential === '') {
    throw new RuntimeException('LEADPING_API_KEY is not set.');
}

$adapter = new GuzzleRequestAdapter(new LeadpingAuthenticationProvider($credential));
$client = new LeadpingOpenApiClient($adapter);
$lead = $client->leads()->byId('lead-id')->get()->wait();
```

The client defaults to `https://api.leadping.ai`. Set `LEADPING_API_KEY` to an organization API key. `$client->users()->me()` requires a user access token; source keys are only for lead intake.

## Call routes

```php theme={null}
$source = $client->sources()->byId("source-id")->get()->wait();
$lead = $client->leads()->byId("lead-id")->get()->wait();
// Requires a user access token.
$currentUser = $client->users()->me()->get()->wait();
```

The SDK does not store credentials. Use generated request-body classes when creating or updating records, confirm contracts in the [API Reference](/docs/api-reference), and follow the [rate-limit guide](/docs/rate-limits).
