dskripchenko / printable-sdk
Official PHP SDK for the Printable document-generation service: HMAC-signed integration API client (templates, print-forms, batches, drafts, webhooks).
Requires
- php: ^8.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- pestphp/pest: ^3.0|^4.0
This package is auto-updated.
Last update: 2026-08-04 16:30:26 UTC
README
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+.
Install
composer require dskripchenko/printable-sdk
Quick start
use 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']);
API surface
| 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.
Webhooks
$valid = $client->verifyWebhook( rawBody: $request->getContent(), signatureHeader: $request->header('X-Printable-Signature'), timestampHeader: $request->header('X-Printable-Timestamp'), );
Testing your integration
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}}']; });
License
MIT