How to integrate adobe echo sign API in Laravel
In this tutorial, We are going to discuss on the topic of integrating Adobe EchoSign API into a Laravel application. The Adobe Echo Sign Document API allows us to integrate EchoSign’s functionality on our website. If you or your customers generate reports and contracts that need electronic signatures, the Adobe API can integrate inside your document flow to increase the signing, tracking, and filing process.
The process of API will work as uploading a document, sending it for signing to an external party via email, and getting back a notification that the document has been signed. Both, the issuer and the signer of the contract are expected to fill some custom data into the contract. The process widely examines the functionality provided by Adobe EchoSign.
Before calling the Adobe EchoSign API you have to create a trial account on adobe echo sign. Now create Client id and Client secret. For Client id and Client secret login to Adobe EchoSign and goto account->Adobe Sign API. See screenshot below:->
Next, go to API Applications and click on the plus icon to create credentials by following the provided instructions. Remember there is two options (1) Customer (2) Partner. We recommend to you select Partner option during credential creation. Because using a partner account you can access API from all regions. If you select Customer option you have to add your region in the API endpoint. For example, if you belong to India add region like below to get the authorization code for an access token:-
[json]
https://secure.in1.echosign.com/public/oauth?
[/json]
Or with Partner option:-
https://secure.echosign.com/public/oauth?
Now you have Client id and Client Secret key. Note when create credentials remain all permissions to account for the first time. Later you can change these permissions. Let start calling API’s step by step.
Get Authorization Code
To request the Sign APIs, you have to first get an OAuth access token on behalf of an Adobe Sign user. This process uses HTTP requests to retrieve the token. Now copy and paste the below URL in your browser and change the values for redirect_uri and client_id. Also, add the necessary scope parameters described below code.
https://secure.echosign.com/public/oauth?redirect_uri=https://vrsoftcoder.com/echo_tokken.php&response_type=code&client_id=CBAThIsIsNoTaReAlmPBvPFsats&scope=user_login:account+agreement_read:account+agreement_send:account+library_read:account
When you select Allow Access, you will be redirected to the following URL:
https://vrsoftcoder.com/echo_tokken.php/?code=CBNCKBAThIsIsNoTaReAlcs_sL4K32wCzs4N&api_access_point=https://api.echosign.com&web_access_point=https://secure.echosign.com
And receive a response like below:-
CBNCKBAAHBCAABAAROoGU-SF0Rs4QxmkGDmgEQ-VsTZSnSxg https://secure.in1.echosign.com/ https://api.in1.echosign.com/
Remember the code CBNCKBAThIsIsNoTaReAlcs_sL4K32wCzs4N is the authorization code that you will use to obtain the OAuth access token. Also, you received an api_access_point and web_access_point for the next API request.
Get Access Token
Next, you have to send the authorization code along with the Client ID and Client Secret to the Sign API to get the access token. Note use the same api_access_point that you got from the previous response.
$url = "https://api.in1.echosign.com/oauth/token?code=CBNCKBAThIsIsNoTaReAlcs_sL4K32wCzs4N&client_id=CBAThIsIsNoTaReAlmPBvPFsats&client_secret=319UThIsIsNoTaReAl2-fgrrawrty&redirect_uri=https://vrsoftcoder.com/echo_tokken.php&grant_type=authorization_code; $header =array("content-type: application/x-www-form-urlencoded"); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => '', CURLOPT_HTTPHEADER => $header )); $Tokkenres = curl_exec($resource); $Tokkenresult = json_decode($Tokkenres,true); $AccessTokken = $Tokkenresult['access_token']; curl_close($resource);
You will get the following JSON response with the access token and the refresh token. You have to use this access token to access for next Adobe Sign API requests. If your access token expires, you have to use the refresh token to request for a new access token. You just need to attach your Client ID and Client Secret handy to request for a new access token.
{ "access_token":"3AAABLblThIsIsCsLa2ZBVpoKeNPr6Cv8KcZ9p7E93k2Tf", "refresh_token":"3AAABLblLtIsIsNoTaReAlToKeWCsLa2ZBVpD0uc*", "token_type":"Bearer", "expires_in":3600 }
Send an Agreement for Signing
Through Adobe EchoSign API you can upload/send documents for signing. When the agreement gets signed by all the receipts, you can fetch status and download a PDF copy of the signed agreement.
Upload a document
To upload a PDF document for signing you have to send a POST request to the transientDocuments endpoint with the following parameters:-
$url = "https://api.in1.echosign.com/api/rest/v5/transientDocuments"; $header =array( "Authorization: Bearer Your Access Token here, "cache-control: no-cache", "content-type: multipart/form-data", ); $filePath= '@'.file_get_contents(public_path('agreements/agreement_name')); $fields = array('File' => $filePath,'Mime-Type' => 'application/pdf', 'File-Name' => 'agreement_name'); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $fields, CURLOPT_HTTPHEADER => $header )); $DocIdres = curl_exec($resource); $DocIdresult = json_decode($DocIdres,true); curl_close($resource);
You will get the unique transientDocumentId in the response that will represent your uploaded document.
{ "transientDocumentId":"3AAABLbllZhBVYbhJbl--iAmtheEaLID_zjaBYK" }
Send The Document
After uploading the document, send the document to all the related clients for signing. To send the document you need to create an agreement by a POST request to the /agreements endpoint with the following JSON body:-
$url = 'https://api.in1.echosign.com/api/rest/v5/agreements'; $header =array( "Authorization: Bearer YOUR ACCESS TOKEN, "cache-control: no-cache", "content-type: application/json" ); $json = '{ "documentCreationInfo": { "signatureType": "ESIGN", "recipientSetInfos": [ { "recipientSetMemberInfos": [ { "email": "Recipient Email" } ], "recipientSetRole": "SIGNER" } ], "signatureFlow": "SENDER_SIGNATURE_NOT_REQUIRED", "message": "Please Sign this from us!", "fileInfos": [ { "transientDocumentId": "YOUR transientDocumentId" } ], "name": "Agreement" } } '; $fields = json_decode($json); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $json, CURLOPT_HTTPHEADER => $header )); $adobe_agreementres = curl_exec($resource); $adobe_agreementresresult = json_decode($adobe_agreementres,true); //print_r($adobe_agreementresresult); curl_close($resource);
You will receive the following response containing the agreement id. This agreement will be used to download the signed agreement, retrieve the status of the agreement.
{ "id": "" }
Get Sign Of Both Sender And Receiver
To get the sign of both parties you have to change the JSON body parameter “signatureFlow” as like below:-
"signatureFlow": "SENDER_SIGNS_LAST",
You have to add adobe sign text tag different for both Sender and Receipt like:-
for Sender:- {{Cmpy_es_:sender:signature}} For Receipt:- {{Client_es_:signer:signature}}
Check Document status
TO check the current status of the document send a GET request to API-Endpoint/agreements/{agreementid} with the following header parameters:-
$url = $this->host.'api/rest/v5/agreements/Document Id Here'; $header = array( "Authorization: Bearer Access Token Here", "cache-control: no-cache", "content-type: application/json" ); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => $header )); $document_status = curl_exec($resource); $result = json_decode($document_status,true); //print_r($result); $document_status = $result['status']; curl_close($resource);
You will get the following JSON response:-
{ "id": "", "name": "Agreement", "participantSetsInfo": [{ "memberInfos": [{ "email": "signer@yourclient.com", "securityOption": { "authenticationMethod": "NONE" } }], "role": "SIGNER", "order": 1 }], "senderEmail": "sender@yourcompany.com", "createdDate": "2018-07-23T08:13:16Z", "signatureType": "ESIGN", "locale": "en_US", "status": "OUT_FOR_SIGNATURE", "documentVisibilityEnabled": false }
Download the Agreement
Once an agreement is signed, you can download the signed copy of the PDF document and store that within your application. You can download signed agreement by sending a GET request to API-Endpoint/agreements/{agreementId}/combinedDocument:
$url = 'https://api.in1.echosign.com/{agreementId}/combinedDocument'; $header = array( "Authorization: Bearer Your Access Token Here", "cache-control: no-cache", "content-type: application/json" ); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => $header )); $Result = curl_exec($resource); $Save_signed_File = file_put_contents(public_path().'/employmentagreements/file_name Here',$Result);
You can save PDF file in your application from body response.
Refresh Token
If your access token has been expired, you can get it by sending get API to /OAuth/refresh? bypassing grant_type=refresh_token, Client Id and Client Secret:-
$url = "https://api.in1.echosign.com/oauth/refresh?grant_type=refresh_token&client_id=CLIENT ID HERE&client_secret=CLIENT SECRET HERE&refresh_token=YOUR REFRESH TOKEN HERE; $header =array("content-type: application/x-www-form-urlencoded"); $resource = curl_init(); curl_setopt_array($resource, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => '', CURLOPT_HTTPHEADER => $header )); $Tokkenres = curl_exec($resource); $Tokkenresult = json_decode($Tokkenres,true); $AccessTokken = $Tokkenresult['access_token']; curl_close($resource);
If you found this article helpful please comment below.
Also check our other tutorial on How to Import CSV and excel files in laravel.
How to integrate adobe echo sign API in Laravel,get sign of both sender and receiver, send the document, send the document adobe cho sign, upload a document, upload a document in adobe echo sign, get access token, get access token adobe echo sign, check document status, check document status in adobe echo sign, download the document, download document adobe echo sign, adobe echosign,adobe echosign api, adobe echosign pricing, adobe echosign trial, adobe echosign support, adobe echosign uk, adobe echosign contact number, adobe echosign for salesforce, adobe echosign login, adobe echosign in, adobe echosign account, adobe echosign app, adobe echosign acquisition, adobe echosign acquisition price, acrobat adobe echosign, adobe buys echosign, echosign acquired by adobe, adobe echosign legally binding, echosign by adobe, adobe echosign customer service, adobe echosign cost, adobe echosigncom, adobe echosign competitors, adobe echosign cfr part 11, adobe echosign callback url, adobe echosign api laravel, adobe echosign api php, adobe creative cloud echosign, adobe echosign digital certificate, adobe echosign digital signature, adobe echosign download, adobe echosign demo, adobe echosign documentation, adobe echosign download free, adobe echosign dashboard, adobe echosign developer account, adobe echosign down, adobe echosign digital signature, adobe echosign deutsch, adobe echosign enterprise pricing, adobe echosign encryption, adobe echosign error, adobe echosign electronic signature, adobe echosign e-signature service, adobe echosign email, adobe echosign free, adobe echosign free trial, adobe echosign free download, adobe echosign forum, adobe echosign file size limit, adobe echosign for microsoft dynamics crm, adobe echosign free account, adobe echosign features, adobe echosign font, adobe echosign gdpr, adobe echosign user guide, adobe echosign là gì, adobe echosign help, adobe echosign how to use, adobe echosign how to, adobe echosign integration key, adobe echosign login uk, adobe echosign multiple signatures, adobe echosign mobile, adobe echosign not working, adobe echosign phone number, adobe echosign outage, adobe echosign terms of use, adobe echosign pricing uk, adobe echosign login page, adobe echosign rest api, adobe echosign revenue, adobe echosign rest api wordpress, adobe echosign reviews, adobe reader echosign, remove adobe echosign, adobe echosign sign in, adobe echosign salesforce, adobe echosign status, adobe echosign support phone number, adobe echosign salesforce integration, adobe sign vs echosign, adobe echosign tutorial, adobe echosign tags, adobe echosign uk login, using adobe echosign, adobe echosign wiki, adobe echosign workflow, adobe echosign integration with salesforce, youtube adobe echosign, access token, refresh Token, The API caller does not have the permission to execute this operation, PERMISSION_DENIED in adobe echo sign