Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
' Use this online tool to generate code from sample JSON: Generate Code to Create JSON
' The following JSON is sent in the request body.
' {
' "documents": [
' {
' "documentBase64": "{{documentBase64}}",
' "documentId": 123,
' "fileExtension": "pdf",
' "name": "document"
' }
' ],
' "emailSubject": "Simple Signing Example",
' "recipients": {
' "signers": [
' {
' "email": "{{email}}",
' "name": "{{name}}",
' "recipientId": "{{recipientId}}"
' }
' ]
' },
' "status": "sent"
' }
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = CreateObject("Chilkat.JsonObject")
success = json.UpdateString("documents[0].documentBase64","{{documentBase64}}")
success = json.UpdateInt("documents[0].documentId",123)
success = json.UpdateString("documents[0].fileExtension","pdf")
success = json.UpdateString("documents[0].name","document")
success = json.UpdateString("emailSubject","Simple Signing Example")
success = json.UpdateString("recipients.signers[0].email","{{email}}")
success = json.UpdateString("recipients.signers[0].name","{{name}}")
success = json.UpdateString("recipients.signers[0].recipientId","{{recipientId}}")
success = json.UpdateString("status","sent")
http.SetRequestHeader "Content-Type","application/json"
' Adds the "Authorization: Bearer {{accessToken}}" header.
http.AuthToken = "{{accessToken}}"
' resp is a Chilkat.HttpResponse
Set resp = http.PostJson3("https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes","application/json",json)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)
outFile.Close
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{accessToken}}"
-d '{
"documents": [
{
"documentBase64": {{document}},
"documentId": {{documentId}},
"fileExtension": "pdf",
"name": "document"
}
],
"emailSubject": "Simple Signing Example",
"recipients": {
"signers": [
{
"email": {{user1}},
"name": {{user1_name}},
"recipientId": "{{recipientId}}"
}
]
},
"status": "sent"
}'
https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes
Postman Collection Item JSON
{
"name": "1. Create an Envelope",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"envelopeId\", jsonData.envelopeId);"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"documents\": [\n {\n \"documentBase64\": {{document}},\n \"documentId\": {{documentId}},\n \"fileExtension\": \"pdf\",\n \"name\": \"document\"\n }\n ],\n \"emailSubject\": \"Simple Signing Example\",\n \"recipients\": {\n \"signers\": [\n {\n \"email\": {{user1}},\n \"name\": {{user1_name}},\n \"recipientId\": \"{{recipientId}}\"\n }\n ]\n },\n \"status\": \"sent\"\n}"
},
"url": {
"raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes",
"host": [
"{{baseUrl}}"
],
"path": [
"{{apiVersion}}",
"accounts",
"{{accountId}}",
"envelopes"
]
},
"description": "This example is a very basic example of creating an evenlope with a document and a single signer. This evenlope does not specify a tab."
},
"response": [
]
}