SDKs
PHP SDK
Install dimmi/dimmi-php to call the REST API, paginate lists, verify webhooks, and sign identity tokens in PHP.
dimmi/dimmi-php requires PHP 8.2 or later. Building with Laravel? Install the Laravel SDK instead, which bundles this client plus Blade and routing helpers.
composer require dimmi/dimmi-phpCreate a client and make a call
Section titled “Create a client and make a call”<?php
require __DIR__ . '/vendor/autoload.php';
$dimmi = new Dimmi\Client(token: getenv('DIMMI_TOKEN'));
try { $contact = $dimmi->contacts->store(['email' => 'ada@example.com', 'name' => 'Ada Lovelace']); echo $contact['data']['id'], "\n";} catch (Dimmi\ValidationException $e) { print_r($e->fields);} catch (Dimmi\DimmiException $e) { echo $e->status, ' ', $e->errorCode, "\n";}
foreach ($dimmi->paginate('/conversations', ['filter[status]' => 'open']) as $conversation) { echo $conversation['id'], "\n";}Set DIMMI_TOKEN to your API token. If you self-host, pass baseUrl: or set DIMMI_BASE_URL.
Three ways to call any endpoint
Section titled “Three ways to call any endpoint”Every operation in the API reference returns a decoded JSON array and can be called three ways:
| Style | Example |
|---|---|
| Resource method | $dimmi->conversations->messages->store($id, ['body' => 'Hello']) |
| Operation ID | $dimmi->call('conversations.messages.store', path: [$id], body: ['body' => 'Hello']) |
| Raw HTTP | $dimmi->request('POST', "/conversations/{$id}/messages", body: ['body' => 'Hello']) |
Resource names map camelCase operation IDs (for example, webhook-endpoints.tests.store is $dimmi->webhookEndpoints->tests->store()). Arguments follow the order: path parameters, $body (on writes), $query, and $options.
Paginate lists
Section titled “Paginate lists”paginate(): yields each item across cursor-paginated endpoints (meta.next_cursor), fetching 100 items per page unless you setlimit.pages(): yields each page across page-numbered endpoints.
Both accept a path or an operation ID, such as $dimmi->paginate('conversations.messages.index', params: [$id]).
Exceptions
Section titled “Exceptions”Every exception extends Dimmi\DimmiException, which exposes status, errorCode, and fields:
| HTTP status | Exception class |
|---|---|
| 400, 422 | Dimmi\ValidationException |
| 401 | Dimmi\AuthenticationException |
| 403 | Dimmi\PermissionDeniedException |
| 404 | Dimmi\NotFoundException |
| 429 | Dimmi\RateLimitException (includes retryAfter in seconds) |
| 500+ | Dimmi\ServerException |
Retries and idempotency
Section titled “Retries and idempotency”The client retries 429, 503, and connection failures up to 2 times while honoring Retry-After. It attaches an Idempotency-Key to every POST and reuses it on retries.
$dimmi = new Dimmi\Client(options: ['maxRetries' => 5, 'timeout' => 10, 'maxRetryDelay' => 30]);
$dimmi->contacts->store(['email' => 'ada@example.com'], options: ['idempotencyKey' => 'signup-4821']);Webhooks and identity tokens
Section titled “Webhooks and identity tokens”Use Dimmi\Webhook for webhook signature checks and Dimmi\Identity::sign() to sign JWTs for identity verification.