├── config
├── BRAND_ID
├── API_ACCOUNT_ID
├── CLICKWRAP_ID
├── ORGANIZATION_ID
├── ds_access_token.txt
└── settings.example.txt
├── documentation
├── account_id.png
└── stripe_skip_account_form_link.png
├── OAuth
├── __pycache__
│ ├── jwt.cpython-39.pyc
│ └── utils.cpython-311.pyc
├── utils.py
└── utils.php
├── docs
└── stripe_skip_account_form_link.png
├── demo_documents
├── World_Wide_Corp_fields.pdf
├── World_Wide_Corp_lorem.pdf
├── World_Wide_Corp_Web_Form.pdf
├── World_Wide_Corp_salary.docx
├── Offer_Letter_Dynamic_Table.docx
├── World_Wide_Corp_fields_shown.docx
├── World_Wide_Corp_Battle_Plan_Trafalgar.docx
├── UserData.example.csv
├── added_document.html
├── doc_1.html
└── order_form.html
├── .gitignore
├── api-reference
├── workspaces
│ └── accounts
│ │ ├── workspaces
│ │ ├── getWorkspaces.sh
│ │ ├── getWorkspace.sh
│ │ ├── getWorkspaceEnvelopes.sh
│ │ └── getWorkspaceAssignableRoles.sh
│ │ ├── workspaceUsers
│ │ ├── getWorkspaceUsers.sh
│ │ ├── restoreWorkspaceUserAccess.sh
│ │ ├── revokeWorkspaceUserAccess.sh
│ │ ├── updateWorkspaceUser.sh
│ │ └── addWorkspaceUser.sh
│ │ └── workspaceDocuments
│ │ ├── getWorkspaceDocuments.sh
│ │ ├── getWorkspaceDocument.sh
│ │ ├── deleteWorkspaceDocument.sh
│ │ └── getWorkspaceDocumentContents.sh
├── navigator
│ └── agreements
│ │ ├── deleteAgreement.sh
│ │ └── createAgreementSummary.sh
└── maestro
│ └── workflows
│ ├── getWorkflowInstance.sh
│ └── getWorkflowInstancesList.sh
├── examples
├── Rooms
│ ├── lib
│ │ └── utils.sh
│ ├── eg003ExportDataFromRoomController.sh
│ ├── eg007CreateFormGroup.sh
│ ├── eg005GetRoomsWithFiltersController.sh
│ ├── eg008AccessFormGroup.sh
│ ├── eg004AddFormsToRoomController.sh
│ └── eg006CreateAnExternalFormFillSessionController.sh
├── Admin
│ ├── utils.sh
│ ├── eg011DeleteUserDataFromAccount.sh
│ ├── eg007RetrieveDocuSignProfileByUserId.sh
│ ├── eg006RetrieveDocuSignProfileByEmailAddress.sh
│ ├── eg010DeleteUserDataFromOrganization.sh
│ ├── eg004AddUsersViaBulkImport.sh
│ ├── eg005AuditUsers.sh
│ ├── eg009DeleteUserProductPermissionProfile.sh
│ ├── eg013CreateAccount.sh
│ ├── eg003BulkExportUserData.sh
│ ├── eg012CloneAccount.sh
│ └── eg008UpdateUserProductPermissionProfile.sh
├── Click
│ ├── eg004GetListOfClickwraps.sh
│ ├── eg005GetClickwrapResponses.sh
│ ├── eg002ActivateClickwrap.sh
│ └── eg006EmbedClickwrap.sh
├── Notary
│ ├── eg003Jurisdictions.sh
│ ├── eg002InviteNotaryToPool.sh
│ └── eg004SendWithThirdPartyNotary.sh
├── eSignature
│ ├── eg004EnvelopeInfo.sh
│ ├── eg003ListEnvelopes.sh
│ ├── eg005EnvelopeRecipients.sh
│ ├── eg015EnvelopeTabData.sh
│ ├── eg018EnvelopeCustomFieldData.sh
│ ├── eg006EnvelopeDocs.sh
│ ├── eg027DeletingPermissions.sh
│ ├── eg009UseTemplate.sh
│ ├── eg033UnpauseSignatureWorkflow.sh
│ ├── eg028CreatingABrand.sh
│ ├── eg012EmbeddedConsole.sh
│ ├── eg007EnvelopeGetDoc.sh
│ ├── eg030ApplyingBrandTemplate.sh
│ ├── eg029ApplyingBrandEnvelope.sh
│ ├── eg022SigningViaEmailWithKnowledgeBasedAuthentication.sh
│ ├── eg019SigningViaEmailWithAccessCode.sh
│ ├── eg026UpdatingIndividualPermission.sh
│ ├── eg035ScheduledSending.sh
│ ├── eg024CreatingPermissionProfiles.sh
│ ├── eg032PauseSignatureWorkflow.sh
│ ├── lib
│ │ └── startServerForFocusedView.php
│ ├── eg036DelayedRouting.sh
│ └── eg002SigningViaEmail.sh
├── Maestro
│ ├── eg003ResumeWorkflow.sh
│ ├── eg002PauseWorkflow.sh
│ ├── lib
│ │ └── startServerForEmbeddedWorkflow.php
│ └── eg004CancelWorkflow.sh
├── Workspaces
│ ├── eg001CreateWorkspace.sh
│ ├── eg004CreateWorkspaceWithBrand.sh
│ ├── eg002AddDocumentToWorkspace.sh
│ ├── eg005CreateUploadRequest.sh
│ └── eg003SendEnvelopeWithRecipientInfo.sh
├── Navigator
│ ├── eg001ListAgreements.sh
│ └── eg002GetSingleAgreement.sh
├── Monitor
│ └── eg001GetMonitoringData.sh
├── WebForms
│ ├── eg002CreateRemoteInstance.sh
│ ├── eg001CreateInstance.sh
│ └── lib
│ │ └── startServerForWebForms.php
└── IdEvidence
│ └── eg001RetrieveEvents.sh
├── PAYMENTS_INSTALLATION.md
├── LICENSE
└── Quick_ACG
└── launcher.sh
/config/BRAND_ID:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/API_ACCOUNT_ID:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/CLICKWRAP_ID:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/ORGANIZATION_ID:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/ds_access_token.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/documentation/account_id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/documentation/account_id.png
--------------------------------------------------------------------------------
/OAuth/__pycache__/jwt.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/OAuth/__pycache__/jwt.cpython-39.pyc
--------------------------------------------------------------------------------
/OAuth/__pycache__/utils.cpython-311.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/OAuth/__pycache__/utils.cpython-311.pyc
--------------------------------------------------------------------------------
/docs/stripe_skip_account_form_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/docs/stripe_skip_account_form_link.png
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_fields.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_fields.pdf
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_lorem.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_lorem.pdf
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_Web_Form.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_Web_Form.pdf
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_salary.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_salary.docx
--------------------------------------------------------------------------------
/demo_documents/Offer_Letter_Dynamic_Table.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/Offer_Letter_Dynamic_Table.docx
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_fields_shown.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_fields_shown.docx
--------------------------------------------------------------------------------
/documentation/stripe_skip_account_form_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/documentation/stripe_skip_account_form_link.png
--------------------------------------------------------------------------------
/demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/docusign/code-examples-bash/master/demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx
--------------------------------------------------------------------------------
/demo_documents/UserData.example.csv:
--------------------------------------------------------------------------------
1 | AccountID,FirstName,LastName,UserEmail,PermissionSet
2 | {account_id},First1,Last1,example1@sampleemail.example,DS Admin
3 | {account_id},First2,Last2,example2@sampleemail.example,DS Admin
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | **/.DS_Store
3 | *.pem
4 | private.key
5 | ENVELOPE_ID
6 | TEMPLATE_ID
7 | settings.txt
8 | config/
9 | debug.log
10 | UserData.csv
11 | config/API_ACCOUNT_ID
12 | config/CLICKWRAP_ID
13 | config/ds_access_token.txt
14 | examples/ConnectedFields/__pycache__/
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaces/getWorkspaces.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaces
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaces
7 |
--------------------------------------------------------------------------------
/api-reference/navigator/agreements/deleteAgreement.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:deleteAgreement
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request DELETE "https://api-d.docusign.com/v1/accounts/{accountId}/agreements/{agreementId}" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:deleteAgreement
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaces/getWorkspace.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspace
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspace
7 |
--------------------------------------------------------------------------------
/api-reference/maestro/workflows/getWorkflowInstance.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkflowInstance
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workflows/${workflow_id}/instances/${instance_id}" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkflowInstance
--------------------------------------------------------------------------------
/api-reference/maestro/workflows/getWorkflowInstancesList.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkflowInstancesList
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workflows/${workflow_id}/instances" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkflowInstancesList
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceUsers/getWorkspaceUsers.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceUsers
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/users" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceUsers
7 |
--------------------------------------------------------------------------------
/api-reference/navigator/agreements/createAgreementSummary.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:createAgreementSummary
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request POST "https://api-d.docusign.com/v1/accounts/{accountId}/agreements/{agreementId}/ai/actions/summarize" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:createAgreementSummary
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaces/getWorkspaceEnvelopes.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceEnvelopes
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/envelopes" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceEnvelopes
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceDocuments/getWorkspaceDocuments.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceDocuments
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/documents" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceDocuments
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceDocuments/getWorkspaceDocument.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceDocument
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/documents/${document_id}" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceDocument
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaces/getWorkspaceAssignableRoles.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceAssignableRoles
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/assignable-roles" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceAssignableRoles
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceDocuments/deleteWorkspaceDocument.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:deleteWorkspaceDocument
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request DELETE "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/documents/${document_id}" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:deleteWorkspaceDocument
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceUsers/restoreWorkspaceUserAccess.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:restoreWorkspaceUserAccess
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request POST "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/users/${user_id}/actions/restore-access" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:restoreWorkspaceUserAccess
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceUsers/revokeWorkspaceUserAccess.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:revokeWorkspaceUserAccess
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request POST "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/users/${user_id}/actions/revoke-access" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:revokeWorkspaceUserAccess
7 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceDocuments/getWorkspaceDocumentContents.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:getWorkspaceDocumentContents
2 | Status=$(curl -s -w "%{http_code}\n" -i \
3 | --request GET "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/documents/${document_id}/contents" \
4 | --header "Authorization: Bearer ${access_token}" \
5 | --output ${response})
6 | #apx-snippet-end:getWorkspaceDocumentContents
7 |
--------------------------------------------------------------------------------
/examples/Rooms/lib/utils.sh:
--------------------------------------------------------------------------------
1 | function GetRoleId()
2 | {
3 |
4 | index=-1
5 | adminFound=false
6 | eval "arrRoles=($1)"
7 | element=$2
8 | arrRoleIds=($3)
9 |
10 | for i in "${!arrRoles[@]}";
11 | do
12 | if [[ "${arrRoles[$i]}" = "${element}" ]];
13 | then
14 | index=$i
15 | adminFound=true
16 | break
17 | fi
18 | done
19 |
20 | if [ "$adminFound" == true ]; then
21 | roleId=${arrRoleIds[$index]}
22 | echo $roleId
23 | fi
24 | }
25 |
26 | export -f GetRoleId
27 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceUsers/updateWorkspaceUser.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:updateWorkspaceUser
2 | printf \
3 | '{
4 | "role_id": "'"${role_id}"'"
5 | }' >> $request_data
6 |
7 | Status=$(curl -s -w "%{http_code}\n" -i \
8 | --request PUT "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/users/${user_id}" \
9 | --header "Authorization: Bearer ${access_token}" \
10 | --header 'Content-Type: application/json' \
11 | --data-binary @${request_data} \
12 | --output ${response})
13 | #apx-snippet-end:updateWorkspaceUser
14 |
--------------------------------------------------------------------------------
/config/settings.example.txt:
--------------------------------------------------------------------------------
1 | export SIGNER_EMAIL="{SIGNER_EMAIL}"
2 | export SIGNER_NAME="{SIGNER_NAME}"
3 | export SIGNER_NOT_CHECKED_NAME="{SIGNER_NOT_CHECKED_NAME}"
4 | export SIGNER_NOT_CHECKED_EMAIL="{SIGNER_NOT_CHECKED_EMAIL}"
5 | export CC_EMAIL="{CC_EMAIL}"
6 | export CC_NAME="{CC_NAME}"
7 | export IMPERSONATION_USER_GUID="{IMPERSONATED_USER_ID}"
8 | export INTEGRATION_KEY_JWT="{INTEGRATION_KEY_JWT}"
9 | export INTEGRATION_KEY_AUTH_CODE="{INTEGRATION_KEY_AUTH_CODE}"
10 | export SECRET_KEY="{SECRET_KEY}"
11 | export GATEWAY_ACCOUNT_ID="{DS_PAYMENT_GATEWAY_ID}"
12 | export QUICKSTART="{QUICKSTART_VALUE}"
13 | export TARGET_ACCOUNT_ID="{TARGET_ACCOUNT_ID}"
14 |
15 |
--------------------------------------------------------------------------------
/api-reference/workspaces/accounts/workspaceUsers/addWorkspaceUser.sh:
--------------------------------------------------------------------------------
1 | #apx-snippet-start:addWorkspaceUser
2 | printf \
3 | '{
4 | "email": "'"${email}"'",
5 | "first_name": "'"${first_name}"'",
6 | "last_name": "'"${last_name}"'",
7 | "role_id": "'"${role_id}"'"
8 | }' >> $request_data
9 |
10 | Status=$(curl -s -w "%{http_code}\n" -i \
11 | --request POST "https://api-d.docusign.com/v1/accounts/${account_id}/workspaces/${workspace_id}/users" \
12 | --header "Authorization: Bearer ${access_token}" \
13 | --header 'Content-Type: application/json' \
14 | --data-binary @${request_data} \
15 | --output ${response})
16 | #apx-snippet-end:addWorkspaceUser
17 |
--------------------------------------------------------------------------------
/examples/Admin/utils.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Check that we're in a bash shell
4 |
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | accessToken=$(cat config/ds_access_token.txt)
10 | response=$(mktemp /tmp/response-orgid.XXXXXX)
11 |
12 | curl --header "Authorization: Bearer ${accessToken}" \
13 | --header "Content-Type: application/json" \
14 | --request GET https://api-d.docusign.net/management/v2/organizations \
15 | --output $response
16 |
17 | organizationId=$(cat $response | sed 's/.*\"organizations\":\[{\"id\":\"//g' | sed 's/\".*//g')
18 |
19 | echo "Organization ID has been written to config/ORGANIZATION_ID"
20 | echo $organizationId > 'config/ORGANIZATION_ID'
21 |
22 | # cleanup
23 | rm "$response"
--------------------------------------------------------------------------------
/PAYMENTS_INSTALLATION.md:
--------------------------------------------------------------------------------
1 | # Configure a payment gateway
2 |
3 | DocuSign offers built-in connections to multiple payment gateways. The payments code example uses a developer account via the Stripe gateway service.
4 |
5 |
6 | ## Create a Stripe payment gateway
7 |
8 | 1. Select the Stripe button on the [**Payments**](https://admindemo.docusign.com/authenticate?goTo=payments) page in your developer account.
9 |
10 | 1. For development, you can skip the Stripe account application by using the **Skip this account form** link at the top of the page.
11 |
12 | 
13 |
14 | An enabled Stripe payment gateway is now associated with your DocuSign developer account and is shown under **Payment Gateway**.
15 |
16 | 1. Save the **Gateway Account ID** GUID to the code example launcher configuration file.
17 |
18 |
19 | ## Additional documentation
20 | * [Managing Payment Gateways](https://support.docusign.com/en/guides/managing-payment-gateways)
21 | * [How to send a request for payment](https://developers.docusign.com/docs/esign-rest-api/how-to/request-a-payment)
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2018 DocuSign, Inc. (https://www.docusign.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/demo_documents/added_document.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | World Wide Corp
9 | Order Processing Division
12 | Item: Oranges, quantity: 20 gross at market price.
13 |
14 | Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
15 |
16 |
17 | Agreed: **signature_1**
18 |
19 |
20 |
--------------------------------------------------------------------------------
/demo_documents/doc_1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | World Wide Corp
9 | Order Processing Division
12 | Ordered by {USER_FULLNAME}
13 | Email: {USER_EMAIL}
14 | Copy to: {CC_NAME}, {CC_EMAIL}
15 |
16 | Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
17 |
18 |
19 | Agreed: **signature_1**/
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/Click/eg004GetListOfClickwraps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/click-api/how-to/retrieve-clickwraps
3 | # How to get a list of Clickwraps
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Step 2. Construct your API headers
19 | #ds-snippet-start:Click4Step2
20 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
21 | '--header' "Accept: application/json")
22 | #ds-snippet-end:Click4Step2
23 |
24 | # Step 3. Call the Click API
25 | # a) Make a GET call to the Clickwraps endpoint to retrieve all Clickwraps for an account
26 | # b) Display the JSON structure of the returned Clickwraps
27 | #Create a temporary file to store the response
28 | response=$(mktemp /tmp/response-cw.XXXXXX)
29 | #ds-snippet-start:Click4Step3
30 | curl --request GET https://demo.docusign.net/clickapi/v1/accounts/${account_id}/clickwraps \
31 | "${Headers[@]}" \
32 | --output ${response}
33 | #ds-snippet-end:Click4Step3
34 |
35 | echo ""
36 | echo "Response:"
37 | cat $response
38 | echo ""
39 |
40 | # Remove the temporary file
41 | rm "$response"
42 |
--------------------------------------------------------------------------------
/examples/Notary/eg003Jurisdictions.sh:
--------------------------------------------------------------------------------
1 | # Returns the status of whether or not jurisdictions are disabled
2 | #
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Step 1 start
9 | # Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 | # Step 1 end
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://notary-d.docusign.net/restapi"
18 |
19 | # Create a temporary file to store the response
20 | response=$(mktemp /tmp/response-notary.XXXXXX)
21 |
22 | echo "Sending the jurisdiction status request to DocuSign..."
23 | echo ""
24 | echo "Results:"
25 | # Step 2 start
26 | #ds-snippet-start:Notary3Step2
27 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
28 | '--header' "Accept: application/json" \
29 | '--header' "Content-Type: application/json")
30 |
31 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v1.0/accounts/${API_ACCOUNT_ID}/jurisdictions \
32 | "${Headers[@]}" \
33 | --output ${response})
34 | #ds-snippet-end
35 | # Step 2 end
36 |
37 | if [[ "$Status" -gt "201" ]]; then
38 | echo ""
39 | echo "Error:"
40 | echo ""
41 | cat $response
42 | exit 1
43 | fi
44 |
45 | echo ""
46 | echo "Response:"
47 | cat $response
48 | echo ""
49 | echo "Done."
50 | echo ""
51 |
--------------------------------------------------------------------------------
/examples/eSignature/eg004EnvelopeInfo.sh:
--------------------------------------------------------------------------------
1 | # Get the envelope's details
2 | #
3 | # This script uses the envelope id stored in config/ENVELOPE_ID.
4 | # config/ENVELOPE_ID will be populated by running example eg002SigningViaEmail.sh
5 | # or can be entered manually.
6 |
7 | # Check that we're in a bash shell
8 | if [[ $SHELL != *"bash"* ]]; then
9 | echo "PROBLEM: Run these scripts from within the bash shell."
10 | fi
11 |
12 | # Step 1: Obtain your OAuth token
13 | # Note: Substitute these values with your own
14 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
15 |
16 | # Set up variables for full code example
17 | # Note: Substitute these values with your own
18 | account_id=$(cat config/API_ACCOUNT_ID)
19 |
20 | base_path="https://demo.docusign.net/restapi"
21 |
22 | # Check that we have an envelope id
23 | if [ ! -f config/ENVELOPE_ID ]; then
24 | echo ""
25 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
26 | echo ""
27 | exit 0
28 | fi
29 | envelope_id=`cat config/ENVELOPE_ID`
30 |
31 |
32 | echo ""
33 | echo "Sending the Envelopes::get request to DocuSign..."
34 | echo "Results:"
35 | echo ""
36 |
37 | #ds-snippet-start:eSign4Step2
38 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
39 | --header "Content-Type: application/json" \
40 | --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}
41 | #ds-snippet-end:eSign4Step2
42 |
43 | echo ""
44 | echo ""
45 | echo "Done."
46 | echo ""
47 |
48 |
--------------------------------------------------------------------------------
/examples/eSignature/eg003ListEnvelopes.sh:
--------------------------------------------------------------------------------
1 | # List envelopes and their status
2 | # List changes for the last 10 days
3 |
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Step 1: Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | account_id=$(cat config/API_ACCOUNT_ID)
16 |
17 | base_path="https://demo.docusign.net/restapi"
18 |
19 |
20 | echo ""
21 | echo "Sending the list envelope status request to DocuSign..."
22 | echo "Results:"
23 | echo ""
24 |
25 | #ds-snippet-start:eSign3Step2
26 | # Calculate the from_date query parameter and use the ISO 8601 format.
27 | # Example:
28 | # from_date=2018-09-30T07:43:12+03:00
29 | # For a Mac, 10 days in the past:
30 | if date -v -10d &> /dev/null ; then
31 | # Mac
32 | from_date=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
33 | else
34 | # Not a Mac
35 | from_date=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
36 | fi
37 |
38 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
39 | --header "Content-Type: application/json" \
40 | --get \
41 | --data-urlencode "from_date=${from_date}" \
42 | --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes
43 | #ds-snippet-end:eSign3Step2
44 |
45 | echo ""
46 | echo ""
47 | echo "Done."
48 | echo ""
49 |
50 |
--------------------------------------------------------------------------------
/examples/eSignature/eg005EnvelopeRecipients.sh:
--------------------------------------------------------------------------------
1 |
2 | # Get the envelope recipients' details
3 | #
4 | # This script uses the envelope id stored in config/ENVELOPE_ID.
5 | # config/ENVELOPE_ID will be populated by running example eg002SigningViaEmail.sh
6 | # or can be entered manually.
7 |
8 | # Check that we're in a bash shell
9 | if [[ $SHELL != *"bash"* ]]; then
10 | echo "PROBLEM: Run these scripts from within the bash shell."
11 | fi
12 |
13 | # Step 1: Obtain your OAuth token
14 | # Note: Substitute these values with your own
15 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
16 |
17 | # Set up variables for full code example
18 | # Note: Substitute these values with your own
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 | base_path="https://demo.docusign.net/restapi"
22 |
23 | # Check that we have an envelope id
24 | if [ ! -f config/ENVELOPE_ID ]; then
25 | echo ""
26 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
27 | echo ""
28 | exit 0
29 | fi
30 | envelope_id=`cat config/ENVELOPE_ID`
31 |
32 | echo ""
33 | echo "Sending the EnvelopeRecipients::list request to DocuSign..."
34 | echo "Results:"
35 | echo ""
36 |
37 | #ds-snippet-start:eSign5Step2
38 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
39 | --header "Content-Type: application/json" \
40 | --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/recipients
41 | #ds-snippet-end:eSign5Step2
42 |
43 | echo ""
44 | echo ""
45 | echo "Done."
46 | echo ""
47 |
48 |
--------------------------------------------------------------------------------
/Quick_ACG/launcher.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | api_version=""
5 |
6 | if [ ! -f "../config/settings.txt" ]; then
7 | echo "Error: "
8 | echo "First copy the file 'config/settings.example.txt' to 'config/settings.txt'."
9 | echo "Next, fill in your API credentials, Signer name and email to continue."
10 | echo ""
11 | exit 1
12 | fi
13 |
14 | if [ -f "../config/settings.txt" ]; then
15 | . ../config/settings.txt
16 | fi
17 |
18 | function resetToken() {
19 | rm -f ../config/ds_access_token* || true
20 | }
21 |
22 | function login() {
23 | php ../OAuth/code_grant.php "eSignature"
24 | bash ../eg001EmbeddedSigning.sh
25 | startSignature
26 |
27 | mv ds_access_token.txt $token_file_name
28 |
29 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
30 | ACCESS_TOKEN=$(cat $token_file_name)
31 |
32 | export ACCOUNT_ID
33 | export ACCESS_TOKEN
34 | }
35 |
36 | # Choose an API
37 | function startQuickACG() {
38 | echo ""
39 | echo "Authentication in progress, please wait"
40 | login
41 | }
42 |
43 | # Select the action
44 | function startSignature() {
45 | echo ""
46 | echo "Pick the next action"
47 | PS3='Pick the next action: '
48 | select CHOICE in \
49 | "Embedded_Signing" \
50 | "Exit"; do
51 | case "$CHOICE" in
52 | Embedded_Signing)
53 | bash ../eg001EmbeddedSigning.sh
54 | startSignature
55 | ;;
56 | Exit)
57 | exit 0
58 | ;;
59 | esac
60 | done
61 | }
62 |
63 | echo "Welcome to the DocuSign Bash Quick Authorization Code Grant Launcher"
64 |
65 | startQuickACG
66 |
--------------------------------------------------------------------------------
/OAuth/utils.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | from flask import Flask, render_template_string, request
4 | from multiprocessing import Process
5 |
6 | HOST = 'localhost'
7 | PORT = 8080
8 |
9 | SUCCESS_PAGE_SOURCE = """
10 |
11 |
12 |
13 |
14 |
18 |
19 |
20 |
21 | Ok. You may close this tab and return to the shell. This window closes automatically in five seconds.
22 |
23 |
24 |
25 | """
26 |
27 | ERROR_PAGE_SOURCE = """
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Bad request.
37 |
38 |
39 |
40 | """
41 |
42 | app = Flask(__name__)
43 | app.env = "development"
44 | logging.getLogger('werkzeug').disabled = True
45 | server = Process(target=app.run, args=(HOST, PORT,))
46 |
47 |
48 | def run_server():
49 | server.run()
50 |
51 |
52 | def shutdown_server():
53 | func = request.environ.get('werkzeug.server.shutdown')
54 | if func is None:
55 | raise RuntimeError('Not running with the Werkzeug Server')
56 | func()
57 |
58 |
59 | @app.route('/shutdown')
60 | def shutdown():
61 | shutdown_server()
62 | return 'Server shutting down...'
63 |
64 |
65 | @app.route('/authorization-code/callback', methods=["GET"])
66 | def result_page():
67 | if request.args.get("code"):
68 | return render_template_string(SUCCESS_PAGE_SOURCE, host=HOST, port=PORT)
69 | else:
70 | return render_template_string(ERROR_PAGE_SOURCE)
71 |
--------------------------------------------------------------------------------
/examples/Click/eg005GetClickwrapResponses.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/click-api/how-to/get-clickwrap-responses
3 | # How to get Clickwrap responses
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Get a Clickwrap ID
19 | if [ -f "config/CLICKWRAP_ID" ]; then
20 | clickwrap_id=$(cat config/CLICKWRAP_ID)
21 | else
22 | echo ""
23 | echo "Clickwrap ID is needed. Please run step 1 - Create Clickwrap..."
24 | exit 0
25 | fi
26 |
27 | # Step 2. Construct your API headers
28 | #ds-snippet-start:Click5Step2
29 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
30 | '--header' "Accept: application/json")
31 | #ds-snippet-end:Click5Step2
32 |
33 | # Step 3. Call the Click API
34 | # a) Make a GET call to the users endpoint to retrieve responses (acceptance) of a specific Clickwrap for an account
35 | # b) Display the returned JSON structure of the responses
36 | # Create a temporary file to store the response
37 | response=$(mktemp /tmp/response-cw.XXXXXX)
38 | #ds-snippet-start:Click5Step3
39 | curl --request GET https://demo.docusign.net/clickapi/v1/accounts/${account_id}/clickwraps/${clickwrap_id}/users \
40 | "${Headers[@]}" \
41 | --output ${response}
42 | #ds-snippet-end:Click5Step3
43 |
44 | echo ""
45 | echo "Response:"
46 | cat $response
47 | echo ""
48 |
49 | # Remove the temporary file
50 | rm "$response"
51 |
--------------------------------------------------------------------------------
/examples/eSignature/eg015EnvelopeTabData.sh:
--------------------------------------------------------------------------------
1 | # Retreive Envelope Tab Data
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Step 1: Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 |
16 | base_path="https://demo.docusign.net/restapi"
17 |
18 | # Check that we have an envelope ID
19 | if [ ! -f config/ENVELOPE_ID ]; then
20 | echo ""
21 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg001EmbeddedSigning.sh"
22 | echo ""
23 | exit 0
24 | fi
25 | envelope_id=`cat config/ENVELOPE_ID`
26 |
27 | #Create your authorization headers
28 | #ds-snippet-start:eSign15Step2
29 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
30 | '--header' "Accept: application/json" \
31 | '--header' "Content-Type: application/json")
32 | #ds-snippet-end:eSign15Step2
33 |
34 | # a) Make a GET call to the form_data endpoint to retrieve your envelope tab values
35 | # b) Display the JSON response
36 | #ds-snippet-start:eSign15Step3
37 | response=$(mktemp /tmp/response-rst.XXXXXX)
38 |
39 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/form_data \
40 | "${Headers[@]}" \
41 | --output ${response})
42 | #ds-snippet-end:eSign15Step3
43 |
44 | if [[ "$Status" -gt "201" ]] ; then
45 | echo ""
46 | echo "Retrieving envelope form data has failed."
47 | echo ""
48 | cat $response
49 | exit 0
50 | fi
51 |
52 | echo ""
53 | echo "Response:"
54 | cat $response
55 | echo ""
56 |
57 | # Remove the temporary files
58 | rm "$response"
59 |
--------------------------------------------------------------------------------
/examples/Rooms/eg003ExportDataFromRoomController.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/export-room-data
3 | # How to export data from a room
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Get a Room ID
19 | if [ -f "config/ROOM_ID" ]; then
20 | room_id=$(cat config/ROOM_ID)
21 | else
22 | echo " Room ID is needed. Please run step 1 or 2..."
23 | exit 0
24 | fi
25 |
26 | base_path="https://demo.docusign.net/restapi"
27 |
28 | # Construct your API headers
29 | #ds-snippet-start:Rooms3Step2
30 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
31 | '--header' "Accept: application/json"
32 | '--header' "Content-Type: application/json")
33 | #ds-snippet-end:Rooms3Step2
34 |
35 | # a) Call the Rooms API
36 | # b) Display JSON response
37 |
38 | # Create a temporary file to store the response
39 | response=$(mktemp /tmp/response-rms-001.XXXXXX)
40 |
41 | #ds-snippet-start:Rooms3Step3
42 | Status=$(curl -w '%{http_code}' -i --request GET https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms/${room_id}/field_data \
43 | "${Headers[@]}" \
44 | --output ${response})
45 |
46 | if [[ "$Status" -gt "201" ]]; then
47 | echo ""
48 | echo "Unable to retrieve field_set on roomId: $room_id"
49 | echo ""
50 | cat $response
51 | exit 0
52 | fi
53 |
54 | echo ""
55 | echo "Response:"
56 | cat $response
57 | echo ""
58 |
59 | # Remove the temporary files
60 | rm "$response"
61 | #ds-snippet-end:Rooms3Step3
--------------------------------------------------------------------------------
/examples/eSignature/eg018EnvelopeCustomFieldData.sh:
--------------------------------------------------------------------------------
1 | # Get the envelope's custom field data
2 | # This script uses the envelope ID stored in ../envelope_id.
3 | # The envelope_id file is created by example eg016SetTabValues.sh or
4 | # can be manually created.
5 |
6 | # Check that we're in a bash shell
7 | if [[ $SHELL != *"bash"* ]]; then
8 | echo "PROBLEM: Run these scripts from within the bash shell."
9 | fi
10 |
11 | # Obtain your OAuth token
12 | # Note: Substitute these values with your own
13 | # Step 1 start
14 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
15 | # Step 1 end
16 |
17 | #Set up variables for full code example
18 | # Note: Substitute these values with your own
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 | base_path="https://demo.docusign.net/restapi"
22 |
23 | # Construct your API headers
24 | #ds-snippet-start:eSign18Step2
25 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
26 | '--header' "Accept: application/json" \
27 | '--header' "Content-Type: application/json")
28 | #ds-snippet-end:eSign18Step2
29 |
30 | # Check that we have an template ID
31 | if [ ! -f config/ENVELOPE_ID ]; then
32 | echo ""
33 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg016SetTabValues.sh"
34 | echo ""
35 | exit 0
36 | fi
37 | envelope_id=`cat config/ENVELOPE_ID`
38 |
39 | echo ""
40 | echo "Sending the EnvelopeCustomFields::list request to DocuSign..."
41 |
42 | # Send a GET request to the Envelopes endpoint
43 | #ds-snippet-start:eSign18Step3
44 | response=$(mktemp /tmp/response-eg-018.XXXXXX)
45 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/custom_fields \
46 | "${Headers[@]}" \
47 | --output ${response})
48 | #ds-snippet-end:eSign18Step3
49 |
50 | echo "Results:"
51 | echo ""
52 |
53 | cat $response
54 | echo ""
55 | echo ""
56 | echo "Done."
57 | echo ""
58 |
--------------------------------------------------------------------------------
/examples/Admin/eg011DeleteUserDataFromAccount.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This shows an account admin how to delete user data from an account
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Note: Substitute these values with your own
10 | # Obtain your OAuth token
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16 | base_path="https://api-d.docusign.net/management"
17 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
18 |
19 | # Construct your API headers
20 | #ds-snippet-start:Admin11Step2
21 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
22 | '--header' "Accept: application/json"
23 | '--header' "Content-Type: application/json")
24 | #ds-snippet-end:Admin11Step2
25 |
26 | response=$(mktemp /tmp/response-oa.XXXXXX)
27 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
28 |
29 | # Get user information
30 | echo "Please enter the user ID of the user whose data will be deleted. Note that this user ID should be associated with a user that has been closed for at least 24 hours."
31 | read USER_ID
32 |
33 | # Construct the request body
34 | #ds-snippet-start:Admin11Step3
35 | printf \
36 | '{
37 | "user_id": "'${USER_ID}'"
38 | }
39 | ' >>$request_data
40 | #ds-snippet-end:Admin11Step3
41 |
42 | #Delete user info from an organization
43 | #ds-snippet-start:Admin11Step4
44 | curl -w '%{http_code}' -i --request POST "${base_path}/v2/data_redaction/accounts/${API_ACCOUNT_ID}/user" \
45 | "${Headers[@]}" \
46 | --data-binary @${request_data} \
47 | --output ${response}
48 | #ds-snippet-end:Admin11Step4
49 |
50 | echo ""
51 | echo "Response: "
52 | echo ""
53 | cat $response
54 | echo ""
55 |
56 | # Remove the temporary files
57 | rm "$request_data"
58 | rm "$response"
59 |
60 | echo ""
61 | echo "Done."
62 | echo ""
63 |
--------------------------------------------------------------------------------
/examples/eSignature/eg006EnvelopeDocs.sh:
--------------------------------------------------------------------------------
1 | # List the envelope's documents
2 | #
3 | # This script uses the envelope id stored in config/ENVELOPE_ID.
4 | # config/ENVELOPE_ID will be populated by running example eg002SigningViaEmail.sh
5 | # or can be entered manually.
6 |
7 | # Check that we're in a bash shell
8 | if [[ $SHELL != *"bash"* ]]; then
9 | echo "PROBLEM: Run these scripts from within the bash shell."
10 | fi
11 |
12 | # Obtain your OAuth token
13 | # Note: Substitute these values with your own
14 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
15 |
16 | # Construct your API headers.
17 | #ds-snippet-start:eSign6Step2
18 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
19 | '--header' "Content-Type: application/json")
20 | #ds-snippet-end:eSign6Step2
21 |
22 | # Set up variables for full code example
23 | # Note: Substitute these values with your own
24 | account_id=$(cat config/API_ACCOUNT_ID)
25 |
26 | base_path="https://demo.docusign.net/restapi"
27 |
28 | # Check that we have an envelope id
29 | if [ ! -f config/ENVELOPE_ID ]; then
30 | echo ""
31 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
32 | echo ""
33 | exit 0
34 | fi
35 | envelope_id=`cat config/ENVELOPE_ID`
36 |
37 | # Call the eSignature API
38 | # Display the JSON response
39 | # Create a temporary file to store the response
40 |
41 | response=$(mktemp /tmp/response-perm.XXXXXX)
42 |
43 | #ds-snippet-start:eSign6Step3
44 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/documents \
45 | "${Headers[@]}" \
46 | --output ${response})
47 | #ds-snippet-end:eSign6Step3
48 | echo ""
49 | echo "Sending the EnvelopeDocuments::list request to DocuSign..."
50 | echo "Results:"
51 | echo ""
52 | cat $response
53 | echo ""
54 | echo ""
55 | echo "Done."
56 | echo ""
57 |
58 | # Remove the temporary file
59 | rm "$response"
60 |
61 |
--------------------------------------------------------------------------------
/examples/Maestro/eg003ResumeWorkflow.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Resume a paused workflow instance
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that there is a workflow
10 | workflow_id=$(cat config/WORKFLOW_ID)
11 | if [ -z "$workflow_id" ]; then
12 | echo "Please run example 1 to create and trigger a workflow before running this example."
13 | exit 0
14 | fi
15 |
16 | # Obtain your OAuth token
17 | # Note: Substitute these values with your own
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 |
20 | # Set up variables
21 | # Note: Substitute these values with your own
22 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
23 | base_path="https://api-d.docusign.com/v1"
24 |
25 | # Construct your API headers
26 | #apx-snippet-start:ResumeWorkflow
27 | #ds-snippet-start:Maestro3Step2
28 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
29 | '--header' "Accept: application/json" \
30 | '--header' "Content-Type: application/json")
31 | #ds-snippet-end:Maestro3Step2
32 | #apx-snippet-end:ResumeWorkflow
33 |
34 | echo ""
35 | echo "Attempting to resume the Workflow..."
36 | echo ""
37 |
38 | # Make the API call to resume
39 | #apx-snippet-start:resumePausedWorkflow
40 | #ds-snippet-start:Maestro3Step3
41 | response=$(mktemp /tmp/response-wftmp.XXXXXX)
42 | Status=$(
43 | curl -w '%{http_code}' --request POST "${base_path}/accounts/${ACCOUNT_ID}/workflows/${workflow_id}/actions/resume" \
44 | "${Headers[@]}" \
45 | --output ${response}
46 | )
47 |
48 | if [[ "$Status" -gt "201" ]]; then
49 | echo ""
50 | echo "Unable to resume workflow: ${workflow_id}"
51 | echo ""
52 | cat $response
53 | exit 0
54 | fi
55 |
56 | echo ""
57 | echo "Workflow has been resumed."
58 | echo ""
59 | echo "Response:"
60 | cat $response
61 | echo ""
62 | #ds-snippet-end:Maestro3Step3
63 | #apx-snippet-end:resumePausedWorkflow
64 |
65 | # Remove the temporary files
66 | rm "$response"
67 |
--------------------------------------------------------------------------------
/examples/Maestro/eg002PauseWorkflow.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Pause a running workflow instance
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that there is a workflow
10 | workflow_id=$(cat config/WORKFLOW_ID)
11 | if [ -z "$workflow_id" ]; then
12 | echo "Please run example 1 to create and trigger a worklow before running this example."
13 | exit 0
14 | fi
15 |
16 | # Obtain your OAuth token
17 | # Note: Substitute these values with your own
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 |
20 |
21 | # Set up variables for full code example
22 | # Note: Substitute these values with your own
23 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
24 |
25 | base_path="https://api-d.docusign.com/v1"
26 |
27 | # Construct your API headers
28 | #ds-snippet-start:Maestro2Step2
29 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
30 | '--header' "Accept: application/json" \
31 | '--header' "Content-Type: application/json")
32 | #ds-snippet-end:Maestro2Step2
33 | echo ""
34 | echo "Attempting to pause the Workflow.."
35 | echo ""
36 |
37 | #ds-snippet-start:Maestro2Step3
38 | #apx-snippet-start:pauseNewWorkflowInstances
39 | response=$(mktemp /tmp/response-wftmp.XXXXXX)
40 | Status=$(
41 | curl -w '%{http_code}' --request POST "${base_path}/accounts/${ACCOUNT_ID}/workflows/${workflow_id}/actions/pause" \
42 | "${Headers[@]}" \
43 | --output ${response}
44 | )
45 | #apx-snippet-end:pauseNewWorkflowInstances
46 | # If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
47 | if [[ "$Status" -gt "201" ]]; then
48 | echo ""
49 | echo "Unable to pause workflow: ${workflow_id}"
50 | echo ""
51 | cat $response
52 | exit 0
53 | fi
54 |
55 | echo ""
56 | echo "Workflow has been paused."
57 | echo ""
58 | echo ""
59 | echo "Response:"
60 | cat $response
61 | echo ""
62 | echo ""
63 | #ds-snippet-end:Maestro2Step3
64 |
65 | # Remove the temporary files
66 | rm "$response"
--------------------------------------------------------------------------------
/examples/Rooms/eg007CreateFormGroup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/create-form-group/
3 | # How to create a form group
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 |
18 | base_path="https://demo.rooms.docusign.com"
19 |
20 | #ds-snippet-start:Rooms7Step2
21 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
22 | '--header' "Accept: application/json"
23 | '--header' "Content-Type: application/json")
24 | #ds-snippet-end:Rooms7Step2
25 |
26 | # Create a temporary file to store the response
27 | response=$(mktemp /tmp/response-rooms.XXXXXX)
28 |
29 |
30 | # Create a temporary file to store the JSON body
31 | request_data=$(mktemp /tmp/request-rooms-007.XXXXXX)
32 |
33 | #ds-snippet-start:Rooms7Step3
34 | printf \
35 | '
36 | {
37 | "name": "Sample Room Form Group",
38 | }' >$request_data
39 | #ds-snippet-end:Rooms7Step3
40 |
41 |
42 | #ds-snippet-start:Rooms7Step4
43 | Status=$(curl -w '%{http_code}' --request POST ${base_path}/restapi/v2/accounts/${API_ACCOUNT_ID}/form_groups \
44 | "${Headers[@]}" \
45 | --data-binary @${request_data} \
46 | --output ${response})
47 | #ds-snippet-end:Rooms7Step4
48 |
49 | FORM_GROUP_ID=$(cat $response | grep formGroupId | sed 's/.*formGroupId\":"//' | sed 's/\".*//')
50 |
51 | # Store FORM_GROUP_ID into the file ./config/FORM_GROUP_ID
52 | echo $FORM_GROUP_ID >./config/FORM_GROUP_ID
53 |
54 | if [[ "$Status" -gt "201" ]]; then
55 | echo ""
56 | echo "Error:"
57 | echo ""
58 | cat $response
59 | exit 1
60 | fi
61 |
62 | echo ""
63 | echo "Response:"
64 | cat $response
65 | echo ""
66 |
67 | # Remove the temporary files
68 | rm "$request_data"
69 | rm "$response"
70 |
--------------------------------------------------------------------------------
/examples/eSignature/eg027DeletingPermissions.sh:
--------------------------------------------------------------------------------
1 | # Delete a permission profile
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 |
9 | # Check that we have a profile id
10 | if [ ! -f config/PROFILE_ID ]; then
11 | echo ""
12 | echo "PROBLEM: Permission profile Id is needed. To fix: execute script eg024CreateingPermissionProfiles.sh"
13 | echo ""
14 | exit -1
15 | fi
16 |
17 | # Step 1: Obtain your OAuth token
18 | # Note: Substitute these values with your own
19 | # Set up variables for full code example
20 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
21 | account_id=$(cat config/API_ACCOUNT_ID)
22 | permission_profile_id=`cat config/PROFILE_ID`
23 | base_path="https://demo.docusign.net/restapi"
24 |
25 | #Step 2: Construct your API headers
26 | #ds-snippet-start:eSign27Step2
27 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
28 | '--header' "Accept: application/json" \
29 | '--header' "Content-Type: application/json")
30 | #ds-snippet-end:eSign27Step2
31 |
32 | # Step 3: a) Call the eSignature API
33 | # b) Display the JSON response
34 | # Create a temporary file to store the response
35 | response=$(mktemp /tmp/response-perm.XXXXXX)
36 |
37 | #ds-snippet-start:eSign27Step3
38 | Status=$(curl -w '%{http_code}' -i --request DELETE ${base_path}/v2.1/accounts/${account_id}/permission_profiles/${permission_profile_id} \
39 | "${Headers[@]}" \
40 | --output ${response})
41 | #ds-snippet-end:eSign27Step3
42 |
43 | # If the Status code returned is greater than 399, display an error message along with the API response
44 | if [[ "$Status" -gt "399" ]] ; then
45 | echo ""
46 | echo "Unable to delete the permission profile."
47 | echo ""
48 | cat $response
49 | exit 0
50 | fi
51 |
52 | echo ""
53 | echo "Response:"
54 | cat $response
55 | echo ""
56 |
57 | # Remove the temporary files
58 | rm "$request_data"
59 | rm "$response"
60 | echo ""
61 | echo ""
62 | echo "Done."
63 | echo ""
64 |
65 |
--------------------------------------------------------------------------------
/examples/Admin/eg007RetrieveDocuSignProfileByUserId.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Retreives DocuSign Profile for a user given the user's email address with the Admin API
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that ORGANIZATION_ID has been set
10 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
11 | if [[ -z "$ORGANIZATION_ID" ]]; then
12 | echo "PROBLEM: Set ORGANIZATION_ID and add to config directory"
13 | fi
14 |
15 |
16 | # Note: Substitute these values with your own
17 | # Obtain your OAuth token
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 |
20 | # Set up variables for full code example
21 | # Note: Substitute these values with your own
22 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
23 | base_path="https://api-d.docusign.net/management"
24 |
25 | echo "Please input userId to lookup DocuSign profile:"
26 | read USER_ID
27 |
28 | # Construct your API headers
29 | # Step 2 start
30 | #ds-snippet-start:Admin7Step2
31 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
32 | '--header' "Accept: application/json" \
33 | '--header' "Content-Type: application/json")
34 | #ds-snippet-end:Admin7Step2
35 | # Step 2 end
36 |
37 | # Step 3 start
38 | #ds-snippet-start:Admin7Step3
39 | # Calculate date parameter to get users modified in the last 10 days
40 | if date -v -10d &>/dev/null; then
41 | # Mac
42 | # modified_since=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
43 | modified_since=$(date -v -10d '+%Y-%m-%d')
44 | else
45 | # Not a Mac
46 | # modified_since=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
47 | modified_since=$(date --date='-10 days' '+%Y-%m-%d')
48 | fi
49 |
50 | response=$(mktemp /tmp/response-admin.XXXXXX)
51 |
52 | # Call the Admin API
53 | curl --request GET ${base_path}/v2.1/organizations/${ORGANIZATION_ID}/users/${USER_ID}/dsprofile \
54 | "${Headers[@]}" \
55 | --output ${response}
56 |
57 | #ds-snippet-end:Admin7Step3
58 | # Step 3 end
59 |
60 | echo ""
61 | echo "Response:"
62 | cat $response
63 | echo ""
64 |
65 | # Remove the temporary file
66 | rm "$response"
67 |
--------------------------------------------------------------------------------
/examples/Admin/eg006RetrieveDocuSignProfileByEmailAddress.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Retreives DocuSign Profile for a user given the user's email address with the Admin API
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that ORGANIZATION_ID has been set
10 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
11 | if [[ -z "$ORGANIZATION_ID" ]]; then
12 | echo "PROBLEM: Set ORGANIZATION_ID and add to config directory"
13 | fi
14 |
15 |
16 | # Note: Substitute these values with your own
17 | # Obtain your OAuth token
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 |
20 | # Set up variables for full code example
21 | # Note: Substitute these values with your own
22 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
23 | base_path="https://api-d.docusign.net/management"
24 |
25 | echo "Please input email address to lookup DocuSign profile:"
26 | read EMAIL_ADDRESS
27 |
28 | # Construct your API headers
29 | # Step 2 start
30 | #ds-snippet-start:Admin6Step2
31 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
32 | '--header' "Accept: application/json" \
33 | '--header' "Content-Type: application/json")
34 | #ds-snippet-end:Admin6Step2
35 | # Step 2 end
36 |
37 | # Step 3 start
38 | #ds-snippet-start:Admin6Step3
39 | # Calculate date parameter to get users modified in the last 10 days
40 | if date -v -10d &>/dev/null; then
41 | # Mac
42 | # modified_since=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
43 | modified_since=$(date -v -10d '+%Y-%m-%d')
44 | else
45 | # Not a Mac
46 | # modified_since=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
47 | modified_since=$(date --date='-10 days' '+%Y-%m-%d')
48 | fi
49 |
50 | response=$(mktemp /tmp/response-admin.XXXXXX)
51 |
52 | # Call the Admin API
53 | curl --request GET ${base_path}/v2.1/organizations/${ORGANIZATION_ID}/users/dsprofile?email=${EMAIL_ADDRESS} \
54 | "${Headers[@]}" \
55 | --output ${response}
56 | #ds-snippet-end:Admin6Step3
57 | # Step 3 end
58 |
59 | echo ""
60 | echo "Response:"
61 | cat $response
62 | echo ""
63 |
64 | # Remove the temporary file
65 | rm "$response"
66 |
--------------------------------------------------------------------------------
/examples/Click/eg002ActivateClickwrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/click-api/how-to/activate-clickwrap
3 | # How to activate a Clickwrap
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Setup variables for full code example
19 | VersionNumber="1"
20 |
21 | # Get a ClickwrapID
22 | if [ -f "config/CLICKWRAP_ID" ]; then
23 | clickwrap_id=$(cat config/CLICKWRAP_ID)
24 | else
25 | echo ""
26 | echo "Clickwrap ID is needed. Please run step 1 - Create Clickwrap..."
27 | exit 0
28 | fi
29 |
30 | # Step 2. Construct your API headers
31 | #ds-snippet-start:Click2Step2
32 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
33 | '--header' "Content-Type: application/json"
34 | '--header' "Accept: application/json")
35 | #ds-snippet-end:Click2Step2
36 |
37 | # Construct your Clickwrap JSON body
38 | # Create a temporary file to store the JSON body
39 | request_data=$(mktemp /tmp/request-cw.XXXXXX)
40 | #ds-snippet-start:Click2Step3
41 | printf \
42 | '{
43 | "status" : "active"
44 | }' >$request_data
45 | #ds-snippet-end:Click2Step3
46 |
47 | # a) Make a POST call to the Clickwraps endpoint to activate the Clickwrap for an account
48 | # b) Display the JSON structure of the created Clickwrap
49 |
50 | # Create a temporary file to store the response
51 | response=$(mktemp /tmp/response-cw.XXXXXX)
52 |
53 | #ds-snippet-start:Click2Step4
54 | curl --request PUT https://demo.docusign.net/clickapi/v1/accounts/${account_id}/clickwraps/${clickwrap_id}/versions/${VersionNumber} \
55 | "${Headers[@]}" \
56 | --data-binary @${request_data} \
57 | --output ${response}
58 | #ds-snippet-end:Click2Step4
59 |
60 | echo ""
61 | echo "Response:"
62 | cat $response
63 | echo ""
64 |
65 | # Remove the temporary files
66 | rm "$request_data"
67 | rm "$response"
68 |
--------------------------------------------------------------------------------
/examples/eSignature/eg009UseTemplate.sh:
--------------------------------------------------------------------------------
1 | # Send a signing request via email using a DocuSign template
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Check for a valid cc email and prompt the user if
9 | #CC_EMAIL and CC_NAME haven't been set in the config file.
10 | source ./examples/eSignature/lib/utils.sh
11 | CheckForValidCCEmail
12 |
13 | # Step 1: Obtain your OAuth token
14 | # Note: Substitute these values with your own
15 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
16 |
17 | # Set up variables for full code example
18 | # Note: Substitute these values with your own
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 |
22 | # Check that we have a template id
23 | if [ ! -f config/TEMPLATE_ID ]; then
24 | echo ""
25 | echo "PROBLEM: An template id is needed. Fix: execute script eg008CreateTemplate.sh"
26 | echo ""
27 | exit 0
28 | fi
29 | template_id=`cat config/TEMPLATE_ID`
30 |
31 | base_path="https://demo.docusign.net/restapi"
32 | # Step 1. Create the envelope request.
33 | # temp files:
34 | #ds-snippet-start:eSign9Step2
35 | request_data=$(mktemp /tmp/request-eg-009.XXXXXX)
36 |
37 | printf \
38 | '{
39 | "templateId": "'"${template_id}"'",
40 | "templateRoles": [
41 | {
42 | "email": "'"${SIGNER_EMAIL}"'",
43 | "name": "'"${SIGNER_NAME}"'",
44 | "roleName": "signer"
45 | },
46 | {
47 | "email": "'"${CC_EMAIL}"'",
48 | "name": "'"${CC_NAME}"'",
49 | "roleName": "cc"
50 | }
51 | ],
52 | "status": "sent"
53 | }' >> $request_data
54 | #ds-snippet-end:eSign9Step2
55 |
56 |
57 | #ds-snippet-start:eSign9Step3
58 | response=$(mktemp /tmp/response-eg-009.XXXXXX)
59 |
60 | echo ""
61 | echo "Sending the envelope request to DocuSign..."
62 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
63 | --header "Content-Type: application/json" \
64 | --data-binary @${request_data} \
65 | --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
66 | --output ${response}
67 | #ds-snippet-end:eSign9Step3
68 |
69 | echo ""
70 | echo "Response:"
71 | cat $response
72 | rm $response
73 | rm $request_data
74 | echo ""
75 | echo ""
76 | echo "Done."
77 | echo ""
78 |
--------------------------------------------------------------------------------
/examples/Rooms/eg005GetRoomsWithFiltersController.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/get-room-with-filters/
3 | # How to get a room with filters
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Construct your API headers
19 | #ds-snippet-start:Rooms5Step2
20 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
21 | '--header' "Accept: application/json"
22 | '--header' "Content-Type: application/json")
23 | #ds-snippet-end:Rooms5Step2
24 |
25 | # Set your filtering parameters
26 | # Calculate the past and current query parameters and use the ISO 8601 format.
27 | #ds-snippet-start:Rooms5Step3
28 | if date -v -10d &>/dev/null; then
29 | # Mac
30 | # past=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
31 | past=$(date -v -10d '+%Y-%m-%d')
32 | # Set the date 1 day forward to account for changes made today
33 | # current=`date -v +1d '+%Y-%m-%dT%H:%M:%S%z'`
34 | current=$(date -v +1d '+%Y-%m-%d')
35 | else
36 | # Not a Mac
37 | # past=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
38 | past=$(date --date='-10 days' '+%Y-%m-%d')
39 | # Set the date 1 day forward to account for changes made today
40 | # current=`date --date='+1 days' '+%Y-%m-%dT%H:%M:%S%z'`
41 | current=$(date --date='+1 days' '+%Y-%m-%d')
42 | fi
43 | #ds-snippet-end:Rooms5Step3
44 |
45 | # Call the v2 Rooms API
46 | # Create a temporary file to store the response
47 | #ds-snippet-start:Rooms5Step4
48 | response=$(mktemp /tmp/response-cw.XXXXXX)
49 | curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms?fieldDataChangedStartDate=${past}&fieldDataChangedEndDate=${current}" \
50 | "${Headers[@]}" \
51 | --output ${response}
52 | #ds-snippet-end:Rooms5Step4
53 |
54 | echo ""
55 | echo "Response:"
56 | cat $response
57 | echo ""
58 |
59 | # Remove the temporary files
60 | rm "$response"
61 |
--------------------------------------------------------------------------------
/examples/eSignature/eg033UnpauseSignatureWorkflow.sh:
--------------------------------------------------------------------------------
1 | # How to unpause a signature workflow
2 | # https://developers.docusign.com/docs/esign-rest-api/how-to/unpause-workflow/
3 |
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that we have an Envelope ID
10 | if [ ! -f config/ENVELOPE_ID ]; then
11 | echo ""
12 | echo "PROBLEM: Envelope Id is needed. To fix: execute script eg032PauseSignatureWorkflow.sh"
13 | echo ""
14 | exit 0
15 | fi
16 | envelope_id=$(cat config/ENVELOPE_ID)
17 |
18 | # Step 1: Create your API Headers
19 | # Note: These values are not valid, but are shown for example purposes only!
20 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
21 | account_id=$(cat config/API_ACCOUNT_ID)
22 | base_path="https://demo.docusign.net/restapi"
23 |
24 | # Step 2: Construct your API headers
25 | # Construct your API headers
26 | #ds-snippet-start:eSign33Step2
27 | declare -a Headers=('--header' "Authorization: Bearer $ACCESS_TOKEN"
28 | '--header' "Accept: application/json"
29 | '--header' "Content-Type: application/json")
30 | #ds-snippet-end:eSign33Step2
31 |
32 | # Create a temporary files to store the JSON body and response
33 | request_data=$(mktemp /tmp/request-bs.XXXXXX)
34 | response=$(mktemp /tmp/response-bs.XXXXXX)
35 |
36 | # Step 3.Construct the JSON body for your envelope
37 | #ds-snippet-start:eSign33Step3
38 | printf \
39 | '{
40 | "workflow":
41 | {
42 | "workflowStatus": "in_progress"
43 | }
44 | }' >>$request_data
45 | #ds-snippet-end:eSign33Step3
46 |
47 | # Step 4. Call the eSignature API
48 | #ds-snippet-start:eSign33Step4
49 | Status=$(curl --request PUT "${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}?resend_envelope=true" \
50 | "${Headers[@]}" \
51 | --data-binary @${request_data} \
52 | --output ${response})
53 | #ds-snippet-end:eSign33Step4
54 |
55 | if [[ "$Status" -gt "201" ]]; then
56 | echo ""
57 | echo "The call of the eSignature API has failed"
58 | echo ""
59 | cat $response
60 | exit 0
61 | fi
62 |
63 | echo ""
64 | echo "Request:"
65 | cat $request_data
66 | echo ""
67 |
68 | # Check the response
69 | echo ""
70 | echo $(cat $response)
71 | echo ""
72 |
73 | # Remove the temporary files
74 | rm "$response"
75 | rm "$request_data"
76 |
--------------------------------------------------------------------------------
/examples/Maestro/lib/startServerForEmbeddedWorkflow.php:
--------------------------------------------------------------------------------
1 |
16 | The document has been embedded using Maestro Embedded Workflow.
17 |
18 |
19 |
20 |
21 |
22 |
23 | Example Workflow
24 |
32 |
33 |
34 |
37 |
38 |
40 |
41 |
44 |
45 |
46 |
47 |
48 | Continue
49 |
50 | ";
51 |
52 | ini_set('default_socket_timeout', 60 * 5);
53 | $server = stream_socket_server($socket, $errno, $errstr);
54 | if (!$server) {
55 | Log::err('Error starting HTTP server');
56 | return false;
57 | }
58 | do {
59 | $sock = stream_socket_accept($server);
60 | if (!$sock) {
61 | Log::err('Error accepting socket connection');
62 | exit(1);
63 | }
64 | $contentLength = 0;
65 | $headers = [];
66 | $body = null;
67 | while (false !== ($line = trim(fgets($sock)))) {
68 | if ($line === '') break;
69 | $regex = '#^Content-Length:\s*([[:digit:]]+)\s*$#i';
70 | if (preg_match($regex, $line, $matches)) {
71 | $contentLength = (int)$matches[1];
72 | }
73 | $headers[] = $line;
74 | }
75 | if ($contentLength > 0) {
76 | $body = fread($sock, $contentLength);
77 | }
78 | list($method, $url, $httpver) = explode(' ', $headers[0]);
79 | if ($method == 'GET') {
80 | fwrite($sock, $responseOk);
81 | fclose($sock);
82 | return;
83 | }
84 | } while (true);
85 |
86 | ?>
87 |
--------------------------------------------------------------------------------
/examples/Maestro/eg004CancelWorkflow.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Cancel a running workflow instance
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that there is a workflow
10 | WORKFLOW_ID=$(cat config/WORKFLOW_ID)
11 | if [ -z "$WORKFLOW_ID" ]; then
12 | echo "Please run example 1 to create and trigger a workflow before running this example."
13 | exit 0
14 | fi
15 |
16 | # Check that there is a running workflow instance to cancel
17 | WORKFLOW_INSTANCE_ID=$(cat config/INSTANCE_ID)
18 | if [ -z "$WORKFLOW_INSTANCE_ID" ]; then
19 | echo "Please run example 1 to trigger a workflow before running this example."
20 | exit 0
21 | fi
22 |
23 | # Obtain your OAuth token
24 | # Note: Substitute these values with your own
25 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
26 |
27 |
28 | # Set up variables for full code example
29 | # Note: Substitute these values with your own
30 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
31 |
32 | BASE_PATH="https://api-d.docusign.com/v1"
33 |
34 | # Construct your API headers
35 | #ds-snippet-start:Maestro4Step2
36 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
37 | '--header' "Accept: application/json" \
38 | '--header' "Content-Type: application/json")
39 | #ds-snippet-end:Maestro4Step2
40 | echo ""
41 | echo "Attempting to cancel the workflow instance..."
42 | echo ""
43 |
44 | #ds-snippet-start:Maestro4Step3
45 | #apx-snippet-start:cancelWorkflowInstance
46 | response=$(mktemp /tmp/response-wftmp.XXXXXX)
47 | Status=$(
48 | curl -w '%{http_code}' --request POST "${BASE_PATH}/accounts/${API_ACCOUNT_ID}/workflows/${WORKFLOW_ID}/instances/${WORKFLOW_INSTANCE_ID}/actions/cancel" \
49 | "${Headers[@]}" \
50 | --output ${response}
51 | )
52 | #apx-snippet-end:cancelWorkflowInstance
53 |
54 | # If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
55 | if [[ "$Status" -gt "201" ]]; then
56 | echo ""
57 | echo "Unable to retrieve workflow instance: ${WORKFLOW_INSTANCE_ID}"
58 | echo ""
59 | cat $response
60 | exit 0
61 | fi
62 |
63 | echo ""
64 | echo "Workflow has been canceled."
65 | echo ""
66 | echo ""
67 | echo "Response:"
68 | cat $response
69 | echo ""
70 | echo ""
71 | #ds-snippet-end:Maestro4Step3
72 |
73 | # Remove the temporary files
74 | rm "$response"
--------------------------------------------------------------------------------
/examples/Notary/eg002InviteNotaryToPool.sh:
--------------------------------------------------------------------------------
1 | # Invite a notary to join your pool
2 | #
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
16 | base_path="https://notary-d.docusign.net/restapi"
17 |
18 | # Create a temporary file to store the response
19 | response=$(mktemp /tmp/response-notary.XXXXXX)
20 |
21 | # Construct your API headers
22 | #ds-snippet-start:Notary2Step2
23 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
24 | '--header' "Accept: application/json" \
25 | '--header' "Content-Type: application/json")
26 | #ds-snippet-end
27 |
28 | #ds-snippet-start:Notary2Step3
29 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v1.0/organizations/${ORGANIZATION_ID}/pools \
30 | "${Headers[@]}" \
31 | --output ${response})
32 |
33 | POOL_ID=$(cat "$response" | sed -n 's/.*"poolId":"\([^"]*\)".*/\1/p')
34 | #ds-snippet-end
35 |
36 | # Create a temporary file to store the request data
37 | request_data=$(mktemp /tmp/request-notary-002.XXXXXX)
38 |
39 | echo ""
40 | read -p "Please enter a username for the new user: " NOTARY_NAME
41 | read -p "Please enter an email for the new user: " NOTARY_EMAIL
42 |
43 | #ds-snippet-start:Notary2Step4
44 | printf \
45 | '
46 | {
47 | "email" : "'"${NOTARY_EMAIL}"'",
48 | "name" : "'"${NOTARY_NAME}"'",
49 | }' >$request_data
50 | #ds-snippet-end
51 |
52 | echo ""
53 | echo "Inviting ${NOTARY_NAME} to your organization's notary pool"
54 | echo ""
55 | echo "Pool id is ${POOL_ID}"
56 | echo ""
57 |
58 | #ds-snippet-start:Notary2Step5
59 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v1.0/organizations/${ORGANIZATION_ID}/pools/${POOL_ID}/invites \
60 | "${Headers[@]}" \
61 | --data-binary @${request_data} \
62 | --output ${response})
63 | #ds-snippet-end
64 |
65 | if [[ "$Status" -gt "201" ]]; then
66 | echo ""
67 | echo "Error:"
68 | echo ""
69 | cat $response
70 | exit 1
71 | fi
72 |
73 |
74 | echo ""
75 | echo "Response:"
76 | cat $response
77 | echo ""
78 | echo "Done."
79 | echo ""
80 |
--------------------------------------------------------------------------------
/examples/Workspaces/eg001CreateWorkspace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Create a workspace
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Step 1: Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | account_id=$(cat config/API_ACCOUNT_ID)
16 |
17 | #Set the Workspace API base path
18 | base_path="https://api-d.docusign.com/v1"
19 |
20 | request_data=$(mktemp /tmp/request-wseg-001.XXXXXX)
21 | response=$(mktemp /tmp/response-wseg-001.XXXXXX)
22 |
23 | #ds-snippet-start:Workspaces1Step2
24 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
25 | '--header' "Accept: application/json" \
26 | '--header' "Content-Type: application/json")
27 | #ds-snippet-end:Workspaces1Step2
28 |
29 | # Enter the name of the workspace to create
30 | echo ""
31 | echo "Enter the name for the new workspace:"
32 | echo ""
33 |
34 | read workspace_name
35 |
36 | # Create the workspace definition
37 | #apx-snippet-start:createWorkspace
38 | #ds-snippet-start:Workspaces1Step3
39 | printf \
40 | '{
41 | "name" : "'"${workspace_name}"'"
42 | }' >> $request_data
43 | #ds-snippet-end:Workspaces1Step3
44 |
45 | #ds-snippet-start:Workspaces1Step4
46 | Status=$(curl -s -w "%{http_code}\n" -i \
47 | --request POST ${base_path}/accounts/${account_id}/workspaces \
48 | "${Headers[@]}" \
49 | --data-binary @${request_data} \
50 | --output ${response})
51 | #ds-snippet-end:Workspaces1Step4
52 | #apx-snippet-end:createWorkspace
53 |
54 | if [[ "$Status" -gt "201" ]] ; then
55 | echo ""
56 | echo "Failed to create Workspace."
57 | echo ""
58 | cat $response
59 | exit 0
60 | fi
61 |
62 | echo ""
63 | echo "Response:"
64 | cat $response
65 | echo ""
66 |
67 | # Pull out the workspace ID and save it
68 | workspace_id=`cat $response | grep workspace_id | sed 's/.*\"workspace_id\":\"//' | sed 's/".*//'`
69 | workspace_creator_id=$(grep -o -m 1 '"created_by_user_id":"[^"]*"' "$response" | \
70 | sed 's/.*"created_by_user_id":"\([^"]*\)".*/\1/')
71 | echo "Workspace created by user ${workspace_creator_id}! Workspace ID: ${workspace_id}"
72 | echo ${workspace_id} > config/WORKSPACE_ID
73 | echo ${workspace_creator_id} > config/WORKSPACE_CREATOR_ID
74 |
75 | rm "$response"
76 | rm "$request_data"
77 |
--------------------------------------------------------------------------------
/examples/Admin/eg010DeleteUserDataFromOrganization.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This shows an organization admin how to delete a user's data from one or more accounts.
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Note: Substitute these values with your own
10 | # Obtain your OAuth token
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16 | base_path="https://api-d.docusign.net/management"
17 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
18 |
19 | # Construct your API headers
20 | #ds-snippet-start:Admin10Step2
21 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
22 | '--header' "Accept: application/json"
23 | '--header' "Content-Type: application/json")
24 | #ds-snippet-end:Admin10Step2
25 |
26 | response=$(mktemp /tmp/response-oa.XXXXXX)
27 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
28 |
29 | # Get user information
30 | echo "Please input the email address of the user whose data will be deleted. Note that this email address should be associated with a user that has been closed for at least 24 hours."
31 | read EMAIL_ADDRESS
32 |
33 | curl -w '%{http_code}' -i --request GET "${base_path}/v2.1/organizations/${ORGANIZATION_ID}/users/dsprofile?email=${EMAIL_ADDRESS}" \
34 | "${Headers[@]}" \
35 | --output ${response}
36 |
37 |
38 | USER_ID=$(cat $response | sed 's/}]}/\n/' | grep users | sed 's/.*\"id\"://' | sed 's/,".*//')
39 | ACCOUNT_ID=$(cat $response | sed 's/}]}/\n/' | grep memberships | sed 's/.*\"account_id\"://' | sed 's/,".*//')
40 |
41 | # Construct the request body
42 | #ds-snippet-start:Admin10Step3
43 | printf \
44 | '{
45 | "user_id": '${USER_ID}',
46 | "memberships": [{
47 | "account_id": '${ACCOUNT_ID}',
48 | }]
49 | }
50 | ' >>$request_data
51 | #ds-snippet-end:Admin10Step3
52 |
53 | #Delete user info from an organization
54 | #ds-snippet-start:Admin10Step4
55 | curl -w '%{http_code}' -i --request POST "${base_path}/v2/data_redaction/organizations/${ORGANIZATION_ID}/user" \
56 | "${Headers[@]}" \
57 | --data-binary @${request_data} \
58 | --output ${response}
59 | #ds-snippet-end:Admin10Step4
60 |
61 | echo ""
62 | echo "Response: "
63 | echo ""
64 | cat $response
65 | echo ""
66 |
67 | # Remove the temporary files
68 | rm "$request_data"
69 | rm "$response"
70 |
71 | echo ""
72 | echo "Done."
73 | echo ""
74 |
--------------------------------------------------------------------------------
/examples/Navigator/eg001ListAgreements.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | ds_access_token_path="config/ds_access_token.txt"
7 | agreements="config/AGREEMENTS.txt"
8 |
9 | # Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat ${ds_access_token_path})
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16 | base_path="https://api-d.docusign.com/v1"
17 |
18 | #ds-snippet-start:Navigator1Step2
19 | #apx-snippet-start:GetAgreementsList
20 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
21 | '--header' "Accept: application/json" \
22 | '--header' "Content-Type: application/json")
23 | #ds-snippet-end:Navigator1Step2
24 |
25 | # List agreements
26 | #ds-snippet-start:Navigator1Step3
27 | response=$(mktemp /tmp/response-cw.XXXXXX)
28 | Status=$(curl -w '%{http_code}' -i --ssl-no-revoke --request GET ${base_path}/accounts/${ACCOUNT_ID}/agreements \
29 | "${Headers[@]}" \
30 | --output ${response})
31 | #apx-snippet-end:GetAgreementsList
32 | #ds-snippet-end:Navigator1Step3
33 |
34 | if [[ "$Status" -gt "399" ]] ; then
35 | echo ""
36 | echo "Listing agreements..."
37 | echo ""
38 | cat $response
39 | exit 0
40 | fi
41 |
42 | echo ""
43 | echo "Response:"
44 | cat $response
45 | echo ""
46 |
47 | # Extract id and file_name from each data object in the $response file
48 | > "$agreements" # Clear the output file at the beginning
49 | capture_id=false
50 |
51 | # Process each line in the $response file
52 | while read -r line; do
53 | # Check for "id" and capture it if found
54 | case "$line" in
55 | *'"id"':*)
56 | # Extract the id value
57 | id="${line#*\"id\": \"}"
58 | id="${id%%\",*}"
59 | capture_id=true
60 | ;;
61 | *'"file_name"':*)
62 | if $capture_id; then
63 | # Extract the file_name value
64 | file_name="${line#*\"file_name\": \"}"
65 | file_name="${file_name%%\"*}"
66 |
67 | # Write id and file_name to the output file
68 | echo "$id $file_name" >> "$agreements"
69 |
70 | # Reset the capture flag
71 | capture_id=false
72 | fi
73 | ;;
74 | esac
75 | done < "$response"
76 |
77 | # Remove the temporary files
78 | rm "$response"
79 |
--------------------------------------------------------------------------------
/examples/eSignature/eg028CreatingABrand.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Creating a brand
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | read -p "Please enter a new brand name [Sample Bash Corp. {date}]: " BRAND
10 | BRAND=${BRAND:-"Sample Bash Corp. "$(date +%Y-%m-%d-%H:%M)}
11 | export BRAND
12 |
13 |
14 |
15 | # Step 1: Obtain your OAuth token
16 | # Note: Substitute these values with your own
17 | # Set up variables for full code example
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 | base_path="https://demo.docusign.net/restapi"
21 |
22 | # Step 2: Construct your API headers
23 | #ds-snippet-start:eSign28Step2
24 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
25 | '--header' "Accept: application/json" \
26 | '--header' "Content-Type: application/json")
27 | #ds-snippet-end:eSign28Step2
28 |
29 | # Step 3: Construct the request body
30 | # Create a temporary file to store the request body
31 | request_data=$(mktemp /tmp/request-brand-001.XXXXXX)
32 | #ds-snippet-start:eSign28Step3
33 | printf \
34 | '{
35 |
36 | "brandName": "'"${BRAND}"'",
37 | "defaultBrandLanguage": "en"
38 |
39 | }' >> $request_data
40 | #ds-snippet-end:eSign28Step3
41 |
42 | # Step 4: a) Call the eSignature API
43 | # b) Display the JSON response
44 | # Create a temporary file to store the response
45 | response=$(mktemp /tmp/response-brand.XXXXXX)
46 |
47 | #ds-snippet-start:eSign28Step4
48 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/brands \
49 | "${Headers[@]}" \
50 | --data-binary @${request_data} \
51 | --output ${response})
52 | #ds-snippet-end:eSign28Step4
53 |
54 | # If the Status code returned is greater than 399, display an error message along with the API response
55 | if [[ "$Status" -gt "399" ]] ; then
56 | echo ""
57 | echo "Creating a new brand has failed."
58 | echo ""
59 | cat $response
60 | exit 0
61 | fi
62 |
63 |
64 | # Retrieve the profile ID from the API response.
65 | brandId=`cat $response | grep brandId | sed 's/.*\"brandId\":\"//' | sed 's/\",.*//'`
66 | # Save the envelope id for use by other scripts
67 | echo "brand Id: ${brandId}"
68 | echo ${brandId} > config/BRAND_ID
69 |
70 |
71 | echo ""
72 | echo "Response:"
73 | cat $response
74 | echo ""
75 |
76 | # Remove the temporary files
77 | rm "$request_data"
78 | rm "$response"
79 |
80 | echo ""
81 | echo ""
82 | echo "Done."
83 | echo ""
84 |
--------------------------------------------------------------------------------
/examples/Navigator/eg002GetSingleAgreement.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | ds_access_token_path="config/ds_access_token.txt"
7 | agreements="config/AGREEMENTS.txt"
8 |
9 | # Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat ${ds_access_token_path})
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16 | base_path="https://api-d.docusign.com/v1"
17 |
18 | # Check if agreements file exists and has content
19 | if [[ ! -s "$agreements" ]]; then
20 | echo "Please run Navigator example 1: List_Agreements first to get a list of agreements."
21 | exit 0
22 | fi
23 |
24 | #Display list of agreements
25 | # Initialize an array to hold the file_names
26 | file_names=()
27 |
28 | # Read each line from AGREEMENTS.txt and populate file_names array
29 | while IFS=' ' read -r id file_name; do
30 | file_names+=("$file_name")
31 | done < $agreements
32 |
33 | # Display the file_name options to the user for selection
34 | echo "Please select an agreement:"
35 | select chosen_name in "${file_names[@]}"; do
36 | if [[ -n "$chosen_name" ]]; then
37 | # Find the matching line and extract the corresponding id
38 | AGREEMENT_ID=$(grep -w "$chosen_name" "$agreements" | awk '{print $1}')
39 | echo "You selected: $chosen_name"
40 | echo "AGREEMENT_ID: $AGREEMENT_ID"
41 | break
42 | else
43 | echo "Invalid selection. Please try again."
44 | fi
45 | done
46 |
47 | #ds-snippet-start:Navigator2Step2
48 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
49 | '--header' "Accept: application/json" \
50 | '--header' "Content-Type: application/json")
51 | #ds-snippet-end:Navigator2Step2
52 |
53 | # Get Agreement
54 | #ds-snippet-start:Navigator2Step3
55 | #apx-snippet-start:GetAgreement
56 | response=$(mktemp /tmp/response-neg-002.XXXXXX)
57 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/accounts/${ACCOUNT_ID}/agreements/${AGREEMENT_ID} \
58 | "${Headers[@]}" \
59 | --output ${response})
60 | #apx-snippet-end:GetAgreement
61 | #ds-snippet-end:Navigator2Step3
62 |
63 |
64 | if [[ "$Status" -gt "399" ]] ; then
65 | echo ""
66 | echo "Error: "
67 | echo ""
68 | cat $response
69 | exit 0
70 | fi
71 |
72 | echo ""
73 | echo "Response:"
74 | cat $response
75 | echo ""
76 |
77 |
78 | # Remove the temporary files
79 | rm "$response"
80 |
--------------------------------------------------------------------------------
/examples/Admin/eg004AddUsersViaBulkImport.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/add-users-bulk-import/
3 | # How to add users via bulk import
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Note: Substitute these values with your own
11 | # Obtain your OAuth token
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 |
19 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
20 |
21 | # Construct your API headers
22 | # Step 2 Start
23 | #ds-snippet-start:Admin4Step2
24 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
25 | '--header' "Content-Disposition: filename=myfile.csv" \
26 | '--header' "Content-Type: text/csv")
27 | #ds-snippet-end:Admin4Step2
28 | # Step 2 End
29 |
30 | # Create the bulk import request
31 | # Step 3 Start
32 | #ds-snippet-start:Admin4Step3
33 | request_data=$(mktemp /tmp/request-oa.XXXXXX)
34 |
35 | printf \
36 | 'AccountID,UserName,UserEmail,PermissionSet
37 | \"'${API_ACCOUNT_ID}'\",FirstLast1,exampleuser1@example.com,DS Viewer,
38 | \"'${API_ACCOUNT_ID}'\",FirstLast2,exampleuser2@example.com,DS Viewer
39 | ' >>$request_data
40 |
41 | # Create a temporary file to store the response
42 | response=$(mktemp /tmp/response-oa.XXXXXX)
43 |
44 | curl --request POST ${base_path}/v2/organizations/${ORGANIZATION_ID}/imports/bulk_users/add \
45 | "${Headers[@]}" \
46 | --data-binary @${request_data} \
47 | --output ${response}
48 |
49 | echo ''
50 | echo 'Response:'
51 | echo ''
52 | cat $response
53 | echo ''
54 | #ds-snippet-end:Admin4Step3
55 | # Step 3 End
56 |
57 | #Pull the first Id from the JSON response
58 | ID=$(cat $response | grep id | sed 's/.*{\"id\":\"//' | sed 's/\",.*//')
59 | importId=${ID}
60 |
61 | #Remove previous temp files
62 | rm $response
63 | rm $request_data
64 |
65 | # Check the request status
66 | echo ''
67 | echo "Waiting for 20 seconds and check the status of the request..."
68 | sleep 20
69 | # Step 4 Start
70 | #ds-snippet-start:Admin4Step4
71 | curl --request GET ${base_path}/v2/organizations/${ORGANIZATION_ID}/imports/bulk_users/${importId} \
72 | "${Headers[@]}" \
73 | --output ${response}
74 | #ds-snippet-end:Admin4Step4
75 | # Step 4 End
76 | echo 'Response:'
77 | echo ''
78 | cat $response
79 | echo ''
80 |
81 | # Remove the temporary files
82 | rm "$response"
83 |
84 | echo ""
85 | echo "Done."
86 | echo ""
87 |
--------------------------------------------------------------------------------
/examples/eSignature/eg012EmbeddedConsole.sh:
--------------------------------------------------------------------------------
1 | # Redirect to the DocuSign console web tool
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Step 1: Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 |
16 | base_path="https://demo.docusign.net/restapi"
17 |
18 | # Check that we have an envelope id
19 | if [ ! -f config/ENVELOPE_ID ]; then
20 | echo ""
21 | echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
22 | echo ""
23 | exit 0
24 | fi
25 | envelope_id=`cat config/ENVELOPE_ID`
26 |
27 | # The returnUrl is normally your own web app. DocuSign will redirect
28 | # the signer to returnUrl when the embedded signing completes.
29 | # For this example, we'll use http://httpbin.org/get to show the
30 | # query parameters passed back from DocuSign
31 |
32 | # The web tool console can be opened in either of two views:
33 | echo ""
34 | PS3='Select the console view: '
35 | options=("Front page" "Envelope view")
36 | select opt in "${options[@]}"
37 | do
38 | case $opt in
39 | "Front page")
40 | json='{"returnUrl": "http://httpbin.org/get"}'
41 | break
42 | ;;
43 | "Envelope view")
44 | json="{\"returnUrl\": \"http://httpbin.org/get\",
45 | \"envelopeId\": \"${envelope_id}\"}"
46 | break
47 | ;;
48 | esac
49 | done
50 |
51 | echo ""
52 | echo "Requesting the console view url"
53 | echo ""
54 |
55 | response=$(mktemp /tmp/response-eg-012.XXXXXX)
56 | #ds-snippet-start:eSign12Step2
57 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
58 | --header "Content-Type: application/json" \
59 | --data-binary "${json}" \
60 | --request POST ${base_path}/v2.1/accounts/${account_id}/views/console \
61 | --output $response
62 |
63 | echo ""
64 | echo "Results:"
65 | echo ""
66 | cat $response
67 | console_url=`cat $response | grep url | sed 's/.*\"url\": \"//' | sed 's/\".*//'`
68 | #ds-snippet-end:eSign12Step2
69 | echo ""
70 | printf "The console URL is ${console_url}\n"
71 | printf "It is only valid for five minutes. Attempting to automatically open your browser...\n"
72 | if which xdg-open &> /dev/null ; then
73 | xdg-open "$console_url"
74 | elif which open &> /dev/null ; then
75 | open "$console_url"
76 | elif which start &> /dev/null ; then
77 | start "$console_url"
78 | fi
79 |
80 | # cleanup
81 | rm "$response"
82 |
83 | echo ""
84 | echo "Done."
85 | echo ""
--------------------------------------------------------------------------------
/examples/Rooms/eg008AccessFormGroup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/access-form-group/
3 | # How to grant office access to a form group
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 |
18 | base_path="https://demo.rooms.docusign.com"
19 |
20 | #ds-snippet-start:Rooms8Step2
21 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
22 | '--header' "Accept: application/json"
23 | '--header' "Content-Type: application/json")
24 | #ds-snippet-end:Rooms8Step2
25 |
26 |
27 | #ds-snippet-start:Rooms8Step3
28 | # Create a temporary file to store the response
29 | response=$(mktemp /tmp/response-rooms.XXXXXX)
30 | echo ""
31 | echo "Getting an Office ID..."
32 | Status=$(
33 | curl -w '%{http_code}' --request GET ${base_path}/restapi/v2/accounts/${API_ACCOUNT_ID}/offices \
34 | "${Headers[@]}" \
35 | --output ${response}
36 | )
37 |
38 | OFFICE_ID=$(cat $response | grep officeId | sed 's/.*\"officeId\"://' | sed 's/,".*//')
39 |
40 | if [[ "$Status" -gt "201" ]]; then
41 | echo ""
42 | echo "Error:"
43 | echo ""
44 | cat $response
45 | exit 1
46 | fi
47 |
48 | echo ""
49 | echo "Response:"
50 | cat $response
51 | echo ""
52 |
53 | request_data=$(mktemp /tmp/request-rooms-008.XXXXXX)
54 | #ds-snippet-end:Rooms8Step3
55 |
56 | # Get a form group ID from the file ./config/FORM_GROUP_ID
57 | #ds-snippet-start:Rooms8Step4
58 | if [ -f "config/FORM_GROUP_ID" ]; then
59 | FORM_GROUP_ID=$(cat config/FORM_GROUP_ID)
60 | else
61 |
62 | echo " Form group ID is needed. Please run step 7 - Create a form group..."
63 | exit 0
64 |
65 | fi
66 | #ds-snippet-end:Rooms8Step4
67 |
68 |
69 | response=$(mktemp /tmp/request-rooms-008step4req.XXXXXX)
70 | echo ""
71 | echo "Call the Rooms API..."
72 |
73 | #ds-snippet-start:Rooms8Step5
74 | Status=$(
75 | curl -w '%{http_code}' --request POST ${base_path}/restapi/v2/accounts/${API_ACCOUNT_ID}/form_groups/$FORM_GROUP_ID/grant_office_access/${OFFICE_ID} \
76 | "${Headers[@]}" \
77 | --data-binary @${request_data} \
78 | --output ${response}
79 | )
80 | #ds-snippet-end:Rooms8Step5
81 |
82 |
83 | if [[ "$Status" -ne "204" ]]; then
84 | echo ""
85 | echo "Error: Unable to grant office access to a form group"
86 | echo ""
87 | cat $response
88 | exit 1
89 | fi
90 |
91 | echo ""
92 | echo "Response status code: $Status "
93 | echo ""
94 |
95 | # Remove the temporary files
96 | rm "$request_data"
97 | rm "$response"
98 |
--------------------------------------------------------------------------------
/examples/Admin/eg005AuditUsers.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Audit users with the Admin API
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that ORGANIZATION_ID has been set
10 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
11 | if [[ -z "$ORGANIZATION_ID" ]]; then
12 | echo "PROBLEM: Set ORGANIZATION_ID and add to config directory"
13 | fi
14 |
15 |
16 | # Note: Substitute these values with your own
17 | # Obtain your OAuth token
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 |
20 | # Set up variables for full code example
21 | # Note: Substitute these values with your own
22 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
23 | base_path="https://api-d.docusign.net/management"
24 |
25 | # Construct your API headers
26 | # Step 2 start
27 | #ds-snippet-start:Admin5Step2
28 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
29 | '--header' "Accept: application/json" \
30 | '--header' "Content-Type: application/json")
31 | #ds-snippet-end:Admin5Step2
32 | # Step 2 end
33 |
34 | # Step 3 start
35 | #ds-snippet-start:Admin5Step3
36 | # Calculate date parameter to get users modified in the last 10 days
37 | if date -v -10d &>/dev/null; then
38 | # Mac
39 | # modified_since=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
40 | modified_since=$(date -v -10d '+%Y-%m-%d')
41 | else
42 | # Not a Mac
43 | # modified_since=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
44 | modified_since=$(date --date='-10 days' '+%Y-%m-%d')
45 | fi
46 |
47 | response=$(mktemp /tmp/response-admin.XXXXXX)
48 |
49 | # Call the Admin API
50 | Status=$(
51 | curl -w '%{http_code}' --request GET "${base_path}/v2/organizations/${ORGANIZATION_ID}/users?account_id=${API_ACCOUNT_ID}&last_modified_since${modified_since}" \
52 | "${Headers[@]}" \
53 | --output $response
54 | )
55 | #ds-snippet-end:Admin5Step3
56 | # Step 3 end
57 |
58 | # Step 4 start
59 | #ds-snippet-start:Admin5Step4
60 | modified_users=$(cat $response)
61 | user_emails=`echo $modified_users | grep -o -P '(?<=email\":\").*?(?=\")'`
62 | array_emails=($user_emails)
63 | #ds-snippet-end:Admin5Step4
64 | # Step 4 end
65 |
66 | # Step 5 start
67 | #ds-snippet-start:Admin5Step5
68 | profiles=$(mktemp /tmp/profiles-oa.XXXXXX)
69 |
70 | echo ''
71 | echo 'User profiles:'
72 |
73 | for email in ${array_emails[@]}
74 | do
75 |
76 | Status=$(
77 | curl -w '%{http_code}' -i --request GET "${base_path}/v2/organizations/${ORGANIZATION_ID}/users/profile?email=${email}" \
78 | "${Headers[@]}" \
79 | --output ${profiles}
80 | )
81 |
82 | echo ''
83 | cat $profiles
84 | echo ''
85 |
86 | done
87 | #ds-snippet-end:Admin5Step5
88 | # Step 5 end
89 |
90 | # Remove the temporary files"
91 | rm "$profiles"
92 | rm "$response"
93 |
94 | echo ""
95 | echo "Done."
96 | echo ""
97 |
--------------------------------------------------------------------------------
/examples/Monitor/eg001GetMonitoringData.sh:
--------------------------------------------------------------------------------
1 | # Step 1: Obtain your OAuth token
2 | # Note: Substitute these values with your own
3 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
4 |
5 | # Construct your API headers
6 | #ds-snippet-start:Monitor1Step2
7 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
8 | '--header' "Accept: application/json"
9 | '--header' "Content-Type: application/json")
10 | #ds-snippet-end:Monitor1Step2
11 |
12 |
13 | # First call the endpoint with no cursor to get the first records.
14 | # After each call, save the cursor and use it to make the next
15 | # call from the point where the previous one left off when iterating through
16 | # the monitoring records
17 |
18 | #ds-snippet-start:Monitor1Step3
19 | if date -v -10d &>/dev/null; then
20 | # Mac
21 | cursorDate=$(date -v -1y '+%Y-%m-%d')
22 | else
23 | # Not a Mac
24 | cursorDate=$(date --date='-1 year' '+%Y-%m-%d')
25 | fi
26 |
27 | complete=false
28 | cursorValue="${cursorDate}T00:00:00Z"
29 | iterations=0
30 |
31 | while [ $complete == false ]; do
32 | ((iterations=iterations+1))
33 | # Create a temporary file to store the response
34 | response=$(mktemp /tmp/response-bs.XXXXXX)
35 | Status=$(curl -w '%{http_code}' -i --request GET "https://lens-d.docusign.net/api/v2.0/datasets/monitor/stream?cursor=${cursorValue}&limit=2000" \
36 | "${Headers[@]}" \
37 | --output ${response})
38 | # If the Status code returned is greater than 201 (OK / Accepted), display an error message
39 | # along with the API response
40 | if [[ "$Status" -gt "201" ]] ; then
41 | echo ""
42 | echo "You do not have Monitor enabled for your account, follow https://developers.docusign.com/docs/monitor-api/how-to/enable-monitor/ to get it enabled."
43 | echo ""
44 | cat $response
45 | exit 1
46 | fi
47 | # Display the data
48 | echo ""
49 | echo "Increment:"
50 | echo $iterations
51 | echo "Response:"
52 | cat $response
53 | echo ""
54 | # Get the endCursor value from the response. This lets you resume
55 | # getting records from the spot where this call left off
56 | endCursorValue=`cat $response | grep endCursor | sed 's/.*\"endCursor\":\"//' | sed 's/\",.*//'`
57 | echo "endCursorValue is:"
58 | echo $endCursorValue
59 | echo "cursorValue is:"
60 | echo $cursorValue
61 | echo ""
62 | # If the endCursor from the response is the same as the one that you already have,
63 | # it means that you have reached the end of the records
64 | if [ "$endCursorValue" == "$cursorValue" ] ; then
65 | echo 'After getting records, the cursor values are the same. This indicates that you have reached the end of your available records.'
66 | complete=$((true))
67 | else
68 | echo 'Updating the cursor value of ' ${cursorValue} ' to the new value of ' ${endCursorValue}
69 | cursorValue="${endCursorValue}"
70 | sleep 5
71 | fi
72 | #ds-snippet-end:Monitor1Step3
73 | echo ""
74 | # Remove the temporary file
75 | rm "$response"
76 | done
77 | echo ""
78 | echo ""
79 | echo "Done."
80 | echo ""
81 |
--------------------------------------------------------------------------------
/examples/Workspaces/eg004CreateWorkspaceWithBrand.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Create a Workspace with an existing brand (Workspaces API only)
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Step 1: Obtain your OAuth token
10 | # Note: Substitute these values with your own
11 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
12 |
13 | # Set up variables for full code example
14 | # Note: Substitute these values with your own
15 | account_id=$(cat config/API_ACCOUNT_ID)
16 |
17 | # Set the Workspace API base path
18 | base_path="https://api-d.docusign.com/v1"
19 |
20 | request_data=$(mktemp /tmp/request-wseg-001.XXXXXX)
21 | response=$(mktemp /tmp/response-wseg-001.XXXXXX)
22 |
23 | # Step 2: Retrieve brand_id from config
24 | #ds-snippet-start:Workspaces4Step2
25 | if [[ ! -s config/BRAND_ID ]]; then
26 | echo "No brand_id found. Attempting to run eg028CreatingABrand.sh..."
27 | if [[ -x ./examples/eSignature/eg028CreatingABrand.sh ]]; then
28 | bash ./examples/eSignature/eg028CreatingABrand.sh
29 | else
30 | echo "eg028CreatingABrand.sh not found or not executable."
31 | echo "Please run the eSignature Create a Brand example first."
32 | exit 1
33 | fi
34 | fi
35 |
36 | # Re-check after attempt
37 | if [[ ! -s config/BRAND_ID ]]; then
38 | echo "Brand creation did not produce a brand_id. Please create a brand first."
39 | exit 1
40 | fi
41 | brand_id=$(cat config/BRAND_ID)
42 | #ds-snippet-end:Workspaces4Step2
43 |
44 | # Step 3: Construct your API headers
45 | #ds-snippet-start:Workspaces4Step3
46 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
47 | '--header' "Accept: application/json" \
48 | '--header' "Content-Type: application/json")
49 | #ds-snippet-end:Workspaces4Step3
50 |
51 | # Step 4: Construct the workspace definition
52 | #ds-snippet-start:Workspaces4Step4
53 | printf \
54 | '{
55 | "name" : "Example workspace",
56 | "brand_id" : "'"${brand_id}"'"
57 | }' >> $request_data
58 | #ds-snippet-end:Workspaces4Step4
59 |
60 | # Step 5: Call the Workspaces API
61 | #ds-snippet-start:Workspaces4Step5
62 | Status=$(curl -s -w "%{http_code}\n" -i \
63 | --request POST ${base_path}/accounts/${account_id}/workspaces \
64 | "${Headers[@]}" \
65 | --data-binary @${request_data} \
66 | --output ${response})
67 | #ds-snippet-end:Workspaces4Step5
68 |
69 | if [[ "$Status" -gt "201" ]] ; then
70 | echo ""
71 | echo "Failed to create Workspace."
72 | echo ""
73 | cat $response
74 | rm "$response"
75 | rm "$request_data"
76 | exit 0
77 | fi
78 |
79 | echo ""
80 | echo "Response:"
81 | cat $response
82 | echo ""
83 |
84 | # Pull out the workspace ID and save it
85 | workspace_id=`cat $response | grep workspace_id | sed 's/.*\"workspace_id\":\"//' | sed 's/".*//'`
86 | echo "Workspace created! ID: ${workspace_id}"
87 | echo "Brand used: ${brand_id}"
88 | echo ${workspace_id} > config/WORKSPACE_ID
89 |
90 | rm "$response"
91 | rm "$request_data"
92 |
--------------------------------------------------------------------------------
/examples/Admin/eg009DeleteUserProductPermissionProfile.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/create-active-user/
3 | # How to create a new user with active status
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Note: Substitute these values with your own
11 | # Obtain your OAuth token
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
19 |
20 | EMAIL_ADDRESS=$(cat config/ESIGN_CLM_USER_EMAIL)
21 |
22 | if [ -z "$EMAIL_ADDRESS" ]; then
23 | echo "Please run example 2: Create_Active_CLM_ESign_User before running this code example"
24 | exit 1
25 | fi
26 |
27 | # Construct your API headers
28 | #ds-snippet-start:Admin9Step2
29 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
30 | '--header' "Accept: application/json"
31 | '--header' "Content-Type: application/json")
32 | #ds-snippet-end:Admin9Step2
33 |
34 | response=$(mktemp /tmp/response-oa.XXXXXX)
35 | #ds-snippet-start:Admin9Step3
36 | curl --request GET ${base_path}/v2.1/organizations/${ORGANIZATION_ID}/accounts/${API_ACCOUNT_ID}/products/permission_profiles/users?email=${EMAIL_ADDRESS} \
37 | "${Headers[@]}" \
38 | --output ${response}
39 | #ds-snippet-end:Admin9Step3
40 | echo ""
41 | cat $response
42 | echo ""
43 |
44 | CLM_PRODUCT_ID="37f013eb-7012-4588-8028-357b39fdbd00"
45 | ESIGN_PRODUCT_ID="f6406c68-225c-4e9b-9894-64152a26fa83"
46 |
47 | echo ""
48 | echo ""
49 | echo "Delete user product permission profile for the following email: $EMAIL_ADDRESS"
50 | echo ""
51 |
52 | PS3='Which product permission profile would you like to delete? '
53 | select choice in eSignature CLM
54 | do
55 | echo $choice
56 | product=$choice
57 | break
58 | done
59 |
60 | if [ "$product" == "eSignature" ]; then
61 | PRODUCT_ID=$ESIGN_PRODUCT_ID
62 | else
63 | PRODUCT_ID=$CLM_PRODUCT_ID
64 | fi
65 |
66 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
67 | # Construct the request body
68 | #ds-snippet-start:Admin9Step4
69 | printf \
70 | '{
71 | "user_email": "'${EMAIL_ADDRESS}'",
72 | "product_ids": [
73 | "'${PRODUCT_ID}'",
74 | ]
75 | }
76 | ' >>$request_data
77 | #ds-snippet-end:Admin9Step4
78 | cat $request_data
79 |
80 | #Delete User Permission Profile
81 | #ds-snippet-start:Admin9Step5
82 | curl -w '%{http_code}' -i --request DELETE "${base_path}/v2.1/organizations/${ORGANIZATION_ID}/accounts/${API_ACCOUNT_ID}/products/users" \
83 | "${Headers[@]}" \
84 | --data-binary @${request_data} \
85 | --output ${response}
86 | #ds-snippet-end:Admin9Step5
87 | echo ""
88 | echo "Response: "
89 | echo ""
90 | cat $response
91 | echo ""
92 |
93 | # Remove the temporary files
94 | rm "$request_data"
95 | rm "$response"
96 |
97 | echo ""
98 | echo "Done."
99 | echo ""
100 |
--------------------------------------------------------------------------------
/examples/Admin/eg013CreateAccount.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/create-active-user/
3 | # How to create a new user with active status
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Note: Substitute these values with your own
11 | # Obtain your OAuth token
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
19 |
20 | # Construct your API headers
21 | #ds-snippet-start:Admin13Step2
22 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
23 | '--header' "Accept: application/json"
24 | '--header' "Content-Type: application/json")
25 | #ds-snippet-end:Admin13Step2
26 |
27 | #ds-snippet-start:Admin13Step3
28 | response=$(mktemp /tmp/response-oa.XXXXXX)
29 | Status=$(curl --request GET ${base_path}/v2/organizations/${ORGANIZATION_ID}/planItems \
30 | "${Headers[@]}" \
31 | --output ${response})
32 |
33 | echo "Results from the GET request:"
34 | cat $response
35 | echo ""
36 |
37 | PLAN_ID=$(cat $response | sed 's/,/\n/g' | grep plan_id | sed 's/.*\"plan_id\":\"//g' | sed 's/\".*//g')
38 | SUBSCRIPTION_ID=$(cat $response | sed 's/,/\n/g' | grep subscription_id | sed 's/.*\"subscription_id\":\"//g' | sed 's/\".*//g')
39 | #ds-snippet-end:Admin13Step3
40 |
41 | request_data=$(mktemp /tmp/request_data-oa.XXXXXX)
42 |
43 | read -p "Please enter the account name for the new account: " ACCOUNT_NAME
44 | read -p "Please enter the email address for the new account: " EMAIL_ADDRESS
45 | read -p "Please enter the first name for the new account: " FIRST_NAME
46 | read -p "Please enter the last name for the new account: " LAST_NAME
47 |
48 | #ds-snippet-start:Admin13Step4
49 | # The country code value is set to "US" for the developer environment
50 | # In production, set the value to the code for the country of the target account
51 | printf \
52 | '{
53 | "subscriptionDetails": {
54 | "id": "'${SUBSCRIPTION_ID}'",
55 | "planId": "'${PLAN_ID}'",
56 | "modules": []
57 | },
58 | "targetAccount": {
59 | "name": "'${ACCOUNT_NAME}'",
60 | "countryCode": "US",
61 | "admin": {
62 | "email": "'${EMAIL_ADDRESS}'",
63 | "firstName": "'${FIRST_NAME}'",
64 | "lastName": "'${LAST_NAME}'",
65 | "locale": "en"
66 | }
67 | }
68 | }
69 | ' >>$request_data
70 | #ds-snippet-end:Admin13Step4
71 |
72 | # Create the new account
73 | #ds-snippet-start:Admin13Step5
74 | response=$(mktemp /tmp/response-oa.XXXXXX)
75 | Status=$(curl --request POST ${base_path}/v2/organizations/${ORGANIZATION_ID}/assetGroups/accountCreate \
76 | "${Headers[@]}" \
77 | --data-binary @${request_data} \
78 | --output ${response})
79 | #ds-snippet-end:Admin13Step5
80 |
81 | echo "Results from the create account method:"
82 | cat $response
83 | echo ""
84 |
85 | # Remove the temporary files
86 | rm "$response"
87 | rm "$request_data"
88 | echo ""
89 | echo "Done."
90 |
--------------------------------------------------------------------------------
/examples/eSignature/eg007EnvelopeGetDoc.sh:
--------------------------------------------------------------------------------
1 | # Download a document from an envelope
2 | #
3 | # This script uses the envelope id stored in config/ENVELOPE_ID.
4 | # config/ENVELOPE_ID will be populated by running example eg002SigningViaEmail.sh
5 | # or can be entered manually.
6 |
7 | # Check that we're in a bash shell
8 | if [[ $SHELL != *"bash"* ]]; then
9 | echo "PROBLEM: Run these scripts from within the bash shell."
10 | fi
11 |
12 | # Obtain your OAuth token
13 | # Note: Substitute these values with your own
14 | # Step 1 start
15 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
16 |
17 | # Set up variables for full code example
18 | # Note: Substitute these values with your own
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 | output_file="envelope_document."
22 |
23 | base_path="https://demo.docusign.net/restapi"
24 | # Step 1 end
25 |
26 | #ds-snippet-start:eSign7Step2
27 | # Construct your API headers
28 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
29 | '--header' "Accept: application/json" \
30 | '--header' "Content-Type: application/json")
31 | #ds-snippet-end:eSign7Step2
32 | # Check that we have an envelope id
33 | if [ ! -f config/ENVELOPE_ID ]; then
34 | echo ""
35 | echo "PROBLEM: An envelope id is needed. Fix: execute code example 2 - Signing_Via_Email"
36 | echo ""
37 | exit 0
38 | fi
39 | envelope_id=`cat config/ENVELOPE_ID`
40 |
41 | doc_choice=1
42 | output_file_extension=pdf
43 | echo "Select a document or document set to download:"
44 | PS3='Please make a selection: '
45 | options=("Document 1" "Document 2" "Document 3" "Certificate of Completion" "Documents combined together" "ZIP file" "PDF Portfolio" )
46 | select opt in "${options[@]}"
47 | do
48 | case $opt in
49 | "Certificate of Completion")
50 | doc_choice=certificate
51 | break
52 | ;;
53 | "Documents combined together")
54 | doc_choice=combined
55 | break
56 | ;;
57 | "ZIP file")
58 | doc_choice=archive
59 | output_file_extension=zip
60 | break
61 | ;;
62 | "PDF Portfolio")
63 | doc_choice=portfolio
64 | output_file_extension=pdf
65 | break
66 | ;;
67 | "Document 1")
68 | doc_choice=1
69 | break
70 | ;;
71 | "Document 2")
72 | doc_choice=2
73 | break
74 | ;;
75 | "Document 3")
76 | doc_choice=3
77 | break
78 | ;;
79 | esac
80 | done
81 |
82 | echo ""
83 | echo "Sending the EnvelopeDocuments::get request to DocuSign..."
84 | echo ""
85 |
86 | #ds-snippet-start:eSign7Step3
87 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/documents/${doc_choice} \
88 | "${Headers[@]}" \
89 | --output ${output_file}${output_file_extension})
90 | #ds-snippet-end:eSign7Step3
91 |
92 | echo ""
93 | echo "The document(s) are stored in file ${output_file}${output_file_extension}"
94 | echo ""
95 | echo "Done."
96 | echo ""
97 |
98 |
--------------------------------------------------------------------------------
/examples/WebForms/eg002CreateRemoteInstance.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | ds_access_token_path="config/ds_access_token.txt"
7 |
8 | # Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat ${ds_access_token_path})
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
15 | base_path="https://apps-d.docusign.com/api/webforms/v1.1"
16 |
17 | # Create template for the Web Form from the API
18 | bash ./examples/WebForms/lib/createWebFormTemplate.sh
19 |
20 | TEMPLATE_ID=$(cat config/WEB_FORM_TEMPLATE_ID)
21 |
22 | web_form_config=$(cat demo_documents/web-form-config.json)
23 | result=$(echo "$web_form_config" | sed "s/template-id/$TEMPLATE_ID/g")
24 | echo $result > demo_documents/web-form-config.json
25 |
26 | echo ""
27 | echo "Go to your Docusign account to create the Web Form. Go to 'Templates' in your developer account, select 'Start,' select 'Web Forms,' and choose 'Upload Web Form.' Upload the JSON config file 'web-form-config.json' found under the demo_documents folder of this project. You will need to activate the web form before proceeding. Press the enter key after doing so."
28 | read choice
29 | #ds-snippet-start:WebForms2Step2
30 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
31 | '--header' "Accept: application/json" \
32 | '--header' "Content-Type: application/json")
33 | #ds-snippet-end:WebForms2Step2
34 |
35 | # List web forms in account that match the name of the web form we just created
36 | #ds-snippet-start:WebForms2Step3
37 | response=$(mktemp /tmp/response-cw.XXXXXX)
38 | Status=$(curl -w '%{http_code}' --request GET ${base_path}/accounts/${ACCOUNT_ID}/forms?search=Web%20Form%20Example%20Template \
39 | "${Headers[@]}" \
40 | --output ${response})
41 |
42 | FORM_ID=$(cat $response | sed 's/,/\n/g' | grep id | sed 's/.*\"id\":\"//g' | sed 's/\".*//g')
43 | #ds-snippet-end:WebForms2Step3
44 |
45 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
46 | #ds-snippet-start:WebForms2Step4
47 | printf \
48 | '{
49 | "sendOption": "now",
50 | "formValues": {
51 | "PhoneNumber": "555-555-5555",
52 | "Yes": ["Yes"],
53 | "Company": "Tally",
54 | "JobTitle": "Programmer Writer"
55 | },
56 | "recipients": [
57 | {
58 | "roleName": "signer",
59 | "name": "'"${SIGNER_NAME}"'",
60 | "email": "'"${SIGNER_EMAIL}"'"
61 | }
62 | ]
63 | }' >$request_data
64 | #ds-snippet-end:WebForms2Step4
65 |
66 | response=$(mktemp /tmp/response-cw.XXXXXX)
67 | #ds-snippet-start:WebForms2Step5
68 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/accounts/${ACCOUNT_ID}/forms/${FORM_ID}/instances \
69 | "${Headers[@]}" \
70 | --data-binary @${request_data} \
71 | --output ${response})
72 | #ds-snippet-end:WebForms2Step5
73 |
74 | if [[ "$Status" -gt "399" ]] ; then
75 | echo ""
76 | echo "Creating a new instance of the web form..."
77 | echo ""
78 | cat $response
79 | exit 0
80 | fi
81 |
82 | echo ""
83 | echo "Response:"
84 | cat $response
85 | echo ""
--------------------------------------------------------------------------------
/examples/Rooms/eg004AddFormsToRoomController.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/add-form-to-room
3 | # How to add forms to a room
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | base_path="https://demo.docusign.net/restapi"
19 | room_id=$(cat config/ROOM_ID)
20 |
21 | # Construct your API headers
22 | #ds-snippet-start:Rooms4Step2
23 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
24 | '--header' "Accept: application/json"
25 | '--header' "Content-Type: application/json")
26 | #ds-snippet-end:Rooms4Step2
27 |
28 | # Get a Room ID
29 | if [ -f "config/ROOM_ID" ]; then
30 | room_id=$(cat config/ROOM_ID)
31 | else
32 | echo "" Room ID is needed. Please run step 1 or 2...
33 | exit 0
34 | fi
35 |
36 | # Get a Library ID
37 | # Create a temporary file to store the response
38 | response=$(mktemp /tmp/response-rms.XXXXXX)
39 | Status=$(curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/form_libraries" \
40 | "${Headers[@]}" \
41 | --output ${response})
42 |
43 | cat $response
44 | form_library_id=$(cat $response | grep formsLibraryId | sed 's/.*\"formsLibraryId\"://' | sed 's/,.*//' | sed 's/\"//g')
45 |
46 | # Get a Library form ID
47 | Status=$(curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/form_libraries/${form_library_id}/forms" \
48 | "${Headers[@]}" \
49 | --output ${response})
50 |
51 | cat $response
52 | library_form_id=$(cat $response | grep libraryFormId | sed 's/.*\"libraryFormId\"://' | sed 's/,.*//' | sed 's/\"//g')
53 |
54 | # Remove the temporary file
55 | rm "$response"
56 |
57 |
58 | # Create a temporary file to store the request body and response
59 | request_data=$(mktemp /tmp/request-rms-001.XXXXXX)
60 | response=$(mktemp /tmp/response-rms.XXXXXX)
61 | # Construct the request body for adding a form
62 | #ds-snippet-start:Rooms4Step3
63 | printf \
64 | '{
65 | "formId":"'"$library_form_id"'",
66 | }' >$request_data
67 | #ds-snippet-end:Rooms4Step3
68 |
69 | # a) Call the Rooms API
70 | # b) Display the JSON response
71 | #ds-snippet-start:Rooms4Step4
72 | Status=$(curl -w '%{http_code}' -i --request POST "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms/${room_id}/forms" \
73 | "${Headers[@]}" \
74 | --data-binary @${request_data} \
75 | --output ${response})
76 | #ds-snippet-end:Rooms4Step4
77 |
78 | # If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
79 | if [[ "$Status" -gt "201" ]]; then
80 | echo ""
81 | echo "Posting the new room has failed."
82 | echo ""
83 | cat $response
84 | exit 0
85 | fi
86 |
87 | echo ""
88 | echo "Response:"
89 | cat $response
90 | echo ""
91 |
92 | # Remove the temporary files
93 | rm "$request_data"
94 | rm "$response"
95 |
--------------------------------------------------------------------------------
/examples/eSignature/eg030ApplyingBrandTemplate.sh:
--------------------------------------------------------------------------------
1 | # Applying a Brand to a template
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Check for a valid cc email and prompt the user if
9 | #CC_EMAIL and CC_NAME haven't been set in the config file.
10 | source ./examples/eSignature/lib/utils.sh
11 | CheckForValidCCEmail
12 |
13 | # Check that we have a template id
14 | if [ ! -f config/TEMPLATE_ID ]; then
15 | echo ""
16 | echo "PROBLEM: Template Id needed. To fix: execute script eg008CreateTemplate.sh"
17 | echo ""
18 | exit 0
19 | fi
20 | template_id=`cat config/TEMPLATE_ID`
21 |
22 | # Check that we have a brand id
23 | if [ ! -f config/BRAND_ID ]; then
24 | echo ""
25 | echo "PROBLEM: Brand Id is needed. To fix: execute script eg028CreateingABrand.sh"
26 | echo ""
27 | exit 0
28 | fi
29 | brand_id=`cat config/BRAND_ID`
30 |
31 |
32 |
33 | # Step 1: Obtain your OAuth token
34 | # Note: Substitute these values with your own
35 | # Set up variables for full code example
36 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
37 | account_id=$(cat config/API_ACCOUNT_ID)
38 | brand_id=$brand_id
39 | template_id=$template_id
40 | base_path="https://demo.docusign.net/restapi"
41 |
42 | #Step 2: Construct your API headers
43 | #ds-snippet-start:eSign30Step2
44 | declare -a Headers=('--header' "Authorization: Bearer $ACCESS_TOKEN" \
45 | '--header' "Accept: application/json" \
46 | '--header' "Content-Type: application/json")
47 | #ds-snippet-end:eSign30Step2
48 |
49 | # Step 3: Construct the request body
50 | # Create a temporary file to store the request body
51 | request_data=$(mktemp /tmp/request-brand-001.XXXXXX)
52 | #ds-snippet-start:eSign30Step3
53 | printf \
54 | '{
55 | "templateId": "'$template_id'",
56 | "brandId": "'$brand_id'",
57 | "templateRoles": [
58 | {
59 | "email": "'"${SIGNER_EMAIL}"'",
60 | "name": "'"${SIGNER_NAME}"'",
61 | "roleName": "signer"
62 | },
63 | {
64 | "email": "'"${CC_EMAIL}"'",
65 | "name": "'"${CC_NAME}"'",
66 | "roleName": "cc"
67 | }
68 | ],
69 | "status": "sent"
70 | }' >> $request_data
71 | #ds-snippet-end:eSign30Step3
72 |
73 | # Step 4: a) Call the eSignature API
74 | # b) Display the JSON response
75 | # Create a temporary file to store the response
76 | response=$(mktemp /tmp/response-brand.XXXXXX)
77 | #ds-snippet-start:eSign30Step4
78 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
79 | "${Headers[@]}" \
80 | --data-binary @${request_data} \
81 | --output ${response})
82 | #ds-snippet-end:eSign30Step4
83 | # If the Status code returned is greater than 399, display an error message along with the API response
84 | if [[ "$Status" -gt "399" ]] ; then
85 | echo ""
86 | echo "Creating a new envelope has failed."
87 | echo ""
88 | cat $response
89 | exit 0
90 | fi
91 | echo ""
92 | echo "Response:"
93 | cat $response
94 | echo ""
95 | # Remove the temporary files
96 | rm "$request_data"
97 | rm "$response"
98 | echo ""
99 | echo ""
100 | echo "Done."
101 | echo ""
102 |
103 |
--------------------------------------------------------------------------------
/examples/Click/eg006EmbedClickwrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/click-api/how-to/embed-clickwrap
3 | # Shows how to embed a clickwrap with dynamic data
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # Get a Clickwrap ID
19 | if [ -f "config/CLICKWRAP_ID" ]; then
20 | clickwrap_id=$(cat config/CLICKWRAP_ID)
21 | if [ -z "$clickwrap_id" ]; then
22 |
23 | echo ""
24 | echo "Clickwrap ID required. Please run code example 1 - Create Clickwrap"
25 | exit 0
26 | fi
27 |
28 |
29 | else
30 | echo ""
31 | echo "Clickwrap ID required. Please run code example 1 - Create Clickwrap"
32 | exit 0
33 | fi
34 |
35 |
36 |
37 | # Construct your API headers
38 | #ds-snippet-start:Click6Step2
39 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
40 | '--header' "Accept: application/json"
41 | '--header' "Content-Type: application/json")
42 | #ds-snippet-end:Click6Step2
43 |
44 |
45 | # Construct the request body
46 | # Create a temporary file to store the JSON body
47 |
48 | echo "Please input a client User Id (your own unique identifier) for the clickwrap: "
49 | read client_user_id
50 | echo "Please input a full name: "
51 | read full_name
52 | echo "Please input an email address: "
53 | read email_address
54 | echo "Please input a company name: "
55 | read company_name
56 | echo "Please input a job title: "
57 | read title
58 |
59 | #ds-snippet-start:Click6Step3
60 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
61 | printf \
62 | '
63 | {
64 | "clientUserId": "'"$client_user_id"'",
65 | "documentData": {
66 | "fullName": "'"$full_name"'",
67 | "email": "'"$email_address"'",
68 | "company": "'"$company_name"'",
69 | "title": "'"$title"'",
70 | "date": "'"$(date -I)"'"
71 | }
72 | }' >$request_data
73 | #ds-snippet-end:Click6Step3
74 |
75 | # Call the Click API
76 | # a) Make a POST call to the agreements endpoint to dynamically generate
77 | # b) Display the returned JSON structure of the response
78 | # Create a temporary file to store the response
79 | #ds-snippet-start:Click6Step4
80 | response=$(mktemp /tmp/response-cw.XXXXXX)
81 |
82 | curl --request POST https://demo.docusign.net/clickapi/v1/accounts/${account_id}/clickwraps/${clickwrap_id}/agreements \
83 | "${Headers[@]}" \
84 | --data-binary @${request_data} \
85 | --output ${response}
86 | #ds-snippet-end:Click6Step4
87 |
88 | message=`cat $response | grep message | sed 's/.*\"message\":\"//'`
89 |
90 |
91 | if [[ "${message}" == *"There are no active versions for clickwrapId"* ]] ;then
92 | echo "Clickwrap must be activated. Please run code example 2 - Activate Clickwrap"
93 | exit 0
94 |
95 | elif [[ "${message}" == *"Unable to find Clickwrap with id"* ]] ;then
96 | echo "Clickwrap ID required. Please run code example 1 - Create Clickwrap"
97 | exit 0
98 |
99 | else
100 | echo ""
101 | echo "Response:"
102 | cat $response
103 | echo ""
104 |
105 |
106 | fi
107 |
108 |
109 | # Remove the temporary file
110 | rm "$response"
111 |
--------------------------------------------------------------------------------
/examples/eSignature/eg029ApplyingBrandEnvelope.sh:
--------------------------------------------------------------------------------
1 | # Applying a Brand to an envelope
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Check that we have a brand id
9 | if [ ! -f config/BRAND_ID ]; then
10 | echo ""
11 | echo "PROBLEM: Brand Id is needed. To fix: execute script eg028CreateingABrand.sh"
12 | echo ""
13 | exit -1
14 | fi
15 | brand_id=`cat config/BRAND_ID`
16 |
17 |
18 | # Step 1: Obtain your OAuth token
19 | # Note: Substitute these values with your own
20 | # Set up variables for full code example
21 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
22 | account_id=$(cat config/API_ACCOUNT_ID)
23 | brand_id=$brand_id
24 | base_path="https://demo.docusign.net/restapi"
25 |
26 | #Step 2: Construct your API headers
27 | #ds-snippet-start:eSign29Step2
28 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
29 | '--header' "Accept: application/json" \
30 | '--header' "Content-Type: application/json")
31 |
32 | #ds-snippet-end:eSign29Step2
33 |
34 | # Step 3: Construct the request body
35 | # Create a temporary file to store the request body
36 | #ds-snippet-start:eSign29Step3
37 | request_data=$(mktemp /tmp/request-brand-001.XXXXXX)
38 | printf \
39 | '{
40 | "documents": [{
41 | "documentBase64": "DQoNCg0KCQkJCXRleHQgZG9jDQoNCg0KDQoNCg0KUk0gIwlSTSAjCVJNICMNCg0KDQoNClxzMVwNCg0KLy9hbmNoMSANCgkvL2FuY2gyDQoJCS8vYW5jaDM=",
42 | "documentId": "1",
43 | "fileExtension": "txt",
44 | "name": "NDA"
45 | }],
46 | "emailBlurb": "Sample text for email body",
47 | "emailSubject": "Please Sign",
48 | "envelopeIdStamping": "true",
49 | "recipients": {
50 | "signers": [{
51 | "name": "'"${SIGNER_NAME}"'",
52 | "email": "'"${SIGNER_EMAIL}"'",
53 | "roleName": "signer",
54 | "note": "",
55 | "routingOrder": 1,
56 | "status": "sent",
57 | "tabs": {
58 | "signHereTabs": [{
59 | "documentId": "1",
60 | "name": "SignHereTab",
61 | "pageNumber": "1",
62 | "recipientId": "1",
63 | "tabLabel": "SignHereTab",
64 | "xPosition": "75",
65 | "yPosition": "572"
66 | }]
67 | },
68 | "deliveryMethod": "email",
69 | "recipientId": "1",
70 | }],
71 | },
72 | "brandId": "'$brand_id'",
73 | "status": "Sent"
74 | }' >> $request_data
75 | #ds-snippet-end:eSign29Step3
76 |
77 | # Step 4: a) Call the eSignature API
78 | # b) Display the JSON response
79 | # Create a temporary file to store the response
80 | response=$(mktemp /tmp/response-brand.XXXXXX)
81 | #ds-snippet-start:eSign29Step4
82 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
83 | "${Headers[@]}" \
84 | --data-binary @${request_data} \
85 | --output ${response})
86 | #ds-snippet-end:eSign29Step4
87 | # If the Status code returned is greater than 399, display an error message along with the API response
88 | if [[ "$Status" -gt "399" ]] ; then
89 | echo ""
90 | echo "Creating a new envelope has failed."
91 | echo ""
92 | cat $response
93 | exit 0
94 | fi
95 | echo ""
96 | echo "Response:"
97 | cat $response
98 | echo ""
99 | # Remove the temporary files
100 | rm "$request_data"
101 | rm "$response"
102 |
103 | echo ""
104 | echo ""
105 | echo "Done."
106 | echo ""
107 |
108 |
--------------------------------------------------------------------------------
/demo_documents/order_form.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | World Wide Corp
9 | Order Processing Division
12 |
13 | Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
14 |
15 |
16 |
17 |
18 |
19 | | Item |
20 | Quantity |
21 | Each |
22 | Extended |
23 |
24 |
25 |
26 |
27 | | Harmonica |
28 |
29 | /l1q/
30 | |
31 | $5 |
32 |
33 | $/l1e/
34 | |
35 |
36 |
37 | | Xylophone |
38 |
39 | /l2q/
40 | |
41 | $150 |
42 |
43 | $/l2e/
44 | |
45 |
46 |
47 | | Total: |
49 |
50 | $/l3t/
51 | |
52 |
53 |
54 |
55 |
56 |
57 |
58 | Agreed: /sn1/
59 |
60 |
61 |
--------------------------------------------------------------------------------
/examples/eSignature/eg022SigningViaEmailWithKnowledgeBasedAuthentication.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | # Step 1: Obtain your OAuth token
7 | # Note: Substitute these values with your own
8 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
9 |
10 | #Set up variables for full code example
11 | # Note: Substitute these values with your own
12 | account_id=$(cat config/API_ACCOUNT_ID)
13 |
14 | base_path="https://demo.docusign.net/restapi"
15 |
16 | # Step 2: Construct your API headers
17 | #ds-snippet-start:eSign22Step2
18 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
19 | '--header' "Accept: application/json" \
20 | '--header' "Content-Type: application/json")
21 |
22 | #ds-snippet-end:eSign22Step2
23 | # Step 3: Construct your envelope JSON body
24 | # Create a temporary file to store the JSON body
25 | is_data_correct=true
26 | while $is_data_correct; do
27 | read -p "Please enter name for the signer: " RECIPIENT_NAME
28 | read -p "Please enter email address for the signer: " RECIPIENT_EMAIL
29 |
30 | if [[ "$RECIPIENT_EMAIL" = "$SIGNER_EMAIL" ]]; then
31 | echo ""
32 | echo "For recipient authentication you must specify a different recipient from the account owner (sender) in order to ensure recipient authentication is performed"
33 | echo ""
34 | else
35 | is_data_correct=false
36 | fi
37 | done
38 |
39 | doc_base64=$(mktemp /tmp/eg-019-doc1.XXXXXX)
40 | cat demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx | base64 > $doc_base64
41 |
42 | request_data=$(mktemp /tmp/request-cw.XXXXXX)
43 | #ds-snippet-start:eSign22Step3
44 | printf \
45 | '{
46 | "documents": [{
47 | "documentBase64":"' > $request_data
48 | cat $doc_base64 >> $request_data
49 | printf '",
50 | "documentId": "1",
51 | "fileExtension": "docx",
52 | "name": "Lorem"
53 | }],
54 | "emailBlurb": "Sample text for email body",
55 | "emailSubject": "Please Sign",
56 | "envelopeIdStamping": "true",
57 | "recipients": {
58 | "signers": [{
59 | "deliveryMethod": "Email",
60 | "name": "'"${RECIPIENT_NAME}"'",
61 | "email": "'"${RECIPIENT_EMAIL}"'",
62 | "idCheckConfigurationName": "ID Check",
63 | "recipientId": "1",
64 | "requireIdLookup": "true",
65 | "routingOrder": "1",
66 | "status": "Created",
67 | "tabs": {
68 | "signHereTabs": [{
69 | "documentId": "1",
70 | "name": "SignHereTab",
71 | "pageNumber": "1",
72 | "recipientId": "1",
73 | "tabLabel": "SignHereTab",
74 | "xPosition": "75",
75 | "yPosition": "572"
76 | }]
77 | }
78 | }]
79 | },
80 | "status": "Sent"
81 | }' >> $request_data
82 | #ds-snippet-end:eSign22Step3
83 |
84 | # Step 4: a) Make a POST call to the createEnvelopes endpoint to create a new envelope.
85 | # b) Display the JSON structure of the created envelope
86 | echo ""
87 | echo "Request:"
88 | echo ""
89 | cat $request_data
90 | # Create a temporary file to store the response
91 | response=$(mktemp /tmp/response-cw.XXXXXX)
92 | #ds-snippet-start:eSign22Step4
93 | curl --request POST "https://demo.docusign.net/restapi/v2.1/accounts/${account_id}/envelopes" \
94 | "${Headers[@]}" \
95 | --data-binary @${request_data} \
96 | --output ${response}
97 | #ds-snippet-end:eSign22Step4
98 |
99 | echo ""
100 | echo "Response:"
101 | cat $response
102 | # Remove the temporary files
103 | rm "$request_data"
104 | rm "$response"
105 |
106 | echo ""
107 | echo ""
108 | echo "Done."
109 | echo ""
110 |
111 |
--------------------------------------------------------------------------------
/examples/eSignature/eg019SigningViaEmailWithAccessCode.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 |
7 |
8 | # Step 1: Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | #Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 |
16 | base_path="https://demo.docusign.net/restapi"
17 |
18 | #ds-snippet-start:eSign19Step2
19 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
20 | '--header' "Accept: application/json" \
21 | '--header' "Content-Type: application/json")
22 | #ds-snippet-end:eSign19Step2
23 |
24 | doc_base64=$(mktemp /tmp/eg-002-doc3.XXXXXX)
25 |
26 | # Fetch docs and encode
27 | cat demo_documents/World_Wide_Corp_lorem.pdf | base64 > $doc_base64
28 |
29 | read -p "Please enter a signer email address (must be different from the developer account email address): " SIGNER_EMAIL
30 | read -p "Please enter a signer name: " SIGNER_NAME
31 |
32 | read -p "Please enter an access code for recipient authentication [Example: nj91@c]: " ACCESS_CODE
33 | ACCESS_CODE=${ACCESS_CODE:-"nj91@c"}
34 | request_data=$(mktemp /tmp/request-ds.XXXXXX)
35 |
36 | # Create a temporary file to store the JSON body
37 | #ds-snippet-start:eSign19Step3
38 | printf \
39 | '{
40 | "documents": [
41 | {
42 | "documentBase64": "' >> $request_data
43 | cat $doc_base64 >> $request_data
44 | printf '",
45 | "name": "Lorem Ipsum",
46 | "fileExtension": "pdf",
47 | "documentId": "1"
48 | }
49 | ],
50 | "emailBlurb": "Sample text for email body",
51 | "emailSubject": "Please Sign",
52 | "envelopeIdStamping": "true",
53 | "recipients": {
54 | "signers": [{
55 | "name": "'"${SIGNER_NAME}"'",
56 | "email": "'"${SIGNER_EMAIL}"'",
57 | "roleName": "",
58 | "note": "",
59 | "routingOrder": 1,
60 | "status": "created",
61 | "tabs": {
62 | "signHereTabs": [{
63 | "documentId": "1",
64 | "name": "SignHereTab",
65 | "pageNumber": "1",
66 | "recipientId": "1",
67 | "tabLabel": "SignHereTab",
68 | "xPosition": "200",
69 | "yPosition": "160"
70 | }]
71 | },
72 | "templateAccessCodeRequired": null,
73 | "deliveryMethod": "email",
74 | "recipientId": "1",
75 | "accessCode": "'"${ACCESS_CODE}"'",
76 | "smsAuthentication": null,
77 | "idCheckConfigurationName": "",
78 | "requireIdLookup": false
79 | }]
80 | },
81 | "status": "Sent"
82 | }
83 | ' >> $request_data
84 | #ds-snippet-end:eSign19Step3
85 |
86 | echo "Access code for this example is ${ACCESS_CODE}"
87 | echo ""
88 | # Step 4: a) Make a POST call to the createEnvelopes endpoint to create a new envelope.
89 | # b) Display the JSON structure of the created envelope
90 | echo ""
91 | echo "Request:"
92 | echo ""
93 | cat $request_data
94 | # Create a temporary file to store the response
95 | response=$(mktemp /tmp/response-cw.XXXXXX)
96 | #ds-snippet-start:eSign19Step4
97 | curl --request POST "https://demo.docusign.net/restapi/v2.1/accounts/${account_id}/envelopes" \
98 | "${Headers[@]}" \
99 | --data-binary @${request_data} \
100 | --output ${response}
101 | #ds-snippet-end:eSign19Step4
102 |
103 | echo ""
104 | echo "Response:"
105 | cat $response
106 | echo ""
107 | # Remove the temporary files
108 | rm "$request_data"
109 | rm "$response"
110 |
--------------------------------------------------------------------------------
/examples/eSignature/eg026UpdatingIndividualPermission.sh:
--------------------------------------------------------------------------------
1 | # Updating Individual Permissions
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Check that we have a profile id
9 | if [ ! -f config/PROFILE_ID ]; then
10 | echo ""
11 | echo "PROBLEM: Permission profile Id is needed. To fix: execute script eg024CreateingPermissionProfiles.sh"
12 | echo ""
13 | exit -1
14 | fi
15 |
16 |
17 | # Step 1: Obtain your OAuth token
18 | # Note: Substitute these values with your own
19 | # Set up variables for full code example
20 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
21 | account_id=$(cat config/API_ACCOUNT_ID)
22 | permission_profile_id=`cat config/PROFILE_ID`
23 | profile_name=`cat config/PROFILE_NAME`
24 | base_path="https://demo.docusign.net/restapi"
25 |
26 | #ds-snippet-start:eSign26Step2
27 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
28 | '--header' "Accept: application/json" \
29 | '--header' "Content-Type: application/json")
30 | #ds-snippet-end:eSign26Step2
31 |
32 | #ds-snippet-start:eSign26Step3
33 | # Create a temporary file to store the request body
34 | request_data=$(mktemp /tmp/request-perm-001.XXXXXX)
35 | printf \
36 | '{
37 |
38 | "permissionProfileName": "'"${profile_name} - updated $(date +%Y-%m-%d-%H:%M:%S) "'",
39 | "settings" : {
40 | "useNewDocuSignExperienceInterface":0,
41 | "allowBulkSending":"true",
42 | "allowEnvelopeSending":"true",
43 | "allowSignerAttachments":"true",
44 | "allowTaggingInSendAndCorrect":"true",
45 | "allowWetSigningOverride":"true",
46 | "allowedAddressBookAccess":"personalAndShared",
47 | "allowedTemplateAccess":"share",
48 | "enableRecipientViewingNotifications":"true",
49 | "enableSequentialSigningInterface":"true",
50 | "receiveCompletedSelfSignedDocumentsAsEmailLinks":"false",
51 | "signingUiVersion":"v2",
52 | "useNewSendingInterface":"true",
53 | "allowApiAccess":"true",
54 | "allowApiAccessToAccount":"true",
55 | "allowApiSendingOnBehalfOfOthers":"true",
56 | "allowApiSequentialSigning":"true",
57 | "enableApiRequestLogging":"true",
58 | "allowDocuSignDesktopClient":"false",
59 | "allowSendersToSetRecipientEmailLanguage":"true",
60 | "allowVaulting":"false",
61 | "allowedToBeEnvelopeTransferRecipient":"true",
62 | "enableTransactionPointIntegration":"false",
63 | "powerFormRole":"admin",
64 | "vaultingMode":"none"
65 | }
66 | }' >> $request_data
67 | #ds-snippet-end:eSign26Step3
68 |
69 | #ds-snippet-start:eSign26Step4
70 | response=$(mktemp /tmp/response-perm.XXXXXX)
71 |
72 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/permission_profiles/${permission_profile_id} \
73 | "${Headers[@]}" \
74 | --data-binary @${request_data} \
75 | --output ${response})
76 |
77 | #ds-snippet-end:eSign26Step4
78 |
79 | # If the Status code returned is greater than 399, display an error message along with the API response
80 | if [[ "$Status" -gt "399" ]] ; then
81 | echo ""
82 | echo "Updating Individual Permission Settings failed."
83 | echo ""
84 | cat $response
85 | exit 0
86 | fi
87 |
88 | echo ""
89 | echo "Response:"
90 | cat $response
91 | echo ""
92 |
93 | # Remove the temporary files
94 | rm "$request_data"
95 | rm "$response"
96 | echo ""
97 | echo ""
98 | echo "Done."
99 | echo ""
100 |
101 |
--------------------------------------------------------------------------------
/examples/eSignature/eg035ScheduledSending.sh:
--------------------------------------------------------------------------------
1 | # Send an envelope with three documents
2 | #
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Step 1: Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 |
16 | base_path="https://demo.docusign.net/restapi"
17 |
18 | # ***DS.snippet.0.start
19 | # document 1 (pdf) has tag /sn1/
20 |
21 | # temp files:
22 | request_data=$(mktemp /tmp/request-eg-002.XXXXXX)
23 | response=$(mktemp /tmp/response-eg-002.XXXXXX)
24 | doc1_base64=$(mktemp /tmp/eg-002-doc1.XXXXXX)
25 |
26 | # Fetch docs and encode
27 | cat demo_documents/World_Wide_Corp_lorem.pdf | base64 > $doc1_base64
28 |
29 | read -p "Please enter the future date for when you want to schedule this envelope as YYYY-MM-DD: " INPUT_DATE
30 | TIME="T00:00:00.000Z"
31 | # Add time and date together for proper formatting
32 | SCHEDULED_DATE="$INPUT_DATE$TIME"
33 |
34 | echo ""
35 | echo "Sending the envelope request to DocuSign..."
36 | echo "The envelope has three documents. Processing time will be about 15 seconds."
37 | echo "Results:"
38 | echo ""
39 |
40 | # Concatenate the different parts of the request
41 | #ds-snippet-start:eSign35Step2
42 | printf \
43 | '{
44 | "emailSubject": "Please sign this document set",
45 | "documents": [
46 | {
47 | "documentBase64": "' >> $request_data
48 | cat $doc1_base64 >> $request_data
49 | printf '",
50 | "name": "Lorem Ipsum",
51 | "fileExtension": "pdf",
52 | "documentId": "1"
53 | }
54 | ],
55 | "workflow": {
56 | "scheduledSending": {
57 | "rules": [{
58 | "resumeDate": "'"${SCHEDULED_DATE}"'"
59 | }]
60 | }
61 | },
62 | "recipients": {
63 | "signers": [
64 | {
65 | "email": "'"${SIGNER_EMAIL}"'",
66 | "name": "'"${SIGNER_NAME}"'",
67 | "recipientId": "1",
68 | "routingOrder": "1",
69 | "tabs": {
70 | "signHereTabs": [
71 | {
72 | "anchorString": "/sn1/",
73 | "anchorUnits": "pixels",
74 | "anchorXOffset": "20",
75 | "anchorYOffset": "10"
76 | }
77 | ]
78 | }
79 | }
80 | ]
81 | },
82 | "status": "sent"
83 | }' >> $request_data
84 | #ds-snippet-end:eSign35Step2
85 |
86 | #ds-snippet-start:eSign35Step3
87 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
88 | --header "Content-Type: application/json" \
89 | --data-binary @${request_data} \
90 | --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
91 | --output $response
92 |
93 | #ds-snippet-end:eSign35Step3
94 |
95 | echo ""
96 | echo "Response:"
97 | cat $response
98 | echo ""
99 |
100 | # pull out the envelopeId
101 | envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//'`
102 | # ***DS.snippet.0.end
103 | # Save the envelope id for use by other scripts
104 | echo "EnvelopeId: ${envelope_id}"
105 | echo ${envelope_id} > config/ENVELOPE_ID
106 |
107 | # cleanup
108 | rm "$request_data"
109 | rm "$response"
110 | rm "$doc1_base64"
111 |
112 | echo ""
113 | echo ""
114 | echo "Done."
115 | echo ""
116 |
--------------------------------------------------------------------------------
/examples/WebForms/eg001CreateInstance.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | ds_access_token_path="config/ds_access_token.txt"
7 |
8 | # Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat ${ds_access_token_path})
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
15 | base_path="https://apps-d.docusign.com/api/webforms/v1.1"
16 |
17 | # Create template for the Web Form from the API
18 | bash ./examples/WebForms/lib/createWebFormTemplate.sh
19 |
20 | TEMPLATE_ID=$(cat config/WEB_FORM_TEMPLATE_ID)
21 |
22 | web_form_config=$(cat demo_documents/web-form-config.json)
23 | result=$(echo "$web_form_config" | sed "s/template-id/$TEMPLATE_ID/g")
24 | echo $result > demo_documents/web-form-config.json
25 |
26 |
27 | echo ""
28 | echo "Go to your Docusign account to create the Web Form. Go to 'Templates' in your developer account, select 'Start,' select 'Web Forms,' and choose 'Upload Web Form.' Upload the JSON config file 'web-form-config.json' found under the demo_documents folder of this project. You will need to activate the web form before proceeding. Press Continue after doing so."
29 | read choice
30 | #ds-snippet-start:WebForms1Step2
31 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
32 | '--header' "Accept: application/json" \
33 | '--header' "Content-Type: application/json")
34 | #ds-snippet-end:WebForms1Step2
35 |
36 | # List web forms in account that match the name of the web form we just created
37 | #ds-snippet-start:WebForms1Step3
38 | response=$(mktemp /tmp/response-cw.XXXXXX)
39 | Status=$(curl -w '%{http_code}' --request GET ${base_path}/accounts/${ACCOUNT_ID}/forms?search=Web%20Form%20Example%20Template \
40 | "${Headers[@]}" \
41 | --output ${response})
42 |
43 | FORM_ID=$(cat $response | sed 's/,/\n/g' | grep id | sed 's/.*\"id\":\"//g' | sed 's/\".*//g')
44 | #ds-snippet-end:WebForms1Step3
45 |
46 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
47 | #ds-snippet-start:WebForms1Step4
48 | printf \
49 | '{
50 | "clientUserId": "1234-5678-abcd-ijkl",
51 | "formValues": {
52 | "PhoneNumber": "555-555-5555",
53 | "Yes": ["Yes"],
54 | "Company": "Tally",
55 | "JobTitle": "Programmer Writer"
56 | },
57 | "expirationOffset": 24
58 | }' >$request_data
59 | #ds-snippet-end:WebForms1Step4
60 |
61 | response=$(mktemp /tmp/response-cw.XXXXXX)
62 | #ds-snippet-start:WebForms1Step5
63 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/accounts/${ACCOUNT_ID}/forms/${FORM_ID}/instances \
64 | "${Headers[@]}" \
65 | --data-binary @${request_data} \
66 | --output ${response})
67 | #ds-snippet-end:WebForms1Step5
68 |
69 | if [[ "$Status" -gt "399" ]] ; then
70 | echo ""
71 | echo "Creating a new instance."
72 | echo ""
73 | cat $response
74 | exit 0
75 | fi
76 |
77 | echo ""
78 | echo "Response:"
79 | cat $response
80 | echo ""
81 |
82 | FORM_URL=$(cat $response | sed 's/,/\n/g' | grep formUrl | sed 's/.*\"formUrl\":\"//g' | sed 's/\".*//g')
83 | INSTANCE_TOKEN=$(cat $response | sed 's/,/\n/g' | grep instanceToken | sed 's/.*\"instanceToken\":\"//g' | sed 's/\".*//g')
84 |
85 | host_url="http://localhost:8080"
86 | if which xdg-open &> /dev/null ; then
87 | xdg-open $host_url
88 | elif which open &> /dev/null ; then
89 | open $host_url
90 | elif which start &> /dev/null ; then
91 | start $host_url
92 | fi
93 | php ./examples/WebForms/lib/startServerForWebForms.php "$INTEGRATION_KEY_AUTH_CODE" "$FORM_URL" "$INSTANCE_TOKEN"
94 |
95 | # Remove the temporary files
96 | rm "$request_data"
97 | rm "$response"
98 |
--------------------------------------------------------------------------------
/examples/Workspaces/eg002AddDocumentToWorkspace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/workspaces-api
3 | # Add a document to a Workspace
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Check that a workspace exists
11 | workspace_id=$(cat config/WORKSPACE_ID)
12 | workspace_name=$(cat config/WORKSPACE_NAME)
13 | if [ -z "$workspace_id" ]; then
14 | echo "Please create a workspace before running this example"
15 | exit 0
16 | fi
17 |
18 | # Step 1: Obtain your OAuth token
19 | # Note: Substitute these values with your own
20 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
21 |
22 | # Set up variables for full code example
23 | # Note: Substitute these values with your own
24 | account_id=$(cat config/API_ACCOUNT_ID)
25 |
26 | # Set the Workspace API base path
27 | base_path="https://api-d.docusign.com/v1"
28 |
29 |
30 | response=$(mktemp /tmp/response-wseg-002.XXXXXX)
31 |
32 | #ds-snippet-start:Workspaces2Step2
33 | declare -a Headers=(
34 | --header "Authorization: Bearer ${ACCESS_TOKEN}"
35 | --header "Accept: application/json"
36 | )
37 | #ds-snippet-end:Workspaces2Step2
38 |
39 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
40 | DEMO_DOCS_PATH_UNIX="$(cd "$SCRIPT_DIR/../../demo_documents" && pwd)"
41 |
42 | if command -v cygpath >/dev/null 2>&1; then
43 | DEMO_DOCS_PATH="$(cygpath -w "$DEMO_DOCS_PATH_UNIX")"
44 | else
45 | DEMO_DOCS_PATH="$DEMO_DOCS_PATH_UNIX"
46 | fi
47 |
48 | # Upload the file path to be added to the workspace
49 | #ds-snippet-start:Workspaces2Step3
50 | while true; do
51 | echo ""
52 | echo "Enter the PDF file name (e.g. World_Wide_Corp_Web_Form.pdf) from the ${DEMO_DOCS_PATH} folder:"
53 | echo ""
54 | read file_name
55 |
56 | file_path="$DEMO_DOCS_PATH/$file_name"
57 |
58 | if [[ "$file_name" != *.pdf ]]; then
59 | echo ""
60 | echo "The file must be a PDF (must end with .pdf). Please try again."
61 | continue
62 | fi
63 |
64 | if [ ! -f "$file_path" ]; then
65 | echo ""
66 | echo "File not found in demo_documents folder."
67 | continue
68 | fi
69 | break
70 | done
71 |
72 | # Enter the document name for the workspace
73 | echo ""
74 | echo "Enter the name for the document in the workspace (must end with .pdf):"
75 | echo ""
76 |
77 | while true; do
78 | read doc_name
79 |
80 | doc_name=$(echo "$doc_name" | xargs)
81 |
82 | if [[ "$doc_name" =~ \.pdf$ ]]; then
83 | break
84 | else
85 | echo ""
86 | echo "Invalid name. The document name must end with '.pdf' (e.g., example.pdf)."
87 | echo "Please try again:"
88 | fi
89 | done
90 | #ds-snippet-end:Workspaces2Step3
91 |
92 | #apx-snippet-start:addWorkspaceDocument
93 | #ds-snippet-start:Workspaces2Step4
94 | Status=$(curl -s -w "%{http_code}" -o "${response}" \
95 | --request POST "${base_path}/accounts/${account_id}/workspaces/${workspace_id}/documents" \
96 | "${Headers[@]}" \
97 | -F "file=@${file_path};filename=${doc_name}" \
98 | )
99 | #ds-snippet-end:Workspaces2Step4
100 | #apx-snippet-end:addWorkspaceDocument
101 |
102 |
103 | if [[ "$Status" -gt "201" ]]; then
104 | echo ""
105 | echo "Failed to add document to workspace."
106 | echo ""
107 | cat $response
108 | rm "$response"
109 | exit 0
110 | fi
111 |
112 | echo ""
113 | echo "Response:"
114 | cat $response
115 | echo ""
116 |
117 | # Pull out the document ID and save it
118 | document_id=$(cat $response | grep document_id | sed 's/.*"document_id":"//' | sed 's/".*//')
119 | echo ""
120 | echo "Document added to the workspace '${workspace_name}'! ID: ${document_id}"
121 | echo ${document_id} > config/DOCUMENT_ID
122 |
123 | rm "$response"
--------------------------------------------------------------------------------
/examples/Admin/eg003BulkExportUserData.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/bulk-export-users/
3 | # How to bulk-export user data
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 |
19 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
20 |
21 | # Construct your API headers
22 | # Step 2 Start
23 | #ds-snippet-start:Admin3Step2
24 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
25 | '--header' "Accept: application/json"
26 | '--header' "Content-Type: application/json")
27 | #ds-snippet-end:Admin3Step2
28 | # Step 2 End
29 |
30 | # Construct the request body to retrieve the user list
31 | # Create a temporary file to store the JSON body
32 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
33 | response=$(mktemp /tmp/response-oa.XXXXXX)
34 | response2=$(mktemp /tmp/response-oa.XXXXXX)
35 |
36 | printf \
37 | '{
38 | "type": "organization_memberships_export"
39 | }
40 | ' >>$request_data
41 |
42 | curl --request POST ${base_path}/v2/organizations/${ORGANIZATION_ID}/exports/user_list \
43 | "${Headers[@]}" \
44 | --data-binary @${request_data} \
45 | --output ${response}
46 |
47 | # Create the bulk export request
48 | requestId=`cat $response | cut -f1 -d"," | sed 's/{//g' | sed 's/.*\"id\"://' | sed 's/\"//g'`
49 | # Step 3 Start
50 | #ds-snippet-start:Admin3Step3
51 | retryCount=0
52 | downloadUrl=''
53 | while [ $retryCount -le 5 ]; do
54 | echo ''
55 | echo 'Retrieving Bulk Action Status...'
56 | echo ''
57 | curl --request GET ${base_path}/v2/organizations/${ORGANIZATION_ID}/exports/user_list/${requestId} \
58 | "${Headers[@]}" \
59 | --output ${response}
60 |
61 | echo ''
62 | echo "Response:"
63 | echo ''
64 | cat $response
65 | echo ''
66 |
67 | #Check the status of the Bulk Action
68 | status=$(cat $response | grep status | sed 's/.*\"status\":\"//' | sed 's/\",.*//')
69 | echo "Status: $status"
70 |
71 | if [ "$status" = "completed" ]; then
72 | echo ''
73 | echo 'Bulk Request has been completed'
74 | echo ''
75 | downloadUrl=$(cat $response | grep url | sed 's/.*\"url\":\"//' | sed 's/\",.*//')
76 | echo "Download Url: $downloadUrl"
77 | let retryCount=6
78 | else
79 | echo ''
80 | echo 'Bulk Request has not been completed. Retrying in 5 seconds'
81 | echo ''
82 | sleep 5
83 | let retryCount=retryCount+1
84 | fi
85 | done
86 | #ds-snippet-end:Admin3Step3
87 | # Step 3 End
88 |
89 | # Check the request status
90 | # Step 4 Start
91 | #ds-snippet-start:Admin3Step4
92 | curl --request GET ${base_path}/v2/organizations/${ORGANIZATION_ID}/exports/user_list/${requestId} \
93 | "${Headers[@]}" \
94 | --output ${response}
95 | #ds-snippet-end:Admin3Step4
96 | # Step 4 End
97 | echo ''
98 | echo "Response:"
99 | echo ''
100 | cat $response
101 | echo ''
102 |
103 | # Download the exported user data
104 | # Step 5 Start
105 | #ds-snippet-start:Admin3Step5
106 | curl --request GET "${downloadUrl}" \
107 | "${Headers[@]}" \
108 | --output ${response2}
109 | #ds-snippet-end:Admin3Step5
110 | # Step 5 End
111 | echo ''
112 | cat $response2
113 |
114 | echo ''
115 | echo "Export data to file myfile.csv..."
116 | cat $response2 > myfile.csv
117 |
118 | # Remove the temporary files
119 | rm "$request_data"
120 | rm "$response"
121 | rm "$response2"
122 |
123 | echo ""
124 | echo "Done."
125 | echo ""
126 |
--------------------------------------------------------------------------------
/examples/Workspaces/eg005CreateUploadRequest.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Create a workspace upload request
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check that a workspace exists
10 | workspace_id=$(cat config/WORKSPACE_ID)
11 | if [ -z "$workspace_id" ]; then
12 | echo "Please run the Create Workspace example before running this code."
13 | exit 0
14 | fi
15 |
16 | # Check that a workspace creator ID exists
17 | workspace_creator_id=$(cat config/WORKSPACE_CREATOR_ID)
18 | if [ -z "$workspace_creator_id" ]; then
19 | echo "No creator ID was recorded. Please run the Create Workspace example before running this code."
20 | exit 0
21 | fi
22 |
23 | # Step 1: Obtain your OAuth token
24 | # Note: Substitute these values with your own
25 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
26 |
27 | # Set up variables for full code example
28 | # Note: Substitute these values with your own
29 | account_id=$(cat config/API_ACCOUNT_ID)
30 |
31 | #Set the Workspace API base path
32 | base_path="https://api-d.docusign.com/v1"
33 |
34 | request_data=$(mktemp /tmp/request-wseg-001.XXXXXX)
35 | response=$(mktemp /tmp/response-wseg-001.XXXXXX)
36 |
37 | # Calculate ISO 8601 date 7 days from now
38 | # Uses 'date -v +7d' on macOS or 'date -d "+7 days"' on Linux (GNU date)
39 | if date -v +1d > /dev/null 2>&1; then
40 | # macOS/BSD 'date'
41 | DUE_DATE=$(date -v +7d "+%Y-%m-%dT%H:%M:%SZ")
42 | else
43 | # Linux (GNU 'date')
44 | DUE_DATE=$(date -d "+7 days" "+%Y-%m-%dT%H:%M:%SZ")
45 | fi
46 |
47 | # This header will be used for both the API call to get the ID of the workspace creator, and to create the upload request
48 | #ds-snippet-start:Workspaces5Step2
49 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
50 | '--header' "Accept: application/json" \
51 | '--header' "Content-Type: application/json")
52 | #ds-snippet-end:Workspaces5Step2
53 |
54 | # Create the workspace upload request definition
55 | #apx-snippet-start:createWorkspaceUploadRequest
56 | #ds-snippet-start:Workspaces5Step3
57 | printf \
58 | '{
59 | "name": "Upload Request example '"${DUE_DATE}"'",
60 | "description": "This is an example upload request created via the workspaces API",
61 | "due_date": "'"${DUE_DATE}"'",
62 | "assignments": [
63 | {
64 | "upload_request_responsibility_type_id": "assignee",
65 | "first_name": "Test",
66 | "last_name": "User",
67 | "email": "'"${SIGNER_EMAIL}"'"
68 | },
69 | {
70 | "assignee_user_id": "'"${workspace_creator_id}"'",
71 | "upload_request_responsibility_type_id": "watcher"
72 | }
73 | ],
74 | "status": "draft"
75 | }' >> $request_data
76 | #ds-snippet-end:Workspaces5Step3
77 |
78 | #ds-snippet-start:Workspaces5Step4
79 | Status=$(curl -s -w "%{http_code}\n" -i \
80 | --request POST ${base_path}/accounts/${account_id}/workspaces/${workspace_id}/upload-requests \
81 | "${Headers[@]}" \
82 | --data-binary @${request_data} \
83 | --output ${response})
84 | #ds-snippet-end:Workspaces5Step4
85 | #apx-snippet-end:createWorkspaceUploadRequest
86 |
87 | if [[ "$Status" -gt "201" ]] ; then
88 | echo ""
89 | echo "Failed to create Workspace upload request."
90 | echo ""
91 | cat $Status
92 | cat $response
93 | exit 0
94 | fi
95 |
96 | echo ""
97 | echo "Response:"
98 | cat $response
99 | echo ""
100 |
101 | # Get the workspace upload request ID and display it
102 | upload_request_id=`cat $response | grep upload_request_id | sed 's/.*\"upload_request_id\":\"//' | sed 's/".*//'`
103 | echo "Workspace upload request created! ID: ${upload_request_id}"
104 |
105 | rm "$response"
106 | rm "$request_data"
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/examples/Admin/eg012CloneAccount.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/create-active-user/
3 | # How to create a new user with active status
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Note: Substitute these values with your own
11 | # Obtain your OAuth token
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
19 |
20 | # Construct your API headers
21 | #ds-snippet-start:Admin12Step2
22 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
23 | '--header' "Accept: application/json"
24 | '--header' "Content-Type: application/json")
25 | #ds-snippet-end:Admin12Step2
26 |
27 | # Get list of asset group accounts for an organization
28 |
29 | response=$(mktemp /tmp/response-oa.XXXXXX)
30 | request_data=$(mktemp /tmp/request_data-oa.XXXXXX)
31 |
32 | #ds-snippet-start:Admin12Step3
33 | Status=$(curl --request GET ${base_path}/v1/organizations/${ORGANIZATION_ID}/assetGroups/accounts?compliant=true \
34 | "${Headers[@]}" \
35 | --output ${response})
36 | #ds-snippet-end:Admin12Step3
37 |
38 | echo ""
39 | echo "Results from the getAssetGroupAccounts method:"
40 | cat $response
41 | echo ""
42 |
43 | # Store account names and if there are more than one accounts, let the user choose which one to clone
44 | asset_group_account_names=$(cat $response | sed 's/,/\n/g' | grep accountName | sed 's/.*\"accountName\":\"//g' | sed 's/\".*//g')
45 | accounts_count=$(echo "$asset_group_account_names" | grep -c '^')
46 |
47 | if [ "$accounts_count" -eq "1" ]; then
48 | SOURCE_ACCOUNT_ID=$(cat $response | sed 's/}]}/\n/g' | grep assetGroupAccounts | sed 's/.*\"accountId\":\"//g' | sed 's/\".*//g')
49 | else
50 | echo ""
51 | PS3='Select an account to clone : '
52 | IFS=$'\n'
53 | select account_name in $asset_group_account_names; do
54 | if [ "$REPLY" -gt "0" ] && [ "$REPLY" -le "$accounts_count" ]; then
55 | SOURCE_ACCOUNT_ID=$(cat $response | sed 's/.*\"assetGroupAccounts\"://' | sed 's/},/\n/g' | grep $account_name | sed 's/.*\"accountId\":\"//g' | sed 's/\".*//g')
56 | break
57 | fi
58 | done
59 | fi
60 |
61 | rm "$response"
62 |
63 | read -p "Please enter the name of the new account: " ACCOUNT_NAME
64 | read -p "Please enter the first name of the new account admin: " FIRST_NAME
65 | read -p "Please enter the last name of the new account admin: " LAST_NAME
66 | read -p "Please enter the email address of the new account admin: " EMAIL
67 |
68 | #ds-snippet-start:Admin12Step4
69 | # The country code value is set to "US" for the developer environment
70 | # In production, set the value to the code for the country of the target account
71 | printf \
72 | '{
73 | "sourceAccount": {
74 | "id": "'${SOURCE_ACCOUNT_ID}'"
75 | },
76 | "targetAccount": {
77 | "name": "'${ACCOUNT_NAME}'",
78 | "admin": {
79 | "firstName": "'${FIRST_NAME}'",
80 | "lastName": "'${LAST_NAME}'",
81 | "email": "'${EMAIL}'"
82 | },
83 | "countryCode": "US"
84 | }
85 | }
86 | ' >>$request_data
87 | #ds-snippet-end:Admin12Step4
88 |
89 | # Clone source account into new account
90 | response=$(mktemp /tmp/response-oa.XXXXXX)
91 | #ds-snippet-start:Admin12Step5
92 | Status=$(curl --request POST ${base_path}/v1/organizations/${ORGANIZATION_ID}/assetGroups/accountClone \
93 | "${Headers[@]}" \
94 | --data-binary @${request_data} \
95 | --output ${response})
96 | #ds-snippet-end:Admin12Step5
97 |
98 | echo "Results from the cloneAssetGroupAccount method:"
99 | cat $response
100 | echo ""
101 |
102 | # Remove the temporary files
103 | rm "$response"
104 | rm "$request_data"
105 | echo ""
106 | echo "Done."
107 |
--------------------------------------------------------------------------------
/examples/eSignature/eg024CreatingPermissionProfiles.sh:
--------------------------------------------------------------------------------
1 | # Create Permission Profile
2 |
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 |
9 |
10 | read -p "Please enter a new permission profile name: " PROFILE_NAME
11 | PROFILE_NAME=${PROFILE_NAME:-"Bash_Perms_"$(date +%Y-%m-%d-%H:%M)}
12 | export PROFILE_NAME
13 |
14 |
15 | # Step 1: Obtain your OAuth token
16 | # Note: Substitute these values with your own
17 | # Set up variables for full code example
18 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 | # Step 2: Construct your API headers
22 | #ds-snippet-start:eSign24Step2
23 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
24 | '--header' "Accept: application/json" \
25 | '--header' "Content-Type: application/json")
26 | #ds-snippet-end:eSign24Step2
27 |
28 | # Step 3: Construct the request body
29 | # Create a temporary file to store the request body
30 | base_path="https://demo.docusign.net/restapi"
31 | request_data=$(mktemp /tmp/request-perm-001.XXXXXX)
32 | #ds-snippet-start:eSign24Step3
33 | printf \
34 | '{
35 | "permissionProfileName": "'"${PROFILE_NAME}"'",
36 | "settings" : {
37 | "useNewDocuSignExperienceInterface":0,
38 | "allowBulkSending":"true",
39 | "allowEnvelopeSending":"true",
40 | "allowSignerAttachments":"true",
41 | "allowTaggingInSendAndCorrect":"true",
42 | "allowWetSigningOverride":"true",
43 | "allowedAddressBookAccess":"personalAndShared",
44 | "allowedTemplateAccess":"share",
45 | "enableRecipientViewingNotifications":"true",
46 | "enableSequentialSigningInterface":"true",
47 | "receiveCompletedSelfSignedDocumentsAsEmailLinks":"false",
48 | "signingUiVersion":"v2",
49 | "useNewSendingInterface":"true",
50 | "allowApiAccess":"true",
51 | "allowApiAccessToAccount":"true",
52 | "allowApiSendingOnBehalfOfOthers":"true",
53 | "allowApiSequentialSigning":"true",
54 | "enableApiRequestLogging":"true",
55 | "allowDocuSignDesktopClient":"false",
56 | "allowSendersToSetRecipientEmailLanguage":"true",
57 | "allowVaulting":"false",
58 | "allowedToBeEnvelopeTransferRecipient":"true",
59 | "enableTransactionPointIntegration":"false",
60 | "powerFormRole":"admin",
61 | "vaultingMode":"none"
62 | }
63 | }' >> $request_data
64 | #ds-snippet-end:eSign24Step3
65 |
66 | # Step 4: a) Call the eSignature API
67 | # b) Display the JSON response
68 | # Create a temporary file to store the response
69 | response=$(mktemp /tmp/response-perm.XXXXXX)
70 |
71 | #ds-snippet-start:eSign24Step4
72 | Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/permission_profiles \
73 | "${Headers[@]}" \
74 | --data-binary @${request_data} \
75 | --output ${response})
76 | #ds-snippet-end:eSign24Step4
77 |
78 | # If the Status code returned is greater than 399, display an error message along with the API response
79 | if [[ "$Status" -gt "399" ]] ; then
80 | echo ""
81 | echo "Unable to create a new permissions profile."
82 | echo ""
83 | cat $response
84 | exit 0
85 | fi
86 |
87 | echo ""
88 | echo "Response:"
89 | cat $response
90 | echo ""
91 |
92 |
93 | # Retrieve the profile ID from the API response.
94 | profileID=`cat $response | grep permissionProfileId | sed 's/.*\"permissionProfileId\":\"//' | sed 's/\",.*//'`
95 | # Save the envelope id for use by other scripts
96 | echo "Permission Profile ID: ${profileID}"
97 | echo ${profileID} > config/PROFILE_ID
98 | echo ${PROFILE_NAME} > config/PROFILE_NAME
99 |
100 | # Remove the temporary files
101 | rm "$request_data"
102 | rm "$response"
103 | echo ""
104 | echo ""
105 | echo "Done."
106 | echo ""
107 |
108 |
--------------------------------------------------------------------------------
/examples/eSignature/eg032PauseSignatureWorkflow.sh:
--------------------------------------------------------------------------------
1 | # How to pause a signature workflow
2 | # https://developers.docusign.com/docs/esign-rest-api/how-to/pause-workflow/
3 |
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | # Check for a valid cc email and prompt the user if
10 | #CC_EMAIL and CC_NAME haven't been set in the config file.
11 | source ./examples/eSignature/lib/utils.sh
12 | CheckForValidCCEmail
13 |
14 | # Step 1: Obtain your OAuth token
15 | # Note: Substitute these values with your own
16 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
17 | account_id=$(cat config/API_ACCOUNT_ID)
18 | base_path="https://demo.docusign.net/restapi"
19 |
20 | # Get values form the settings.txt config file
21 | SIGNER1_EMAIL=$SIGNER_EMAIL
22 | SIGNER1_NAME=$SIGNER_NAME
23 | SIGNER2_EMAIL=$CC_EMAIL
24 | SIGNER2_NAME=$CC_NAME
25 |
26 | # Step 2: Construct your API headers
27 | # Construct your API headers
28 | #ds-snippet-start:eSign32Step2
29 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
30 | '--header' "Accept: application/json"
31 | '--header' "Content-Type: application/json")
32 | #ds-snippet-end:eSign32Step2
33 |
34 | # Step 3. Construct the request body
35 | # Create a temporary files to store the JSON body and response
36 | request_data=$(mktemp /tmp/request-bs.XXXXXX)
37 | response=$(mktemp /tmp/response-bs.XXXXXX)
38 | # Create the request body
39 | #ds-snippet-start:eSign32Step3
40 | printf \
41 | '{
42 | "documents": [
43 | {
44 | "documentBase64": "DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=",
45 | "documentId": "1",
46 | "fileExtension": "txt",
47 | "name": "Welcome"
48 | }
49 | ],
50 | "emailSubject": "EnvelopeWorkflowTest",
51 | "workflow":
52 | {
53 | "workflowSteps":
54 | [
55 | {
56 | "action": "pause_before",
57 | "triggerOnItem": "routing_order",
58 | "itemId": "2"
59 | }
60 | ]
61 | },
62 | "recipients": {
63 | "signers": [
64 | {
65 | "email": "'"${SIGNER1_EMAIL}"'",
66 | "name": "'"${SIGNER1_NAME}"'",
67 | "recipientId": "1",
68 | "routingOrder": "1",
69 | "tabs": {
70 | "signHereTabs": [
71 | {
72 | "documentId": "1",
73 | "pageNumber": "1",
74 | "tabLabel": "Sign Here",
75 | "xPosition": "200",
76 | "yPosition": "200"
77 | }
78 | ]
79 | }
80 | },
81 | {
82 | "email": "'"${SIGNER2_EMAIL}"'",
83 | "name": "'"${SIGNER2_NAME}"'",
84 | "recipientId": "2",
85 | "routingOrder": "2",
86 | "tabs": {
87 | "signHereTabs": [
88 | {
89 | "documentId": "1",
90 | "pageNumber": "1",
91 | "tabLabel": "Sign Here",
92 | "xPosition": "300",
93 | "yPosition": "200"
94 | }
95 | ]
96 | }
97 | }
98 | ]
99 | },
100 | "status": "Sent"
101 | }
102 | ' >>$request_data
103 | #ds-snippet-end:eSign32Step3
104 |
105 | # Step 4. Call the eSignature API
106 | #ds-snippet-start:eSign32Step4
107 | Status=$(curl --request POST "${base_path}/v2.1/accounts/${account_id}/envelopes" \
108 | "${Headers[@]}" \
109 | --data-binary @${request_data} \
110 | --output ${response})
111 | #ds-snippet-end:eSign32Step4
112 |
113 | if [[ "$Status" -gt "201" ]]; then
114 | echo ""
115 | echo "The call of the eSignature API has failed"
116 | echo ""
117 | cat $response
118 | exit 0
119 | fi
120 |
121 | echo ""
122 | echo "Request:"
123 | cat $request_data
124 | echo ""
125 |
126 | # Obtain the Envelope ID from the JSON response
127 | envelope_id=$(cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//')
128 | echo "Envelope Id: $envelope_id"
129 | echo ""
130 |
131 | # Store the envelope_id into the config file
132 | echo $envelope_id >config/ENVELOPE_ID
133 |
134 | # Remove the temporary files
135 | rm "$response"
136 | rm "$request_data"
137 |
--------------------------------------------------------------------------------
/examples/Rooms/eg006CreateAnExternalFormFillSessionController.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/rooms-api/how-to/external-form-fill
3 | # How to create an external form fillable session
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Step 1: Obtain your OAuth token
11 | # Note: Substitute these values with your own
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | account_id=$(cat config/API_ACCOUNT_ID)
17 |
18 | # 3. Obtain your accountId from demo.docusign.net -- the account id is shown in
19 | # the drop down on the upper right corner of the screen by your picture or
20 | # the default picture.
21 | account_id=$(cat config/API_ACCOUNT_ID)
22 |
23 | # Construct your API headers
24 | #ds-snippet-start:Rooms6Step2
25 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
26 | '--header' "Accept: application/json"
27 | '--header' "Content-Type: application/json")
28 | #ds-snippet-end:Rooms6Step2
29 |
30 | # Get a Room ID
31 | if [ -f "config/ROOM_ID" ]; then
32 | room_id=$(cat config/ROOM_ID)
33 | else
34 | echo "" Problem: Create a room using example 1.
35 | exit 0
36 | fi
37 |
38 | # Get a Library ID
39 | # Create a temporary file to store the response
40 | response=$(mktemp /tmp/response-rms.XXXXXX)
41 | Status=$(curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/form_libraries" \
42 | "${Headers[@]}" \
43 | --output ${response})
44 |
45 | cat $response
46 | form_library_id=$(cat $response | grep formsLibraryId | sed 's/.*\"formsLibraryId\"://' | sed 's/,.*//' | sed 's/\"//g')
47 |
48 | # Get a Library form ID
49 | Status=$(curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/form_libraries/${form_library_id}/forms" \
50 | "${Headers[@]}" \
51 | --output ${response})
52 |
53 | cat $response
54 | library_form_id=$(cat $response | grep libraryFormId | sed 's/.*\"libraryFormId\"://' | sed 's/,.*//' | sed 's/\"//g')
55 |
56 | # Remove the temporary file
57 | rm "$response"
58 |
59 | # Construct your request body
60 | # Create a temporary file to store the JSON body
61 |
62 | #ds-snippet-start:Rooms6Step3
63 | request_data=$(mktemp /tmp/request-rooms.XXXXXX)
64 | printf \
65 | '{
66 | "roomId": '$room_id',
67 | "formIds": ["'$library_form_id'"],
68 | "xFrameAllowedUrl": "https://iframetester.com"
69 | }' >$request_data
70 | #ds-snippet-end:Rooms6Step3
71 |
72 | # Call the v2 Rooms API
73 | # Create a temporary file to store the response
74 | #ds-snippet-start:Rooms6Step4
75 | response=$(mktemp /tmp/response-rooms.XXXXXX)
76 |
77 | curl --request POST https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/external_form_fill_sessions \
78 | "${Headers[@]}" \
79 | --data-binary @${request_data} \
80 | --output ${response}
81 |
82 | if grep -q FORM_NOT_IN_ROOM "$response"
83 | then
84 | echo ""
85 | echo "" Problem: Selected room does not have any forms. Add a form to a room using example 4.
86 | exit 0
87 | else
88 | echo ""
89 | echo "URL to be Embedded:"
90 | cat $response
91 | echo ""
92 | fi
93 | #ds-snippet-end:Rooms6Step4
94 |
95 | #ds-snippet-start:Rooms6Step5
96 | embed_url=`cat $response | grep url | sed 's/.*\"url\":\"//' | sed 's/\".*//'`
97 | redirect_url="https://iframetester.com/?url=${embed_url}"
98 | echo ""
99 |
100 | echo "The embedded form URL is ${redirect_url}"
101 | echo ""
102 | echo "Attempting to automatically open your browser..."
103 | #ds-snippet-end:Rooms6Step5
104 |
105 | if which xdg-open &> /dev/null ; then
106 | xdg-open "$redirect_url"
107 | elif which open &> /dev/null ; then
108 | open "$redirect_url"
109 | elif which start &> /dev/null ; then
110 | start "$redirect_url"
111 | fi
112 |
113 |
114 | # Remove the temporary files
115 | rm "$request_data"
116 | rm "$response"
117 |
--------------------------------------------------------------------------------
/OAuth/utils.php:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Ok. You may close this tab and return to the shell. This window closes automatically in five seconds.
34 |
35 |
36 |
37 | ';
38 |
39 |
40 | $responseErr = "HTTP/1.0 400 Bad Request\r\n"
41 | . "Content-Type: text/plain\r\n\r\n"
42 | . "Bad Request\r\n";
43 |
44 | ini_set('default_socket_timeout', 60 * 5);
45 | $server = stream_socket_server($socket, $errno, $errstr);
46 |
47 | if (!$server) {
48 | Log::err('Error starting HTTP server');
49 | return false;
50 | }
51 |
52 | do {
53 | $sock = stream_socket_accept($server);
54 |
55 | if (!$sock) {
56 | Log::err('Error accepting socket connection');
57 | exit(1);
58 | }
59 |
60 | $contentLength = 0;
61 | $headers = [];
62 | $body = null;
63 |
64 | while (false !== ($line = trim(fgets($sock)))) {
65 | if ($line === '') break;
66 | $regex = '#^Content-Length:\s*([[:digit:]]+)\s*$#i';
67 |
68 | if (preg_match($regex, $line, $matches)) {
69 | $contentLength = (int)$matches[1];
70 | }
71 |
72 | $headers[] = $line;
73 | }
74 |
75 | if ($contentLength > 0) {
76 | $body = fread($sock, $contentLength);
77 | }
78 |
79 | list($method, $url, $httpver) = explode(' ', $headers[0]);
80 |
81 | if ($method == 'GET') {
82 | $parts = parse_url($url);
83 |
84 | if (isset($parts['path']) && $parts['path'] == '/authorization-code/callback' && isset($parts['query'])) {
85 | parse_str($parts['query'], $query);
86 |
87 | if (isset($query['code']) && isset($query['state'])) {
88 | fwrite($sock, $responseOk);
89 | fclose($sock);
90 | return $query;
91 | }
92 | }
93 | }
94 |
95 | fwrite($sock, $responseErr);
96 | fclose($sock);
97 | } while (true);
98 | }
99 |
100 | function http($url, $params = false, $headers = false, $post = false)
101 | {
102 | $ch = curl_init($url);
103 |
104 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
105 | curl_setopt($ch, CURLINFO_HEADER_OUT, true);
106 | curl_setopt($ch, CURLOPT_VERBOSE, 1);
107 |
108 | if ($post) curl_setopt($ch, CURLOPT_POST, 1);
109 |
110 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
111 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
112 |
113 | if ($params) {
114 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
115 | }
116 |
117 | if ($headers) {
118 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
119 | }
120 |
121 | $resp = curl_exec($ch);
122 | return json_decode($resp);
123 | }
124 |
125 | function encodeBase64URL($data)
126 | {
127 | return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
128 | }
129 |
130 | ?>
131 |
--------------------------------------------------------------------------------
/examples/Workspaces/eg003SendEnvelopeWithRecipientInfo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Send an Workspace Envelope with Recipient Info
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | #check that a workspace exists
10 | workspace_id=$(cat config/WORKSPACE_ID)
11 | if [ -z "$workspace_id" ]; then
12 | echo "please create a workspace before running this example"
13 | exit 0
14 | fi
15 |
16 | #check that a document exists in the workspace
17 | document_id=$(cat config/DOCUMENT_ID)
18 | if [ -z "$workspace_id" ]; then
19 | echo "please create a document in the workspace before running this example"
20 | exit 0
21 | fi
22 |
23 | # Step 1: Obtain your OAuth token
24 | # Note: Substitute these values with your own
25 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
26 |
27 |
28 | # Set up variables for full code example
29 | # Note: Substitute these values with your own
30 | account_id=$(cat config/API_ACCOUNT_ID)
31 |
32 | #Set the Workspace API base path
33 | workspaces_base_path="https://api-d.docusign.com/v1"
34 |
35 | request_data=$(mktemp /tmp/request-wseg-001.XXXXXX)
36 | response=$(mktemp /tmp/response-wseg-001.XXXXXX)
37 |
38 | #ds-snippet-start:Workspaces3Step2
39 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
40 | '--header' "Accept: application/json" \
41 | '--header' "Content-Type: application/json")
42 | #ds-snippet-end:Workspaces3Step2
43 |
44 | # Create the workspace envelope definition
45 | #apx-snippet-start:createWorkspaceEnvelope
46 | #ds-snippet-start:Workspaces3Step3
47 | printf \
48 | '{
49 | "envelope_name": "Example Workspace Envelope",
50 | "document_ids": ["'"${document_id}"'"]
51 | }' >> $request_data
52 | #ds-snippet-end:Workspaces3Step3
53 |
54 | #ds-snippet-start:Workspaces3Step4
55 | Status=$(curl -s -w "%{http_code}\n" -i \
56 | --request POST ${workspaces_base_path}/accounts/${account_id}/workspaces/${workspace_id}/envelopes \
57 | "${Headers[@]}" \
58 | --data-binary @${request_data} \
59 | --output ${response})
60 | #ds-snippet-end:Workspaces3Step4
61 | #apx-snippet-end:createWorkspaceEnvelope
62 |
63 | if [[ "$Status" -gt "201" ]] ; then
64 | echo ""
65 | echo "Failed to send envelope."
66 | echo ""
67 | cat $response
68 | exit 0
69 | fi
70 |
71 | echo ""
72 | echo "Response:"
73 | cat $response
74 | echo ""
75 |
76 | # pull out the envelope_id
77 | envelope_id=`cat $response | grep envelope_id | sed 's/.*\"envelope_id\":\"//' | sed 's/".*//'`
78 | echo "Envelope created! ID: ${envelope_id}"
79 |
80 | rm "$response"
81 | rm "$request_data"
82 | request_data=$(mktemp /tmp/request2-wseg-001.XXXXXX)
83 | response=$(mktemp /tmp/response2-wseg-001.XXXXXX)
84 |
85 | #Set the eSignature REST API base path
86 | esign_base_path="https://demo.docusign.net/restapi"
87 |
88 | #ds-snippet-start:Workspaces3Step5
89 | printf \
90 | '{
91 | "emailSubject": "Please sign this document",
92 | "recipients": {
93 | "signers": [
94 | {
95 | "email": "'"${SIGNER_EMAIL}"'",
96 | "name": "'"${SIGNER_NAME}"'",
97 | "recipientId": "1",
98 | "routingOrder": "1",
99 | "tabs": {
100 | "signHereTabs": [
101 | {
102 | "anchorString": "/sn1/",
103 | "anchorUnits": "pixels",
104 | "anchorXOffset": "20",
105 | "anchorYOffset": "10"
106 | }
107 | ]
108 | }
109 | }
110 | ]
111 | },
112 | "status": "sent"
113 | }' >> $request_data
114 | #ds-snippet-end:Workspaces3Step5
115 |
116 | #ds-snippet-start:Workspaces3Step6
117 | Status=$(curl -s -o "${response}" -w "%{http_code}" \
118 | --request PUT "${esign_base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}" \
119 | "${Headers[@]}" \
120 | --data-binary @"${request_data}")
121 | #ds-snippet-end:Workspaces3Step6
122 |
123 | if [[ "$Status" -gt "201" ]] ; then
124 | echo ""
125 | echo "Failed to send envelope."
126 | echo ""
127 | cat $response
128 | exit 0
129 | fi
130 |
131 | echo ""
132 | echo "Response:"
133 | cat $response
134 | echo ""
135 | echo ""
136 | echo "Envelope Sent!"
137 | echo ""
138 |
139 | rm "$response"
140 | rm "$request_data"
--------------------------------------------------------------------------------
/examples/eSignature/lib/startServerForFocusedView.php:
--------------------------------------------------------------------------------
1 |
19 |
20 | The document has been embedded with focused view.
21 |
22 |
23 |
24 |
25 |
26 |
27 | Signing
28 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | Continue
48 |
49 |
50 |
91 |
92 | ";
95 |
96 | ini_set('default_socket_timeout', 60 * 5);
97 | $server = stream_socket_server($socket, $errno, $errstr);
98 | if (!$server) {
99 | Log::err('Error starting HTTP server');
100 | return false;
101 | }
102 | do {
103 | $sock = stream_socket_accept($server);
104 | if (!$sock) {
105 | Log::err('Error accepting socket connection');
106 | exit(1);
107 | }
108 | $contentLength = 0;
109 | $headers = [];
110 | $body = null;
111 | while (false !== ($line = trim(fgets($sock)))) {
112 | if ($line === '') break;
113 | $regex = '#^Content-Length:\s*([[:digit:]]+)\s*$#i';
114 | if (preg_match($regex, $line, $matches)) {
115 | $contentLength = (int)$matches[1];
116 | }
117 | $headers[] = $line;
118 | }
119 | if ($contentLength > 0) {
120 | $body = fread($sock, $contentLength);
121 | }
122 | list($method, $url, $httpver) = explode(' ', $headers[0]);
123 | if ($method == 'GET') {
124 | fwrite($sock, $responseOk);
125 | fclose($sock);
126 | return;
127 | }
128 | } while (true);
129 |
130 | ?>
131 |
--------------------------------------------------------------------------------
/examples/IdEvidence/eg001RetrieveEvents.sh:
--------------------------------------------------------------------------------
1 | # Check that we're in a bash shell
2 | if [[ $SHELL != *"bash"* ]]; then
3 | echo "PROBLEM: Run these scripts from within the bash shell."
4 | fi
5 |
6 | # Obtain your OAuth token
7 | access_token=$(cat config/ds_access_token.txt)
8 |
9 | # Set up variables for full code example
10 | account_id=$(cat config/API_ACCOUNT_ID)
11 | idv_envelope_id=$(cat config/IDV_ENVELOPE_ID)
12 |
13 | if [ -z "$idv_envelope_id" ]; then
14 | echo "An IDV Envelope ID is needed. Run eSignature example 23 'Signing via Email with IDV Authentication' and complete IDV before running this code example."
15 | exit 1
16 | fi
17 |
18 | # Construct your API headers
19 | declare -a Headers=('--header' "Authorization: Bearer ${access_token}" \
20 | '--header' "Accept: application/json, text/plain, */*" \
21 | '--header' "Content-Type: application/json;charset=UTF-8")
22 |
23 | # Retrieve recipient data
24 | #ds-snippet-start:IDEvidence1Step2
25 | uri="https://demo.docusign.net/restapi/v2.1/accounts/${account_id}/envelopes/${idv_envelope_id}/recipients"
26 | response=$(mktemp /tmp/response.XXXXXX)
27 |
28 | echo "Retrieving recipient data"
29 |
30 | status=$(curl -s -w "%{http_code}" --request GET "${uri}" \
31 | "${Headers[@]}" \
32 | --output ${response})
33 | #ds-snippet-end
34 |
35 | # If the status code returned a response greater than 201, display an error message
36 | if [[ "$status" -gt "201" ]]; then
37 | echo ""
38 | cat $response
39 | exit 0
40 | fi
41 |
42 | echo ""
43 | echo "Response:"
44 |
45 | recipientIdGuid=$(cat $response | grep -o '"recipientIdGuid":"[^"]*' | sed 's/"recipientIdGuid":"//')
46 |
47 | echo ""
48 | echo "recipientIdGuid: $recipientIdGuid"
49 | echo ""
50 |
51 | echo $recipientIdGuid >config/RECIPIENT_ID_GUID
52 |
53 | # Construct your API headers
54 | declare -a Headers=('--header' "Authorization: Bearer ${access_token}" \
55 | '--header' "Accept: application/json, text/plain, */*" \
56 | '--header' "Content-Length: 0" \
57 | '--header' "Content-Type: application/json;charset=UTF-8")
58 |
59 | # Obtain identity proof token (resource token)
60 | #ds-snippet-start:IDEvidence1Step3
61 | uri="https://demo.docusign.net/restapi/v2.1/accounts/${account_id}/envelopes/${idv_envelope_id}/recipients/${recipientIdGuid}/identity_proof_token"
62 | response=$(mktemp /tmp/response.XXXXXX)
63 |
64 | echo "Attempting to retrieve your identity proof token"
65 |
66 | status=$(curl -s -w "%{http_code}" --request POST "${uri}" \
67 | "${Headers[@]}" \
68 | --output ${response})
69 | #ds-snippet-end
70 |
71 | # If the status code returned a response greater than 201, display an error message
72 | if [[ "$status" -gt "201" ]]; then
73 | echo ""
74 | cat $response
75 | exit 0
76 | fi
77 |
78 | echo ""
79 | echo "Response:"
80 |
81 | #Obtain the resourceToken from the API response
82 | resourceToken=$(cat $response | grep -o '"resourceToken":"[^"]*' | sed 's/"resourceToken":"//')
83 |
84 | echo ""
85 | echo "resourceToken: $resourceToken"
86 | echo ""
87 |
88 | # Save the Resource Token for use by other scripts
89 | echo $resourceToken >config/RESOURCE_TOKEN
90 |
91 | # Construct your API headers
92 | #ds-snippet-start:IDEvidence1Step4
93 | declare -a Headers=('--header' "Authorization: Bearer ${resourceToken}" \
94 | '--header' "Accept: application/json, text/plain, */*" \
95 | '--header' "Content-Type: application/json;charset=UTF-8")
96 | #ds-snippet-end
97 | # Obtain identity proof token (resource token)
98 | #ds-snippet-start:IDEvidence1Step5
99 | uri="https://proof-d.docusign.net/api/v1/events/person/${recipientIdGuid}.json"
100 | response=$(mktemp /tmp/response.XXXXXX)
101 |
102 | echo "Retrieving recipient data"
103 |
104 | status=$(curl -s -w "%{http_code}" --request GET "${uri}" \
105 | "${Headers[@]}" \
106 | --output ${response})
107 | #ds-snippet-end
108 |
109 | # If the status code returned a response greater than 201, display an error message
110 | if [[ "$status" -gt "201" ]]; then
111 | echo ""
112 | cat $response
113 | exit 0
114 | fi
115 |
116 | # Obtain the Event List from the API response
117 | events=`cat $response | grep events | sed 's/.*\"events\":\"//' | sed 's/\",.*//'`
118 | echo ""
119 | echo "Response:"
120 | cat $response
121 | echo ""
122 |
123 | copy_of_id_front=$(cat $response | grep -o '"copy_of_id_front":"[^"]*' | sed 's/"copy_of_id_front":"//')
124 |
125 | echo ""
126 | echo "copy_of_id_front: $copy_of_id_front"
127 |
128 | # Save the copy_of_id_front URL for use by other scripts
129 | echo $copy_of_id_front >config/COPY_OF_ID_FRONT_URL
130 |
131 | # Remove the temporary files
132 | rm "$response"
133 |
134 | echo ""
135 | echo "Done."
136 | echo ""
137 |
--------------------------------------------------------------------------------
/examples/WebForms/lib/startServerForWebForms.php:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
32 |
33 |
34 |
37 |
38 |
102 |
105 | ";
106 |
107 | ini_set('default_socket_timeout', 60 * 5);
108 | $server = stream_socket_server($socket, $errno, $errstr);
109 | if (!$server) {
110 | Log::err('Error starting HTTP server');
111 | return false;
112 | }
113 | do {
114 | $sock = stream_socket_accept($server);
115 | if (!$sock) {
116 | Log::err('Error accepting socket connection');
117 | exit(1);
118 | }
119 | $contentLength = 0;
120 | $headers = [];
121 | $body = null;
122 | while (false !== ($line = trim(fgets($sock)))) {
123 | if ($line === '') break;
124 | $regex = '#^Content-Length:\s*([[:digit:]]+)\s*$#i';
125 | if (preg_match($regex, $line, $matches)) {
126 | $contentLength = (int)$matches[1];
127 | }
128 | $headers[] = $line;
129 | }
130 | if ($contentLength > 0) {
131 | $body = fread($sock, $contentLength);
132 | }
133 | list($method, $url, $httpver) = explode(' ', $headers[0]);
134 | if ($method == 'GET') {
135 | fwrite($sock, $responseOk);
136 | fclose($sock);
137 | return;
138 | }
139 | } while (true);
140 |
141 | ?>
142 |
--------------------------------------------------------------------------------
/examples/eSignature/eg036DelayedRouting.sh:
--------------------------------------------------------------------------------
1 | # Send an envelope with three documents
2 | #
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Obtain your OAuth token
9 | # Note: Substitute these values with your own
10 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11 |
12 | # Set up variables for full code example
13 | # Note: Substitute these values with your own
14 | account_id=$(cat config/API_ACCOUNT_ID)
15 |
16 | base_path="https://demo.docusign.net/restapi"
17 |
18 | # document 1 (pdf) has tag /sn1/
19 | #
20 | # The envelope has two recipients.
21 | # recipient 1 - signer
22 | # recipient 2 - signer
23 | # The envelope will be sent first to the signer.
24 | # There will be a one day delay before it is sent to the second signer.
25 |
26 | # temp files:
27 | request_data=$(mktemp /tmp/request-eg-002.XXXXXX)
28 | response=$(mktemp /tmp/response-eg-002.XXXXXX)
29 | doc1_base64=$(mktemp /tmp/eg-002-doc1.XXXXXX)
30 |
31 | # Fetch docs and encode
32 | cat demo_documents/World_Wide_Corp_lorem.pdf | base64 > $doc1_base64
33 |
34 | # Get the email and name for the second signer
35 | read -p "Enter an email address for the second signer recipient different from the first signer: " SIGNER_EMAIL2
36 | read -p "Enter a name for the second signer recipient: " SIGNER_NAME2
37 |
38 | read -p "Please enter the delay (in hours): " DELAY_HOURS
39 |
40 | DELAY_DAYS="0."
41 | DELAY_MINUTES_SECONDS="00:00"
42 | DELAY="$DELAY_DAYS$DELAY_HOURS:$DELAY_MINUTES_SECONDS"
43 |
44 | echo ""
45 | echo "Sending the envelope request to DocuSign..."
46 | echo "The envelope has three documents. Processing time will be about 15 seconds."
47 | echo "Results:"
48 | echo ""
49 |
50 | # Concatenate the different parts of the request
51 | #ds-snippet-start:eSign36Step2
52 | printf \
53 | '{
54 | "emailSubject": "Please sign this document set",
55 | "documents": [
56 | {
57 | "documentBase64": "' >> $request_data
58 | cat $doc1_base64 >> $request_data
59 | printf '",
60 | "name": "Lorem Ipsum",
61 | "fileExtension": "pdf",
62 | "documentId": "1"
63 | }
64 | ],
65 | "workflow": {
66 | "workflowSteps": [{
67 | "action": "pause_before",
68 | "triggerOnItem": "routing_order",
69 | "itemId": 2,
70 | "delayedRouting": {
71 | "rules": [{
72 | "delay": "'"${DELAY}"'"
73 | }]
74 | }
75 | }]
76 | },
77 | "recipients": {
78 | "signers": [
79 | {
80 | "email": "'"${SIGNER_EMAIL}"'",
81 | "name": "'"${SIGNER_NAME}"'",
82 | "recipientId": "1",
83 | "routingOrder": "1",
84 | "tabs": {
85 | "signHereTabs": [
86 | {
87 | "anchorString": "/sn1/",
88 | "anchorUnits": "pixels",
89 | "anchorXOffset": "20",
90 | "anchorYOffset": "10"
91 | }
92 | ]
93 | }
94 | },
95 | {
96 | "email": "'"${SIGNER_EMAIL2}"'",
97 | "name": "'"${SIGNER_NAME2}"'",
98 | "recipientId": "2",
99 | "routingOrder": "2",
100 | "tabs": {
101 | "signHereTabs": [
102 | {
103 | "xPosition": "400",
104 | "yPosition": "172",
105 | "documentId": "1",
106 | "pageNumber": "1"
107 | }
108 | ]
109 | }
110 |
111 | }
112 | ]
113 | },
114 | "status": "sent"
115 | }' >> $request_data
116 | #ds-snippet-end:eSign36Step2
117 |
118 | #ds-snippet-start:eSign36Step3
119 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
120 | --header "Content-Type: application/json" \
121 | --data-binary @${request_data} \
122 | --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
123 | --output $response
124 | #ds-snippet-end:eSign36Step3
125 |
126 | echo ""
127 | echo "Response:"
128 | cat $response
129 | echo ""
130 |
131 | # pull out the envelopeId
132 | envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//'`
133 | # Save the envelope id for use by other scripts
134 | echo "EnvelopeId: ${envelope_id}"
135 | echo ${envelope_id} > config/ENVELOPE_ID
136 |
137 | # cleanup
138 | rm "$request_data"
139 | rm "$response"
140 | rm "$doc1_base64"
141 |
142 | echo ""
143 | echo ""
144 | echo "Done."
145 | echo ""
146 |
--------------------------------------------------------------------------------
/examples/Notary/eg004SendWithThirdPartyNotary.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Use embedded signing
3 | #
4 | # Check that we're in a bash shell
5 | if [[ $SHELL != *"bash"* ]]; then
6 | echo "PROBLEM: Run these scripts from within the bash shell."
7 | fi
8 |
9 | ds_access_token_path="config/ds_access_token.txt"
10 | api_account_id_path="config/API_ACCOUNT_ID"
11 | document_path="demo_documents/World_Wide_Corp_lorem.pdf"
12 |
13 | if [ ! -f $ds_access_token_path ]; then
14 | ds_access_token_path="../config/ds_access_token.txt"
15 | api_account_id_path="../config/API_ACCOUNT_ID"
16 | document_path="../demo_documents/World_Wide_Corp_lorem.pdf"
17 | fi
18 |
19 | # Step 1: Obtain your OAuth token
20 | # Note: Substitute these values with your own
21 | ACCESS_TOKEN=$(cat ${ds_access_token_path})
22 |
23 | # Set up variables for full code example
24 | # Note: Substitute these values with your own
25 | ACCOUNT_ID=$(cat ${api_account_id_path})
26 |
27 |
28 | # Create the envelope.
29 | # The signer recipient includes a clientUserId setting
30 | #
31 | # document 1 (pdf) has tag /sn1/
32 | # The envelope will be sent to the signer.
33 |
34 | base_path="https://demo.docusign.net/restapi"
35 |
36 | # temp files:
37 | request_data=$(mktemp /tmp/request-eg-001.XXXXXX)
38 | response=$(mktemp /tmp/response-eg-001.XXXXXX)
39 | doc_base64=$(mktemp /tmp/eg-001-doc.XXXXXX)
40 |
41 | cat demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx | base64 > $doc_base64
42 |
43 | echo ""
44 | echo "Sending the envelope request to Docusign..."
45 |
46 | # Construct API headers
47 |
48 | #ds-snippet-start:Notary4Step2
49 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
50 | '--header' "Accept: application/json" \
51 | '--header' "Content-Type: application/json")
52 | #ds-snippet-end:Notary4Step2
53 |
54 | # Concatenate the different parts of the request
55 | #ds-snippet-start:Notary4Step3
56 | printf \
57 | '{
58 | "emailSubject": "Please sign this document set",
59 | "documents": [
60 | {
61 | "documentBase64": "' >> $request_data
62 | cat $doc_base64 >> $request_data
63 | printf '",
64 | "name": "Order acknowledgement",
65 | "fileExtension": "html",
66 | "documentId": "1",
67 | },
68 | ],
69 | "recipients": {
70 | "signers": [
71 | {
72 | "clientUserId": "1000",
73 | "email": "'"${SIGNER_EMAIL}"'",
74 | "name": "'"${SIGNER_NAME}"'",
75 | "recipientId": "2",
76 | "routingOrder": "1",
77 | "notaryId": "1",
78 | "tabs": {
79 | "signHereTabs": [
80 | {
81 | "documentId": "1",
82 | "xPosition": "200",
83 | "yPosition": "235",
84 | "pageNumber": "1",
85 | },
86 | {
87 | "stampType": "stamp",
88 | "documentId": "1",
89 | "xPosition": "200",
90 | "yPosition": "150",
91 | "pageNumber": "1",
92 | },
93 | ],
94 | },
95 | }
96 | ],
97 | "notaries": [
98 | {
99 | "name": "Notary",
100 | "recipientId": "1",
101 | "routingOrder": "1",
102 | "recipientSignatureProviders": [
103 | {
104 | "sealDocumentsWithTabsOnly": "false",
105 | "signatureProviderName": "ds_authority_idv"
106 | }
107 | ],
108 | "tabs": {
109 | "notarySealTabs": [
110 | {
111 | "xPosition": "300",
112 | "yPosition": "235",
113 | "documentId": "1",
114 | "pageNumber": "1",
115 | },
116 | ],
117 | "signHereTabs": [
118 | {
119 | "xPosition": "300",
120 | "yPosition": "150",
121 | "documentId": "1",
122 | "pageNumber": "1",
123 | },
124 | ]
125 | },
126 | "notaryType": "remote",
127 | "notarySourceType": "thirdparty",
128 | "notaryThirdPartyPartner": "onenotary"
129 | }
130 | ]
131 | },
132 | "status": "sent"
133 | }' >> $request_data
134 | #ds-snippet-end:Notary4Step3
135 |
136 | # Call Docusign to create the envelope
137 |
138 | #ds-snippet-start:Notary4Step4
139 | curl --data-binary @${request_data} \
140 | --request POST ${base_path}/v2.1/accounts/${ACCOUNT_ID}/envelopes \
141 | "${Headers[@]}" \
142 | --output ${response}
143 | #ds-snippet-end:Notary4Step4
144 |
145 | echo ""
146 | echo "Response:" `cat $response`
147 | echo ""
148 |
149 | # pull out the envelopeId
150 | envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//'`
151 | echo "EnvelopeId: ${envelope_id}"
152 |
153 |
154 | # cleanup
155 | rm "$request_data"
156 | rm "$response"
157 | rm "$doc_base64"
158 |
159 | echo ""
160 | echo "Done."
--------------------------------------------------------------------------------
/examples/eSignature/eg002SigningViaEmail.sh:
--------------------------------------------------------------------------------
1 | # Send an envelope with three documents
2 | #
3 | # Check that we're in a bash shell
4 | if [[ $SHELL != *"bash"* ]]; then
5 | echo "PROBLEM: Run these scripts from within the bash shell."
6 | fi
7 |
8 | # Check for a valid cc email and prompt the user if
9 | # CC_EMAIL and CC_NAME haven't been set in the config file.
10 | source ./examples/eSignature/lib/utils.sh
11 | CheckForValidCCEmail
12 |
13 | # Obtain your OAuth token
14 | # Note: Substitute these values with your own
15 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
16 |
17 | # Set up variables for full code example
18 | # Note: Substitute these values with your own
19 | account_id=$(cat config/API_ACCOUNT_ID)
20 |
21 | base_path="https://demo.docusign.net/restapi"
22 |
23 | # document 1 (html) has tag **signature_1**
24 | # document 2 (docx) has tag /sn1/
25 | # document 3 (pdf) has tag /sn1/
26 | #
27 | # The envelope has two recipients.
28 | # recipient 1 - signer
29 | # recipient 2 - cc
30 | # The envelope will be sent first to the signer.
31 | # After it is signed, a copy is sent to the cc person.
32 |
33 | # temp files:
34 | request_data=$(mktemp /tmp/request-eg-002.XXXXXX)
35 | response=$(mktemp /tmp/response-eg-002.XXXXXX)
36 | doc1_base64=$(mktemp /tmp/eg-002-doc1.XXXXXX)
37 | doc2_base64=$(mktemp /tmp/eg-002-doc2.XXXXXX)
38 | doc3_base64=$(mktemp /tmp/eg-002-doc3.XXXXXX)
39 |
40 | # Fetch docs and encode
41 | cat demo_documents/doc_1.html | base64 > $doc1_base64
42 | cat demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx | base64 > $doc2_base64
43 | cat demo_documents/World_Wide_Corp_lorem.pdf | base64 > $doc3_base64
44 |
45 | echo ""
46 | echo "Sending the envelope request to DocuSign..."
47 | echo "The envelope has three documents. Processing time will be about 15 seconds."
48 | echo "Results:"
49 | echo ""
50 |
51 | # Concatenate the different parts of the request
52 | #ds-snippet-start:eSign2Step2
53 | printf \
54 | '{
55 | "emailSubject": "Please sign this document set",
56 | "documents": [
57 | {
58 | "documentBase64": "' > $request_data
59 | cat $doc1_base64 >> $request_data
60 | printf '",
61 | "name": "Order acknowledgement",
62 | "fileExtension": "html",
63 | "documentId": "1"
64 | },
65 | {
66 | "documentBase64": "' >> $request_data
67 | cat $doc2_base64 >> $request_data
68 | printf '",
69 | "name": "Battle Plan",
70 | "fileExtension": "docx",
71 | "documentId": "2"
72 | },
73 | {
74 | "documentBase64": "' >> $request_data
75 | cat $doc3_base64 >> $request_data
76 | printf '",
77 | "name": "Lorem Ipsum",
78 | "fileExtension": "pdf",
79 | "documentId": "3"
80 | }
81 | ],
82 | "recipients": {
83 | "carbonCopies": [
84 | {
85 | "email": "'"${CC_EMAIL}"'",
86 | "name": "'"${CC_NAME}"'",
87 | "recipientId": "2",
88 | "routingOrder": "2"
89 | }
90 | ],
91 | "signers": [
92 | {
93 | "email": "'"${SIGNER_EMAIL}"'",
94 | "name": "'"${SIGNER_NAME}"'",
95 | "recipientId": "1",
96 | "routingOrder": "1",
97 | "tabs": {
98 | "signHereTabs": [
99 | {
100 | "anchorString": "**signature_1**",
101 | "anchorUnits": "pixels",
102 | "anchorXOffset": "20",
103 | "anchorYOffset": "10"
104 | },
105 | {
106 | "anchorString": "/sn1/",
107 | "anchorUnits": "pixels",
108 | "anchorXOffset": "20",
109 | "anchorYOffset": "10"
110 | }
111 | ]
112 | }
113 | }
114 | ]
115 | },
116 | "status": "sent"
117 | }' >> $request_data
118 | #ds-snippet-end:eSign2Step2
119 |
120 | #ds-snippet-start:eSign2Step3
121 | curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
122 | --header "Content-Type: application/json" \
123 | --data-binary @${request_data} \
124 | --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
125 | --output $response
126 | #ds-snippet-end:eSign2Step3
127 |
128 | echo ""
129 | echo "Response:"
130 | cat $response
131 | echo ""
132 |
133 | # pull out the envelopeId
134 | envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//'`
135 |
136 | # Save the envelope id for use by other scripts
137 | echo "EnvelopeId: ${envelope_id}"
138 | echo ${envelope_id} > config/ENVELOPE_ID
139 |
140 | # cleanup
141 | rm "$request_data"
142 | rm "$response"
143 | rm "$doc1_base64"
144 | rm "$doc2_base64"
145 | rm "$doc3_base64"
146 |
147 | echo ""
148 | echo ""
149 | echo "Done."
150 | echo ""
151 |
--------------------------------------------------------------------------------
/examples/Admin/eg008UpdateUserProductPermissionProfile.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://developers.docusign.com/docs/admin-api/how-to/create-active-user/
3 | # How to create a new user with active status
4 | #
5 | # Check that we're in a bash shell
6 | if [[ $SHELL != *"bash"* ]]; then
7 | echo "PROBLEM: Run these scripts from within the bash shell."
8 | fi
9 |
10 | # Note: Substitute these values with your own
11 | # Obtain your OAuth token
12 | ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13 |
14 | # Set up variables for full code example
15 | # Note: Substitute these values with your own
16 | API_ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
17 | base_path="https://api-d.docusign.net/management"
18 | ORGANIZATION_ID=$(cat config/ORGANIZATION_ID)
19 |
20 | # Construct your API headers
21 | #ds-snippet-start:Admin8Step2
22 | declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
23 | '--header' "Accept: application/json"
24 | '--header' "Content-Type: application/json")
25 | #ds-snippet-end:Admin8Step2
26 |
27 | EMAIL_ADDRESS=$(cat config/ESIGN_CLM_USER_EMAIL)
28 |
29 | if [ -z "$EMAIL_ADDRESS" ]; then
30 | echo "Please run example 2: Create_Active_CLM_ESign_User before running this code example"
31 | exit 1
32 | fi
33 |
34 |
35 | # Create a temporary file to store the response
36 | response=$(mktemp /tmp/response-admin.XXXXXX)
37 | echo ""
38 | echo "Getting permission profiles..."
39 | Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/v2.1/organizations/${ORGANIZATION_ID}/accounts/${API_ACCOUNT_ID}/products/permission_profiles \
40 | "${Headers[@]}" \
41 | --output ${response})
42 |
43 | if [[ "$Status" -gt "201" ]]; then
44 | echo ""
45 | echo "Error:"
46 | echo ""
47 | cat $response
48 | exit 1
49 | fi
50 |
51 | echo ""
52 | echo "Response:"
53 | cat $response
54 | echo ""
55 |
56 | echo ""
57 |
58 | CLM_PRODUCT_ID=$(cat $response | sed 's/}]}/\n/' | grep CLM | sed 's/.*\"product_id\"://' | sed 's/,".*//')
59 | clm_profile_names=$(cat $response | sed 's/}]}/\n/' | grep CLM | sed 's/,/\n/g' | grep permission_profile_name | sed 's/.*\"permission_profile_name\":\"//g' | sed 's/\".*//g')
60 | clm_profiles_count=$(echo "$clm_profile_names" | grep -c '^')
61 |
62 | ESIGN_PRODUCT_ID=$(cat $response | sed 's/}]}/\n/' | grep ESign | sed 's/.*\"product_id\"://' | sed 's/,".*//')
63 | esign_profile_names=$(cat $response | sed 's/}]}/\n/' | grep ESign | sed 's/,/\n/g' | grep permission_profile_name | sed 's/.*\"permission_profile_name\":\"//g' | sed 's/\".*//g')
64 | esign_profiles_count=$(echo "$esign_profile_names" | grep -c '^')
65 |
66 | echo ""
67 | echo "Update user product permission profile for the following email: $EMAIL_ADDRESS"
68 | echo ""
69 |
70 | PS3='Would you like to update the permission profile for the eSignature or CLM product? '
71 | select choice in eSignature CLM
72 | do
73 | echo $choice
74 | product=$choice
75 | break
76 | done
77 |
78 |
79 | if [ "$product" == "eSignature" ]; then
80 | PRODUCT_ID=$ESIGN_PRODUCT_ID
81 | echo ""
82 | PS3='Select an eSignature permission profile to add: '
83 | IFS=$'\n'
84 | select esign_permission_profile in $esign_profile_names; do
85 | if [ "$REPLY" -gt "0" ] && [ "$REPLY" -le "$esign_profiles_count" ]; then
86 | PERMISSION_PROFILE_ID=$(cat $response | sed 's/}]}/\n/' | grep ESign | sed 's/.*\"permission_profiles\"://' | sed 's/},/\n/g' | grep $esign_permission_profile | sed 's/.*\"permission_profile_id\":\"//g' | sed 's/\".*//g')
87 | break
88 | fi
89 | done
90 | else
91 | PRODUCT_ID=$CLM_PRODUCT_ID
92 | echo ""
93 | PS3='Select a CLM permission profile to assign to the new user: '
94 | IFS=$'\n'
95 | select clm_permission_profile in $clm_profile_names; do
96 | if [ "$REPLY" -gt "0" ] && [ "$REPLY" -le "$clm_profiles_count" ]; then
97 | PERMISSION_PROFILE_ID=$(cat $response | sed 's/}]}/\n/' | grep CLM | sed 's/.*\"permission_profiles\"://' | sed 's/},/\n/g' | grep $clm_permission_profile | sed 's/.*\"permission_profile_id\":\"//g' | sed 's/\".*//g')
98 | break
99 | fi
100 | done
101 | fi
102 |
103 | request_data=$(mktemp /tmp/request-cw-001.XXXXXX)
104 | # Construct the request body
105 | #ds-snippet-start:Admin8Step3
106 | printf \
107 | '{
108 | "email": "'${EMAIL_ADDRESS}'",
109 | "product_permission_profiles": [
110 | {
111 | "product_id": '${PRODUCT_ID}',
112 | "permission_profile_id": '${PERMISSION_PROFILE_ID}',
113 | }
114 | ]
115 | }
116 | ' >>$request_data
117 | #ds-snippet-end:Admin8Step3
118 | echo $request_data
119 | Add user permission profile
120 | #ds-snippet-start:Admin8Step4
121 | curl -w '%{http_code}' -i --request POST "${base_path}/v2.1/organizations/${ORGANIZATION_ID}/accounts/${API_ACCOUNT_ID}/products/permission_profiles/users" \
122 | "${Headers[@]}" \
123 | --data-binary @${request_data} \
124 | --output ${response}
125 | #ds-snippet-end:Admin8Step4
126 | echo ""
127 | echo "Response: "
128 | echo ""
129 | cat $response
130 | echo ""
131 |
132 | # Remove the temporary files
133 | rm "$request_data"
134 | rm "$response"
135 |
136 | echo ""
137 | echo "Done."
138 | echo ""
139 |
--------------------------------------------------------------------------------