autoit / DocuSign Click API / 18. Send Envelope with Template
Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "emailBlurb": "Create an envelope with a templateId",
; "emailSubject": "Template",
; "templateId": "{{templateId}}",
; "status": "sent"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("emailBlurb","Create an envelope with a templateId")
$oJson.UpdateString("emailSubject","Template")
$oJson.UpdateString("templateId","{{templateId}}")
$oJson.UpdateString("status","sent")
; Adds the "Authorization: Bearer {{accessToken}}" header.
$oHttp.AuthToken = "{{accessToken}}"
Local $oResp = $oHttp.PostJson3("https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)
Curl Command
curl -X POST
-H "Authorization: Bearer {{accessToken}}"
-d '{
"emailBlurb": "Create an envelope with a templateId",
"emailSubject": "Template",
"templateId": "{{templateId}}",
"status": "sent"
}'
https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes
Postman Collection Item JSON
{
"name": "18. Send Envelope with Template",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"emailBlurb\": \"Create an envelope with a templateId\",\n \"emailSubject\": \"Template\",\n \"templateId\": \"{{templateId}}\",\n \"status\": \"sent\"\n}"
},
"url": {
"raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes",
"host": [
"{{baseUrl}}"
],
"path": [
"{{apiVersion}}",
"accounts",
"{{accountId}}",
"envelopes"
]
},
"description": "Send an envelop with a single template."
},
"response": [
]
}