Goal : Use docusign REST API with your Magic xpi Platform
Prerequisites :
- Access to docusign admin endpoint (https://apps-d.docusign.com)
- Some knowledge on docusign functionnalities (envelope, document, …)
1/ Configure an Apps in the docusign Admin console
Access to your admin console : https://apps-d.docusign.com/admin
Choose on the Left menu : Apps And Keys

Create an Apps

Choose options below

Clic on Add Secret Key

(*) Copy the secret value in a secure place
Set a value for the URL Redirect and Allow all the HTTP methods

After saving, you should get all the relevant informations in other to connect to the API

2/ Check with Postman that your API is working
Define 5 environment variables in your postman collection and leave accountid and envelopeid empty at this stage

Clic on the Auth tab control, choose OAuth 2.0 in the Auth Type and fil all the relevant information like below

Client ID corresponds to your docusign Integration Key
Client Secret corresponds to your docusign Secret Key
Auth URL : https://account-d.docusign.com/oauth/auth
Access Token URL : https://account-d.docusign.com/oauth/token
(*) I choose signature in the scope because i want to play only with this functionality (can be adjusted according to your needs)
Clic on the button « Get New Access Token » then sign in with tour credebtials and you should receive an access token.
add a request in your postman collection and make a GET on https://{{hostenv}}/oauth/userinfo, you should get information on your profile

3/ Assume that you have followed the process to sign a document in the docusign plaform

and i want to retrieve this signed document in Magic xpi
4/ Define a REST Client resource in your Magic xpi projet like below

Click on Paths and define paths that you want (please refer to : https://developers.docusign.com/docs/esign-rest-api/reference/)
Il will define this one /accounts/{accountid}/envelopes/{envelopeid}/documents/{documentid} in other to be able to download a signed document for example

Click OK and then click on Access Token and enter tour credentials. Access token should be generated successfully/
5/ Drag and drop a REST Client connector into your flow and configure like below

Click OK and set values for the accountid, envelopeid and documentid (you can get these infomration from your docusign dmin console

6/ Add a FileManagement Step after the REST Client in other to save the document on the disk.

7 After executing the flow, you should get the document on the disk

8/ WebHooks
You can use docusign push service (WebHooks) (to send realtime data update)s to trigger a magic xpi flow whenever an event occurs in docusign (Envelope Sent, Envelope Delivered, …).

