Skip to content

PHP SDK

The PHP SDK provides a client for integrating with Subnoto’s API. It handles Oak tunnel encryption, HTTP signature authentication, and includes a native PHP extension for AMD SEV-SNP attestation.

Download the latest release tarball from GitLab Packages and extract it into your project:

Terminal window
tar xzf subnoto-api-client-php-*.tar.gz -C vendor/subnoto

Add the PSR-4 autoload entry to your composer.json:

{
"autoload": {
"psr-4": {
"Subnoto\\ApiClient\\": "vendor/subnoto/src/"
}
},
"require": {
"ext-oak_client_php": "*",
"guzzlehttp/guzzle": "^7.0"
}
}

Load the native extension by adding to your php.ini:

extension=/path/to/vendor/subnoto/ext/oak_client_php.so

Set your credentials as environment variables — SubnotoConfig picks them up automatically.

Terminal window
export SUBNOTO_ACCESS_KEY="your-access-key"
export SUBNOTO_SECRET_KEY="your-secret-key-hex"
<?php
require_once 'vendor/autoload.php';
use Subnoto\ApiClient\SubnotoClient;
use Subnoto\ApiClient\SubnotoConfig;
$config = new SubnotoConfig();
$client = new SubnotoClient($config);
// Check authentication
$whoami = $client->utils()->publicUtilsWhoamiPost();
echo "Authenticated as: " . $whoami->getTeamName() . "\n";
// List workspaces
$workspaces = $client->workspace()->publicWorkspaceListPost();
foreach ($workspaces as $ws) {
echo "Workspace: " . $ws->getName() . "\n";
}
use Subnoto\ApiClient\Model\PublicEnvelopeCreateFromFilePostRequest;
$request = new PublicEnvelopeCreateFromFilePostRequest([
'workspace_id' => 'your-workspace-id',
'name' => 'Contract for signing',
'document' => fopen('/path/to/document.pdf', 'r'),
]);
$envelope = $client->envelope()->publicEnvelopeCreateFromFilePost(
workspace_id: $request->getWorkspaceId(),
name: $request->getName(),
document: $request->getDocument(),
);
echo "Created envelope: " . $envelope->getId() . "\n";
use Subnoto\ApiClient\SubnotoError;
try {
$result = $client->workspace()->publicWorkspaceGetPost(
new \Subnoto\ApiClient\Model\PublicWorkspaceGetPostRequest([
'workspace_id' => 'nonexistent-id',
])
);
} catch (SubnotoError $e) {
echo "API error ({$e->getStatusCode()}): {$e->getMessage()}\n";
}

The SubnotoClient provides typed sub-clients for each API group:

Sub-clientAccess methodDescription
Envelope$client->envelope()Create, send, sign envelopes and manage documents
Workspace$client->workspace()List and manage workspaces
Contact$client->contact()Create and manage contacts
Template$client->template()List templates
Logs$client->logs()View audit logs
Authentication$client->authentication()Create iframe tokens for embedded signing
Utils$client->utils()Utility endpoints (whoami)

SubnotoConfig accepts the following parameters:

ParameterEnvironment VariableDescription
accessKeySUBNOTO_ACCESS_KEYYour API access key
secretKeySUBNOTO_SECRET_KEYYour API secret key (hex-encoded)
$config = new SubnotoConfig(
accessKey: 'your-access-key',
secretKey: 'your-secret-key-hex',
);

The PHP SDK uses the oak_client_php native extension to establish an encrypted tunnel with Subnoto’s AMD SEV-SNP enclaves. This ensures end-to-end encryption between your application and the enclave, with cryptographic attestation that the server is running in a genuine secure enclave.

The tunnel is established automatically when creating a SubnotoClient instance. Session management (including automatic retry on tunnel errors) is handled transparently.