Skip to main content

Installation

composer require verilock/php-sdk
Requires PHP 8.1+ and the json extension.

Configuration

use Verilock\Verilock;

$verilock = new Verilock([
    'api_key'     => 'qi_live_...',              // or set VERILOCK_API_KEY env var
    'base_url'    => 'https://verilock.io/api/v1',  // optional
    'timeout'     => 30,                          // optional, seconds (default: 30)
    'max_retries' => 2,                           // optional, retries on 429/5xx
]);
Use a qi_test_ key during development. Test keys return simulated results and are free to use.

Quick Start

use Verilock\Verilock;

$verilock = new Verilock(['api_key' => $_ENV['VERILOCK_API_KEY']]);

// Create a KYC session
$session = $verilock->sessions->create([
    'applicant_email' => 'john@example.com',
    'applicant_name'  => 'John Doe',
    'redirect_url'    => 'https://example.com/callback',
]);

// Redirect the user to complete verification
echo $session['session_url'];

// Later, retrieve the result
$result = $verilock->sessions->retrieve($session['id']);
echo $result['status']; // 'approved' | 'rejected' | 'pending' | ...

KYC Sessions

Create a session

$session = $verilock->sessions->create([
    'applicant_email' => 'jane@example.com',
    'applicant_name'  => 'Jane Smith',
    'redirect_url'    => 'https://example.com/done',
]);
// $session['session_url'] -> hosted verification link

List sessions

$response = $verilock->sessions->list([
    'status'   => 'approved',
    'page'     => 1,
    'per_page' => 25,
]);

foreach ($response['data'] as $item) {
    echo $item['id'] . ': ' . $item['status'] . PHP_EOL;
}

Retrieve a session

$session = $verilock->sessions->retrieve('sess_abc123');

Upload a document

$verilock->sessions->uploadDocument([
    'session_id'    => 'sess_abc123',
    'file'          => file_get_contents('./id_front.jpg'),
    'side'          => 'front',
    'document_type' => 'passport',
]);

Upload a selfie

$verilock->sessions->uploadSelfie([
    'session_id' => 'sess_abc123',
    'file'       => file_get_contents('./selfie.jpg'),
]);

Submit for evaluation

$result = $verilock->sessions->submit('sess_abc123');
echo $result['status']; // 'processing'
Call submit() only after all required documents and selfie have been uploaded. The session enters asynchronous processing and you will receive a webhook when it completes.

AML Screening

Screen a person

$result = $verilock->aml->screen([
    'name'          => 'John Doe',
    'date_of_birth' => '1990-01-15',
    'nationality'   => 'US',
]);

if ($result['status'] === 'match') {
    echo "Found {$result['matches_found']} matches";
}

Retrieve a screening

$screening = $verilock->aml->retrieve('aml_abc123');

Submit a decision

$verilock->aml->decide('aml_abc123', [
    'decision' => 'false_positive',
    'reason'   => 'Name similarity only, different date of birth.',
]);

Transaction Monitoring

Screen a transaction

$result = $verilock->transactions->screen([
    'transaction_ref' => 'TX-001',
    'sender_name'     => 'Alice Corp',
    'receiver_name'   => 'Bob Ltd',
    'amount'          => 15000,
    'currency'        => 'USD',
]);

if ($result['risk_level'] === 'high') {
    echo "{$result['alerts_count']} alerts triggered";
}

Batch screening

$batch = $verilock->transactions->screenBatch([
    'transactions' => [
        ['transaction_ref' => 'TX-002', 'sender_name' => 'Alice', 'receiver_name' => 'Bob', 'amount' => 500, 'currency' => 'EUR'],
        ['transaction_ref' => 'TX-003', 'sender_name' => 'Carol', 'receiver_name' => 'Dave', 'amount' => 12000, 'currency' => 'USD'],
    ],
]);

List, retrieve, and decide

$response = $verilock->transactions->list(['risk_level' => 'high']);

$detail = $verilock->transactions->retrieve('txn_abc123');

$verilock->transactions->decide('txn_abc123', [
    'decision' => 'approve',
    'reason'   => 'Verified sender identity manually.',
]);

Premium Features

Premium features require a paid plan. Calls made without an active subscription throw an InsufficientBalanceException.
// Biometric face authentication
$match = $verilock->biometric->verify([
    'session_id' => 'sess_abc123',
    'selfie'     => file_get_contents('./selfie.jpg'),
]);

// Government database validation
$dbCheck = $verilock->database->validate([
    'document_number' => 'AB123456',
    'country'         => 'US',
]);

// 1:N face duplicate detection
$duplicates = $verilock->faceSearch->search([
    'selfie' => file_get_contents('./selfie.jpg'),
]);

// Crypto wallet compliance screening
$walletResult = $verilock->wallet->screen([
    'address' => '0xabc...',
    'chain'   => 'ethereum',
]);

// Reusable KYC credentials
$credential = $verilock->credentials->issue([
    'session_id' => 'sess_abc123',
]);

// Age verification from selfie
$age = $verilock->ageVerify->verify([
    'selfie'  => file_get_contents('./selfie.jpg'),
    'min_age' => 18,
]);

Error Handling

All SDK exceptions extend VerilockException. Use specific classes for granular handling.
use Verilock\Exceptions\VerilockException;
use Verilock\Exceptions\AuthenticationException;
use Verilock\Exceptions\InsufficientBalanceException;
use Verilock\Exceptions\NotFoundException;
use Verilock\Exceptions\ValidationException;
use Verilock\Exceptions\RateLimitException;

try {
    $session = $verilock->sessions->create([
        'applicant_email' => 'john@example.com',
        'redirect_url'    => 'https://example.com/callback',
    ]);
} catch (InsufficientBalanceException $e) {
    echo "Balance: {$e->getBalance()}, required: {$e->getRequired()}";
} catch (ValidationException $e) {
    echo 'Field errors: ' . json_encode($e->getErrors());
} catch (RateLimitException $e) {
    echo "Retry after {$e->getRetryAfter()}s";
} catch (AuthenticationException $e) {
    echo 'Invalid API key';
} catch (NotFoundException $e) {
    echo 'Resource not found';
} catch (VerilockException $e) {
    echo "API error [{$e->getErrorCode()}]: {$e->getMessage()}";
}
All resource methods accept an optional associative array of request options as the last argument for per-request overrides such as custom headers or timeouts.