Official PHP client for the Printable document-generation service integration API: templates, print-forms, batch rendering, document drafts and webhook verification — with the HMAC request signing (simple and strict canonical modes) built in and byte-compatible with the server implementation.
Zero runtime dependencies (ext-curl, ext-json). PHP 8.2+.
composer require dskripchenko/printable-sdkuse Dskripchenko\PrintableSdk\PrintableClient;
$client = new PrintableClient(
baseUrl: 'https://printable.example.com',
token: 'erp-main-7f3a',
secretKey: getenv('PRINTABLE_SECRET'),
salt: getenv('PRINTABLE_SALT'),
strict: false, // true if the credential has "verify full payload hash" enabled
);
// Render a document
$doc = $client->printFormCreate([
'template' => 'invoice',
'variables' => ['company' => ['name' => 'ACME Ltd']],
'format' => 'link',
]);
echo $doc['link'];
// Batch with archive + email delivery
$batch = $client->printFormBatch([
'template' => 'certificate',
'items' => [
['variables' => ['name' => 'Alice']],
['variables' => ['name' => 'Bob']],
],
'archive' => true,
'deliver' => ['email' => 'hr@example.com'],
]);
$status = $client->printFormBatchGet($batch['uuid']);| Method | Endpoint |
|---|---|
templateList() |
GET template/list |
templateContract($slug, $version?) |
GET template/contract |
templateExport($slug, $version?) |
GET template/export |
templateImport($packageB64, $groupId, $options?) |
POST template/import |
printFormCreate($params) |
POST print-form/create |
printFormGet($uuid, $format?) |
GET print-form/get |
printFormRules($slug, $version?) |
GET print-form/rules |
printFormBatch($params) |
POST print-form/batch |
printFormBatchGet($uuid) |
GET print-form/batch-get |
documentDraftCreate($params) |
POST document-draft/create |
documentDraftGet($uuid) |
GET document-draft/get |
call($method, $endpoint, $params) |
anything else |
Every method returns the decoded payload array of the response envelope.
Errors (non-2xx or success: false) raise PrintableException with
status, errorKey and the raw error payload.
$valid = $client->verifyWebhook(
rawBody: $request->getContent(),
signatureHeader: $request->header('X-Printable-Signature'),
timestampHeader: $request->header('X-Printable-Timestamp'),
);Pass a custom transport callable to stub HTTP without touching cURL:
$client = new PrintableClient(..., transport: function ($method, $url, $body) {
return [200, '{"success":true,"payload":{"ok":true}}'];
});MIT