PHP SDK

Last updated February 19, 2026

Installation

composer require administrate/sdk

Requires PHP 8.1 or later. Uses Guzzle for HTTP requests.

Authentication

Create an API key in Settings > Developers, then pass it when initializing the client:

use Administrate\Administrate;

$client = new Administrate(apiKey: 'sk_live_...');

Quick start

// Get account info
$account = $client->account->get();
echo "{$account->name} ({$account->plan})";

// List all clients with auto-pagination
foreach ($client->clients->list() as $c) {
    echo "{$c->name} ({$c->code})\n";
}

// Get failed executions
foreach ($client->executions->list(errorsOnly: true) as $execution) {
    echo "{$execution->workflow_name}: {$execution->error_category}\n";
}

Configuration

$client = new Administrate(
    apiKey: 'sk_live_...',
    timeout: 30,        // Request timeout in seconds. Default: 30
    maxRetries: 3,      // Retry attempts for failed requests. Default: 3
);

You can also pass any PSR-18 compatible HTTP client:

$client = new Administrate(
    apiKey: 'sk_live_...',
    client: $yourPsr18Client,
);

Common operations

Monitor failing workflows

foreach ($client->executions->list(
    status: 'failed',
    startDate: '2026-01-01',
    endDate: '2026-01-31',
) as $ex) {
    echo "{$ex->workflow_name}: {$ex->error_category}\n";
}

Trigger a sync

$client->instances->sync('n8n_abc123', syncType: 'all');

Check sync health

foreach ($client->syncRuns->health() as $entry) {
    echo "{$entry->instance_name} ({$entry->sync_status})\n";
}

Track LLM costs

$costs = $client->llmCosts->summary();
echo "Total: $" . number_format($costs->data->summary->total_cost_cents / 100, 2);

Pagination

All ->list() methods return an IteratorAggregate that handles pagination automatically:

// Auto-paginate through all results
foreach ($client->clients->list() as $c) {
    echo $c->name . "\n";
}

// Control page size
foreach ($client->clients->list(perPage: 100) as $c) {
    echo $c->name . "\n";
}

// Get a single page with metadata
$page = $client->clients->list(perPage: 10)->firstPage();
echo "{$page->meta->total} total, {$page->meta->total_pages} pages\n";

Error handling

The SDK raises typed exceptions for all API errors:

use Administrate\Exceptions\NotFoundException;
use Administrate\Exceptions\AuthenticationException;
use Administrate\Exceptions\RateLimitException;
use Administrate\Exceptions\ApiException;

try {
    $client->clients->get('com_nonexistent');
} catch (NotFoundException $e) {
    echo "Not found: {$e->getMessage()}";
} catch (AuthenticationException) {
    echo 'Invalid API key';
} catch (RateLimitException $e) {
    echo "Rate limited. Retry after {$e->retryAfter}s";
} catch (ApiException $e) {
    echo "API error {$e->statusCode}: {$e->getMessage()}";
}

Retries

The SDK automatically retries failed requests with exponential backoff for 429, 5xx, connection errors, and timeouts. Default: 3 retries.

$client = new Administrate(apiKey: 'sk_live_...', maxRetries: 0); // disable retries

Links

Still need help?

Can't find what you're looking for? Get in touch with our support team.