> This page is part of EVVA for Developers (https://developers.evvahub.com), the documentation of the EVVA Partner API. The API is in developer preview and the SDK packages are not yet published: do not suggest installing them. Index: https://developers.evvahub.com/llms.txt

# PHP SDK

## Requirements

| Requirement         | Detail                                                                                                                                                                                    |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PHP                 | **8.3 or later** — supported 8.3, 8.4, 8.5 and 8.6; **8.5 recommended**                                                                                                                   |
| Required extensions | `ext-hash`, `ext-json`, `ext-openssl`                                                                                                                                                     |
| mbstring            | Provided automatically by the `symfony/polyfill-mbstring` dependency — a no-op where `ext-mbstring` is installed. It is needed because the official PHP 8.6 image ships without mbstring. |
| Optional            | `ext-pdo` (the durable PDO checkpoint and dedup stores), `ext-pcntl` (graceful shutdown of long-running consumers), a PSR-18 HTTP client — Guzzle or Symfony HttpClient                   |

With Guzzle or Symfony HttpClient installed, the SDK builds the HTTP client itself, with timeouts and **redirects
disabled** (a redirect could carry your token to another origin; the API never redirects). With any other PSR-18
client, timeouts and redirects are that client's configuration.

## Install

> **Info**
>
> Coming at general availability. Until then, this page shows the requirements and how the SDK is used.

## Configure

**`client.php`**

```php title="client.php"
use Evva\Partner\Auth\ClientCredentials;
use Evva\Partner\PartnerClient;

$evva = new PartnerClient(
    baseUrl: 'https://api.evvahub.com',
    credentials: ClientCredentials::secretBasic(getenv('EVVA_CLIENT_ID'), getenv('EVVA_CLIENT_SECRET')),
);
```

**`Other client authentication`**

```php title="Other client authentication"
ClientCredentials::secretPost($clientId, $secret);
ClientCredentials::privateKeyJwt($clientId, file_get_contents('/run/secrets/evva.pem'), 'key-2026-12', AssertionAlgorithm::ES256);
```

Several PHP processes (FPM workers, queue workers, cron) can share one token: pass a PSR-16 cache as `tokenCache:`
(Redis, APCu, Laravel's cache). It stores a bearer token, so use a private store.

## First calls

**`first-calls.php`**

```php title="first-calls.php"
$me = $evva->app->me();                                    // applicationId names the realtime channel
foreach ($evva->accounts->iterate() as $creator) {         // creators granted to this application
    $page = $evva->conversations->list($creator->creatorId, limit: 20);
}
$evva->messages->sendText($creatorId, $conversationId, 'Hello!');   // AI_AUTOMATED, with an Idempotency-Key
```

## Receive events

**`consumer.php`**

```php title="consumer.php"
$consumer = $evva->feedConsumer('crm-sync', function (PartnerEvent $event, EventContext $ctx) { /* … */ },
    checkpointStore: new PdoCheckpointStore($pdo), dedupStore: new PdoDedupStore($pdo));
$consumer->run();      // long-running; SIGTERM/SIGINT finish the in-flight event, checkpoint, exit
$consumer->drain();    // or: catch up once and return (cron, replay)
```

`$evva->eventStream(…)` combines realtime (WebSocket) with the feed: one handler, one dedup store, and a feed
catch-up after any gap. `ServerCheckpointStore` uses the API's consumer groups, so several workers share one position.
Stores: `InMemory*` (tests only), `File*` (one host), `Pdo*` (SQLite, MySQL/MariaDB, PostgreSQL).

> **Note**
>
> The PHP SDK speaks WebSocket only — PHP has no maintained WebTransport client. The semantics are identical.

## Errors

All exceptions extend `EvvaException`; API errors carry `status`, `requestId` and `details`.

| Exception                                           | When                                                                                                                                             |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ValidationException`                               | `400`, `422`                                                                                                                                     |
| `AuthException`                                     | `401`                                                                                                                                            |
| `PermissionException`                               | `403`                                                                                                                                            |
| `NotFoundException`                                 | `404`                                                                                                                                            |
| `ConflictException`, `IdempotencyConflictException` | `409` — also `LeaseHeldException`, `StaleFencingTokenException`, `ConversationAdvancedException`, `AutomationPausedException`                    |
| `CursorExpiredException`                            | `410 CURSOR_EXPIRED`                                                                                                                             |
| `RateLimitedException`                              | `429` — `retryAfterSeconds`, `level()`                                                                                                           |
| `ServerException`, `NetworkException`               | `5xx`, no response                                                                                                                               |
| `ApprovalRequiredException`                         | `202 APPROVAL_REQUIRED` — re-send with `RequestOptions::approved($e->approvalId, $e->idempotencyKey)` once approved; see [Approvals](/approvals) |

## Webhooks

**`webhook.php`**

```php title="webhook.php"
$handler = new WebhookHandler([$currentSecret, $previousSecret], function (PartnerEvent $event) { /* enqueue */ },
    new FileDedupStore('/var/lib/my-app/evva-dedup.log'));   // durable: survives a restart
$result = $handler->handle($headers, $rawBody);
http_response_code($result->status);
```

`WebhookVerificationMiddleware` (PSR-15) and the Laravel `evva.webhook` middleware answer the same statuses and
deduplicate the same way.

## Laravel

An optional integration ships a service provider, the `EvvaPartner` alias (a Laravel `Facade`), configuration, the webhook middleware and a feed-consumer
command. It is used only when `laravel/framework` is installed.

## Next steps

#### [Quickstart](/quickstart)

Your first integration, end to end.

#### [Event feed](/event-feed)

The durable record and consumer groups.

#### [Webhooks](/webhooks/overview)

Subscribe and verify.

#### [API reference](/api-reference)

Every operation.