1. Go to this page and download the library: Download docwal/sdk 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/ */
docwal / sdk example snippets
ocWal\DocWalClient;
// Initialize client with your API key
$client = new DocWalClient('docwal_live_xxxxx');
// Issue a credential
$result = $client->credentials->issue([
'template_id' => 'template-123',
'individual_email' => '[email protected]',
'credential_data' => [
'student_name' => 'John Doe',
'degree' => 'Bachelor of Science',
'major' => 'Computer Science',
'graduation_date' => '2024-05-15',
'gpa' => '3.8'
]
]);
echo "Credential issued! Doc ID: {$result['doc_id']}\n";
echo "Claim token: {$result['claim_token']}\n";
// Production (default)
$client = new DocWalClient('docwal_live_xxxxx');
// Staging
$client = new DocWalClient(
'docwal_test_xxxxx',
'https://sandbox.docwal.com/api'
);
// Custom timeout (seconds)
$client = new DocWalClient(
'docwal_live_xxxxx',
'https://docwal.com/api',
60 // timeout in seconds
);
// Generate new API key (Owner/Admin only)
$result = $client->apiKeys->generate();
echo "New API key: {$result['api_key']}\n";
echo "⚠️ Store securely - shown only once!\n";
// Get API key info
$info = $client->apiKeys->info();
echo "Masked key: {$info['api_key_masked']}\n";
echo "Created: {$info['created_at']}\n";
echo "Last used: {$info['last_used_at']}\n";
// Regenerate API key
$result = $client->apiKeys->regenerate();
echo "New API key: {$result['api_key']}\n";
// Revoke API key
$client->apiKeys->revoke();
// List team members
$team = $client->team->list();
echo "Active members: {$team['stats']['active_members']}\n";
echo "Pending invitations: {$team['stats']['pending_invitations']}\n";
// Check email before inviting
$check = $client->team->checkEmail('[email protected]');
if ($check['recommendation'] === 'add_directly') {
echo "User exists - can add directly\n";
} elseif ($check['recommendation'] === 'send_invitation') {
echo "User doesn't exist - must send invitation\n";
}
// Invite team member
$result = $client->team->invite([
'email' => '[email protected]',
'role' => 'issuer',
'send_email' => true
]);
// Update member role
$client->team->updateRole('member-123', 'admin');
// Deactivate member
$client->team->deactivate('member-123', 'Employee on leave');
// Reactivate member
$client->team->reactivate('member-123');
// Remove member permanently
$client->team->remove('member-123');
use DocWal\DocWalClient;
use DocWal\Exceptions\AuthenticationException;
use DocWal\Exceptions\ValidationException;
use DocWal\Exceptions\NotFoundException;
use DocWal\Exceptions\RateLimitException;
use DocWal\Exceptions\DocWalException;
$client = new DocWalClient('docwal_live_xxxxx');
try {
$result = $client->credentials->issue([
'template_id' => 'invalid-template',
'individual_email' => '[email protected]',
'credential_data' => []
]);
} catch (AuthenticationException $e) {
echo "Authentication failed: {$e->getMessage()}\n";
echo "Check your API key\n";
} catch (ValidationException $e) {
echo "Validation error: {$e->getMessage()}\n";
echo "Check
namespace App\Http\Controllers;
use DocWal\DocWalClient;
use DocWal\Exceptions\DocWalException;
use Illuminate\Http\Request;
class CredentialController extends Controller
{
private $docwal;
public function __construct()
{
$this->docwal = new DocWalClient(config('services.docwal.api_key'));
}
public function issueCredential(Request $request)
{
try {
$result = $this->docwal->credentials->issue([
'template_id' => $request->input('template_id'),
'individual_email' => $request->input('email'),
'credential_data' => $request->input('data')
]);
return response()->json([
'success' => true,
'data' => $result
]);
} catch (DocWalException $e) {
return response()->json([
'success' => false,
'error' => $e->getMessage()
], $e->getCode() ?: 500);
}
}
}