Laravel Connection to Docusign php example – Part 2

In the second part of the tutorial.If you miss first part please check

Laravel Connection to Docusign php example


1: How to pass web hook URL, while creating document to sign

2: How to get Status of Envelops-  Delivered document(Sign/Opened/)

2: How to get PDF link to download


For passing the webhook, while generating the docs , like in the previous part of the tutorial. Every thing will be same only thing is that , we will add  event notification , while sending the docs like this.

As you can see $webhook URL : I will explain the function used in webhook below.

We will use this variable in $envelop_defination function


 We have used many function flags  like set URL, Set Logging Enabled, just google it.

Now below are the code of the webhoook. The DocuSign send the XML file as a PHP://input on our webhhook URL , triggering on every even like , email send, delivered, signed etc

The laravel function, which will handle the Webhook.

What the above code is doing is with respect to the Envelop ID: Its storing all the data  coming from docusign via webhook in storage directory. Including all file like Signed PDF or any other status.

Typically if document has been signed its look like this

[parent directory]

Name Size Date Modified
cld.pdf 263 kB 6/30/20, 7:54:50 PM
cld1.pdf 187 kB 6/30/20, 7:54:50 PM
T2020-06-30T07_21_51.6396372.xml 134 kB 6/30/20, 7:51:53 PM
T2020-06-30T07_23_34.4715086.xml 341 kB 6/30/20, 7:53:37 PM
T2020-06-30T07_24_46.8977331.xml 617 kB 6/30/20, 7:54:50 PM


It basically has: XML file with info about signed or unsigned PDF. We are just storing in our storage folder inside laravel.

Now in the last piece of code , we need to retrieve that information  in any sort of list or in API. So from part one . We already have Envelop ID from Step 1, Save it in database first so that we can use that to query the status of the Document/Envelope.

Afterward we will pass an array of envelop Id’s in the following  function to get the status. You can call this function as a post request  in laravel or you can modify it .

It’s taking an array of envelope id’s. In my case i have multiple docs signed under 1 user therefore i have multiple Envelop Ids , therefore i have sent an array of envelope id  to this function.

It’s basically getting info from a file , which is stored in a storage folder via webhook and returning  status data about the document.


Following Flags








Now , we already have status of document and its name, $type from above code , which has been returned as a array.


Now in that array we have

EnvelopID , $type,

$type is path to PDF file

We will pass again to new function in laravel above to parameter and our laravel get the pdf from storage directory and return PDF like following.


Now you will get the status and file name easily.


1 thought on “Laravel Connection to Docusign php example – Part 2”

Leave a comment