Chilkat Online Tools

TCL / DocuSign REST API / 18. Send Envelope with Template

Back to Collection Items

load ./chilkat.dll

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

# 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"
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "emailBlurb" "Create an envelope with a templateId"
CkJsonObject_UpdateString $json "emailSubject" "Template"
CkJsonObject_UpdateString $json "templateId" "{{templateId}}"
CkJsonObject_UpdateString $json "status" "sent"

CkHttp_SetRequestHeader $http "Content-Type" "application/json"
# Adds the "Authorization: Bearer {{accessToken}}" header.
CkHttp_put_AuthToken $http "{{accessToken}}"

# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonObject $json

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-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": "Content-Type",
        "value": "application/json"
      },
      {
        "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": [
  ]
}