PHP SDK

Easily integrate BoldSign's e-signature features into your PHP applications. This SDK simplifies sending documents for signature, embedding signing ceremonies, tracking document status, downloading signed documents, and managing e-signature workflows.

The PHP SDK is available on Packagist and the source code can be found in the GitHub repository.

Install the package

Install the BoldSign PHP SDK package in your project using the below command.

{
"require": {
"boldsign/php": "1.0.0"
},
"minimum-stability": "dev" 
}

Then, run the following command in the terminal to install the dependencies.

composer install

By default, the latest stable version will be installed. If you want to switch to any specific version, you can do by mentioning the exact version in the command.

composer require boldsign/php:1.0.0

Authentication

You can authenticate and configure the BoldSign PHP SDK using either an API Key or a Bearer Token. Depending on your authentication method, you can set up with one of the two configurations outlined below.

API Key

To authenticate using an API Key, you'll need to first generate your API key. You can refer to the API-Key for more details .

Once you have your API key, you can configure as follows:

$config = new BoldSign\Configuration();
$config->setApiKey('Your-API-Key-Here');

Replace "Your-API-Key-Here" with the actual API key you generated. After setting this up, the SDK will use this API key for authenticating all API requests.

OAuth 2.0

To authenticate using an Bearer Token(Access Token), you'll need to first generate your Bearer Token. You can refer to the OAuth 2.0 for more details .

Once you have your Bearer Token, you can configure as follows:

$config = new BoldSign\Configuration();
$config->setAccessToken("Your-Bearer-Token-Here");

Replace "Your-Bearer-Token-Here" with the actual Bearer Token you generated. After setting this up, the SDK will use this Bearer Token for authenticating all API requests.

Getting started

To prepare for sending a document for signing, you can authenticate using an API key after importing the BoldSign SDK. This example demonstrates the authentication process using an API key.

<?php
require_once __DIR__ . "/vendor/autoload.php";

// Configure API key authorization: X-API-KEY
$config = new BoldSign\Configuration();
$config->setApiKey('YOUR_API_KEY');

// Create an instance of the DocumentApi class
$documentApi = new BoldSign\Api\DocumentApi($config);

Now, define the signature field that will be added to your document. This involves specifying the field type (Signature), page number, and the bounds (position and size) of the field on the page.

$bounds = new BoldSign\Model\Rectangle([100, 100, 100, 50]);
// Define the signature field to be added to the document
$signatureField = new BoldSign\Model\FormField();
$signatureField->setFieldType('Signature');
$signatureField->setPageNumber(1);
$signatureField->setBounds($bounds);

The document and its form fields require signing. So, specify the signer to sign the form fields, including their name and email address.

// Define the signer with a name and email address
$signer = new BoldSign\Model\DocumentSigner();
$signer->setName("David");
$signer->setEmailAddress("david@example.com");
$signer->setSignerType("Signer");
$signer->setFormFields([$signatureField]);

Now, prepare the document you want to send for signature. Specify the title of the document, the signers involved, and the file(s) to be signed. In this case, we are sending a PDF document.

// Prepare the request body for sending the document for signature
$send_for_sign = new BoldSign\Model\SendForSign();
$send_for_sign->setTitle('Agreement');
$send_for_sign->setSigners([$signer]);
$send_for_sign->setFiles(['\tests\data\agreement.pdf']);

The last step is to send the document for signing with the defined document, form fields and signer.

// Send the document for signature and capture the response
$documentCreated = $documentApi->sendDocument($send_for_sign);

The return type documentCreated will contain the document ID of the document created, which can be used in later stages to get the particular document related operations.

Examples

You can find the PHP example application in the official GitHub repository. Additional code examples are available in this GitHub repository.

Class reference

Refer to the PHP SDK class reference documentation here.