Chilkat Online Tools

Android / DocuSign Click API / 11. Lock the Envelope

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  public void onCreate(Bundle savedInstanceState) {

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

    CkHttp http = new CkHttp();
    boolean success;

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "lockDurationInSeconds": "500",
    //   "lockType": "edit"
    // }

    CkJsonObject json = new CkJsonObject();

    // Adds the "Authorization: Bearer {{accessToken}}" header.

    CkHttpResponse resp = http.PostJson3("{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId}}/lock","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());

    Log.i(TAG, String.valueOf(resp.get_StatusCode()));
    Log.i(TAG, resp.bodyStr());


  static {

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."

Curl Command

curl -X POST
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
  "lockDurationInSeconds": "500",
  "lockType": "edit"

Postman Collection Item JSON

  "name": "11. Lock the Envelope",
  "event": [
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "var jsonData = JSON.parse(responseBody);",
          "postman.setEnvironmentVariable(\"lockToken\", jsonData.lockToken);"
  "request": {
    "method": "POST",
    "header": [
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
    "body": {
      "mode": "raw",
      "raw": "{\n  \"lockDurationInSeconds\": \"500\",\n  \"lockType\": \"edit\"\n}"
    "url": {
      "raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId}}/lock",
      "host": [
      "path": [
    "description": "This method locks the specified envelope and sets the time until the lock expires to prevent other users or recipients from changing the envelope.\n\nThe response to this request returns a `lockToken` parameter. You must use the lockToken to update or delete an existing lock. You must also include the `lockToken` in the header for every PUT call that you make on the envelope while it is locked. If you do not include the `lockToken`, the system returns the following error:\n\n```{\n   \"errorCode\": \"EDIT_LOCK_NOT_LOCK_OWNER\",\n   \"message\": \"The user is not the owner of the lock. The template is locked by another user or in another application\"\n}```\n\n`Note`: Users must have envelope locking capability enabled to use this function (userSetting canLockEnvelopes must be set to true for the user)."
  "response": [