API Signature Tools

API Explorer – Make Any Call

Our easy to use API Explorer allows you to construct, execute, and analyze API calls without writing a single line of code! Based off of ioDocs technology, simply input your developer account credentials near the top and you can select which API call to make, add parameters if needed, and hit the Try It button! Best of all, it shows you the request and response headers and bodies for each request, giving you instant insight into how our API works.

API Call To Request a Signature

To request a signature on a document we will make a multi-part/form-data POST request to the endpoint:

http://{server}/restapi/{apiVersion}/accounts/{accountId}/envelopes

This endpoint is identical to the baseUrl that we retrieved through the Login call in the previous section, with the URI /envelopes appended to it. We will add the same 3 http headers to this request that we used for the Login call – X-DocuSign-Authentication, Content-Type, and Accept. The body of the request has boundary separated parts, with the first part containing JSON that configures request information such as email subject, document(s), and recipient(s). The second part of the body contains the bytes of the document we want signed.

The following is a sample request for requesting a signature on a PDF document:

POST http://demo.docusign.net/restapi/v2/accounts/12345/envelopes

X-DocuSign-Authentication: <DocuSignCredentials><Username>{name}</Username><Password>{password}</Password><IntegratorKey>{integrator_key}</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary=MYBOUNDARY

--MYBOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
    "status": "sent",
    "emailBlurb": "Test Email Body",
    "emailSubject": "Test Email Subject",
    "documents": [
        {
            "name": "test.pdf",
            "documentId": "1",
            "order": "1"
        }
    ],
    "recipients": {
        "signers": [
            {
                "email": "test@domain.com ",
                "name": "John Doe",
                "recipientId": "1",
                "tabs": {
                    "signHereTabs": [
                        {
                            "xPosition": "100",
                            "yPosition": "100",
                            "documentId": "1",
                            "pageNumber": "1"
                        }
                    ]
                }
            }
        ]
    }
}
--MYBOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="test.pdf";documentid=1

<document bytes go here...>

--MYBOUNDARY--

Note: Never made a multipart/form-data http request before? Here’s some info from www.w3.org

In this example we add one document, one recipient (of type signer), and one sign here tab for that recipient- which will be located 100 pixels to the right and 100 pixels down from the top left of the document. If any of this is confusing don’t worry- once you send your first request it will all make sense.

Below is a PHP script which sends a signature request on a PDF document. Instructions on how to run are listed below. Note: Don’t like PHP? We have 6 other languages in our API Walkthrough for requesting a signature on a document.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
109
110 111 112 113 114 115 116 117 118 119 120 121 122
<?php
// Input your info here:
$integratorKey = ***; // found on Preferences -> API page
$username = ***; // userId or email address
$password = ***; // member password
$recipientName = ***; // recipient (signer) name
$recipientEmail = ***; // recipient (signer) email
$documentName = ***; // copy doc with same name into this directory
// construct the authentication header:
$header = <DocuSignCredentials><Username> . $username . </Username><Password> . $password . </Password><IntegratorKey> . $integratorKey . </IntegratorKey></DocuSignCredentials>;
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 – Login (to retrieve baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = https://demo.docusign.net/restapi/v2/login_information;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(X-DocuSign-Authentication: $header));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo error calling webservice, status is: . $status;
exit(1);
}
$response = json_decode($json_response, true);
$accountId = $response[loginAccounts][0][accountId];
$baseUrl = $response[loginAccounts][0][baseUrl];
curl_close($curl);
//— display results
echo \naccountId = . $accountId . \nbaseUrl = . $baseUrl . \n;
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 – Create an envelope with one document, one recipient, one tab and send!
/////////////////////////////////////////////////////////////////////////////////////////////////
// The following JSON request body will place a signature tab 100 pixels to the right and
// 150 pixels down from the top left corner of the document, as an example. You can also
// position tabs through Templates and or Anchor Tagging
//
// Templates – https://www.docusign.com/developer-center/explore/features/templates
// Anchor Tagging – https://www.docusign.com/developer-center/explore/features/stick-etabs
//
$data = {
\”emailSubject\”:\”DocuSign API Sample – Please Sign This Document!\”,
\”documents\”:[
{
\”documentId\”:\”1\”,
\”name\”:\”$documentName\”
}
],
\”recipients\”:{
\”signers\”:[
{
\”email\”:\”$recipientEmail\”,
\”name\”:\”$recipientName\”,
\”recipientId\”:\”1\”,
\”tabs\”:{
\”signHereTabs\”:[
{
\”xPosition\”:\”100\”,
\”yPosition\”:\”150\”,
\”documentId\”:\”1\”,
\”pageNumber\”:\”1\”
}
]
}
}
]
},
\”status\”:\”sent\”
};
// read contents of the test document you copied into same directory
$file_contents = file_get_contents($documentName);
$requestBody = \r\n
.\r\n
.–myboundary\r\n
.Content-Type: application/json\r\n
.Content-Disposition: form-data\r\n
.\r\n
.$data\r\n
.–myboundary\r\n
.Content-Type:application/pdf\r\n
.Content-Disposition: file; filename=\”$documentName\”; documentid=1 \r\n
.\r\n
.$file_contents\r\n
.–myboundary–\r\n
.\r\n;
// *** append “/envelopes” to baseUrl and as signature request endpoint
$curl = curl_init($baseUrl . /envelopes );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
Content-Type: multipart/form-data;boundary=myboundary,
Content-Length: . strlen($requestBody),
X-DocuSign-Authentication: $header )
);
// parse the response
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo error calling webservice, status is: . $status . \nerror text is –> ;
print_r($json_response); echo \n;
exit(1);
}
$response = json_decode($json_response, true);
$envelopeId = $response[envelopeId];
//— display results
echo Document has been sent to $recipientEmail! Envelope ID is . $envelopeId . \n\n;
?>

To make the above signature request…

1. Download/copy the source code into a local file on your machine and name it with a .php file extension (i.e. sig_request.php).

2. Download document.pdf (which is an officially accepted IRS 4506T form) to the same directory your PHP file is in.

document.pdf

3. Update the variables at the top of sig_request.php with your Integrator Key, Name, Email, and Password information. Note: Use the same email address that you used to create your developer account.

4. Open a command prompt (Terminal on Mac), navigate to the directory that contains both your php file and the test pdf, and run by typing “php sig_request.php”.

A successful call sends an email that contains a hyperlink you can use to start the signing process. (Note: You do not need an account with DocuSign to sign documents, only to send them.)

The above script is a relatively simple signature request that contains one PDF document, one recipient, and one signature tab where the recipient is asked to sign. There are many other types of tabs, documents, recipients and other features that are available – this was just to get you warmed up!

API Walkthroughs – Start Coding

Ready to dive into some code? Our API Walkthroughs allow you to go from no code to working application in minutes if not seconds. The walkthroughs demonstrate the most common uses of our REST API and are each written in 6 different languages – PHP, JavaScript, C#, Java, Python, and Objective-C. To run, all you have to do is copy the code into your favorite IDE or editor, input your credentials at the top of the source file, and RUN! It’s that simple.

Mobile SDK (Beta)

The DocuSign Mobile SDK (Beta) is a native, open-source SDK designed for rapid development of iOS applications. Forged through collaboration with DocuSign’s partners and customers, the mobile SDK (beta) will allow you to integrate DocuSign’s rich eSignature capabilities into your app in under an hour. The Mobile SDK (Beta) currently supports authentication, native signing and sending, downloading of completed documents, signature adoption, and more.

Helper Libraries

In addition to the above API tools (which are all focused on the DocuSign REST API) we have additional API helper libraries written in multiple languages/environments for both REST and SOAP APIs.

Technical Documentation

Our technical documentation is frequently updated and well maintained, with online versions and PDF downloads available for both REST and SOAP APIs. There’s also Certification documents, API best practices, DocuSign CONNECT documentation, and more.

Add a Comment

Your email address will not be published. Required fields are marked *