authensure/authensure-php

Official PHP SDK for Authensure - Electronic signature and document authentication platform

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/authensure/authensure-php

dev-development 2026-02-07 09:30 UTC

This package is auto-updated.

Last update: 2026-02-07 09:30:58 UTC


README

Packagist Version PHP Version License: MIT

Official PHP SDK for Authensure - the electronic signature and document authentication platform.

Features

  • Full API Coverage - Access all Authensure API endpoints
  • PHP 8.1+ - Modern PHP with strict typing
  • Automatic Retries - Built-in exponential backoff for transient errors
  • Rate Limit Handling - Automatic rate limit detection and backoff
  • Webhook Verification - Easy webhook signature verification
  • File Uploads - Simplified document upload handling with Guzzle
  • PSR Compliant - Built on PSR-7 HTTP message interfaces

Installation

composer require authensure/authensure-php

Quick Start

<?php

require_once 'vendor/autoload.php';

use Authensure\Client;

$client = Client::withApiKey('your_api_key');

// Create an envelope
$envelope = $client->envelopes->create([
    'name' => 'Contract Agreement',
    'message' => 'Please review and sign this document',
]);

echo "Created envelope: " . $envelope['id'];

Configuration

Global Configuration

use Authensure\Authensure;

Authensure::configure()
    ->setApiKey('your_api_key')
    ->setBaseUrl('https://api.authensure.app/api')
    ->setTimeout(30)
    ->setDebug(false);

$client = Authensure::client();

Per-Client Configuration

use Authensure\Client;
use Authensure\Configuration;

$config = new Configuration();
$config->setApiKey('your_api_key')
       ->setTimeout(30)
       ->setRetryAttempts(3);

$client = new Client($config);

API Reference

Envelopes

// List envelopes
$envelopes = $client->envelopes->list(['status' => 'DRAFT']);

// Get an envelope
$envelope = $client->envelopes->get('envelope_id');

// Create an envelope
$envelope = $client->envelopes->create([
    'name' => 'My Contract',
    'message' => 'Please sign',
]);

// Add a recipient
$recipient = $client->envelopes->addRecipient('envelope_id', [
    'email' => 'signer@example.com',
    'name' => 'John Doe',
    'role' => 'signer',
]);

// Send for signing
$envelope = $client->envelopes->send('envelope_id');

// Void an envelope
$envelope = $client->envelopes->void('envelope_id', 'Contract cancelled');

Documents

// Upload a document
$document = $client->documents->upload(
    'envelope_id',
    file_get_contents('contract.pdf'),
    'contract.pdf'
);

// Download a document
$content = $client->documents->download('document_id');
file_put_contents('signed_contract.pdf', $content);

Templates

// Use a template
$envelope = $client->templates->use('template_id', [
    'name' => 'New Contract',
    'recipients' => [
        ['roleId' => 'role_1', 'email' => 'signer@example.com', 'name' => 'John Doe'],
    ],
]);

Webhooks

// Create a webhook
$webhook = $client->webhooks->create([
    'url' => 'https://your-app.com/webhooks/authensure',
    'events' => ['envelope.signed', 'envelope.completed'],
]);

// Verify webhook signature
use Authensure\Resources\Webhooks;

$isValid = Webhooks::verifySignature($payload, $signature, 'your_webhook_secret');

// Construct verified event
$event = Webhooks::constructEvent($payload, $signature, 'your_webhook_secret');
echo "Event type: " . $event['event'];

Error Handling

use Authensure\Exceptions\AuthensureException;
use Authensure\Exceptions\NotFoundException;
use Authensure\Exceptions\AuthenticationException;
use Authensure\Exceptions\RateLimitException;
use Authensure\Exceptions\ValidationException;

try {
    $envelope = $client->envelopes->get('invalid_id');
} catch (NotFoundException $e) {
    echo "Envelope not found";
} catch (AuthenticationException $e) {
    echo "Invalid API key";
} catch (RateLimitException $e) {
    echo "Rate limited, retry after: " . $e->getRetryAfter() . " seconds";
} catch (ValidationException $e) {
    echo "Validation errors: " . print_r($e->getValidationErrors(), true);
} catch (AuthensureException $e) {
    echo "API error: " . $e->getMessage() . " (code: " . $e->getErrorCode() . ")";
}

Laravel Integration

Add to your config/services.php:

'authensure' => [
    'api_key' => env('AUTHENSURE_API_KEY'),
],

Create a service provider or use in your controller:

use Authensure\Client;

class EnvelopeController extends Controller
{
    private Client $authensure;

    public function __construct()
    {
        $this->authensure = Client::withApiKey(config('services.authensure.api_key'));
    }

    public function store(Request $request)
    {
        $envelope = $this->authensure->envelopes->create([
            'name' => $request->name,
            'message' => $request->message,
        ]);

        return response()->json($envelope);
    }
}

Development

# Install dependencies
composer install

# Run tests
composer test

# Run static analysis
composer phpstan

# Check code style
composer cs-check

Resources

License

This package is open-sourced software licensed under the MIT license.