Chilkat Online Tools

Go / 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.

    http := chilkat.NewHttp()
    var success bool

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

    json := chilkat.NewJsonObject()
    json.UpdateString("emailBlurb","Create an envelope with a templateId")
    json.UpdateString("emailSubject","Template")
    json.UpdateString("templateId","{{templateId}}")
    json.UpdateString("status","sent")

    // Adds the "Authorization: Bearer {{accessToken}}" header.
    http.SetAuthToken("{{accessToken}}")

    resp := http.PostJson3("https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes","application/json",json)
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        json.DisposeJsonObject()
        return
    }

    fmt.Println(resp.StatusCode())
    fmt.Println(resp.BodyStr())
    resp.DisposeHttpResponse()

    http.DisposeHttp()
    json.DisposeJsonObject()

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": [
  ]
}