PHP code example of praxicraft / assess
1. Go to this page and download the library: Download praxicraft/assess library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
praxicraft / assess example snippets
use Praxicraft\Assess\Client;
$client = new Client(['apiKey' => 'ct_live_xxxxxxxxxxxxxxxx']);
use Praxicraft\Assess\Client;
$client = new Client(); // reads PRAXICRAFT_API_KEY
$page = $client->assessments->list();
foreach ($page['results'] as $assessment) {
echo $assessment['slug'], ' ', $assessment['status'], PHP_EOL;
}
// Invite a candidate (idempotent on email — safe to retry)
$invite = $client->invites->create('senior-backend-screen', [
'email' => '[email protected] ',
'name' => 'Jane Doe',
'send_email' => true,
]);
echo $invite['invite_token'], ' ', $invite['invite_url'] ?? '', PHP_EOL;
$result = $client->results->retrieve($invite['invite_token']);
print_r($result);
$org = $client->org->retrieve();
if (($org['invites_remaining'] ?? 0) < count($candidates)) {
throw new RuntimeException('Not enough invites remaining this month');
}
$client->invites->bulkCreate('senior-backend-screen', [
['email' => '[email protected] ', 'name' => 'Alex'],
['email' => '[email protected] ', 'name' => 'Blair'],
], ['send_email' => true]);
$assessment = $client->assessments->create(['title' => 'Backend screen']);
$client->assessments->attachTasks($assessment['slug'], [
'tasks' => [['task_id' => '<platform-or-org-task-uuid>', 'source' => 'platform']],
]);
$client->assessments->activate($assessment['slug']);
$hook = $client->webhooks->create([
'url' => 'https://example.com/hooks/praxicraft',
'events' => ['assessment.completed', 'candidate.passed'],
]);
// Store $hook['secret_key'] (whsec_…) — shown once
$client->webhooks->test($hook['id']);
$client->webhooks->update($hook['id'], ['is_active' => true]);
$enrollment = $client->pipelines->enroll('grad-2025', [
'email' => '[email protected] ',
'name' => 'Alex Lee',
'send_email' => true,
]);
$status = $client->pipelines->getEnrollment($enrollment['enrollment_id']);
foreach ($client->results->iterAll('senior-backend-screen', ['page_size' => 50]) as $row) {
echo ($row['email'] ?? ''), ' ', ($row['score_percentage'] ?? ''), ' ', ($row['passed'] ?? ''), PHP_EOL;
}
use Praxicraft\Assess\Webhooks;
function handleWebhook(string $rawBody, string $signatureHeader, string $secret): bool
{
return Webhooks::verifySignature($secret, $rawBody, $signatureHeader);
}
use Praxicraft\Assess\Exception\AuthenticationException;
use Praxicraft\Assess\Exception\InsufficientScopeException;
use Praxicraft\Assess\Exception\RateLimitException;
use Praxicraft\Assess\Exception\ValidationException;
try {
$client->invites->create('demo', ['email' => '[email protected] ']);
} catch (ValidationException $exc) {
echo $exc->errorCode, ' ', json_encode($exc->details), PHP_EOL;
} catch (InsufficientScopeException $exc) {
echo $exc->errorCode, PHP_EOL;
} catch (AuthenticationException $exc) {
echo $exc->errorCode, PHP_EOL;
} catch (RateLimitException $exc) {
echo $exc->retryAfter, PHP_EOL;
}