PHP Migration Guide

View as Markdown

Migrating the PHP SDK from hellosign/hellosign-php-sdk to dropbox/sign

Welcome! Dropbox Sign's new PHP SDK is generated from our officially maintained OpenAPI spec. In this release, we've made important updates that introduce new functionality and create feature parity between the Dropbox Sign API and the PHP SDK. However, some of these changes are considered "breaking" in the sense that they'll require you to update your existing code in order to continue using the SDK.

In this migration guide, we'll cover core concepts in the new SDK, highlight differences from legacy versions, and provide example code showing how past implementations map to the new version's syntax. We'll link out to supporting documents that offer more context behind the breaking changes and why we made them. We apologize for any inconvenience these changes may cause, but are confident the new features will add value to your integration.

Remember that we are here to help if you have any questions or need assistance along the way. Thank you for using Dropbox Sign's PHP SDK. We hope you enjoy the improvements!

Architecture and Tooling

As mentioned above, the new PHP SDK (dropbox/sign) is generated from our OpenAPI Spec. Some of the architectural changes impact the tools and locations you use to interact with the SDK.

SDK Resources

  • Download -- using this new packagist repo. New PHP SDK versions will now be published here.
  • Development -- active development against the PHP SDK happens here: hellosign-openapi/sdks/php.
  • SDK GitHub Repo -- dropbox-sign-php is updated based on changes to hellosign-openapi/sdks/php, but no active development work happens there.
  • Reference Docs -- the automatically generated Reference Docs are a great way to explore the SDK.
  • Examples -- our full suite of ready to use examples will help you get started quickly.
  • Engagement -- use the OpenAPI repo to submit Issues or Pull Requests for the PHP SDK.

Core Concepts and Patterns

This section contains the core concepts and patterns of the new SDK and highlights differences from the legacy SDK.

Installation

There are two methods for installing the new SDK:

Install from Packagist

  1. To install from Packagist run:

    composer require dropbox/sign

Build from Source

  1. Download the package ZIP
  2. Move the downloaded file (dropbox-sign-php-main.zip or similar) to your project directory

  3. In the respositories array of your composer.json file, add

    { “type”: “artifact”, “url”: ”./PATH_TO_DIRECTORY_WITH_ZIP_FILE” }

  4. Run composer install


Importing the SDK

Use Composer to autoload the package when needed.

Legacy SDK

Use require statement to bring in the entire Dropbox Sign SDK.

New SDK

Use import statement to add the entire SDK or only the pieces you need.

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5use HelloSign;
6
7$client = new HelloSign\Client($apikey);

Authentication

Legacy SDKNew SDK
The API key, Email/Password combination or access token was needed to instantiate a Client object.The API key or access token are utilized to configure HTTP basic auth or Bearer auth, respectively. Subsequently, this configuration object is used for the instantiation of API group endpoint classes within the SDK.
1<?php
2
3require_once 'vendor/autoload.php';
4
5// API Key config
6$client = new HelloSign\Client($apikey);
7
8// Email/Password config
9$client = new HelloSign\Client($email_address, $password);
10
11// OAuth config
12$client = new HelloSign\Client($access_token); //instance of HelloSign\OAuthToken

Endpoints Grouped into Classes

The new SDK divides endpoints across unique Classes:


Using Models to Pass Parameters

Models are used to define the structure and value of the parameters being passed. The fully assembled model is passed to the API endpoint method.

New SDK Using Models to Pass Parameters

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$apiAppApi = new Dropbox\Sign\Api\ApiAppApi($config);
10
11$oauth = new Dropbox\Sign\Model\SubOAuth();
12$oauth->setCallbackUrl("https://example.com/oauth")
13 ->setScopes([
14 Dropbox\Sign\Model\SubOAuth::SCOPES_BASIC_ACCOUNT_INFO,
15 Dropbox\Sign\Model\SubOAuth::SCOPES_REQUEST_SIGNATURE,
16 ]);
17
18$whiteLabelingOptions = new Dropbox\Sign\Model\SubWhiteLabelingOptions();
19$whiteLabelingOptions->setPrimaryButtonColor("#00b3e6")
20 ->setPrimaryButtonTextColor("#ffffff");
21
22$customLogoFile = new SplFileObject(__DIR__ . "/CustomLogoFile.png");
23
24$data = new Dropbox\Sign\Model\ApiAppCreateRequest();
25$data->setName("My Production App")
26 ->setDomains(["example.com"])
27 ->setOauth($oauth)
28 ->setWhiteLabelingOptions($whiteLabelingOptions)
29 ->setCustomLogoFile($customLogoFile);
30
31try {
32 $result = $apiAppApi->apiAppCreate($data);
33 print_r($result);
34} catch (Dropbox\Sign\ApiException $e) {
35 $error = $e->getResponseObject();
36 echo "Exception when calling Dropbox Sign API: "
37 . print_r($error->getError());
38}

Path and Query Parameters

In the legacy SDK you would pass Path and Query parameters alongside any POST data to the API endpoint:

Legacy SDK - Path and Query Parameters

1<?php
2
3require_once 'vendor/autoload.php';
4
5$client = new HelloSign\Client($apikey);
6
7$emailAddress = "john@example.com";
8$signatureRequestId = "2f9781e1a8e2045224d808c153c2e1d3df6f8f2f";
9
10$response = $client->requestEmailReminder($signatureRequestId, $emailAddress);
11print_r($response);

The new SDK now requires POST data be an object when calling any API endpoint. Path and Query parameters must be passed individually to these methods.

New SDK - Path and Query Parameters

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$signatureRequestApi = new Dropbox\Sign\Api\SignatureRequestApi($config);
10
11$data = new Dropbox\Sign\Model\SignatureRequestRemindRequest();
12$data->setEmailAddress("john@example.com");
13
14$signatureRequestId = "2f9781e1a8e2045224d808c153c2e1d3df6f8f2f";
15
16try {
17 $result = $signatureRequestApi->signatureRequestRemind($signatureRequestId, $data);
18 print_r($result);
19} catch (Dropbox\Sign\ApiException $e) {
20 $error = $e->getResponseObject();
21 echo "Exception when calling Dropbox Sign API: "
22 . print_r($error->getError());
23}

Error Handling and Warnings

The New SDK handles errors and warnings differently.

Error Handling

Errors are an instance of Dropbox\Sign\ApiException with its getResponseObject() method returning an instance of Dropbox\Sign\Model\ErrorResponse class and should be handled using Try/Catch blocks.

New SDK - Error Handling

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$accountApi = new Dropbox\Sign\Api\AccountApi($config);
10
11try {
12 $result = $accountApi->accountGet(null, 'jack@example.com');
13 print_r($result);
14} catch (Dropbox\Sign\ApiException $e) {
15 $error = $e->getResponseObject();
16 echo "Exception when calling Dropbox Sign API: "
17 . print_r($error->getError());
18}

Warnings

Warnings are a list of Dropbox\Sign\Model\WarningResponse.

New SDK - Warnings

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$api = new Dropbox\Sign\Api\AccountApi($config);
10
11$data = new Dropbox\Sign\Model\AccountCreateRequest();
12$data->setEmailAddress("newuser@dropboxsign.com");
13
14try {
15 $result = $api->accountCreate($data);
16 print_r($result);
17
18 // warning loop
19 foreach ($result->getWarnings() as $warning) {
20 print_r("Warning Name: {$warning->getWarningName()}");
21 print_r("Warning Message: {$warning->getWarningMsg()}");
22 }
23} catch (Dropbox\Sign\ApiException $e) {
24 $error = $e->getResponseObject();
25 echo "Exception when calling Dropbox Sign API: "
26 . print_r($error->getError());
27}

Instantiating Objects From Data

There are three ways to instantiate an object.

  • You can instantiate a class directly and pass an array of data
  • You can use setter methods
  • You can use the init() static method
1$signer1 = new Dropbox\Sign\Model\SubSignatureRequestSigner([
2 "email_address" => "jack@example.com",
3 "name" => "Jack",
4 "order" => 0,
5]);
6
7$attachment1 = new Dropbox\Sign\Model\SubAttachment([
8 "name" => "Attachment 1",
9 "instructions" => "Please download this file",
10 "signer_index" => 0,
11 "required" => true,
12]);
Note

init() creates a full object using all the data you pass, including nested data to instantiate nested objects. Any parameters that you do not pass data for will be set to their default value (including null).


Event Callback Helper

A callback helper class is included in the New SDK repo to assist in verifying callbacks. The helper simplifies:

  1. Checking event authenticity with built in event hash check
  2. Displaying event types (account callback vs. app callback)
  3. Displaying event messages

The EventCallbackHelper and EventCallbackRequest classes facilitate parsing of event data and assist in validating that a callback originated from Dropbox Sign.

We will send event callback payloads to you as a multipart/form-data request with a single json formfield that contains your event callback as a JSON string.

Example Event Callback Request From US to YOU

$curl -X POST 'https://example.com/YOUR_EVENT_CALLBACK_URL' \
> -F 'json={"event":{"event_type":"account_confirmed","event_time":"1669926463","event_hash":"ff8b03439122f9160500c3fb855bdee5a9ccba5fff27d3b258745d8f3074832f","event_metadata":{"related_signature_id":null,"reported_for_account_id":"6421d70b9bd45059fa207d03ab8d1b96515b472c","reported_for_app_id":null,"event_message":null}}}'

Example JSON Payload

1{
2 "event": {
3 "event_type": "account_confirmed",
4 "event_time": "1669926463",
5 "event_hash": "ff8b03439122f9160500c3fb855bdee5a9ccba5fff27d3b258745d8f3074832f",
6 "event_metadata": {
7 "related_signature_id": null,
8 "reported_for_account_id": "6421d70b9bd45059fa207d03ab8d1b96515b472c",
9 "reported_for_app_id": null,
10 "event_message": null
11 }
12 }
13}

How to use the EventCallbackHelper

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5// use your API key
6$api_key = "324e3b0840f065eb51f3fd63231d0d33daa35d4ed10d27718839e81737065782";
7
8// $callback_data represents data we send to you
9$callback_data = json_decode($_POST["json"] ?? [], true);
10
11$callback_event = Dropbox\Sign\Model\EventCallbackRequest::init($callback_data);
12
13// verify that a callback came from HelloSign.com
14if (Dropbox\Sign\EventCallbackHelper::isValid($api_key, $callback_event)) {
15 // one of "account_callback" or "api_app_callback"
16 $callback_type = Dropbox\Sign\EventCallbackHelper::getCallbackType($callback_event);
17
18 // do your magic below!
19}

HTTP Header Info

All methods include a WithHttpInfo() variant. This method ensures HTTP header information and status code will be included in the response received from the API.

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$signatureRequestApi = new Dropbox\Sign\Api\SignatureRequestApi($config);
10
11$data = new Dropbox\Sign\Model\SignatureRequestRemindRequest();
12$data->setEmailAddress("john@example.com");
13
14$signatureRequestId = "2f9781e1a8e2045224d808c153c2e1d3df6f8f2f";
15
16try {
17 // No HTTP headers included:
18 // $result = $signatureRequestApi->signatureRequestGet($signatureRequestId);
19
20 $result = $signatureRequestApi->signatureRequestGetWithHttpInfo($signatureRequestId);
21 print_r($result);
22} catch (Dropbox\Sign\ApiException $e) {
23 $error = $e->getResponseObject();
24 echo "Exception when calling Dropbox Sign API: "
25 . print_r($error->getError());
26}
Note

You can also get the last response object that includes body, status code, and headers, using the ::getResponse() method against an API object: $response = $signatureRequestApi->getResponse();


Differences from Legacy SDK

This section highlights larger changes to be aware of when migrating to the new SDK.

Form Fields per Document

The Form Fields per Document parameter has changed from a two dimensional array, to a one dimensional array—allowing you to designate which file you to add the field to using document_index. You can learn more about this change here: Form Fields per Document.

1$request->setFormFieldsPerDocument(
2 [
3 [ //document 1
4 [ //field 1
5 "api_id" => $random_prefix . "_1",
6 "name" => "",
7 "type" => "text",
8 "x" => 112,
9 "y" => 328,
10 "width" => 100,
11 "height" => 16,
12 "required" => true,
13 "signer" => 0
14 ],
15 [ //field 2
16 "api_id" => $random_prefix . "_2",
17 "name" => "",
18 "type" => "signature",
19 "x" => 530,
20 "y" => 415,
21 "width" => 150,
22 "height" => 30,
23 "required" => true,
24 "signer" => 1
25 ],
26 ],
27 ],
28);

Instantiating the Correct Field Class

There are several different types of form fields you can define, identified by the value of the type field and a few ways to instantiate the correct object when making an API request.

The different classes for each type are:

You can use ::init() on the base request class

1# instantiates a new `SignatureRequestSendRequest` object
2$data = Dropbox\Sign\Model\SignatureRequestSendRequest::init([
3 "title" => "NDA with Acme Co.",
4 "subject" => "The NDA we talked about",
5 "message" => "Please sign this NDA and then we can discuss more.",
6 "signers" => [
7 [
8 "email_address" => "jill@example.com",
9 "name" => "Jill",
10 "order" => 1,
11 ],
12 ],
13 "files" => [new SplFileObject(__DIR__ . "/pdf-sample.pdf")],
14 "form_fields_per_document" => [
15 [
16 "type" => "signature",
17 "document_index" => 0,
18 "api_id" => "4688957689",
19 "name" => "signature1",
20 "x" => 5,
21 "y" => 7,
22 "width" => 60,
23 "height" => 30,
24 "required" => true,
25 "signer" => 0,
26 "page" => 1,
27 ],
28 ],
29]);

You can use ::init() on the field class

1$form_field_1 = Dropbox\Sign\Model\SubFormFieldsPerDocumentSignature::init([
2 "document_index" => 0,
3 "api_id" => "4688957689",
4 "name" => "signature1",
5 "x" => 5,
6 "y" => 7,
7 "width" => 60,
8 "height" => 30,
9 "required" => true,
10 "signer" => 0,
11 "page" => 1,
12]);

You can instantiate the class directly

1$form_field_1 = new Dropbox\Sign\Model\SubFormFieldsPerDocumentSignature();
2$form_field_1->setDocumentIndex(0)
3 ->setApiId("4688957689")
4 ->setName("signature1")
5 ->setX(5)
6 ->setY(7)
7 ->setWidth(60)
8 ->setHeight(30)
9 ->setRequired(true)
10 ->setSigner(0)
11 ->setPage(1);

Form Fields per Document Examples using the new SDK:

1$form_field_1 = Dropbox\Sign\Model\SubFormFieldsPerDocumentSignature::init([
2 "document_index" => 0,
3 "api_id" => "4688957689",
4 "name" => "signature1",
5 "x" => 5,
6 "y" => 7,
7 "width" => 60,
8 "height" => 30,
9 "required" => true,
10 "signer" => 0,
11 "page" => 1,
12]);

“role” Value in signers Object

In the Legacy SDK when making a Signature Request using a Template the signers property was an object with the role name as the key. In the new SDK the role value has been moved into the signer object itself.

For example for the /signature_request/send_with_template endpoint the signers property could be represented as:

1{
2 "signers": {
3 "Client": {
4 "name": "George",
5 "email_address": "george@example.com"
6 },
7 "Manager": {
8 "name": "Bob",
9 "email_address": "bob@example.com"
10 }
11 }
12}

Using the new SDK you would now send this data as follows:

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$signatureRequestApi = new Dropbox\Sign\Api\SignatureRequestApi($config);
10
11$data = new Dropbox\Sign\Model\SignatureRequestSendWithTemplateRequest();
12$data->setTemplateIds(["c26b8a16784a872da37ea946b9ddec7c1e11dff6"])
13 ->setSubject("Purchase Order")
14 ->setMessage("Glad we could come to an agreement.")
15 ->setSigners([
16 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
17 "role" => "Client",
18 "name" => "George",
19 "email_address" => "george@example.com",
20 ]),
21 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
22 "role" => "Manager",
23 "name" => "Bob",
24 "email_address" => "bob@example.com",
25 ]),
26 ]);
27
28try {
29 $result = $signatureRequestApi->signatureRequestSendWithTemplate($data);
30 print_r($result);
31} catch (Dropbox\Sign\ApiException $e) {
32 $error = $e->getResponseObject();
33 echo "Exception when calling Dropbox Sign API: "
34 . print_r($error->getError());
35}

“role” Value in ccs Property

In the Legacy SDK when making a Signature Request using a Template the ccs property was an object with the role name as the key. In the new SDK the role value has been moved into the cc object itself, alongside a new email_address property.

For example for the /signature_request/send_with_template endpoint the ccs property could be represented as:

1{
2 "ccs": {
3 "Client": "george@example.com",
4 "Manager": "bob@example.com"
5 }
6}

Using the new SDK you would now send this data as follows:

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$signatureRequestApi = new Dropbox\Sign\Api\SignatureRequestApi($config);
10
11$data = new Dropbox\Sign\Model\SignatureRequestSendWithTemplateRequest();
12$data->setTemplateIds(["c26b8a16784a872da37ea946b9ddec7c1e11dff6"])
13 ->setSubject("Purchase Order")
14 ->setMessage("Glad we could come to an agreement.")
15 ->setSigners([
16 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
17 "role" => "Client",
18 "name" => "George",
19 "email_address" => "george@example.com",
20 ]),
21 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
22 "role" => "Manager",
23 "name" => "Bob",
24 "email_address" => "bob@example.com",
25 ]),
26 ])
27 ->setCcs([
28 Dropbox\Sign\Model\SubCC::init([
29 "role" => "Client",
30 "email_address" => "george@example.com",
31 ]),
32 Dropbox\Sign\Model\SubCC::init([
33 "role" => "Manager",
34 "email_address" => "bob@example.com",
35 ]),
36 ]);
37
38try {
39 $result = $signatureRequestApi->signatureRequestSendWithTemplate($data);
40 print_r($result);
41} catch (Dropbox\Sign\ApiException $e) {
42 $error = $e->getResponseObject();
43 echo "Exception when calling Dropbox Sign API: "
44 . print_r($error->getError());
45}

“name” Value in custom_fields Property

In the Legacy SDK when making a Signature Request with the custom_fields property it was an object with the name as the key. In the new SDK the name value has been moved into the custom_field object itself.

For example for the /signature_request/send_with_template endpoint the custom_fields property could be represented as:

1{
2 "custom_fields": {
3 "company": {
4 "value": "ABC Corp",
5 "required": true
6 }
7 }
8}

Using the new SDK you would now send this data as follows:

1<?php
2
3require_once __DIR__ . "/vendor/autoload.php";
4
5$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
6
7$config->setUsername("YOUR_API_KEY");
8
9$signatureRequestApi = new Dropbox\Sign\Api\SignatureRequestApi($config);
10
11$data = new Dropbox\Sign\Model\SignatureRequestSendWithTemplateRequest();
12$data->setTemplateIds(["c26b8a16784a872da37ea946b9ddec7c1e11dff6"])
13 ->setSubject("Purchase Order")
14 ->setMessage("Glad we could come to an agreement.")
15 ->setSigners([
16 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
17 "role" => "Client",
18 "name" => "George",
19 "email_address" => "george@example.com",
20 ]),
21 Dropbox\Sign\Model\SubSignatureRequestTemplateSigner::init([
22 "role" => "Manager",
23 "name" => "Bob",
24 "email_address" => "bob@example.com",
25 ]),
26 ])
27 ->setCustomFields([
28 Dropbox\Sign\Model\SubCustomField::init([
29 "name" => "company",
30 "value" => "ABC Corp",
31 "required" => true,
32 ]),
33 ]);
34
35try {
36 $result = $signatureRequestApi->signatureRequestSendWithTemplate($data);
37 print_r($result);
38} catch (Dropbox\Sign\ApiException $e) {
39 $error = $e->getResponseObject();
40 echo "Exception when calling Dropbox Sign API: "
41 . print_r($error->getError());
42}

template_id to template_ids

The template_id parameter has been removed. You must now use template_ids.

Legacy SDK versionNew SDK Version
Template ID (template_id) is passed as a singular string:

template_id : “1234567890”
Template ID is passed as an array of strings (template_ids):

template_ids:[“1234567890”]

file to files

The file parameter has been renamed to files. Usage remains the same.

Use ->setFiles([...]);


file_url to file_urls

The file_url parameter has been renamed to file_urls. Usage remains the same.

Use ->setFileUrls([...]);


Interacting with Files

The new SDK version introduces some new patterns around uploading and downloading files. You can read about them more in depth here: Interacting with Files.

Uploading Files

The file upload process changed with the newly-adopted OpenAPI-specification — it is no longer possible to pass file paths into file upload methods. You can learn more about this update here: New Patterns: Interacting with Files.

Legacy SDK versionNew SDK Version
A file path was passed into the addFile() and setLogo() methods.An SplFileObject object must be created and then passed into the setFiles() or setCustomLogoFile() methods.
1// Signature request
2$request->addFile('nda.pdf'); // Adding file from local;
3
4// API app request
5$request->setLogo('logo_file.png'); // Adding file from local;

Downloading Files

The file retrieval process changed with the newly-adopted OpenAPI-specification — one endpoint was branched off into three separate endpoints. You can learn more about this update here: New Patterns: Interacting with Files.

Legacy SDKNew SDK
A single method (getFiles()) would be called to retrieve files. If a local destination path and a file type (PDF or ZIP) were passed into the method, a binary stream would be returned to save locally. If no local destination path nor file type were passed, an auto-generated URL would be returned.Three separate methods are introduced to retrieve files as either a binary stream, an auto-generated URL or as a base64 string:
  • signatureRequestFiles()
  • signatureRequestFilesAsFileUrl()
  • signatureRequestFilesAsDataUri()
1// Binary stream
2$client->getFiles(
3 $signature_request_id,
4 "{$dest_file_path}/{$title}.zip",
5 HelloSign\SignatureRequest::FILE_TYPE_ZIP
6);
7
8// Auto-generated URL
9$client->getFiles($signature_request_id);

Downloading Templates

1$client->getTemplateFiles(
2 $tenokate_id,
3 "{$dest_file_path}/{$title}.zip",
4 "pdf"
5);

Endpoint Classes

Legacy SDKNew SDK
Requests to the API were made by calling methods within the Client object.Each endpoint group has its own class. Within each class, there are specific methods for calls to every single API endpoint.
1$client->createEmbeddedSignatureRequest($embedded_request);
2
3$client->sendSignatureRequest($request);
4
5$client->getSignatureRequest($signature_request_id);
6
7$client->getAccount();
8
9$client->getTemplate($templateId);

Endpoint Mapping

This section shows you how endpoints in the legacy SDK map to the new SDK. It doesn’t cover all endpoints, but gives you an idea of mapping implementations between the two SDKs. Please reach out if you think we’re missing an important example.

Update API App with White Labeling Options

1<?php
2
3require_once 'vendor/autoload.php';
4
5$client = new HelloSign\Client($apikey);
6
7$clientId = "7deab03c18acf4097fb675f2a566d49f";
8
9$apiApp = new ApiApp();
10$apiApp->setName('Updating Name')
11->setWhiteLabeling([
12 "primary_button_color" => "#00B3E6",
13 "primary_button_text_color" => "#FFFFFF"
14])
15->setLogo('my_company_logo.png');
16
17$response = $client->updateApiApp($clientId, $apiApp);
18print_r($response);

Embedded Signature Request and Get Sign URL

1<?php
2require_once 'vendor/autoload.php';
3
4$client = new HelloSign\Client($apikey);
5
6// Create the SignatureRequest object
7$request = new HelloSign\SignatureRequest;
8$request->enableTestMode();
9$request->setTitle('NDA with Acme Co.');
10$request->setSubject('The NDA we talked about');
11$request->setMessage('Please sign this NDA and let\'s discuss.');
12$request->addSigner('jack@example.com', 'Jack');
13$request->addSigner('jill@example.com', 'Jill');
14$request->addCC('lawyer@example.com');
15$request->addFile('nda.pdf'); //Adding file from local
16
17// Turn it into an embedded request
18$embedded_request = new HelloSign\EmbeddedSignatureRequest($request, $client_id);
19
20// Send it to HelloSign
21$response = $client->createEmbeddedSignatureRequest($embedded_request);
22
23// Grab the signature ID for the signature page that will be embedded in the
24// page (for the demo, we'll just use the first one)
25$signatures = $response->getSignatures();
26$signature_id = $signatures[0]->getId();
27
28// Retrieve the URL to sign the document
29$response = $client->getEmbeddedSignUrl($signature_id);
30
31// Store it to use with the embedded.js HelloSign.open() call
32$sign_url = $response->getSignUrl();

Get Signature Request

1<?php
2
3require_once 'vendor/autoload.php';
4
5$client = new HelloSign\Client($apikey);
6
7$response = $client->getSignatureRequest($signature_request_id);
8print_r($response);

Get Template

1<?php
2require_once 'vendor/autoload.php';
3
4$client = new HelloSign\Client($apikey);
5
6$templateId = '11b77b90f5e7156d961d4bbe26b872ca04edddbb';
7
8$response = $client->getTemplate($templateId);
9
10print_r($response);
11print_r($response->getTitle());
12print_r($response->getSignerRoles());

Send Signature Request with Template

1$request = new HelloSign\TemplateSignatureRequest;
2$request->enableTestMode();
3$request->setTemplateId($template->getId());
4$request->setSubject('Purchase Order');
5$request->setMessage('Glad we could come to an agreement.');
6$request->setSigner('Client', 'george@example.com', 'George');
7$request->setCC('Accounting', 'accounting@example.com');
8$request->setCustomFieldValue('Cost', '$20,000');
9
10$response = $client->sendTemplateSignatureRequest($request);

Get Account

1<?php
2require_once 'vendor/autoload.php';
3
4$client = new HelloSign\Client($apikey);
5
6$account = $client->getAccount();
7
8print_r($account->toArray());

Download Files

1<?php
2
3require_once 'vendor/autoload.php';
4
5$client = new HelloSign\Client($apikey);
6
7$signature_request_id = "e541d3d8df85c8e944f0793c8530e915d750";
8
9// Retrieve the signature request object
10$response = $client->getSignatureRequest($signature_request_id);
11
12// Set the destination path for the file
13$dest_file_path = 'Signature Request Files';
14// Retrieve the title from the signature request object
15$title = $response->getTitle();
16
17// Save the file locally
18$client->getFiles(
19 $signature_request_id,
20 "{$dest_file_path}/{$title}.zip",
21 HelloSign\SignatureRequest::FILE_TYPE_ZIP
22);
23
24// Or
25
26// Retrieve an auto-generated URL
27$client->getFiles($signature_request_id);

Supporting Legacy SDKs

Following the official release of the new SDK version, we'll be preparing to deprecate all legacy versions of the PHP SDK for one year after launch. That means, once fully launched, we'll only support critical vulnerabilities and bug fixes for legacy SDK versions 3.8.0 for 12 months. After that, legacy versions are considered officially deprecated and are no longer supported. You can find more information in our SDK Versioning Policy.

We encourage you to start migrating (or planning to migrate) to the new SDK as soon as possible. Please don't hesitate to reach out if you have questions or need assistance.


Feedback and Assistance

We know that dealing with "breaking" changes is inconvenient for those of you currently using the legacy SDK, but believe the new SDK offers a better experience while providing access to more features. If you need help or get stuck, please reach out to API support: Submit a Ticket

We warmly welcome your feedback, feature requests, and bug reports in our OpenAPI repo. All of the engineering work on the PHP SDK happens in the PHP folder of the repo.