1. Go to this page and download the library: Download turbodocx/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/ */
turbodocx / sdk example snippets
use TurboDocx\TurboSign;
use TurboDocx\Config\HttpClientConfig;
use TurboDocx\Types\Recipient;
use TurboDocx\Types\Field;
use TurboDocx\Types\SignatureFieldType;
use TurboDocx\Types\TemplateConfig;
use TurboDocx\Types\FieldPlacement;
use TurboDocx\Types\Requests\SendSignatureRequest;
// 1. Configure with your API key and sender information
TurboSign::configure(new HttpClientConfig(
apiKey: $_ENV['TURBODOCX_API_KEY'],
orgId: $_ENV['TURBODOCX_ORG_ID'],
senderEmail: $_ENV['TURBODOCX_SENDER_EMAIL'], // REQUIRED
senderName: $_ENV['TURBODOCX_SENDER_NAME'] // OPTIONAL (but strongly recommended)
));
// 2. Send a document for signature
$result = TurboSign::sendSignature(
new SendSignatureRequest(
recipients: [
new Recipient('John Doe', '[email protected]', 1)
],
fields: [
new Field(
type: SignatureFieldType::SIGNATURE,
recipientEmail: '[email protected]',
template: new TemplateConfig(
anchor: '{signature1}',
placement: FieldPlacement::REPLACE,
size: ['width' => 100, 'height' => 30]
)
)
],
file: file_get_contents('contract.pdf'),
documentName: 'Partnership Agreement'
)
);
echo "Document ID: {$result->documentId}\n";
use TurboDocx\TurboWebhooks;
TurboWebhooks::configureFromCredentials(
apiKey: getenv('TURBODOCX_API_KEY'),
orgId: getenv('TURBODOCX_ORG_ID'),
// baseUrl: 'http://localhost:3000', // optional, defaults to https://api.turbodocx.com
);
$created = TurboWebhooks::createWebhook(
urls: ['https://your-server.example.com/webhooks/turbodocx'], // HTTPS only
events: ['signature.document.completed', 'signature.document.voided'],
);
// `secret` is shown ONCE here. Store it securely; it cannot be retrieved later.
echo "Save this secret: {$created['secret']}";
$webhook = TurboWebhooks::getWebhook();
// $webhook['deliveryStats'] and $webhook['availableEvents'] are
use function TurboDocx\Utils\verifyWebhookSignature;
// In your webhook endpoint:
$rawBody = file_get_contents('php://input'); // CRITICAL: raw bytes only.
// Do NOT json_decode first; the
// signature is over the exact bytes.
$signature = $_SERVER['HTTP_X_TURBODOCX_SIGNATURE'] ?? '';
$timestamp = $_SERVER['HTTP_X_TURBODOCX_TIMESTAMP'] ?? '';
$secret = getenv('TURBODOCX_WEBHOOK_SECRET');
if (!verifyWebhookSignature($rawBody, $signature, $timestamp, $secret)) {
http_response_code(401);
exit('invalid signature');
}
$event = json_decode($rawBody, true);
// ... process event ...
use TurboDocx\Types\SignatureFieldType;
SignatureFieldType::SIGNATURE // Signature field
SignatureFieldType::INITIAL // Initial field
SignatureFieldType::DATE // Date stamp
SignatureFieldType::TEXT // Free text input
SignatureFieldType::FULL_NAME // Full name
SignatureFieldType::FIRST_NAME // First name
SignatureFieldType::LAST_NAME // Last name
SignatureFieldType::EMAIL // Email address
SignatureFieldType::TITLE // Job title
SignatureFieldType::COMPANY // Company name
SignatureFieldType::CHECKBOX // Checkbox field
new Field(
type: SignatureFieldType::SIGNATURE,
recipientEmail: '[email protected]',
page: 1, // Page number (1-indexed)
x: 100, // X coordinate
y: 500, // Y coordinate
width: 200, // Width in pixels
height: 50 // Height in pixels
)
new Field(
type: SignatureFieldType::SIGNATURE,
recipientEmail: '[email protected]',
template: new TemplateConfig(
anchor: '{signature1}', // Text to find in PDF
placement: FieldPlacement::REPLACE, // How to place the field
size: ['width' => 100, 'height' => 30]
)
)
$result = TurboSign::sendSignature(
new SendSignatureRequest(
recipients: [
new Recipient('Alice', '[email protected]', 1), // Signs first
new Recipient('Bob', '[email protected]', 2), // Signs after Alice
new Recipient('Carol', '[email protected]', 3) // Signs last
],
fields: [
// Fields for each recipient...
],
file: file_get_contents('contract.pdf')
)
);
$result = TurboSign::sendSignature(/* ... */);
// Poll for completion
while (true) {
sleep(2);
$status = TurboSign::getStatus($result->documentId);
if ($status->status === 'completed') {
echo "Document completed!\n";
// Download signed document
$signedPdf = TurboSign::download($result->documentId);
file_put_contents('signed.pdf', $signedPdf);
break;
}
echo "Status: {$status->status}\n";
}
use TurboDocx\TurboPartner;
use TurboDocx\Config\PartnerClientConfig;
TurboPartner::configure(new PartnerClientConfig(
partnerApiKey: getenv('TURBODOCX_PARTNER_API_KEY'), // REQUIRED - must start with TDXP-
partnerId: getenv('TURBODOCX_PARTNER_ID'), // REQUIRED - your partner UUID
baseUrl: 'https://api.turbodocx.com' // Optional
));
// Or use auto-configuration from environment
TurboPartner::configure(PartnerClientConfig::fromEnvironment());
use TurboDocx\Types\Requests\Partner\AddOrgUserRequest;
use TurboDocx\Types\Enums\OrgUserRole;
$result = TurboPartner::addUserToOrganization(
'org-uuid-here',
new AddOrgUserRequest(
email: '[email protected]',
role: OrgUserRole::ADMIN // ADMIN, CONTRIBUTOR, or VIEWER
)
);
echo "User ID: {$result->data->id}\n";
use TurboDocx\Types\Requests\Partner\ListOrgUsersRequest;
$result = TurboPartner::listOrganizationUsers(
'org-uuid-here',
new ListOrgUsersRequest(limit: 50, offset: 0)
);
echo "User Limit: {$result->userLimit}\n";
foreach ($result->results as $user) {
echo "- {$user->email} ({$user->role})\n";
}
use TurboDocx\Types\Requests\Partner\UpdateOrgUserRequest;
use TurboDocx\Types\Enums\OrgUserRole;
$result = TurboPartner::updateOrganizationUserRole(
'org-uuid-here',
'user-uuid-here',
new UpdateOrgUserRequest(role: OrgUserRole::CONTRIBUTOR)
);
use TurboDocx\Types\Requests\Partner\CreateOrgApiKeyRequest;
$result = TurboPartner::createOrganizationApiKey(
'org-uuid-here',
new CreateOrgApiKeyRequest(
name: 'Production API Key',
role: 'admin' // admin, contributor, or viewer
)
);
echo "Key ID: {$result->data->id}\n";
echo "Full Key: {$result->data->key}\n"; // Only shown once!
use TurboDocx\Types\Requests\Partner\ListOrgApiKeysRequest;
$result = TurboPartner::listOrganizationApiKeys(
'org-uuid-here',
new ListOrgApiKeysRequest(limit: 50)
);
use TurboDocx\Types\Requests\Partner\UpdateOrgApiKeyRequest;
$result = TurboPartner::updateOrganizationApiKey(
'org-uuid-here',
'api-key-uuid-here',
new UpdateOrgApiKeyRequest(name: 'Updated Key Name', role: 'contributor')
);
use TurboDocx\Types\Requests\Partner\AddPartnerUserRequest;
use TurboDocx\Types\Partner\PartnerPermissions;
$result = TurboPartner::addUserToPartnerPortal(
new AddPartnerUserRequest(
email: '[email protected]',
role: 'admin', // admin, member, or viewer
permissions: new PartnerPermissions(
canManageOrgs: true,
canManageOrgUsers: true,
canManagePartnerUsers: false,
canManageOrgAPIKeys: false,
canManagePartnerAPIKeys: false,
canUpdateEntitlements: true,
canViewAuditLogs: true
)
)
);
use TurboDocx\Types\Requests\Partner\ListPartnerUsersRequest;
$result = TurboPartner::listPartnerPortalUsers(
new ListPartnerUsersRequest(limit: 50)
);
use TurboDocx\Types\Requests\Partner\UpdatePartnerUserRequest;
use TurboDocx\Types\Partner\PartnerPermissions;
$result = TurboPartner::updatePartnerUserPermissions(
'partner-user-uuid-here',
new UpdatePartnerUserRequest(
role: 'admin',
permissions: new PartnerPermissions(
canManageOrgs: true,
canManageOrgUsers: true,
canManagePartnerUsers: true,
canManageOrgAPIKeys: true,
canManagePartnerAPIKeys: true,
canUpdateEntitlements: true,
canViewAuditLogs: true
)
)
);